Example #1
0
 public HarvestResource(Actor self, int2 cell)
 {
     harv = self.Trait<Harvester>();
     facing = self.Trait<IFacing>();
     renderUnit = self.Trait<RenderUnit>();
     resourceLayer = self.World.WorldActor.Trait<ResourceLayer>();
     harvestCell = cell;
 }
Example #2
0
 public HarvestResource(Actor self)
 {
     harv = self.Trait<Harvester>();
     harvInfo = self.Info.Traits.Get<HarvesterInfo>();
     facing = self.Trait<IFacing>();
     territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
     resLayer = self.World.WorldActor.Trait<ResourceLayer>();
 }
Example #3
0
 public FindResources(Actor self)
 {
     harv = self.Trait<Harvester>();
     harvInfo = self.Info.Traits.Get<HarvesterInfo>();
     mobile = self.Trait<Mobile>();
     mobileInfo = self.Info.Traits.Get<MobileInfo>();
     resLayer = self.World.WorldActor.Trait<ResourceLayer>();
     territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
     pathFinder = self.World.WorldActor.Trait<IPathFinder>();
 }
Example #4
0
        public SeedsResource(Actor self, SeedsResourceInfo info)
        {
            this.info = info;

            resourceType = self.World.WorldActor.TraitsImplementing<ResourceType>()
                .FirstOrDefault(t => t.Info.Name == info.ResourceType);

            if (resourceType == null)
                throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType));

            resLayer = self.World.WorldActor.Trait<ResourceLayer>();
        }
Example #5
0
        public static bool CanHarvestAt(this Actor self, CPos pos, ResourceLayer resLayer, HarvesterInfo harvInfo,
			ResourceClaimLayer territory)
        {
            var resType = resLayer.GetResource(pos);
            if (resType == null)
                return false;

            // Can the harvester collect this kind of resource?
            if (!harvInfo.Resources.Contains(resType.Info.Type))
                return false;

            if (territory != null)
            {
                // Another harvester has claimed this resource:
                ResourceClaim claim;
                if (territory.IsClaimedByAnyoneElse(self as Actor, pos, out claim))
                    return false;
            }

            return true;
        }
Example #6
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);
		}
        public ViewportControllerWidget(World world, WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = Exts.Lazy(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            resourceLayer = world.WorldActor.TraitOrDefault<ResourceLayer>();
        }