Example #1
0
        void Deploy()
        {
            // Something went wrong, most likely due to deploy order spam and the fact that this is a delayed action.
            if (deployState != TimedDeployState.Ready)
            {
                return;
            }

            deployState = TimedDeployState.Deploying;

            if (!string.IsNullOrEmpty(info.DeploySound))
            {
                Game.Sound.Play(info.DeploySound, self.CenterPosition);
            }

            // If there is no animation to play just grant the upgrades that are used while deployed.
            // Alternatively, play the deploy animation and then grant the upgrades.
            if (string.IsNullOrEmpty(info.DeployAnimation) || body.Value == null)
            {
                OnDeployCompleted();
            }
            else
            {
                body.Value.PlayCustomAnimation(self, info.DeployAnimation, OnDeployCompleted);
            }
        }
        void ITick.Tick(Actor self)
        {
            if (IsTraitPaused || IsTraitDisabled)
            {
                return;
            }

            if (deployState == TimedDeployState.Ready || deployState == TimedDeployState.Deploying || deployState == TimedDeployState.Undeploying)
            {
                return;
            }

            if (--ticks < 0)
            {
                if (deployState == TimedDeployState.Charging)
                {
                    ticks       = Info.DeployedTicks;
                    deployState = TimedDeployState.Ready;
                }
                else
                {
                    RevokeDeploy();
                }
            }
        }
        void Deploy()
        {
            // Something went wrong, most likely due to deploy order spam and the fact that this is a delayed action.
            if (deployState != TimedDeployState.Ready)
            {
                return;
            }

            deployState = TimedDeployState.Deploying;

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

            var wsb = wsbs.FirstEnabledTraitOrDefault();

            // If there is no animation to play just grant the upgrades that are used while deployed.
            // Alternatively, play the deploy animation and then grant the upgrades.
            if (string.IsNullOrEmpty(Info.DeployAnimation) || wsb == null)
            {
                OnDeployCompleted();
            }
            else
            {
                if (manager != null && !string.IsNullOrEmpty(Info.DeployingCondition) && deployingToken == ConditionManager.InvalidConditionToken)
                {
                    deployingToken = manager.GrantCondition(self, Info.DeployingCondition);
                }
                wsb.PlayCustomAnimation(self, Info.DeployAnimation, OnDeployCompleted);
            }
        }
Example #4
0
        void OnDeployCompleted()
        {
            foreach (var up in info.DeployedUpgrades)
            {
                manager.GrantUpgrade(self, up, this);
            }

            deployState = TimedDeployState.Active;
        }
Example #5
0
        void OnUndeployCompleted()
        {
            foreach (var up in info.DeployedUpgrades)
            {
                manager.RevokeUpgrade(self, up, this);
            }

            deployState = TimedDeployState.Charging;
            ticks       = info.CooldownTicks;
        }
Example #6
0
 void INotifyCreated.Created(Actor self)
 {
     if (info.StartsFullyCharged)
     {
         ticks       = info.DeployedTicks;
         deployState = TimedDeployState.Ready;
     }
     else
     {
         ticks       = info.CooldownTicks;
         deployState = TimedDeployState.Charging;
     }
 }
        void OnDeployCompleted()
        {
            if (manager != null && !string.IsNullOrEmpty(Info.DeployedCondition) && deployedToken == ConditionManager.InvalidConditionToken)
            {
                deployedToken = manager.GrantCondition(self, Info.DeployedCondition);
            }

            if (deployingToken != ConditionManager.InvalidConditionToken)
            {
                deployingToken = manager.RevokeCondition(self, deployingToken);
            }

            deployState = TimedDeployState.Active;
        }
        void OnUndeployCompleted()
        {
            if (deployedToken != ConditionManager.InvalidConditionToken)
            {
                deployedToken = manager.RevokeCondition(self, deployedToken);
            }

            if (deployingToken != ConditionManager.InvalidConditionToken)
            {
                deployingToken = manager.RevokeCondition(self, deployingToken);
            }

            deployState = TimedDeployState.Charging;
            ticks       = Info.CooldownTicks;
        }
Example #9
0
        void INotifyCreated.Created(Actor self)
        {
            manager = self.Trait <ConditionManager>();

            if (info.StartsFullyCharged)
            {
                ticks       = info.DeployedTicks;
                deployState = TimedDeployState.Ready;
            }
            else
            {
                ticks       = info.CooldownTicks;
                deployState = TimedDeployState.Charging;
            }
        }
        void INotifyCreated.Created(Actor self)
        {
            manager = self.Trait <ConditionManager>();
            wsbs    = self.TraitsImplementing <WithSpriteBody>().Where(w => Info.BodyNames.Contains(w.Info.Name)).ToArray();

            if (Info.StartsFullyCharged)
            {
                ticks       = Info.DeployedTicks;
                deployState = TimedDeployState.Ready;
            }
            else
            {
                ticks       = Info.CooldownTicks;
                deployState = TimedDeployState.Charging;
            }
        }
        protected override void Created(Actor self)
        {
            wsbs = self.TraitsImplementing <WithSpriteBody>().Where(w => Info.BodyNames.Contains(w.Info.Name)).ToArray();

            if (Info.StartsFullyCharged)
            {
                ticks       = Info.DeployedTicks;
                deployState = TimedDeployState.Ready;
            }
            else
            {
                ticks       = Info.CooldownTicks;
                deployState = TimedDeployState.Charging;
            }

            base.Created(self);
        }
Example #12
0
        void ITick.Tick(Actor self)
        {
            if (deployState == TimedDeployState.Ready || deployState == TimedDeployState.Deploying || deployState == TimedDeployState.Undeploying)
            {
                return;
            }

            if (--ticks < 0)
            {
                if (deployState == TimedDeployState.Charging)
                {
                    ticks       = info.DeployedTicks;
                    deployState = TimedDeployState.Ready;
                }
                else
                {
                    RevokeDeploy();
                }
            }
        }
Example #13
0
        void RevokeDeploy()
        {
            deployState = TimedDeployState.Undeploying;

            if (!string.IsNullOrEmpty(info.UndeploySound))
            {
                Game.Sound.Play(info.UndeploySound, self.CenterPosition);
            }

            // If there is no animation to play just grant the upgrades that are used while undeployed.
            // Alternatively, play the undeploy animation and then grant the upgrades.
            if (string.IsNullOrEmpty(info.DeployAnimation) || body.Value == null)
            {
                OnUndeployCompleted();
            }
            else
            {
                body.Value.PlayCustomAnimationBackwards(self, info.DeployAnimation, OnUndeployCompleted);
            }
        }
Example #14
0
        void RevokeDeploy()
        {
            deployState = TimedDeployState.Undeploying;

            if (!string.IsNullOrEmpty(info.UndeploySound))
            {
                Game.Sound.Play(SoundType.World, info.UndeploySound, self.CenterPosition);
            }

            if (string.IsNullOrEmpty(info.UndeployAnimation) || body.Value == null)
            {
                OnUndeployCompleted();
            }
            else
            {
                if (manager != null && !string.IsNullOrEmpty(info.DeployingCondition) && deployingToken == ConditionManager.InvalidConditionToken)
                {
                    deployingToken = manager.GrantCondition(self, info.DeployingCondition);
                }
                body.Value.PlayCustomAnimation(self, info.UndeployAnimation, OnUndeployCompleted);
            }
        }
        void RevokeDeploy()
        {
            deployState = TimedDeployState.Undeploying;

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

            var wsb = wsbs.FirstEnabledTraitOrDefault();

            if (string.IsNullOrEmpty(Info.UndeployAnimation) || wsb == null)
            {
                OnUndeployCompleted();
            }
            else
            {
                if (manager != null && !string.IsNullOrEmpty(Info.DeployingCondition) && deployingToken == ConditionManager.InvalidConditionToken)
                {
                    deployingToken = manager.GrantCondition(self, Info.DeployingCondition);
                }
                wsb.PlayCustomAnimation(self, Info.UndeployAnimation, OnUndeployCompleted);
            }
        }