Пример #1
0
    /// <summary>
    /// Enqueue a job in it's designated queue, but reset the queue before enqueueing it. Only use when adding a job for the first time after deserialisation
    /// </summary>
    /// <typeparam name="T">The type of the job you are enqueueing</typeparam>
    /// <param name="job">The job to enqueue</param>
    public void EnqueueJobAndResetQueue <T>(T job) where T : Job
    {
        SpecificQueue <T> queue = SpecificQueue <T> .Instance;

        UnityEngine.Debug.Log("Enqueuing job of type " + job.GetType() + " and resetting queue: " + queue.GetType());
        queue.HardResetQueue();
        EnqueueJob(job);
    }
Пример #2
0
    /// <summary>
    /// Enqueue a job in it's designated queue
    /// </summary>
    /// <typeparam name="T">The type of the job you are enqueueing</typeparam>
    /// <param name="job">The job to enqueue</param>
    public void EnqueueJob <T>(T job) where T : Job
    {
        SpecificQueue <T> queue = SpecificQueue <T> .Instance;

        UnityEngine.Debug.Log("Enqueuing job of type " + job.GetType() + " for queue: " + queue.GetType());
        if (activeQueuesWithKey.Keys.Contains(queue.GetDescription()))
        {
            // We are keeping track of the queue
        }
        else
        {
            // This is a job type that we don't have a queue for yet! Add it to the list of tracked job queues so the user can see it exists
            activeQueuesWithKey.Add(queue.GetDescription(), queue);
            if (JobQueueAdded != null)
            {
                JobQueueAdded(this, queue.GetDescription());
            }
        }

        // The reason to do this here is because here we know the job is properly instantiated but hasn't been enqueued yet.
        // If a job is directly assigned to a character we don't need it to pop up on the tile.

        // Makes sure that the active tile is aware of it's currently active job. Unregistering is done by the tile itself.
        job.GetActiveTile().AddJob(job);
        // If the active tile is updated, the new tile should be informed
        job.OnJobDestinationUpdated += (j) => { j.GetActiveTile().AddJob(j); };
        queue.OfferJob(job);
    }