2024-02-10 16:04:03 +00:00
|
|
|
|
using GameServer.Systems.Entity.Component;
|
|
|
|
|
using Protocol;
|
|
|
|
|
|
|
|
|
|
namespace GameServer.Systems.Entity;
|
|
|
|
|
internal class PlayerEntity : EntityBase
|
|
|
|
|
{
|
|
|
|
|
public PlayerEntity(long id, int configId, int playerId) : base(id)
|
|
|
|
|
{
|
|
|
|
|
ConfigId = configId;
|
|
|
|
|
PlayerId = playerId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int ConfigId { get; }
|
|
|
|
|
public int PlayerId { get; }
|
|
|
|
|
|
2024-02-10 22:28:35 +00:00
|
|
|
|
public bool IsCurrentRole { get; set; }
|
|
|
|
|
|
|
|
|
|
public override void OnCreate()
|
2024-02-10 16:04:03 +00:00
|
|
|
|
{
|
2024-02-10 22:28:35 +00:00
|
|
|
|
base.OnCreate();
|
2024-02-10 16:04:03 +00:00
|
|
|
|
|
2024-02-10 22:28:35 +00:00
|
|
|
|
// Should be created immediately
|
2024-02-10 16:04:03 +00:00
|
|
|
|
EntityConcomitantsComponent concomitantsComponent = ComponentSystem.Create<EntityConcomitantsComponent>();
|
|
|
|
|
concomitantsComponent.CustomEntityIds.Add(Id);
|
|
|
|
|
|
|
|
|
|
EntityVisionSkillComponent visionSkillComponent = ComponentSystem.Create<EntityVisionSkillComponent>();
|
|
|
|
|
visionSkillComponent.SetExploreTool(1001);
|
2024-02-10 22:28:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Activate()
|
|
|
|
|
{
|
|
|
|
|
base.Activate();
|
2024-02-10 16:04:03 +00:00
|
|
|
|
|
|
|
|
|
_ = ComponentSystem.Create<EntityAttributeComponent>();
|
|
|
|
|
InitAttributes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitAttributes()
|
|
|
|
|
{
|
|
|
|
|
EntityAttributeComponent attributeComponent = ComponentSystem.Get<EntityAttributeComponent>();
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.Life, 1000);
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.LifeMax, 1000);
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.Lv, 1);
|
2024-02-10 19:28:57 +00:00
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.AutoAttackSpeed, 10000);
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.CastAttackSpeed, 10000);
|
2024-02-10 16:04:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override EEntityType Type => EEntityType.Player;
|
|
|
|
|
public override EntityConfigType ConfigType => EntityConfigType.Character;
|
|
|
|
|
|
2024-02-10 22:28:35 +00:00
|
|
|
|
public override bool IsVisible => IsCurrentRole;
|
|
|
|
|
|
2024-02-10 16:04:03 +00:00
|
|
|
|
public override EntityPb Pb
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
EntityPb pb = new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
EntityType = (int)Type,
|
|
|
|
|
ConfigType = (int)ConfigType,
|
|
|
|
|
EntityState = (int)State,
|
|
|
|
|
ConfigId = ConfigId,
|
|
|
|
|
Pos = Pos,
|
|
|
|
|
Rot = Rot,
|
|
|
|
|
PlayerId = PlayerId,
|
|
|
|
|
LivingStatus = (int)LivingStatus,
|
|
|
|
|
IsVisible = IsVisible,
|
|
|
|
|
InitLinearVelocity = new(),
|
|
|
|
|
InitPos = new()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pb.ComponentPbs.AddRange(ComponentSystem.Pb);
|
|
|
|
|
|
|
|
|
|
return pb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|