Remove hardcode for FightRoleInfo
This commit is contained in:
parent
5b927b99a8
commit
838faa5938
2 changed files with 55 additions and 53 deletions
|
@ -1,5 +1,4 @@
|
|||
using System.Security.Principal;
|
||||
using Core.Config;
|
||||
using Core.Config;
|
||||
using GameServer.Controllers.Attributes;
|
||||
using GameServer.Models;
|
||||
using GameServer.Network;
|
||||
|
@ -81,7 +80,7 @@ internal class CreatureController : Controller
|
|||
|
||||
IEnumerable<PlayerEntity> oldEntities = _entitySystem.EnumerateEntities()
|
||||
.Where(e => e is PlayerEntity entity && entity.PlayerId == _modelManager.Player.Id)
|
||||
.Cast<PlayerEntity>().ToArray();
|
||||
.Cast<PlayerEntity>();
|
||||
|
||||
foreach (PlayerEntity oldEntity in oldEntities)
|
||||
{
|
||||
|
@ -122,18 +121,7 @@ internal class CreatureController : Controller
|
|||
await Session.Push(MessageId.UpdatePlayerAllFightRoleNotify, new UpdatePlayerAllFightRoleNotify
|
||||
{
|
||||
PlayerId = _modelManager.Player.Id,
|
||||
FightRoleInfos =
|
||||
{
|
||||
newEntities.Select(entity => new FightRoleInformation
|
||||
{
|
||||
EntityId = entity.Id,
|
||||
CurHp = 1000,
|
||||
MaxHp = 1000,
|
||||
IsControl = _modelManager.Creature.PlayerEntityId == entity.Id,
|
||||
RoleId = entity.ConfigId,
|
||||
RoleLevel = 1,
|
||||
})
|
||||
}
|
||||
FightRoleInfos = { GetFightRoleInfos() }
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -178,15 +166,16 @@ internal class CreatureController : Controller
|
|||
await OnVisionSkillChanged();
|
||||
}
|
||||
|
||||
private SceneInformation CreateSceneInfo()
|
||||
{
|
||||
SceneInformation scene = new()
|
||||
private SceneInformation CreateSceneInfo() => new()
|
||||
{
|
||||
InstanceId = _modelManager.Creature.InstanceId,
|
||||
OwnerId = _modelManager.Creature.OwnerId,
|
||||
CurContextId = _modelManager.Player.Id,
|
||||
TimeInfo = new(),
|
||||
AoiData = new(),
|
||||
AoiData = new PlayerSceneAoiData
|
||||
{
|
||||
Entities = { _entitySystem.Pb }
|
||||
},
|
||||
PlayerInfos =
|
||||
{
|
||||
new ScenePlayerInformation
|
||||
|
@ -200,28 +189,29 @@ internal class CreatureController : Controller
|
|||
Y = -2000,
|
||||
Z = 260
|
||||
},
|
||||
PlayerName = _modelManager.Player.Name
|
||||
PlayerName = _modelManager.Player.Name,
|
||||
FightRoleInfos = { GetFightRoleInfos() }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < _modelManager.Player.Characters.Length; i++)
|
||||
private IEnumerable<FightRoleInformation> GetFightRoleInfos()
|
||||
{
|
||||
scene.PlayerInfos[0].FightRoleInfos.Add(new FightRoleInformation
|
||||
IEnumerable<PlayerEntity> playerEntities = _entitySystem.EnumerateEntities()
|
||||
.Where(e => e is PlayerEntity entity && entity.PlayerId == _modelManager.Player.Id)
|
||||
.Cast<PlayerEntity>();
|
||||
|
||||
return playerEntities.Select(playerEntity => new FightRoleInformation
|
||||
{
|
||||
EntityId = i + 1,
|
||||
CurHp = 1000,
|
||||
MaxHp = 1000,
|
||||
IsControl = i == 0,
|
||||
RoleId = _modelManager.Player.Characters[i],
|
||||
EntityId = playerEntity.Id,
|
||||
CurHp = playerEntity.Health,
|
||||
MaxHp = playerEntity.HealthMax,
|
||||
IsControl = playerEntity.Id == _modelManager.Creature.PlayerEntityId,
|
||||
RoleId = playerEntity.ConfigId,
|
||||
RoleLevel = 1,
|
||||
});
|
||||
}
|
||||
|
||||
scene.AoiData.Entities.AddRange(_entitySystem.Pb);
|
||||
return scene;
|
||||
}
|
||||
|
||||
private void CreateTeamPlayerEntities()
|
||||
{
|
||||
for (int i = 0; i < _modelManager.Formation.RoleIds.Length; i++)
|
||||
|
|
|
@ -21,6 +21,18 @@ internal class PlayerEntity : EntityBase
|
|||
set => ComponentSystem.Get<EntityEquipComponent>().WeaponId = value;
|
||||
}
|
||||
|
||||
public int Health
|
||||
{
|
||||
get => ComponentSystem.Get<EntityAttributeComponent>().GetAttribute(EAttributeType.Life);
|
||||
set => ComponentSystem.Get<EntityAttributeComponent>().SetAttribute(EAttributeType.Life, value);
|
||||
}
|
||||
|
||||
public int HealthMax
|
||||
{
|
||||
get => ComponentSystem.Get<EntityAttributeComponent>().GetAttribute(EAttributeType.LifeMax);
|
||||
set => ComponentSystem.Get<EntityAttributeComponent>().SetAttribute(EAttributeType.LifeMax, value);
|
||||
}
|
||||
|
||||
public override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
|
@ -33,14 +45,14 @@ internal class PlayerEntity : EntityBase
|
|||
visionSkillComponent.SetExploreTool(1001);
|
||||
|
||||
_ = ComponentSystem.Create<EntityEquipComponent>();
|
||||
_ = ComponentSystem.Create<EntityAttributeComponent>();
|
||||
|
||||
InitAttributes();
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
base.Activate();
|
||||
|
||||
_ = ComponentSystem.Create<EntityAttributeComponent>();
|
||||
InitAttributes();
|
||||
}
|
||||
|
||||
private void InitAttributes()
|
||||
|
|
Loading…
Reference in a new issue