void ITick.Tick(Actor self)
        {
            if (conditionManager == null)
            {
                return;
            }

            var activity      = self.CurrentActivity as AttackMoveActivity;
            var attackActive  = activity != null && !assaultMoving;
            var assaultActive = activity != null && assaultMoving;

            if (attackActive && attackMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.AttackMoveScanCondition))
            {
                attackMoveToken = conditionManager.GrantCondition(self, Info.AttackMoveScanCondition);
            }
            else if (!attackActive && attackMoveToken != ConditionManager.InvalidConditionToken)
            {
                attackMoveToken = conditionManager.RevokeCondition(self, attackMoveToken);
            }

            if (assaultActive && assaultMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.AssaultMoveScanCondition))
            {
                assaultMoveToken = conditionManager.GrantCondition(self, Info.AssaultMoveScanCondition);
            }
            else if (!assaultActive && assaultMoveToken != ConditionManager.InvalidConditionToken)
            {
                assaultMoveToken = conditionManager.RevokeCondition(self, assaultMoveToken);
            }
        }
コード例 #2
0
        void OnDeployStarted()
        {
            if (undeployedToken != ConditionManager.InvalidConditionToken)
            {
                undeployedToken = conditionManager.RevokeCondition(self, undeployedToken);
            }

            deployState = DeployState.Deploying;
        }
コード例 #3
0
 protected virtual void UpdateConditions(Actor self, byte oldLayer, byte newLayer)
 {
     if (newLayer == ValidLayerType && oldLayer != ValidLayerType && conditionToken == ConditionManager.InvalidConditionToken)
     {
         conditionToken = conditionManager.GrantCondition(self, Info.Condition);
     }
     else if (newLayer != ValidLayerType && oldLayer == ValidLayerType && conditionToken != ConditionManager.InvalidConditionToken)
     {
         conditionToken = conditionManager.RevokeCondition(self, conditionToken);
     }
 }
コード例 #4
0
ファイル: Passenger.cs プロジェクト: Mete0/anki-OpenRA
        void INotifyExitedCargo.OnExitedCargo(Actor self, Actor cargo)
        {
            if (anyCargoToken != ConditionManager.InvalidConditionToken)
            {
                anyCargoToken = conditionManager.RevokeCondition(self, anyCargoToken);
            }

            if (specificCargoToken != ConditionManager.InvalidConditionToken)
            {
                specificCargoToken = conditionManager.RevokeCondition(self, specificCargoToken);
            }
        }
コード例 #5
0
ファイル: Aircraft.cs プロジェクト: alexeik/openRA.Engine.Hg
        void OnAirborneAltitudeLeft()
        {
            if (!airborne)
            {
                return;
            }

            airborne = false;
            if (conditionManager != null && airborneToken != ConditionManager.InvalidConditionToken)
            {
                airborneToken = conditionManager.RevokeCondition(self, airborneToken);
            }
        }
コード例 #6
0
ファイル: Carryable.cs プロジェクト: alexeik/openRA.Engine.Hg
        // This gets called by carrier after we touched down
        public virtual void Detached(Actor self)
        {
            if (!attached)
            {
                return;
            }

            attached = false;

            if (carriedToken != ConditionManager.InvalidConditionToken)
            {
                carriedToken = conditionManager.RevokeCondition(self, carriedToken);
            }
        }
コード例 #7
0
ファイル: Cargo.cs プロジェクト: anvilvapre/OpenRA-1
        internal void UnreserveSpace(Actor a)
        {
            if (!reserves.Contains(a))
            {
                return;
            }

            reservedWeight -= GetWeight(a);
            reserves.Remove(a);

            if (loadingToken != ConditionManager.InvalidConditionToken)
            {
                loadingToken = conditionManager.RevokeCondition(self, loadingToken);
            }
        }
コード例 #8
0
ファイル: Mobile.cs プロジェクト: cjshmyr/OpenRA
        [Sync] public int PathHash;             // written by Move.EvalPath, to temporarily debug this crap.

        // Sets only the location (fromCell, toCell, FromSubCell, ToSubCell)
        public void SetLocation(CPos from, SubCell fromSub, CPos to, SubCell toSub)
        {
            if (FromCell == from && ToCell == to && FromSubCell == fromSub && ToSubCell == toSub)
            {
                return;
            }

            RemoveInfluence();
            fromCell    = from;
            toCell      = to;
            FromSubCell = fromSub;
            ToSubCell   = toSub;
            AddInfluence();

            // Tunnel condition is added/removed when starting the transition between layers
            if (toCell.Layer == CustomMovementLayerType.Tunnel && conditionManager != null &&
                !string.IsNullOrEmpty(Info.TunnelCondition) && tunnelToken == ConditionManager.InvalidConditionToken)
            {
                tunnelToken = conditionManager.GrantCondition(self, Info.TunnelCondition);
            }
            else if (toCell.Layer != CustomMovementLayerType.Tunnel && tunnelToken != ConditionManager.InvalidConditionToken)
            {
                tunnelToken = conditionManager.RevokeCondition(self, tunnelToken);
            }

            // Play submerging animation as soon as it starts to submerge (before applying the condition)
            if (toCell.Layer == CustomMovementLayerType.Subterranean && fromCell.Layer != CustomMovementLayerType.Subterranean)
            {
                if (!string.IsNullOrEmpty(Info.SubterraneanTransitionSequence))
                {
                    self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(self.World.Map.CenterOfCell(fromCell), self.World, Info.SubterraneanTransitionImage,
                                                                           Info.SubterraneanTransitionSequence, Info.SubterraneanTransitionPalette)));
                }

                if (!string.IsNullOrEmpty(Info.SubterraneanTransitionSound))
                {
                    Game.Sound.Play(SoundType.World, Info.SubterraneanTransitionSound);
                }
            }

            // Grant the jumpjet condition as soon as the actor starts leaving the ground layer
            // The condition is revoked from FinishedMoving
            if (toCell.Layer == CustomMovementLayerType.Jumpjet && conditionManager != null &&
                !string.IsNullOrEmpty(Info.JumpjetCondition) && jumpjetToken == ConditionManager.InvalidConditionToken)
            {
                jumpjetToken = conditionManager.GrantCondition(self, Info.JumpjetCondition);
            }
        }
コード例 #9
0
 void ITick.Tick(Actor self)
 {
     if (info.Duration >= 0 && token != ConditionManager.InvalidConditionToken && --ticks < 0)
     {
         token = conditionManager.RevokeCondition(self, token);
     }
 }
コード例 #10
0
        void ITick.Tick(Actor self)
        {
            if (IsTraitDisabled)
            {
                return;
            }

            foreach (var a in actions)
            {
                if (a.Delay-- <= 0)
                {
                    var modifiers = self.TraitsImplementing <IDamageModifier>()
                                    .Concat(self.Owner.PlayerActor.TraitsImplementing <IDamageModifier>())
                                    .Select(t => t.GetDamageModifier(self, null));

                    if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
                    {
                        self.Kill(a.Saboteur);
                    }
                    else if (a.Token != ConditionManager.InvalidConditionToken)
                    {
                        conditionManager.RevokeCondition(self, a.Token);
                        removeActions.Add(a);
                    }
                }
            }

            // Remove expired actions to avoid double-revoking
            foreach (var a in removeActions)
            {
                actions.Remove(a);
            }

            removeActions.Clear();
        }
コード例 #11
0
 void Revoke(Actor self)
 {
     if (token != ConditionManager.InvalidConditionToken)
     {
         token = conditionManager.RevokeCondition(self, token);
     }
 }
コード例 #12
0
        /// <summary>
        /// Called by CaptureActor when the activity finishes or is cancelled
        /// This method revokes the capturing conditions on the captor and target
        /// and resets any capturing progress.
        /// </summary>
        public void CancelCapture(Actor self, Actor target, CaptureManager targetManager)
        {
            if (currentTarget == null)
            {
                return;
            }

            foreach (var w in progressWatchers)
            {
                w.Update(self, self, target, 0, 0);
            }

            foreach (var w in targetManager.progressWatchers)
            {
                w.Update(target, self, target, 0, 0);
            }

            if (capturingToken != ConditionManager.InvalidConditionToken)
            {
                capturingToken = conditionManager.RevokeCondition(self, capturingToken);
            }

            if (targetManager.beingCapturedToken != ConditionManager.InvalidConditionToken)
            {
                targetManager.beingCapturedToken = targetManager.conditionManager.RevokeCondition(self, targetManager.beingCapturedToken);
            }

            currentTarget         = null;
            currentTargetManager  = null;
            currentTargetDelay    = 0;
            enteringCurrentTarget = false;
            targetManager.currentCaptors.Remove(self);
        }
コード例 #13
0
        public void SetPrimaryProducer(Actor self, bool isPrimary)
        {
            IsPrimary = isPrimary;

            if (isPrimary)
            {
                // Cancel existing primaries
                // TODO: THIS IS SHIT
                var queues = Info.ProductionQueues.Length == 0 ? self.Info.TraitInfos <ProductionInfo>().SelectMany(pi => pi.Produces) : Info.ProductionQueues;
                foreach (var q in queues)
                {
                    foreach (var b in self.World
                             .ActorsWithTrait <PrimaryBuilding>()
                             .Where(a =>
                                    a.Actor != self &&
                                    a.Actor.Owner == self.Owner &&
                                    a.Trait.IsPrimary &&
                                    a.Actor.Info.TraitInfos <ProductionInfo>().Any(pi => pi.Produces.Contains(q))))
                    {
                        b.Trait.SetPrimaryProducer(b.Actor, false);
                    }
                }

                if (conditionManager != null && primaryToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.PrimaryCondition))
                {
                    primaryToken = conditionManager.GrantCondition(self, Info.PrimaryCondition);
                }

                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.SelectionNotification, self.Owner.Faction.InternalName);
            }
            else if (primaryToken != ConditionManager.InvalidConditionToken)
            {
                primaryToken = conditionManager.RevokeCondition(self, primaryToken);
            }
        }
コード例 #14
0
        void ITick.Tick(Actor self)
        {
            var loc = self.Location;

            if (conditionManager == null)
            {
                return;
            }

            // The terrain type may change between ticks without the actor moving
            var currentTerrain = loc.Layer == 0 ? self.World.Map.GetTerrainInfo(loc).Type :
                                 tileSet[self.World.GetCustomMovementLayers()[loc.Layer].GetTerrainIndex(loc)].Type;

            var wantsGranted = info.TerrainTypes.Contains(currentTerrain);

            if (currentTerrain != cachedTerrain)
            {
                if (wantsGranted && conditionToken == ConditionManager.InvalidConditionToken)
                {
                    conditionToken = conditionManager.GrantCondition(self, info.Condition);
                }
                else if (!wantsGranted && conditionToken != ConditionManager.InvalidConditionToken)
                {
                    conditionToken = conditionManager.RevokeCondition(self, conditionToken);
                }
            }

            cachedTerrain = currentTerrain;
        }
コード例 #15
0
 void INotifyAiming.StoppedAiming(Actor self, AttackBase attack)
 {
     if (conditionToken != ConditionManager.InvalidConditionToken)
     {
         conditionToken = conditionManager.RevokeCondition(self, conditionToken);
     }
 }
コード例 #16
0
        public void EnablePlug(Actor self, string type)
        {
            string condition;

            if (!Info.Conditions.TryGetValue(type, out condition))
            {
                return;
            }

            if (conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionManager.RevokeCondition(self, conditionToken);
            }

            conditionToken = conditionManager.GrantCondition(self, condition);
            active         = type;
        }
コード例 #17
0
        protected override void TraitDisabled(Actor self)
        {
            if (conditionToken == ConditionManager.InvalidConditionToken)
            {
                return;
            }

            conditionToken = conditionManager.RevokeCondition(self, conditionToken);
        }
        void RevokeInstance(Actor self, bool revokeAll)
        {
            shotsFired = 0;

            if (manager == null || tokens.Count == 0)
            {
                return;
            }

            if (!revokeAll)
            {
                manager.RevokeCondition(self, tokens.Pop());
            }
            else
            {
                while (tokens.Count > 0)
                {
                    manager.RevokeCondition(self, tokens.Pop());
                }
            }
        }
コード例 #19
0
        void ITick.Tick(Actor self)
        {
            if (!IsTraitDisabled)
            {
                if (remainingTime > 0 && !isDocking)
                {
                    remainingTime--;
                }

                if (self.IsDisabled())
                {
                    Uncloak();
                }

                if (Info.UncloakOn.HasFlag(UncloakType.Move) && (lastPos == null || lastPos.Value != self.Location))
                {
                    Uncloak();
                    lastPos = self.Location;
                }
            }

            var isCloaked = Cloaked;

            if (isCloaked && !wasCloaked)
            {
                if (conditionManager != null && cloakedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CloakedCondition))
                {
                    cloakedToken = conditionManager.GrantCondition(self, Info.CloakedCondition);
                }

                // Sounds shouldn't play if the actor starts cloaked
                if (!(firstTick && Info.InitialDelay == 0) && !self.TraitsImplementing <Cloak>().Any(a => a != this && a.Cloaked))
                {
                    Game.Sound.Play(SoundType.World, Info.CloakSound, self.CenterPosition);
                }
            }
            else if (!isCloaked && wasCloaked)
            {
                if (cloakedToken != ConditionManager.InvalidConditionToken)
                {
                    cloakedToken = conditionManager.RevokeCondition(self, cloakedToken);
                }

                if (!(firstTick && Info.InitialDelay == 0) && !self.TraitsImplementing <Cloak>().Any(a => a != this && a.Cloaked))
                {
                    Game.Sound.Play(SoundType.World, Info.UncloakSound, self.CenterPosition);
                }
            }

            wasCloaked = isCloaked;
            firstTick  = false;
        }
コード例 #20
0
        public void DisablePlug(Actor self, string type)
        {
            if (type != active)
            {
                return;
            }

            if (conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }

            active = null;
        }
コード例 #21
0
        void Update(Actor self)
        {
            if (conditionManager == null)
            {
                return;
            }

            if (isPoweredDown && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, Info.PowerdownCondition);
            }
            else if (!isPoweredDown && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
        }
コード例 #22
0
        void UpdateCondition(Actor self)
        {
            if (conditionManager == null || string.IsNullOrEmpty(Info.AmmoCondition))
            {
                return;
            }

            while (currentAmmo > tokens.Count && tokens.Count < Info.Ammo)
            {
                tokens.Push(conditionManager.GrantCondition(self, Info.AmmoCondition));
            }

            while (currentAmmo < tokens.Count && tokens.Count > 0)
            {
                conditionManager.RevokeCondition(self, tokens.Pop());
            }
        }
コード例 #23
0
        void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
        {
            if (conditionManager == null)
            {
                return;
            }

            if (conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }

            if (info.Bots.Contains(newOwner.BotType))
            {
                conditionToken = conditionManager.GrantCondition(self, info.Condition);
            }
        }
コード例 #24
0
        void UpdateCondition(Actor self, MovementType types)
        {
            if (conditionManager == null)
            {
                return;
            }

            var validMovement = !IsTraitDisabled && (types & Info.ValidMovementTypes) != 0;

            if (!validMovement && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
            else if (validMovement && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, Info.Condition);
            }
        }
コード例 #25
0
        public void Tick(Actor self)
        {
            if (conditionManager == null)
            {
                return;
            }

            var disabled = self.IsDisabled();

            if (disabled && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, info.Condition);
            }
            else if (!disabled && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
        }
コード例 #26
0
        public void PrerequisitesUpdated(Actor self, bool available)
        {
            if (available == wasAvailable || conditionManager == null)
            {
                return;
            }

            if (available && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, info.Condition);
            }
            else if (!available && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }

            wasAvailable = available;
        }
コード例 #27
0
        void Update(Actor self)
        {
            if (conditionManager == null)
            {
                return;
            }

            validPowerState = !IsTraitDisabled && Info.ValidPowerStates.HasFlag(playerPower.PowerState);

            if (validPowerState && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, Info.Condition);
            }
            else if (!validPowerState && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
        }
コード例 #28
0
ファイル: Armament.cs プロジェクト: reaperrr/OpenRA
        void UpdateCondition(Actor self)
        {
            if (string.IsNullOrEmpty(Info.ReloadingCondition) || conditionManager == null)
            {
                return;
            }

            var enabled = !IsTraitDisabled && IsReloading;

            if (enabled && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, Info.ReloadingCondition);
            }
            else if (!enabled && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
        }
コード例 #29
0
        void ITick.Tick(Actor self)
        {
            if (string.IsNullOrEmpty(info.Condition) || conditionManager == null)
            {
                return;
            }

            var enabled = playerResources.Resources > info.Threshold;

            if (enabled && conditionToken == ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.GrantCondition(self, info.Condition);
            }
            else if (!enabled && conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }
        }
コード例 #30
0
        void ApplyStanceCondition(Actor self)
        {
            if (conditionManager == null)
            {
                return;
            }

            if (conditionToken != ConditionManager.InvalidConditionToken)
            {
                conditionToken = conditionManager.RevokeCondition(self, conditionToken);
            }

            string condition;

            if (Info.ConditionByStance.TryGetValue(stance, out condition))
            {
                conditionToken = conditionManager.GrantCondition(self, condition);
            }
        }