public void Tick(PlayerResources pr, PowerManager pm) { if (Done) { if (OnComplete != null) OnComplete(); return; } if (Paused) return; if (pm.PowerState != PowerState.Normal) { if (--slowdown <= 0) slowdown = Queue.Info.LowPowerSlowdown; else return; } var costThisFrame = RemainingCost / RemainingTime; if (costThisFrame != 0 && !pr.TakeCash(costThisFrame)) return; RemainingCost -= costThisFrame; RemainingTime -= 1; if (RemainingTime > 0) return; Done = true; }
public Building(ActorInitializer init) { this.self = init.self; this.topLeft = init.Get<LocationInit,int2>(); this.Info = self.Info.Traits.Get<BuildingInfo>(); this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>(); }
public OreRefinery(Actor self, OreRefineryInfo info) { this.self = self; Info = info; PlayerResources = self.Owner.PlayerActor.Trait<PlayerResources>(); PlayerPower = self.Owner.PlayerActor.Trait<PowerManager>(); }
public BaseBuilder(HackyAI ai, string category, Player p, PowerManager pm, PlayerResources pr) { this.ai = ai; world = p.World; player = p; playerPower = pm; playerResources = pr; this.category = category; }
public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete) { Item = item; RemainingTime = TotalTime = 1; RemainingCost = TotalCost = cost; OnComplete = onComplete; Queue = queue; this.pm = pm; }
public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete) { Item = item; RemainingTime = TotalTime = 1; RemainingCost = TotalCost = cost; OnComplete = onComplete; Queue = queue; this.pm = pm; //Log.Write("debug", "new ProductionItem: {0} time={1} cost={2}", item, time, cost); }
public BaseBuilder(HackyAI ai, string category, Player p, PowerManager pm, PlayerResources pr) { this.ai = ai; world = p.World; player = p; playerPower = pm; playerResources = pr; this.category = category; failRetryTicks = ai.Info.StructureProductionResumeDelay; }
public Building(ActorInitializer init) { this.self = init.self; this.topLeft = init.Get<LocationInit,int2>(); Info = self.Info.Traits.Get<BuildingInfo>(); self.CenterLocation = Game.CellSize * ((float2)topLeft + .5f * (float2)Info.Dimensions); PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>(); }
public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete) { Item = item; RemainingTime = TotalTime = 1; RemainingCost = TotalCost = cost; OnComplete = onComplete; Queue = queue; this.pm = pm; ai = Queue.Actor.World.Map.Rules.Actors[Item]; bi = ai.TraitInfo<BuildableInfo>(); }
public void Activate(Player p) { this.p = p; this.world = p.World; GameStarted = true; random = new XRandom((int)p.PlayerActor.ActorID); SpecialPowers = p.PlayerActor.Trait<SupportPowerManager>(); Power = p.PlayerActor.Trait<PowerManager>(); Resources = p.PlayerActor.Trait<PlayerResources>(); squadmanager = new SquadManager(this); // Initialize builders Builders = new List<IAIBuilder>() { new BaseBuilder(this), new DefenseBuilder(this), new InfantryBuilder(this), new VehicleBuilder(this), new AircraftBuilder(this), new ShipBuilder(this) }; // Have the bot cheat, gets free 500 000 credits at the start of the match Resources.GiveCash(500000); }
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { power = newOwner.PlayerActor.Trait<PowerManager>(); }
public PowerMultiplier(Actor self, PowerMultiplierInfo info) : base(info, "PowerMultiplier", self.Info.Name) { power = self.Owner.PlayerActor.Trait<PowerManager>(); }
public ProductionQueue( Actor self, Actor playerActor, ProductionQueueInfo info ) { this.self = self; this.Info = info; playerResources = playerActor.Trait<PlayerResources>(); PlayerPower = playerActor.Trait<PowerManager>(); Race = self.Owner.Country; Produceable = InitTech(playerActor); }
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { PlayerPower = newOwner.PlayerActor.Trait<PowerManager>(); playerResources = newOwner.PlayerActor.Trait<PlayerResources>(); ClearQueue(); // Produceable contains the tech from the original owner - this is desired so we don't clear it. Produceable = InitTech(self.Owner.PlayerActor); // Force a third(!) tech tree update to ensure that prerequisites are correct. // The first two updates are triggered by adding/removing the actor when // changing ownership, *before* the new techtree watchers have been set up. // This is crap. self.Owner.PlayerActor.Trait<TechTree>().Update(); }
public PowerTooltip(Actor self) { this.self = self; powerManager = self.Owner.PlayerActor.Trait<PowerManager>(); developerMode = self.Owner.PlayerActor.Trait<DeveloperMode>(); }
// Called by the host's player creation code public void Activate(Player p) { Player = p; enabled = true; playerPower = p.PlayerActor.Trait<PowerManager>(); supportPowerMngr = p.PlayerActor.Trait<SupportPowerManager>(); playerResource = p.PlayerActor.Trait<PlayerResources>(); foreach (var building in Info.BuildingQueues) builders.Add(new BaseBuilder(this, building, p, playerPower, playerResource)); foreach (var defense in Info.DefenseQueues) builders.Add(new BaseBuilder(this, defense, p, playerPower, playerResource)); Random = new MersenneTwister((int)p.PlayerActor.ActorID); // Avoid all AIs trying to rush in the same tick, randomize their initial rush a little. var smallFractionOfRushInterval = Info.RushInterval / 20; rushTicks = Random.Next(Info.RushInterval - smallFractionOfRushInterval, Info.RushInterval + smallFractionOfRushInterval); // Avoid all AIs reevaluating assignments on the same tick, randomize their initial evaluation delay. assignRolesTicks = Random.Next(0, Info.AssignRolesInterval); attackForceTicks = Random.Next(0, Info.AttackForceInterval); minAttackForceDelayTicks = Random.Next(0, Info.MinimumAttackForceDelay); resourceTypeIndices = new BitArray(World.TileSet.TerrainInfo.Length); // Big enough foreach (var t in Map.Rules.Actors["world"].TraitInfos<ResourceTypeInfo>()) resourceTypeIndices.Set(World.TileSet.GetTerrainIndex(t.TerrainType), true); }
public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info) { self = init.Self; Info = info; playerResources = playerActor.Trait<PlayerResources>(); playerPower = playerActor.Trait<PowerManager>(); developerMode = playerActor.Trait<DeveloperMode>(); Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName; Enabled = !info.Factions.Any() || info.Factions.Contains(Faction); CacheProducibles(playerActor); allProducibles = producible.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key); buildableProducibles = producible.Where(a => a.Value.Buildable).Select(a => a.Key); }
public InfiltrateForPowerOutage(Actor self, InfiltrateForPowerOutageInfo info) { this.info = info; playerPower = self.Owner.PlayerActor.Trait<PowerManager>(); }
public AffectedByPowerOutage(Actor self) { playerPower = self.Owner.PlayerActor.Trait<PowerManager>(); }
public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info) { self = init.self; Info = info; playerResources = playerActor.Trait<PlayerResources>(); playerPower = playerActor.Trait<PowerManager>(); developerMode = playerActor.Trait<DeveloperMode>(); Race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race; Enabled = !info.Race.Any() || info.Race.Contains(Race); CacheProduceables(playerActor); }
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { // Steal any docked harv too if (dockedHarv != null) dockedHarv.ChangeOwner(newOwner); // Unlink any non-docked harvs foreach (var harv in GetLinkedHarvesters()) if (harv.Actor.Owner == oldOwner) harv.Trait.UnlinkProc(harv.Actor, self); PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>(); PlayerPower = newOwner.PlayerActor.Trait<PowerManager>(); }
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { playerPower = newOwner.PlayerActor.Trait<PowerManager>(); }
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { PlayerPower = newOwner.PlayerActor.Trait<PowerManager>(); PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>(); Queue.Clear(); // Produceable contains the tech from the original owner - this is desired so we don't clear it. Produceable = InitTech(self.Owner.PlayerActor); }
public CanPowerDown(ActorInitializer init) { PowerManager = init.self.Owner.PlayerActor.Trait<PowerManager>(); normalPower = init.self.Info.Traits.Get<BuildingInfo>().Power; }
public RequiresPower( Actor self ) { power = self.Owner.PlayerActor.Trait<PowerManager>(); }
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { PowerManager = newOwner.PlayerActor.Trait<PowerManager>(); }
/* called by the host's player creation code */ public void Activate(Player p) { this.p = p; enabled = true; playerPower = p.PlayerActor.Trait<PowerManager>(); builders = new BaseBuilder[] { new BaseBuilder( this, "Building", ChooseBuildingToBuild ), new BaseBuilder( this, "Defense", ChooseDefenseToBuild ) }; }
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { ClearQueue(); playerPower = newOwner.PlayerActor.Trait<PowerManager>(); playerResources = newOwner.PlayerActor.Trait<PlayerResources>(); developerMode = newOwner.PlayerActor.Trait<DeveloperMode>(); if (!Info.Sticky) { Race = self.Owner.Country.Race; Enabled = !Info.Race.Any() || Info.Race.Contains(Race); } // Regenerate the produceables and tech tree state oldOwner.PlayerActor.Trait<TechTree>().Remove(this); CacheProduceables(newOwner.PlayerActor); newOwner.PlayerActor.Trait<TechTree>().Update(); }
public ProductionQueue( Actor self, Actor playerActor, ProductionQueueInfo info ) { this.self = self; this.Info = info; PlayerResources = playerActor.Trait<PlayerResources>(); PlayerPower = playerActor.Trait<PowerManager>(); var ttc = playerActor.Trait<TechTree>(); foreach (var a in AllBuildables(Info.Type)) { var bi = a.Traits.Get<BuildableInfo>(); // Can our race build this by satisfying normal prereqs? var buildable = bi.Owner.Contains(self.Owner.Country.Race); Produceable.Add( a, new ProductionState(){ Visible = buildable && !bi.Hidden } ); if (buildable) ttc.Add( a.Name, a.Traits.Get<BuildableInfo>().Prerequisites.ToList(), this ); } }