コード例 #1
0
ファイル: DeployToUpgrade.cs プロジェクト: huwpascoe/OpenRA
        void OnDeployStarted()
        {
            foreach (var up in info.UndeployedUpgrades)
            {
                manager.RevokeUpgrade(self, up, this);
            }

            deployState = DeployState.Deploying;
        }
コード例 #2
0
 void OnAirborneAltitudeLeft()
 {
     if (!airborne)
     {
         return;
     }
     airborne = false;
     if (um != null)
     {
         foreach (var u in Info.AirborneUpgrades)
         {
             um.RevokeUpgrade(self, u, this);
         }
     }
 }
コード例 #3
0
        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString != "DeployToUpgrade")
            {
                return;
            }

            if (!OnValidTerrain())
            {
                return;
            }

            if (isUpgraded)
            {
                foreach (var up in info.Upgrades)
                {
                    manager.RevokeUpgrade(self, up, this);
                }
            }
            else
            {
                foreach (var up in info.Upgrades)
                {
                    manager.GrantUpgrade(self, up, this);
                }
            }

            isUpgraded = !isUpgraded;
        }
コード例 #4
0
        void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
        {
            if (um == null)
            {
                return;
            }

            var rand = Game.CosmeticRandom;

            if (!granted && info.ValidDamageStates.HasFlag(e.DamageState) && !info.ValidDamageStates.HasFlag(e.PreviousDamageState))
            {
                granted = true;
                var sound = info.EnabledSounds.RandomOrDefault(rand);
                Game.Sound.Play(sound, self.CenterPosition);
                foreach (var u in info.Upgrades)
                {
                    um.GrantUpgrade(self, u, this);
                }
            }
            else if (granted && !info.ValidDamageStates.HasFlag(e.DamageState) && info.ValidDamageStates.HasFlag(e.PreviousDamageState))
            {
                granted = false;
                var sound = info.DisabledSounds.RandomOrDefault(rand);
                Game.Sound.Play(sound, self.CenterPosition);
                foreach (var u in info.Upgrades)
                {
                    um.RevokeUpgrade(self, u, this);
                }
            }
        }
コード例 #5
0
        public void Tick(Actor self)
        {
            var currentTerrain = self.World.Map.GetTerrainInfo(self.Location).Type;
            var wantsGranted   = info.TerrainTypes.Contains(currentTerrain);

            if (currentTerrain != previousTerrain)
            {
                if (wantsGranted && !granted)
                {
                    foreach (var up in info.Upgrades)
                    {
                        manager.GrantUpgrade(self, up, this);
                    }

                    granted = true;
                }
                else if (!wantsGranted && granted)
                {
                    foreach (var up in info.Upgrades)
                    {
                        manager.RevokeUpgrade(self, up, this);
                    }

                    granted = false;
                }
            }

            previousTerrain = currentTerrain;
        }
コード例 #6
0
ファイル: Cargo.cs プロジェクト: Walkman-Mirror/OpenRA
        internal void UnreserveSpace(Actor a)
        {
            if (!reserves.Contains(a))
            {
                return;
            }

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

            if (reserves.Count == 0)
            {
                foreach (var u in Info.LoadingUpgrades)
                {
                    upgradeManager.RevokeUpgrade(self, u, this);
                }
            }
        }
コード例 #7
0
 void RevokeUpgrades(Actor self)
 {
     if (upgradeManager != null)
     {
         foreach (var u in Info.WhileCloakedUpgrades)
         {
             upgradeManager.RevokeUpgrade(self, u, this);
         }
     }
 }
コード例 #8
0
ファイル: Pluggable.cs プロジェクト: huwpascoe/OpenRA
        public void DisablePlug(Actor self, string type)
        {
            if (type != active)
            {
                return;
            }

            foreach (var u in Info.Upgrades[type])
            {
                upgradeManager.RevokeUpgrade(self, u, this);
            }
        }
コード例 #9
0
ファイル: Carryable.cs プロジェクト: SoftEngGroup/OpenRAGroup
        // This gets called by carrier after we touched down
        public virtual void Detached(Actor self)
        {
            if (!attached)
            {
                return;
            }

            attached = false;
            foreach (var u in info.CarryableUpgrades)
            {
                upgradeManager.RevokeUpgrade(self, u, this);
            }
        }
コード例 #10
0
        void Unlock()
        {
            if (!locked)
            {
                return;
            }

            locked = false;
            foreach (var u in info.CarryableUpgrades)
            {
                upgradeManager.RevokeUpgrade(self, u, this);
            }
        }
コード例 #11
0
ファイル: Cloak.cs プロジェクト: huwpascoe/OpenRA
        public void Uncloak(int time)
        {
            if (Cloaked)
            {
                Game.Sound.Play(Info.UncloakSound, self.CenterPosition);
                if (upgradeManager != null)
                {
                    foreach (var u in Info.WhileCloakedUpgrades)
                    {
                        upgradeManager.RevokeUpgrade(self, u, this);
                    }
                }
            }

            remainingTime = Math.Max(remainingTime, time);
        }
コード例 #12
0
        public void SetPrimaryProducer(Actor self, bool state)
        {
            if (state == false)
            {
                IsPrimary = false;
                foreach (var up in info.Upgrades)
                {
                    manager.RevokeUpgrade(self, up, this);
                }
                return;
            }

            // TODO: THIS IS SHIT
            // Cancel existing primaries
            foreach (var p in self.Info.TraitInfo <ProductionInfo>().Produces)
            {
                var productionType = p;                         // benign closure hazard
                foreach (var b in self.World
                         .ActorsWithTrait <PrimaryBuilding>()
                         .Where(a =>
                                a.Actor.Owner == self.Owner &&
                                a.Trait.IsPrimary &&
                                a.Actor.Info.TraitInfo <ProductionInfo>().Produces.Contains(productionType)))
                {
                    b.Trait.SetPrimaryProducer(b.Actor, false);
                }
            }

            IsPrimary = true;
            foreach (var up in info.Upgrades)
            {
                manager.GrantUpgrade(self, up, this);
            }

            Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.SelectionNotification, self.Owner.Faction.InternalName);
        }
コード例 #13
0
        public void PrerequisitesUpdated(Actor self, bool available)
        {
            if (available == wasAvailable)
            {
                return;
            }

            if (available)
            {
                foreach (var u in info.Upgrades)
                {
                    manager.GrantUpgrade(self, u, this);
                }
            }
            else
            {
                foreach (var u in info.Upgrades)
                {
                    manager.RevokeUpgrade(self, u, this);
                }
            }

            wasAvailable = available;
        }