public override Activity Tick(Actor self) { if (NextActivity != null) { return(NextActivity); } // Find the nearest best refinery if not explicitly ordered to a specific refinery: if (harv.OwnerLinkedProc == null || !harv.OwnerLinkedProc.IsInWorld) { // Maybe we lost the owner-linked refinery: harv.OwnerLinkedProc = null; if (self.World.WorldTick - chosenTicks > NextChooseTime) { harv.ChooseNewProc(self, null); chosenTicks = self.World.WorldTick; } } else { harv.LinkProc(self, harv.OwnerLinkedProc); } if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld) { harv.ChooseNewProc(self, null); } // No refineries exist; check again after delay defined in Harvester. if (harv.LinkedProc == null) { return(ActivityUtils.SequenceActivities(new Wait(harv.Info.SearchForDeliveryBuildingDelay), this)); } var proc = harv.LinkedProc; var iao = proc.Trait <IAcceptResources>(); self.SetTargetLine(Target.FromActor(proc), Color.Green, false); if (self.Location != proc.Location + iao.DeliveryOffset) { var notify = self.TraitsImplementing <INotifyHarvesterAction>(); var next = new DeliverResources(self); foreach (var n in notify) { n.MovingToRefinery(self, proc.Location + iao.DeliveryOffset, next); } return(ActivityUtils.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this)); } if (!isDocking) { isDocking = true; iao.OnDock(self, this); } return(ActivityUtils.SequenceActivities(new Wait(10), this)); }
public override Activity Tick(Actor self) { if (NextInQueue != null) { return(NextInQueue); } if (harv.OwnerLinkedProc == null || !harv.OwnerLinkedProc.IsInWorld) { harv.OwnerLinkedProc = null; if (self.World.WorldTick - chosenTicks > NextChooseTime) { harv.ChooseNewProc(self, null); chosenTicks = self.World.WorldTick; } } else { harv.LinkProc(self, harv.OwnerLinkedProc); } if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld) { harv.ChooseNewProc(self, null); } if (harv.LinkedProc == null) { return(ActivityUtils.SequenceActivities(new Wait(harv.Info.SearchForDeliveryBuildingDelay), this)); } var proc = harv.LinkedProc; var iao = proc.Trait <IAcceptResources>(); self.SetTargetLine(Target.FromActor(proc), Color.Green, false); if (self.Location != proc.Location + iao.DeliveryOffset) { return(ActivityUtils.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this)); } if (!isDocking) { isDocking = true; iao.OnDock(self, this); } return(ActivityUtils.SequenceActivities(new Wait(10), this)); }
public override Activity Tick(Actor self) { if (ChildActivity != null) { ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); if (ChildActivity != null) { return(this); } } if (IsCanceling || isDocking) { return(NextActivity); } // Find the nearest best refinery if not explicitly ordered to a specific refinery: if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld) { harv.ChooseNewProc(self, null); } // No refineries exist; check again after delay defined in Harvester. if (harv.LinkedProc == null) { QueueChild(self, new Wait(harv.Info.SearchForDeliveryBuildingDelay), true); return(this); } var proc = harv.LinkedProc; var iao = proc.Trait <IAcceptResources>(); self.SetTargetLine(Target.FromActor(proc), Color.Green, false); if (self.Location != proc.Location + iao.DeliveryOffset) { foreach (var n in self.TraitsImplementing <INotifyHarvesterAction>()) { n.MovingToRefinery(self, proc, new FindAndDeliverResources(self)); } QueueChild(self, movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), true); return(this); } if (!isDocking) { QueueChild(self, new Wait(10), true); isDocking = true; iao.OnDock(self, this); return(this); } return(NextActivity); }
public override bool Tick(Actor self) { if (harv.IsTraitDisabled) { Cancel(self, true); } if (IsCanceling) { return(true); } // Find the nearest best refinery if not explicitly ordered to a specific refinery: if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld) { harv.ChooseNewProc(self, null); } // No refineries exist; check again after delay defined in Harvester. if (harv.LinkedProc == null) { QueueChild(new Wait(harv.Info.SearchForDeliveryBuildingDelay)); return(false); } proc = harv.LinkedProc; var iao = proc.Trait <IAcceptResources>(); if (self.Location != proc.Location + iao.DeliveryOffset) { foreach (var n in notifyHarvesterActions) { n.MovingToRefinery(self, proc); } QueueChild(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0)); return(false); } QueueChild(new Wait(10)); iao.OnDock(self, this); return(true); }