public LayMines(Actor self, List <CPos> minefield = null) { minelayer = self.Trait <Minelayer>(); ammoPools = self.TraitsImplementing <AmmoPool>().ToArray(); movement = self.Trait <IMove>(); moveInfo = self.Info.TraitInfo <IMoveInfo>(); rearmableInfo = self.Info.TraitInfoOrDefault <RearmableInfo>(); this.minefield = minefield; }
/// <summary> /// Moves the transaction back to a specific step (all undo functions for the back steps will be executed). /// </summary> /// <param name="id">The step id to move.</param> /// <param name="comparer">The equality comparer.</param> public void GoBack(TStepId id, IEqualityComparer <TStepId> comparer) { this.MoveInfo = new MoveInfo <TStepId>() { Id = id, Comparer = comparer ?? EqualityComparer <TStepId> .Default, MoveType = MoveType.Back }; }
protected BaseMovesModel(IMoveInfo move) : this() { GenericMove = move; if (GenericMove.GetDate() == DateTime.MinValue) { Date = now.ToShortDateString(); } arrangeDetails(); }
public Resupply(Actor self, Actor host, WDist closeEnough, bool stayOnResupplier = false) { this.host = Target.FromActor(host); this.closeEnough = closeEnough; this.stayOnResupplier = stayOnResupplier; allRepairsUnits = host.TraitsImplementing <RepairsUnits>().ToArray(); health = self.TraitOrDefault <IHealth>(); repairable = self.TraitOrDefault <Repairable>(); repairableNear = self.TraitOrDefault <RepairableNear>(); rearmable = self.TraitOrDefault <Rearmable>(); notifyResupplies = host.TraitsImplementing <INotifyResupply>().ToArray(); notifyBeingResupplied = self.TraitsImplementing <INotifyBeingResupplied>().ToArray(); transportCallers = self.TraitsImplementing <ICallForTransport>().ToArray(); move = self.Trait <IMove>(); aircraft = move as Aircraft; moveInfo = self.Info.TraitInfo <IMoveInfo>(); playerResources = self.Owner.PlayerActor.Trait <PlayerResources>(); var valued = self.Info.TraitInfoOrDefault <ValuedInfo>(); unitCost = valued != null ? valued.Cost : 0; var cannotRepairAtHost = health == null || health.DamageState == DamageState.Undamaged || !allRepairsUnits.Any() || ((repairable == null || !repairable.Info.RepairActors.Contains(host.Info.Name)) && (repairableNear == null || !repairableNear.Info.RepairActors.Contains(host.Info.Name))); if (!cannotRepairAtHost) { activeResupplyTypes |= ResupplyType.Repair; // HACK: Reservable logic can't handle repairs, so force a take-off if resupply included repairs. // TODO: Make reservation logic or future docking logic properly handle this. wasRepaired = true; } var cannotRearmAtHost = rearmable == null || !rearmable.Info.RearmActors.Contains(host.Info.Name) || rearmable.RearmableAmmoPools.All(p => p.HasFullAmmo); if (!cannotRearmAtHost) { activeResupplyTypes |= ResupplyType.Rearm; } }
public static async Task MoveForward <TStepId, TData>(MoveToStepContext <TStepId, TData> context) #endif { IStepEnumerator <TStepId, TData> stepEnumerator = context.Session.StepEnumerator; IMoveInfo <TStepId> moveInfo = context.Session.MoveInfo; int moveCount = 0; do { stepEnumerator.MoveNext(); ++moveCount; }while (stepEnumerator.CurrentStep != null && !moveInfo.Comparer.Equals(stepEnumerator.CurrentStep.Id, moveInfo.Id)); context.Session.MoveInfo = null; if (stepEnumerator.CurrentStep == null) { for (int i = 0; i < moveCount; ++i) { stepEnumerator.MovePrevious(); } #if NET35 || NOASYNC RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #else await RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #endif { Result = ResultType.Failed, CaughtException = new InvalidOperationException(string.Format("Could not move forward to a step with id '{0}' as the step does not exist.", moveInfo.Id)), Session = context.Session }); return; } #if NET35 || NOASYNC context.MoveToStepFinishAction(); #else await context.MoveToStepFinishAction(); #endif }
public static MoveValueType ValueType(this IMoveInfo move) { var type = MoveValueType.Empty; if (move.Value != 0) { type += (Int32)MoveValueType.Unique; } var details = move.DetailList .Sum(d => d.Amount * d.Value); if (move.DetailList.Any() && details != 0) { type += (Int32)MoveValueType.Detailed; } return(type); }
public static async Task MoveBack <TStepId, TData>(MoveToStepContext <TStepId, TData> context) #endif { IMoveInfo <TStepId> moveInfo = context.Session.MoveInfo; bool stepFound = false; Func <ITransactionStep <TStepId, TData>, bool> processStepPredicate = step => { if (step == null) { return(false); } if (stepFound) { return(false); } else { stepFound = moveInfo.Comparer.Equals(step.Id, moveInfo.Id); return(true); } }; #if NET35 || NOASYNC RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #else await RunUndoOperation.RunUndo(new RunUndoContext <TStepId, TData>() #endif { Session = context.Session, NoSessionEnd = true, ProcessStepPredicate = processStepPredicate, #if NET35 || NOASYNC UndoFinishAction = () => MoveBackUndoFinishAction(context, stepFound) #else UndoFinishAction = async() => await MoveBackUndoFinishAction(context, stepFound) #endif });
public EntersTunnels(Actor self, EntersTunnelsInfo info) { this.info = info; move = self.Trait <IMove>(); moveInfo = self.Info.TraitInfo <IMoveInfo>(); }
public static Boolean IsDetailed(this IMoveInfo move) { return(move.ValueType() == MoveValueType.Detailed); }
protected BaseMovesModel(IMoveInfo iMove, OperationType type) : this(iMove) { Type = type; }