コード例 #1
0
        public bool HasPrerequisites(IEnumerable <string> prerequisites)
        {
            var ownedPrereqs = TechTree.GatherOwnedPrerequisites(player);

            return(prerequisites.All(p => !(p.Replace("~", "").StartsWith("!")
                                            ^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", "")))));
        }
コード例 #2
0
 int IProductionTimeModifierInfo.GetProductionTimeModifier(TechTree techTree, string queue)
 {
     // Equivalent to the build speed handicap from C&C3:
     //  5% handicap = 105% build time
     // 50% handicap = 150% build time
     // 95% handicap = 195% build time
     return(100 + techTree.Owner.Handicap);
 }
コード例 #3
0
        protected override void Created(Actor self)
        {
            techTree = self.Owner.PlayerActor.Trait <TechTree>();

            Update();

            base.Created(self);
        }
コード例 #4
0
        int IProductionCostModifierInfo.GetProductionCostModifier(TechTree techTree, string queue)
        {
            if ((!Queue.Any() || Queue.Contains(queue)) && (!Prerequisites.Any() || techTree.HasPrerequisites(Prerequisites)))
            {
                return(Multiplier);
            }

            return(100);
        }
コード例 #5
0
ファイル: ProductionQueue.cs プロジェクト: dnqbob/OpenRA
        void INotifyCreated.Created(Actor self)
        {
            playerPower     = self.Owner.PlayerActor.TraitOrDefault <PowerManager>();
            playerResources = self.Owner.PlayerActor.Trait <PlayerResources>();
            developerMode   = self.Owner.PlayerActor.Trait <DeveloperMode>();
            techTree        = self.Owner.PlayerActor.Trait <TechTree>();

            productionTraits = self.TraitsImplementing <Production>().Where(p => p.Info.Produces.Contains(Info.Type)).ToArray();
            CacheProducibles(self.Owner.PlayerActor);
        }
コード例 #6
0
ファイル: SupportPowerManager.cs プロジェクト: cjshmyr/OpenRA
        public SupportPowerManager(ActorInitializer init)
        {
            Self       = init.Self;
            DevMode    = Self.Trait <DeveloperMode>();
            TechTree   = Self.Trait <TechTree>();
            RadarPings = Exts.Lazy(() => init.World.WorldActor.TraitOrDefault <RadarPings>());

            init.World.ActorAdded   += ActorAdded;
            init.World.ActorRemoved += ActorRemoved;
        }
コード例 #7
0
        public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
        {
            techTree = newOwner.PlayerActor.Trait <TechTree>();

            if (Info.ResetOnOwnerChange)
            {
                faction = newOwner.Faction.InternalName;
            }

            Update();
        }
コード例 #8
0
        protected override void Created(Actor self)
        {
            // Special case handling is required for the Player actor.
            // Created is called before Player.PlayerActor is assigned,
            // so we must query other player traits from self, knowing that
            // it refers to the same actor as self.Owner.PlayerActor
            var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;

            techTree = playerActor.Trait <TechTree>();

            Update();

            base.Created(self);
        }
コード例 #9
0
        public SupportPower(Actor self, SupportPowerInfo info)
            : base(info)
        {
            Self      = self;
            this.info = info;

            // Special case handling is required for the Player actor.
            // Created is called before Player.PlayerActor is assigned,
            // so we must query other player traits from self, knowing that
            // it refers to the same actor as self.Owner.PlayerActor
            var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;

            techTree      = playerActor.Trait <TechTree>();
            developerMode = playerActor.Trait <DeveloperMode>();
        }
コード例 #10
0
        void INotifyCreated.Created(Actor self)
        {
            // Special case handling is required for the Player actor.
            // Created is called before Player.PlayerActor is assigned,
            // so we must query other player traits from self, knowing that
            // it refers to the same actor as self.Owner.PlayerActor
            var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;

            playerPower     = playerActor.TraitOrDefault <PowerManager>();
            playerResources = playerActor.Trait <PlayerResources>();
            developerMode   = playerActor.Trait <DeveloperMode>();
            techTree        = playerActor.Trait <TechTree>();

            productionTraits = self.TraitsImplementing <Production>().Where(p => p.Info.Produces.Contains(Info.Type)).ToArray();
            CacheProducibles(playerActor);
        }
コード例 #11
0
ファイル: ProductionQueue.cs プロジェクト: dnqbob/OpenRA
        void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
        {
            ClearQueue();

            playerPower     = newOwner.PlayerActor.TraitOrDefault <PowerManager>();
            playerResources = newOwner.PlayerActor.Trait <PlayerResources>();
            developerMode   = newOwner.PlayerActor.Trait <DeveloperMode>();
            techTree        = newOwner.PlayerActor.Trait <TechTree>();

            if (!Info.Sticky)
            {
                Faction        = self.Owner.Faction.InternalName;
                IsValidFaction = !Info.Factions.Any() || Info.Factions.Contains(Faction);
            }

            // Regenerate the producibles and tech tree state
            oldOwner.PlayerActor.Trait <TechTree>().Remove(this);
            CacheProducibles(newOwner.PlayerActor);
            techTree.Update();
        }
コード例 #12
0
 public GlobalUpgradeManager(ActorInitializer init)
 {
     self     = init.Self;
     techTree = self.Trait <TechTree>();
 }
 public GrantConditionOnPrerequisiteManager(ActorInitializer init)
 {
     self     = init.Self;
     techTree = self.Trait <TechTree>();
 }
コード例 #14
0
 void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
 {
     techTree      = newOwner.PlayerActor.Trait <TechTree>();
     developerMode = newOwner.PlayerActor.Trait <DeveloperMode>();
 }