protected override void TraitEnabled(Actor self) { domainIndex = world.WorldActor.Trait <DomainIndex>(); resLayer = world.WorldActor.TraitOrDefault <ResourceLayer>(); claimLayer = world.WorldActor.TraitOrDefault <ResourceClaimLayer>(); scanForIdleHarvestersTicks = Info.ScanForIdleHarvestersInterval; }
public HackyAI(HackyAIInfo info, ActorInitializer init) { Info = info; World = init.World; if (World.Type == WorldType.Editor) { return; } domainIndex = World.WorldActor.Trait <DomainIndex>(); resLayer = World.WorldActor.Trait <ResourceLayer>(); territory = World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); pathfinder = World.WorldActor.Trait <IPathFinder>(); isEnemyUnit = unit => Player.Stances[unit.Owner] == Stance.Enemy && !unit.Info.HasTraitInfo <HuskInfo>() && unit.Info.HasTraitInfo <ITargetableInfo>(); unitCannotBeOrdered = a => a.Owner != Player || a.IsDead || !a.IsInWorld; foreach (var decision in info.PowerDecisions) { powerDecisions.Add(decision.OrderName, decision); } }
protected override void TraitEnabled(Actor self) { // Avoid all AIs reevaluating assignments on the same tick, randomize their initial evaluation delay. minCaptureDelayTicks = world.LocalRandom.Next(0, Info.MinimumCaptureDelay); pathfinder = world.WorldActor.Trait <IPathFinder>(); domainIndex = world.WorldActor.Trait <DomainIndex>(); }
public AIHarvesterManager(HackyAI ai, Player p) { this.ai = ai; world = p.World; pathfinder = world.WorldActor.Trait <IPathFinder>(); domainIndex = world.WorldActor.Trait <DomainIndex>(); resLayer = world.WorldActor.TraitOrDefault <ResourceLayer>(); claimLayer = world.WorldActor.TraitOrDefault <ResourceClaimLayer>(); }
public FindAndDeliverResources(Actor self, Actor deliverActor = null) { harv = self.Trait <Harvester>(); harvInfo = self.Info.TraitInfo <HarvesterInfo>(); mobile = self.Trait <Mobile>(); claimLayer = self.World.WorldActor.Trait <ResourceClaimLayer>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); this.deliverActor = deliverActor; }
public SpawnerRefineryHarvest(Actor self) { harv = self.Trait <SpawnerRefineryMaster>(); harvInfo = self.Info.TraitInfo <SpawnerRefineryMasterInfo>(); claimLayer = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); lastScanRange = harvInfo.LongScanRadius; }
public SlaveMinerMasterHarvest(Actor self) { harv = self.Trait <SlaveMinerMaster>(); harvInfo = self.Info.TraitInfo <SlaveMinerMasterInfo>(); claimLayer = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); lastScanRange = harvInfo.LongScanRadius; ChildHasPriority = false; }
public FindResources(Actor self) { harv = self.Trait <Harvester>(); harvInfo = self.Info.TraitInfo <HarvesterInfo>(); mobile = self.Trait <Mobile>(); mobileInfo = self.Info.TraitInfo <MobileInfo>(); claimLayer = self.World.WorldActor.Trait <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); }
public MoveAdjacentTo(Actor self, Target target) { this.target = target; mobile = self.Trait<Mobile>(); pathFinder = self.World.WorldActor.Trait<PathFinder>(); domainIndex = self.World.WorldActor.TraitOrDefault<DomainIndex>(); movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet); repath = true; }
public MoveAdjacentTo(Actor self, Target target) { this.target = target; mobile = self.Trait <Mobile>(); pathFinder = self.World.WorldActor.Trait <PathFinder>(); domainIndex = self.World.WorldActor.TraitOrDefault <DomainIndex>(); movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet); repath = true; }
protected override void TraitEnabled(Actor self) { // PERF: Avoid all AIs reevaluating assignments on the same tick, randomize their initial evaluation delay. scanForIdleMinersTicks = world.LocalRandom.Next(0, Info.MinimumScanDelay); pathfinder = world.WorldActor.Trait <IPathFinder>(); domainIndex = world.WorldActor.Trait <DomainIndex>(); resourceLayer = world.WorldActor.TraitOrDefault <UndergroundResourceLayer>(); requestUnitProduction = player.PlayerActor.TraitsImplementing <IBotRequestUnitProduction>().ToArray(); }
public FindResources(Actor self) { harv = self.Trait<Harvester>(); harvInfo = self.Info.TraitInfo<HarvesterInfo>(); mobile = self.Trait<Mobile>(); mobileInfo = self.Info.TraitInfo<MobileInfo>(); resLayer = self.World.WorldActor.Trait<ResourceLayer>(); territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait<IPathFinder>(); domainIndex = self.World.WorldActor.Trait<DomainIndex>(); }
public FindAndEatResources(Actor self, Actor deliverActor = null) { harv = self.Trait <Sandworm>(); harvInfo = self.Info.TraitInfo <SandwormInfo>(); mobile = self.Trait <Mobile>(); locomotorInfo = mobile.Info.LocomotorInfo; claimLayer = self.World.WorldActor.Trait <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); this.deliverActor = deliverActor; }
protected override void TraitEnabled(Actor self) { pathfinder = world.WorldActor.Trait <IPathFinder>(); domainIndex = world.WorldActor.Trait <DomainIndex>(); resLayer = world.WorldActor.TraitOrDefault <ResourceLayer>(); claimLayer = world.WorldActor.TraitOrDefault <ResourceClaimLayer>(); // Avoid all AIs scanning for idle harvesters on the same tick, randomize their initial scan delay. scanForIdleHarvestersTicks = world.LocalRandom.Next(Info.ScanForIdleHarvestersInterval, Info.ScanForIdleHarvestersInterval * 2); scanForEnoughHarvestersTicks = Info.ProduceHarvestersInterval; }
public SpawnerHarvesterHarvest(Actor self) { harv = self.Trait <SpawnerHarvesterMaster>(); harvInfo = self.Info.TraitInfo <SpawnerHarvesterMasterInfo>(); mobile = self.Trait <Mobile>(); mobileInfo = self.Info.TraitInfo <MobileInfo>(); deploy = self.Trait <GrantConditionOnDeploy>(); claimLayer = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); tranforms = self.Trait <Transforms>(); }
public MoveAdjacentTo(Actor self, Target target) { Target = target; mobile = self.Trait<Mobile>(); pathFinder = self.World.WorldActor.Trait<IPathFinder>(); domainIndex = self.World.WorldActor.Trait<DomainIndex>(); movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet); if (target.IsValidFor(self)) targetPosition = self.World.Map.CellContaining(target.CenterPosition); repath = true; }
public MoveAdjacentTo(Actor self, Target target) { Target = target; Mobile = self.Trait <Mobile>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); if (target.IsValidFor(self)) { targetPosition = self.World.Map.CellContaining(target.CenterPosition); } repath = true; }
public MoveAdjacentTo(Actor self, Target target) { Target = target; mobile = self.Trait <Mobile>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); movementClass = (uint)mobile.Info.GetMovementClass(self.World.Map.Rules.TileSet); if (target.IsValidFor(self)) { targetPosition = self.World.Map.CellContaining(target.CenterPosition); } repath = true; }
public HackyAI(HackyAIInfo info, ActorInitializer init) { Info = info; World = init.World; domainIndex = World.WorldActor.Trait <DomainIndex>(); resLayer = World.WorldActor.TraitOrDefault <ResourceLayer>(); claimLayer = World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); pathfinder = World.WorldActor.Trait <IPathFinder>(); isEnemyUnit = unit => Player.Stances[unit.Owner] == Stance.Enemy && !unit.Info.HasTraitInfo <HuskInfo>() && unit.Info.HasTraitInfo <ITargetableInfo>(); unitCannotBeOrdered = a => a.Owner != Player || a.IsDead || !a.IsInWorld; }
public AutoDeployMinersBotModule(Actor self, AutoDeployMinersBotModuleInfo info) : base(info) { world = self.World; player = self.Owner; resourceLayer = self.World.WorldActor.Trait <ResourceLayer>(); claimLayer = self.World.WorldActor.Trait <ResourceClaimLayer>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); var resourceTypes = self.World.WorldActor.TraitsImplementing <ResourceType>().ToArray(); var resourceType = resourceTypes.FirstOrDefault(a => string.Equals(a.Info.Type, info.TargetResourceType, StringComparison.InvariantCultureIgnoreCase)); if (resourceType == null) { throw new ArgumentException($"Couldn't find resource type: {info.TargetResourceType}"); } }
public MoveAdjacentTo(Actor self, Target target, WPos?initialTargetPosition = null, Color?targetLineColor = null) { this.target = target; this.targetLineColor = targetLineColor; Mobile = self.Trait <Mobile>(); pathFinder = self.World.WorldActor.Trait <IPathFinder>(); domainIndex = self.World.WorldActor.Trait <DomainIndex>(); ChildHasPriority = false; // The target may become hidden between the initial order request and the first tick (e.g. if queued) // Moving to any position (even if quite stale) is still better than immediately giving up if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner)) || target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain) { lastVisibleTarget = Target.FromPos(target.CenterPosition); lastVisibleTargetLocation = self.World.Map.CellContaining(target.CenterPosition); } else if (initialTargetPosition.HasValue) { lastVisibleTarget = Target.FromPos(initialTargetPosition.Value); lastVisibleTargetLocation = self.World.Map.CellContaining(initialTargetPosition.Value); } }
public ReinforcementsGlobal(ScriptContext context) : base(context) { domainIndex = context.World.WorldActor.Trait <DomainIndex>(); }
public HackyAI(HackyAIInfo info, ActorInitializer init) { Info = info; World = init.World; if (World.Type == WorldType.Editor) return; domainIndex = World.WorldActor.Trait<DomainIndex>(); resLayer = World.WorldActor.Trait<ResourceLayer>(); territory = World.WorldActor.TraitOrDefault<ResourceClaimLayer>(); pathfinder = World.WorldActor.Trait<IPathFinder>(); isEnemyUnit = unit => Player.Stances[unit.Owner] == Stance.Enemy && !unit.Info.HasTraitInfo<HuskInfo>() && unit.Info.HasTraitInfo<ITargetableInfo>(); unitCannotBeOrdered = a => a.Owner != Player || a.IsDead || !a.IsInWorld; foreach (var decision in info.PowerDecisions) powerDecisions.Add(decision.OrderName, decision); }
protected override void TraitEnabled(Actor self) { pathfinder = world.WorldActor.Trait <IPathFinder>(); domainIndex = world.WorldActor.Trait <DomainIndex>(); scanForcubesTicks = Info.ScanForCubesInterval; }