Exemplo n.º 1
0
 public CraftingGoal(IJob job, CraftingJobSettings settings)
 {
     CraftingJobInstance = job as CraftingJobInstance;
     Job = job;
     CraftingJobSettings = settings;
     ClosestCrate        = StorageFactory.GetClosestCrateLocation(CraftingJobInstance.Position, job.Owner);
 }
Exemplo n.º 2
0
 public CraftingGoal(IJob job, IPandaJobSettings jobSettings, CraftingJobSettings settings)
 {
     CraftingJobInstance = job as CraftingJobInstance;
     JobSettings         = jobSettings;
     CurrentlyCrafing.Add(this);
     Job = job;
     CraftingJobSettings = settings;
     ClosestCrate        = CraftingJobInstance.Position.GetClosestPosition(StorageFactory.CrateLocations[Job.Owner].Keys.ToList());
 }
 public PandaCrafingSettings(CraftingJobSettings settings)
 {
     BlockTypes       = settings.BlockTypes;
     CraftingCooldown = settings.CraftingCooldown;
     MaxCraftsPerHaul = settings.MaxCraftsPerHaul;
     NPCType          = settings.NPCType;
     NPCTypeKey       = settings.NPCTypeKey;
     OnCraftedAudio   = settings.OnCraftedAudio;
     RecruitmentItem  = settings.RecruitmentItem;
 }
Exemplo n.º 4
0
        public static bool TryGetNPCCraftSettings(this IJob job, out CraftingJobSettings settings)
        {
            if (job != null && job is CraftingJobInstance craftingJob)
            {
                settings = (CraftingJobSettings)craftingJob.Settings;
                return(true);
            }

            settings = null;
            return(false);
        }
Exemplo n.º 5
0
        public static bool TryGetNPCCraftDefaultSettings(this IJob job, out CraftingJobSettings settings)
        {
            if (job != null && job is CraftingJobInstance craftingJob)
            {
                settings = (CraftingJobSettings)craftingJob.Settings;

                if (ServerManager.BlockEntityCallbacks.TryGetCraftJobSettings(settings.NPCTypeKey, out settings))
                {
                    return(true);
                }
            }

            settings = null;
            return(false);
        }
Exemplo n.º 6
0
        public static bool TryGetNPCCraftSettings(this IJob job, out CraftingJobSettings settings)
        {
            if (job != null && job is CraftingJobInstance craftingJob)
            {
                settings = craftingJob.Settings as CraftingJobRotatedLitSettings;

                if (settings == null)
                {
                    return(false);
                }

                return(true);
            }

            settings = null;
            return(false);
        }
Exemplo n.º 7
0
        public virtual void GetNextRecipe(ref NPCBase.NPCState state)
        {
            NextRecipe = Recipe.MatchRecipe(CraftingJobSettings.GetPossibleRecipes(CraftingJobInstance), Job.Owner, RecipeSettingsGroup);

            switch (NextRecipe.MatchType)
            {
            case Recipe.RecipeMatchType.FoundMissingRequirements:
            case Recipe.RecipeMatchType.AllDone:
            {
                if (!state.Inventory.IsEmpty)
                {
                    PutItemsInCrate(ref state);
                    break;
                }

                float cooldown = Pipliz.Random.NextFloat(8f, 16f);
                if (NextRecipe.MatchType == Recipe.RecipeMatchType.AllDone)
                {
                    state.SetIndicator(new IndicatorState(cooldown, BuiltinBlocks.Indices.erroridle));
                }
                else
                {
                    GetItemsFromCrate(ref state);
                }

                Job.Owner.Stats.RecordNPCIdleSeconds(Job.NPCType, cooldown);
                break;
            }

            case Recipe.RecipeMatchType.FoundCraftable:
                CraftingJobInstance.SelectedRecipe      = NextRecipe.FoundRecipe;
                CraftingJobInstance.SelectedRecipeCount = NextRecipe.FoundRecipeCount;
                GetItemsFromCrate(ref state);
                state.SetCooldown(0.2, 0.4);
                NextRecipe = Recipe.MatchRecipe(CraftingJobSettings.GetPossibleRecipes(CraftingJobInstance), Job.Owner, RecipeSettingsGroup);
                break;

            default:
                UnityEngine.Assertions.Assert.IsTrue(condition: false, "Unexpected RecipeMatchType: " + NextRecipe.MatchType);
                break;
            }
        }
Exemplo n.º 8
0
 public static bool TryGetNPCCraftDefaultSettings(this NPC.NPCBase npc, out CraftingJobSettings settings)
 {
     return(TryGetNPCCraftDefaultSettings(npc.Job, out settings));
 }
Exemplo n.º 9
0
        public static bool TryGetCraftJobSettings(this BlockEntities.BlockEntityCallbacks callbacks, string name, out CraftingJobSettings craftingJobSettings)
        {
            craftingJobSettings = null;

            var craftJobInstance = callbacks.AutoLoadedInstances.FirstOrDefault(o => o is BlockJobManager <CraftingJobInstance> manager && manager.Settings is CraftingJobSettings set && set.NPCTypeKey == name) as BlockJobManager <CraftingJobInstance>;

            if (craftJobInstance == null)
            {
                PandaLogger.Log(ChatColor.yellow, "Unable to find craft job settings for {0}", name);
            }
            else
            {
                craftingJobSettings = craftJobInstance.Settings as CraftingJobSettings;
            }

            return(craftingJobSettings != null);
        }
Exemplo n.º 10
0
 public CraftingRotatedGoal(IJob job, CraftingJobSettings settings) : base(job, settings)
 {
 }
Exemplo n.º 11
0
 public CraftingLitGoal(IJob job, CraftingJobSettings settings) : base(job, settings)
 {
 }
Exemplo n.º 12
0
 public CraftingRotatedGoal(IJob job, IPandaJobSettings jobSettings, CraftingJobSettings settings) : base(job, jobSettings, settings)
 {
 }