Ejemplo n.º 1
0
 public override void Tick()
 {
     base.Tick();
     if (Find.TickManager.TicksGame >= this.NextMoveTick)
     {
         pather.PatherTick();
         tweener.TweenerTick();
         if (this.DestinationReached)
         {
             ValidateParentSettlement();
             ArrivalAction();
         }
         Options.SettingsRef settingsRef = new Options.SettingsRef();
         this.nextMoveTickIncrement = (int)Rand.Range(settingsRef.woEventFrequency * .9f, settingsRef.woEventFrequency * 1.1f);
         this.NextMoveTick          = Find.TickManager.TicksGame + this.nextMoveTickIncrement;
         if (!UseDestinationTile)
         {
             if (this.DestinationTarget != null)
             {
                 if (DestinationTarget.Tile != pather.Destination)
                 {
                     this.launched = false;
                     PathToTargetTile(DestinationTarget.Tile);
                 }
             }
             else
             {
                 canReachDestination = false;
                 pather.StopDead();
             }
         }
         if (!canReachDestination)
         {
             ValidateParentSettlement();
             if (this.ParentSettlement == null)
             {
                 FindParentSettlement();
             }
             if (ParentSettlement != null && (!Utility.WorldReachability.CanReach(this.Tile, ParentSettlement.Tile) || Find.WorldGrid.ApproxDistanceInTiles(this.Tile, ParentSettlement.Tile) > 100))
             {
                 this.Destroy();
             }
             this.canReachDestination = true;
             this.DestinationTarget   = ParentSettlement.RimWorld_Settlement;
             PathToTarget(this.DestinationTarget);
         }
     }
 }
Ejemplo n.º 2
0
        //NextSearchTick
        //NextSearchTickIncrement (override by type)
        //ScanRange (override by type)
        //EngageNearbyWarObject --> IncidentUtility -- > ImmediateAction
        //EngageNearbyCaravan --> IncidentUtility --> ImmediateAction
        //NotifyPlayer
        //NextMoveTick
        //NextMoveTickIncrement (default is settings based)
        //ArrivalAction

        public override void Tick()
        {
            base.Tick();
            ValidateTargets();
            if (Find.TickManager.TicksGame >= this.NextSearchTick)
            {
                NextSearchTick = Find.TickManager.TicksGame + NextSearchTickIncrement;
                this.ValidateParentSettlement();
                //scan for nearby engagements
                ScanAction(ScanRange); //WorldUtility.GetRimWarDataForFaction(this.Faction).GetEngagementRange()
                Notify_Player();
            }
            if (Find.TickManager.TicksGame >= this.NextMoveTick)
            {
                NextMoveTick = Find.TickManager.TicksGame + NextMoveTickIncrement;
                pather.PatherTick();
                tweener.TweenerTick();
                if (this.DestinationReached)
                {
                    ValidateParentSettlement();
                    try
                    {
                        ArrivalAction();
                    }
                    catch (NullReferenceException ex)
                    {
                        Log.Message(this.Name + " threw an error during arrival - RWD(" + this.rimwarData + ") dest(" + this.DestinationTarget + ") parent(" + this.ParentSettlement + ")");
                        this.Destroy();
                    }
                }

                if (!UseDestinationTile)
                {
                    if (this.DestinationTarget != null)
                    {
                        if (DestinationTarget.Tile != pather.Destination)
                        {
                            this.launched = false;
                            PathToTargetTile(DestinationTarget.Tile);
                        }
                    }
                    else
                    {
                        canReachDestination = false;
                        pather.StopDead();
                    }
                }
                if (!canReachDestination)
                {
                    ValidateParentSettlement();
                    if (this.ParentSettlement == null)
                    {
                        FindParentSettlement();
                    }
                    if (ParentSettlement != null && (!Utility.WorldReachability.CanReach(this.Tile, ParentSettlement.Tile) || Find.WorldGrid.ApproxDistanceInTiles(this.Tile, ParentSettlement.Tile) > 100))
                    {
                        this.Destroy();
                    }
                    this.canReachDestination = true;
                    this.DestinationTarget   = ParentSettlement;
                    PathToTarget(this.DestinationTarget);
                }
            }
        }