Ejemplo n.º 1
0
    public void AbandonJob(bool intoWaitingQueue)
    {
        Debug.ULogChannel("Character", name + " abandoned their job.");
        if (MyJob == null)
        {
            return;
        }

        if (MyJob.IsNeed)
        {
            MyJob.OnJobStopped -= OnJobStopped;
            MyJob = null;
            return;
        }

        // Character does not have to move,
        // so destination tile is the one
        // he is standing on.
        nextTile = DestTile = CurrTile;

        // Drops the priority a level, to lowest.
        MyJob.DropPriority();

        if (intoWaitingQueue)
        {
            // If the job gets abandoned because of missing materials,
            // put it into the waiting queue.
            // Also create a callback for when an inventory gets created.
            // Lastly, remove the job from "MyJob".
            World.Current.jobWaitingQueue.Enqueue(MyJob);
            World.Current.OnInventoryCreated += OnInventoryCreated;
            MyJob.OnJobStopped -= OnJobStopped;
            MyJob = null;
        }
        else
        {
            // If the job gets abandoned because of pathing issues or something else,
            // just put it into the normal job queue and remove the job from "MyJob".
            World.Current.jobQueue.Enqueue(MyJob);
            MyJob.OnJobStopped -= OnJobStopped;
            MyJob = null;
        }
    }