Skip to content

Commit

Permalink
Trying to resolve zero craft time bug with time management
Browse files Browse the repository at this point in the history
  • Loading branch information
devopsdinosaur committed Jan 23, 2023
1 parent c621640 commit e026796
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions craft_from_storage/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Plugin : BaseUnityPlugin {

private Harmony m_harmony = new Harmony("devopsdinosaur.sunhaven.craft_from_storage");
public static ManualLogSource logger;
public static BaseUnityPlugin m_time_management_plugin = null;

private static ConfigEntry<bool> m_enabled;
private static ConfigEntry<bool> m_use_inventory_first;
Expand Down Expand Up @@ -339,6 +340,14 @@ float ___craftSpeedMultiplier
Item item = recipe.output.item.GenerateItem(list);
float multiplier = ___craftSpeedMultiplier * ((GameSave.CurrentCharacter.race == (int) Race.Human) ? 1.2f : 1f);
float craftTime = recipe.GetHoursToCraft(multiplier) * Settings.DaySpeedMultiplier;
if (craftTime < 0.001) {
if (m_time_management_plugin == null) {
foreach (string key in BepInEx.Bootstrap.Chainloader.PluginInfos.Keys) {
if (key == "devopsdinosaur.sunhaven.time_management"
}

}
}
ItemCraftInfo itemCraftInfo = new ItemCraftInfo {
item = item,
craftTime = craftTime,
Expand Down
13 changes: 12 additions & 1 deletion time_management/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ public class Plugin : BaseUnityPlugin {

public static float m_time_stop_multiplier = 1f;
public static bool m_is_ui_hidden = false;

private static Plugin m_instance;
public static Plugin Instance {
get {
return m_instance;
}
}

public Plugin() {
}

private void Awake() {
m_instance = this;
Plugin.logger = this.Logger;
logger.LogInfo((object) "devopsdinosaur.sunhaven.time_management v0.0.1 loaded.");
this.m_harmony.PatchAll();
Expand Down Expand Up @@ -127,6 +133,10 @@ private static void Postfix(ref Player __instance) {
}
}

private void update_transform_hack() {
this.transform.position = new Vector3(Plugin.m_time_speed.Value, Plugin.m_time_stop_multiplier);
}

[HarmonyPatch(typeof(Settings))]
[HarmonyPatch("DaySpeedMultiplier", MethodType.Getter)]
class HarmonyPatch_Wish_Settings_DaySpeedMultiplier {
Expand All @@ -136,6 +146,7 @@ private static bool Prefix(ref float __result) {
return true;
}
__result = (m_is_ui_hidden ? 0f : Plugin.m_time_speed.Value * Plugin.m_time_stop_multiplier);
Plugin.Instance.update_transform_hack();
return false;
}
}
Expand Down

0 comments on commit e026796

Please sign in to comment.