Code Snippets

Time Acceleration
Credit TTR:

this might be interesting to someone -> when you use time acceleration, like sleep, pass time, actions, or console command, all Update functions will be triggered, but in end, there is TodMaterial.UpdateAll also, which will recalculate "things" based on how much time was skipped

so, eg, when you patch fire.update to change burning time, and skip time, this will get nasty

in vanilla (or by TodMaterial.UpdateAll) embers (max) where not calculated but burn time was, and then normal update will kick int to decide to what to do now, if your patched update does something like calculate burn time based on temerature, ember storage that time will be removed twice.

bottom line, passing/acceleration of time and update patches doe not go well together someone might find this usefull

Credit:Leonardevvil and ds5678

private const string IMPROVISED_NAME = "GEAR_LeatherHide";

private const string HUNTING_NAME = "GEAR_Leather";

private const string SCRAP_METAL_NAME = "GEAR_ScrapMetal";

private const string SCRAP_METAL_CRAFTING_ICON_NAME = "ico_CraftItem__ScrapMetal";

private const int SCRAP_METAL_NEEDED = 2;

private const int CRAFTING_TIME = 360;

[HarmonyPatch(typeof(GameManager), "Awake")]

private static class AddBreakDownRecipe

{

internal static void Postfix

{

BlueprintItem blueprint = GameManager.GetBlueprints.AddComponent;

// Inputs

blueprint.m_RequiredGear = new Il2CppReferenceArray(1) { [0] = GetGearItemPrefab(IMPROVISED_NAME) };

blueprint.m_RequiredGearUnits = new Il2CppStructArray (1) { [0] = 1  };

blueprint.m_KeroseneLitersRequired = 0f;

blueprint.m_GunpowderKGRequired = 0f;

blueprint.m_RequiredTool = null;

blueprint.m_OptionalTools = new Il2CppReferenceArray(0);

// Outputs

blueprint.m_CraftedResult = GetGearItemPrefab(HUNTING_NAME);

blueprint.m_CraftedResultCount = 2;

// Process

blueprint.m_Locked = false;

blueprint.m_AppearsInStoryOnly = false;

blueprint.m_RequiresLight = true;

blueprint.m_RequiresLitFire = false;

blueprint.m_RequiredCraftingLocation = CraftingLocation.Anywhere;

blueprint.m_DurationMinutes = CRAFTING_TIME;

blueprint.m_CraftingAudio = "PLAY_CRAFTINGGENERIC";

blueprint.m_AppliedSkill = SkillType.None;

blueprint.m_ImprovedSkill = SkillType.None;

}

private static GearItem GetGearItemPrefab(string name) => Resources.Load(name).Cast.GetComponent;

this code snnipet is for adding item in the game

Credits:Filigrani Credits:Filigrani Credits:Filigrani