internal override void ActionCommand(Game game) { OrderableProcessor.ProcessOrderList(game, NestedCommands); if (NestedCommands.Count == 0) { if (!IsRunning) { var entPos = _entityCommanding.GetDataBlob <PositionDB>().PositionInKm; var tarPos = _targetEntity.GetDataBlob <PositionDB>().PositionInKm; double distanceAU = PositionDB.GetDistanceBetween(_entityCommanding.GetDataBlob <PositionDB>(), _targetEntity.GetDataBlob <PositionDB>()); var rangeAU = ApihelionInKM / GameConstants.Units.KmPerAu; if (Math.Abs(rangeAU - distanceAU) <= 500 / GameConstants.Units.MetersPerAu) //distance within 500m { DateTime datenow = _entityCommanding.Manager.ManagerSubpulses.SystemLocalDateTime; var newOrbit = ShipMovementProcessor.CreateOrbitHereWithPerihelion(_entityCommanding, _targetEntity, PerhelionInKM, datenow); _entityCommanding.SetDataBlob(newOrbit); IsRunning = true; } else //insert new translate move { var cmd = new TranslateMoveCommand() { RequestingFactionGuid = this.RequestingFactionGuid, EntityCommandingGuid = this.EntityCommandingGuid, CreatedDate = this.CreatedDate, TargetEntityGuid = this.TargetEntityGuid, RangeInKM = this.ApihelionInKM }; NestedCommands.Insert(0, cmd); cmd.IsValidCommand(game); cmd.ActionCommand(game); } } } }
public void SMSetOrbitToEntity(Entity entity, Entity parentEntity, double perihelionKM, DateTime time) { var db = ShipMovementProcessor.CreateOrbitHereWithPerihelion(entity, parentEntity, perihelionKM, time); entity.SetDataBlob(db); }