2024-02-12 20:15:14 +00:00
|
|
|
|
using GameServer.Systems.Entity.Component;
|
2024-02-24 21:49:57 +00:00
|
|
|
|
using GameServer.Systems.Notify;
|
2024-02-12 20:15:14 +00:00
|
|
|
|
using Protocol;
|
|
|
|
|
|
|
|
|
|
namespace GameServer.Systems.Entity;
|
|
|
|
|
internal class MonsterEntity : EntityBase
|
|
|
|
|
{
|
2024-02-24 21:49:57 +00:00
|
|
|
|
public MonsterEntity(long id, int configId, IGameActionListener listener) : base(id, listener)
|
2024-02-12 20:15:14 +00:00
|
|
|
|
{
|
|
|
|
|
ConfigId = configId;
|
2024-02-25 20:29:35 +00:00
|
|
|
|
DynamicId = configId;
|
2024-02-12 20:15:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int ConfigId { get; }
|
|
|
|
|
|
|
|
|
|
public override EEntityType Type => EEntityType.Monster;
|
|
|
|
|
public override EntityConfigType ConfigType => EntityConfigType.Level;
|
|
|
|
|
|
|
|
|
|
public override void OnCreate()
|
|
|
|
|
{
|
|
|
|
|
base.OnCreate();
|
|
|
|
|
|
|
|
|
|
EntityAttributeComponent attributeComponent = ComponentSystem.Create<EntityAttributeComponent>();
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.LifeMax, 100);
|
|
|
|
|
attributeComponent.SetAttribute(EAttributeType.Life, 100);
|
|
|
|
|
|
|
|
|
|
State = EntityState.Born;
|
|
|
|
|
|
|
|
|
|
EntityMonsterAiComponent aiComponent = ComponentSystem.Create<EntityMonsterAiComponent>();
|
|
|
|
|
aiComponent.AiTeamInitId = 100;
|
|
|
|
|
|
|
|
|
|
EntityFsmComponent fsm = ComponentSystem.Create<EntityFsmComponent>();
|
2024-02-14 21:22:21 +00:00
|
|
|
|
|
|
|
|
|
fsm.Fsms.Add(new DFsm
|
|
|
|
|
{
|
|
|
|
|
FsmId = 10007, // Main State Machine
|
2024-02-25 20:29:35 +00:00
|
|
|
|
CurrentState = 10013 // Battle Branching
|
2024-02-14 21:22:21 +00:00
|
|
|
|
});
|
|
|
|
|
|
2024-02-12 20:15:14 +00:00
|
|
|
|
fsm.Fsms.Add(new DFsm
|
|
|
|
|
{
|
|
|
|
|
FsmId = 10007, // Main State Machine
|
2024-02-25 20:29:35 +00:00
|
|
|
|
CurrentState = 10015 // Moving Combat
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Some monsters need weapon
|
|
|
|
|
fsm.Fsms.Add(new DFsm
|
|
|
|
|
{
|
|
|
|
|
FsmId = 100,
|
|
|
|
|
CurrentState = 9 // [9 - Empty hand, 10 - Crowbar, 11 - flamethrower, 12 - chainsaw, 13 - electric blade, 14 - sniper rifle]
|
2024-02-12 20:15:14 +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,
|
|
|
|
|
LivingStatus = (int)LivingStatus,
|
|
|
|
|
IsVisible = IsVisible,
|
|
|
|
|
InitLinearVelocity = new(),
|
|
|
|
|
InitPos = new()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pb.ComponentPbs.AddRange(ComponentSystem.Pb);
|
|
|
|
|
|
|
|
|
|
return pb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|