Esempio n. 1
0
        // LOGIC FOR DETERMINING PLAYER ACTION //

        internal static void DetermineCreatureAction(Creature c, bool calledFromCraftingScheduler = false)
        {
            if (!creatureStates.ContainsKey(c.ID))
            {
                creatureStates.Add(c.ID, CreatureState.Idle);
            }

            if (calledFromCraftingScheduler)
            {
                c.Wait();
                return;
            }

            DetermineNextConstruction();
            if (nextConstruction.Equals(new Point()) == false) // this means a pending construction has been found and it can definitely be built
            {
                RecipeComponent nextComponent = RecipeComponent.Null;
                if (currentConstructRecipe.Count > getIndex) // if get has not gotten up to the count
                {
                    nextComponent = currentConstructRecipe[getIndex];
                }
                else
                {
                    c.Path = null;
                    creatureStates[c.ID] = CreatureState.PlaceMaterials;
                }
                if (creatureStates[c.ID] == CreatureState.Idle)
                {
                    creatureStates[c.ID] = CreatureState.GetMaterial;
                }

                if (creatureStates[c.ID] == CreatureState.GetMaterial)
                {
                    HandleGetMaterial(c, nextComponent);
                }
                else if (creatureStates[c.ID] == CreatureState.PlaceMaterials)
                {
                    HandlePlaceMaterials(c, nextComponent);
                }
            }
            else /* there is no pending construction */
            {
                creatureStates[c.ID] = CreatureState.Idle;
                paused = true;
            }

            c.DetermineAction();
        }