Exemplo n.º 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>();
 }
Exemplo n.º 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>();
 }
Exemplo n.º 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;
 }
Exemplo n.º 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]);
        }
Exemplo n.º 5
0
		public DeliverResources(Actor self)
		{
			movement = self.Trait<IMove>();
			harv = self.Trait<Harvester>();
		}
Exemplo n.º 6
0
 public WithHarvestAnimation(ActorInitializer init, WithHarvestAnimationInfo info)
 {
     Info = info;
     harv = init.Self.Trait <Harvester>();
     wsb  = init.Self.Trait <WithSpriteBody>();
 }
Exemplo n.º 7
0
 public DeliverResources(Actor self)
 {
     movement = self.Trait<IMove>();
     harv = self.Trait<Harvester>();
     IsInterruptible = false;
 }
Exemplo n.º 8
0
 public DeliverResources(Actor self)
 {
     movement = self.Trait<IMove>();
     harv = self.Trait<Harvester>();
     harvInfo = self.Info.Traits.Get<HarvesterInfo>();
 }