66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
namespace SepCore.Simulation
|
|
{
|
|
internal sealed class EnemyStore : EntityComponentStore
|
|
{
|
|
private Column<EnemyIdentitySim> _identity;
|
|
private Column<EnemyTransformSim> _transform;
|
|
private Column<EnemyMoveInputSim> _moveInput;
|
|
private Column<EnemyMoveConfigSim> _moveConfig;
|
|
private Column<EnemyAttackSim> _attack;
|
|
private Column<EnemyBehaviorSim> _behavior;
|
|
private Column<EnemySeparationSim> _separation;
|
|
|
|
public Column<EnemyIdentitySim> Identity => _identity;
|
|
public Column<EnemyTransformSim> Transform => _transform;
|
|
public Column<EnemyMoveInputSim> MoveInput => _moveInput;
|
|
public Column<EnemyMoveConfigSim> MoveConfig => _moveConfig;
|
|
public Column<EnemyAttackSim> Attack => _attack;
|
|
public Column<EnemyBehaviorSim> Behavior => _behavior;
|
|
public Column<EnemySeparationSim> Separation => _separation;
|
|
|
|
public void Initialize(int capacity)
|
|
{
|
|
if (IsCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Dispose();
|
|
_identity = Register<EnemyIdentitySim>(capacity);
|
|
_transform = Register<EnemyTransformSim>(capacity);
|
|
_moveInput = Register<EnemyMoveInputSim>(capacity);
|
|
_moveConfig = Register<EnemyMoveConfigSim>(capacity);
|
|
_attack = Register<EnemyAttackSim>(capacity);
|
|
_behavior = Register<EnemyBehaviorSim>(capacity);
|
|
_separation = Register<EnemySeparationSim>(capacity);
|
|
MarkInitialized();
|
|
}
|
|
|
|
public int Add(in EnemyIdentitySim identity, in EnemyTransformSim transform, in EnemyMoveInputSim moveInput,
|
|
in EnemyMoveConfigSim moveConfig, in EnemyAttackSim attack, in EnemyBehaviorSim behavior)
|
|
{
|
|
int index = AppendRow(identity.EntityId);
|
|
_identity.Data.Add(identity);
|
|
_transform.Data.Add(transform);
|
|
_moveInput.Data.Add(moveInput);
|
|
_moveConfig.Data.Add(moveConfig);
|
|
_attack.Data.Add(attack);
|
|
_behavior.Data.Add(behavior);
|
|
_separation.Data.Add(default);
|
|
return index;
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
_identity = null;
|
|
_transform = null;
|
|
_moveInput = null;
|
|
_moveConfig = null;
|
|
_attack = null;
|
|
_behavior = null;
|
|
_separation = null;
|
|
}
|
|
}
|
|
}
|