示例#1
0
 protected override void TraitEnabled(Actor self)
 {
     domainIndex = world.WorldActor.Trait <DomainIndex>();
     resLayer    = world.WorldActor.TraitOrDefault <ResourceLayer>();
     claimLayer  = world.WorldActor.TraitOrDefault <ResourceClaimLayer>();
     scanForIdleHarvestersTicks = Info.ScanForIdleHarvestersInterval;
 }
示例#2
0
        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);
            }
        }
示例#3
0
        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>();
        }
示例#4
0
 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>();
 }
示例#5
0
 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;
 }
示例#6
0
 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;
 }
示例#7
0
 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;
 }
示例#8
0
 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>();
 }
示例#9
0
        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;
        }
示例#10
0
        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();
        }
示例#12
0
 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;
 }
示例#14
0
        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;
        }
示例#15
0
 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>();
 }
示例#16
0
        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;
        }
示例#17
0
        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;
        }
示例#18
0
        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;
        }
示例#19
0
        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;
        }
示例#20
0
        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}");
            }
        }
示例#21
0
        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);
            }
        }
示例#22
0
 public ReinforcementsGlobal(ScriptContext context)
     : base(context)
 {
     domainIndex = context.World.WorldActor.Trait <DomainIndex>();
 }
示例#23
0
		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);
		}
示例#24
0
 protected override void TraitEnabled(Actor self)
 {
     pathfinder        = world.WorldActor.Trait <IPathFinder>();
     domainIndex       = world.WorldActor.Trait <DomainIndex>();
     scanForcubesTicks = Info.ScanForCubesInterval;
 }