示例#1
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>();
 }
示例#2
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>();
 }
示例#3
0
 public HarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
 {
     dockingState = State.Turn;
     Refinery = refinery;
     DockAngle = dockAngle;
     IsDragRequired = isDragRequired;
     DragOffset = dragOffset;
     DragLength = dragLength;
     Harv = self.Trait<Harvester>();
     StartDrag = self.CenterPosition;
     EndDrag = refinery.CenterPosition + DragOffset;
 }
示例#4
0
        CPos FindNextResource(Actor actor, Harvester harv)
        {
            var locomotorInfo = actor.Info.TraitInfo <MobileInfo>().LocomotorInfo;

            Func <CPos, bool> isValidResource = cell =>
                                                domainIndex.IsPassable(actor.Location, cell, locomotorInfo) &&
                                                harv.CanHarvestCell(actor, cell) &&
                                                claimLayer.CanClaimCell(actor, cell);

            var path = pathfinder.FindPath(
                PathSearch.Search(world, locomotorInfo, actor, true, isValidResource)
                .WithCustomCost(loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
                                .Where(u => !u.IsDead && actor.Owner.Stances[u.Owner] == Stance.Enemy)
                                .Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length)))
                .FromPoint(actor.Location));

            if (path.Count == 0)
            {
                return(CPos.Zero);
            }

            return(path[0]);
        }
示例#5
0
		public DeliverResources(Actor self)
		{
			movement = self.Trait<IMove>();
			harv = self.Trait<Harvester>();
		}
 public WithHarvestAnimation(ActorInitializer init, WithHarvestAnimationInfo info)
 {
     Info = info;
     harv = init.Self.Trait <Harvester>();
     wsb  = init.Self.Trait <WithSpriteBody>();
 }
示例#7
0
 public DeliverResources(Actor self)
 {
     movement = self.Trait<IMove>();
     harv = self.Trait<Harvester>();
     IsInterruptible = false;
 }
示例#8
0
 public DeliverResources(Actor self)
 {
     movement = self.Trait<IMove>();
     harv = self.Trait<Harvester>();
     harvInfo = self.Info.Traits.Get<HarvesterInfo>();
 }