/// <summary> /// Applied before Update runs. /// </summary> internal static bool Prefix(DecorMonitor.Instance __instance, float dt, Klei.AI.AmountInstance ___amount, Klei.AI.AttributeModifier ___modifier, ref float ___cycleTotalDecor) { bool cont = true; ChoreDriver driver; // If no chore driver, allow stock implementation if ((driver = __instance.GetComponent<ChoreDriver>()) != null) { var chore = driver.GetCurrentChore(); cont = false; // Slew to half decor if sleeping float decorAtCell = GameUtil.GetDecorAtCell(Grid.PosToCell(__instance)); if (chore != null && chore.choreType == Db.Get().ChoreTypes.Sleep) decorAtCell *= DecorTuning.DECOR_FRACTION_SLEEP; ___cycleTotalDecor += decorAtCell * dt; // Constants are the same as the base game float value = 0.0f, curDecor = ___amount.value; if (Mathf.Abs(decorAtCell - curDecor) > 0.5f) { if (decorAtCell > curDecor) value = 3.0f * SLEW; else if (decorAtCell < curDecor) value = -SLEW; } else ___amount.value = decorAtCell; ___modifier.SetValue(value); } return cont; }
/// <summary> /// Updates the decor levels of the specified decor monitor. /// </summary> /// <param name="instance">The decor level monitor to modify.</param> internal static void UpdateDecorLevels(DecorMonitor.Instance __instance) { // Retrieve the decor lookup from the DecorMonitor class var decorLookup = Traverse.Create(__instance).GetField <List <KeyValuePair < float, string> > >("effectLookup"); if (decorLookup != null) { decorLookup.Clear(); foreach (var decorLevel in DECOR_LEVELS) { decorLookup.Add(new KeyValuePair <float, string>(decorLevel.MinDecor, decorLevel.ID)); } } }
public override string GetTooltip(Amount master, AmountInstance instance) { string str = string.Format(master.description, formatter.GetFormattedValue(instance.value, GameUtil.TimeSlice.None, null)); int cell = Grid.PosToCell(instance.gameObject); if (Grid.IsValidCell(cell)) { str += string.Format(DUPLICANTS.STATS.DECOR.TOOLTIP_CURRENT, GameUtil.GetDecorAtCell(cell)); } str += "\n"; DecorMonitor.Instance sMI = instance.gameObject.GetSMI <DecorMonitor.Instance>(); if (sMI != null) { str += string.Format(DUPLICANTS.STATS.DECOR.TOOLTIP_AVERAGE_TODAY, formatter.GetFormattedValue(sMI.GetTodaysAverageDecor(), GameUtil.TimeSlice.None, null)); str += string.Format(DUPLICANTS.STATS.DECOR.TOOLTIP_AVERAGE_YESTERDAY, formatter.GetFormattedValue(sMI.GetYesterdaysAverageDecor(), GameUtil.TimeSlice.None, null)); } return(str); }