简单重构拆分 SimulationWorld
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
namespace SepCore.Simulation
|
||||
{
|
||||
internal sealed class ProjectileStore : EntityComponentStore
|
||||
{
|
||||
private Column<ProjectileIdentitySim> _identity;
|
||||
private Column<ProjectileTransformSim> _transform;
|
||||
private Column<ProjectileVelocitySim> _velocity;
|
||||
private Column<ProjectileLifeSim> _life;
|
||||
|
||||
public Column<ProjectileIdentitySim> Identity => _identity;
|
||||
public Column<ProjectileTransformSim> Transform => _transform;
|
||||
public Column<ProjectileVelocitySim> Velocity => _velocity;
|
||||
public Column<ProjectileLifeSim> Life => _life;
|
||||
|
||||
public void Initialize(int capacity)
|
||||
{
|
||||
if (IsCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dispose();
|
||||
_identity = Register<ProjectileIdentitySim>(capacity);
|
||||
_transform = Register<ProjectileTransformSim>(capacity);
|
||||
_velocity = Register<ProjectileVelocitySim>(capacity);
|
||||
_life = Register<ProjectileLifeSim>(capacity);
|
||||
MarkInitialized();
|
||||
}
|
||||
|
||||
public int Add(in ProjectileIdentitySim identity, in ProjectileTransformSim transform,
|
||||
in ProjectileVelocitySim velocity, in ProjectileLifeSim life)
|
||||
{
|
||||
int index = AppendRow(identity.EntityId);
|
||||
_identity.Data.Add(identity);
|
||||
_transform.Data.Add(transform);
|
||||
_velocity.Data.Add(velocity);
|
||||
_life.Data.Add(life);
|
||||
return index;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_identity = null;
|
||||
_transform = null;
|
||||
_velocity = null;
|
||||
_life = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user