40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using ActiveProtect.Models;
|
|
|
|
namespace ActiveProtect.SimulationEnvironment
|
|
{
|
|
public abstract class SimulationElement(string id, Vector3D position, Orientation orientation, ISimulationManager simulationManager)
|
|
{
|
|
public string Id { get; set; } = id;
|
|
public Vector3D Position { get; set; } = position;
|
|
public Orientation Orientation { get; set; } = orientation;
|
|
public ISimulationManager SimulationManager { get; set; } = simulationManager;
|
|
public bool IsActive { get; protected set; } = true;
|
|
|
|
public abstract void Update(double deltaTime);
|
|
|
|
public virtual string GetStatus()
|
|
{
|
|
return $"{GetType().Name} {Id} at {Position}, Orientation: {Orientation}, Active: {IsActive}";
|
|
}
|
|
|
|
protected void PublishEvent(SimulationEvent evt)
|
|
{
|
|
evt.SenderId = Id;
|
|
evt.Timestamp = SimulationManager.CurrentTime;
|
|
SimulationManager.PublishEvent(evt);
|
|
}
|
|
|
|
protected virtual void Activate()
|
|
{
|
|
IsActive = true;
|
|
PublishEvent(new EntityActivatedEvent { ActivatedEntityId = Id });
|
|
}
|
|
|
|
protected virtual void Deactivate()
|
|
{
|
|
IsActive = false;
|
|
PublishEvent(new EntityDeactivatedEvent { DeactivatedEntityId = Id });
|
|
}
|
|
}
|
|
}
|