public void inputEnergy(int input) { if (state != FacilityState.LOCKED && input != 0) { storedEnergy += input; state = FacilityState.ACTIVE; } }
public static IEnumerable <IFacilityState> ToFacilityStateCollection(IEnumerable <string> ids) { var states = new List <FacilityState>(); foreach (var id in ids) { var s = new FacilityState(); s.FacilityId = id; states.Add(s); } return(states); }
public IFacilityState Get(string id, bool nullAllowed) { IFacilityState state = CurrentSession.Get <FacilityState> (id); if (!nullAllowed && state == null) { state = new FacilityState(); (state as FacilityState).FacilityId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IFacilityState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public FacilityData(FacilityState newState, int newEnergy, int newProperty) { state = newState; storedEnergy = newEnergy; energyProperty = newProperty; }
void OnCurrentOrderChanged() { //TODO if orders arrive when in a Call()ed state, the Call()ed state must Return() before the new state may be initiated if (CurrentState == FacilityState.Repairing) { Return(); // IMPROVE Attacking is not here as it is not really a state so far. It has no duration so it could be replaced with a method // I'm deferring doing that right now as it is unclear how Attacking will evolve } if (CurrentOrder != null) { D.Log("{0} received new order {1}.", FullName, CurrentOrder.Directive.GetValueName()); FacilityDirective order = CurrentOrder.Directive; switch (order) { case FacilityDirective.Attack: CurrentState = FacilityState.ExecuteAttackOrder; break; case FacilityDirective.StopAttack: // issued when peace declared while attacking CurrentState = FacilityState.Idling; break; case FacilityDirective.Repair: CurrentState = FacilityState.Repairing; break; case FacilityDirective.Refit: CurrentState = FacilityState.Refitting; break; case FacilityDirective.Disband: CurrentState = FacilityState.Disbanding; break; case FacilityDirective.None: default: throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(order)); } } }
/// <summary> /// The method Facilities use to actually incur individual damage. /// </summary> /// <param name="damage">The damage to apply to this facility.</param> /// <param name="isDirectlyAttacked">if set to <c>true</c> this facility is the one being directly attacked.</param> private void TakeDistributedDamage(float damage, bool isDirectlyAttacked) { D.Assert(CurrentState != FacilityState.Dead, "{0} should not already be dead!".Inject(Data.Name)); bool isElementAlive = ApplyDamage(damage); bool isCmdHit = false; if (IsHQElement && isDirectlyAttacked) { isCmdHit = Command.__CheckForDamage(isElementAlive); } if (!isElementAlive) { CurrentState = FacilityState.Dead; return; } if (isDirectlyAttacked) { // only show being hit if this facility is the one being directly attacked var hitAnimation = isCmdHit ? EffectID.CmdHit : EffectID.Hit; OnShowAnimation(hitAnimation); } AssessNeedForRepair(); }
private IMortalTarget _primaryTarget; // IMPROVE take this previous target into account when PickPrimaryTarget() IEnumerator ExecuteAttackOrder_EnterState() { D.Log("{0}.ExecuteAttackOrder_EnterState() called.", FullName); _ordersTarget = CurrentOrder.Target; while (_ordersTarget.IsAlive) { // bool inRange = PickPrimaryTarget(out _primaryTarget); // if a primaryTarget is inRange, primary target is not null so OnWeaponReady will attack it // if not in range, then primary target will be null, so OnWeaponReady will attack other targets of opportunity, if any yield return null; } CurrentState = FacilityState.Idling; }