public bool HasPrerequisites(IEnumerable <string> prerequisites) { var ownedPrereqs = TechTree.GatherOwnedPrerequisites(player); return(prerequisites.All(p => !(p.Replace("~", "").StartsWith("!") ^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", ""))))); }
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); }
protected override void Created(Actor self) { techTree = self.Owner.PlayerActor.Trait <TechTree>(); Update(); base.Created(self); }
int IProductionCostModifierInfo.GetProductionCostModifier(TechTree techTree, string queue) { if ((!Queue.Any() || Queue.Contains(queue)) && (!Prerequisites.Any() || techTree.HasPrerequisites(Prerequisites))) { return(Multiplier); } return(100); }
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); }
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; }
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { techTree = newOwner.PlayerActor.Trait <TechTree>(); if (Info.ResetOnOwnerChange) { faction = newOwner.Faction.InternalName; } Update(); }
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); }
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>(); }
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); }
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(); }
public GlobalUpgradeManager(ActorInitializer init) { self = init.Self; techTree = self.Trait <TechTree>(); }
public GrantConditionOnPrerequisiteManager(ActorInitializer init) { self = init.Self; techTree = self.Trait <TechTree>(); }
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { techTree = newOwner.PlayerActor.Trait <TechTree>(); developerMode = newOwner.PlayerActor.Trait <DeveloperMode>(); }