public virtual void OnCurrencyChange(NetIntDelta field, int old_value, int new_value) { if (Game1.gameMode != 3) { return; } string currency_key = null; foreach (string key in registeredCurrencyDisplays.Keys) { if (registeredCurrencyDisplays[key].netIntDelta == field) { currency_key = key; break; } } if (currency_key == null) { return; } SetDisplayedCurrency(currency_key); if (_currentDisplayedCurrency != null) { _moneyDial.currentValue = old_value; if (_moneyDial.onPlaySound != null) { _moneyDial.onPlaySound(new_value - old_value); } } timeToLive = 5f; }
protected void OnCurrentCountChanged(NetIntDelta field, int oldValue, int newValue) { if (!Utility.ShouldIgnoreValueChangeCallback()) { CheckCompletion(); } }
public virtual void Register(string key, NetIntDelta net_int_delta, Action <int> sound_function = null, Action <SpriteBatch, Vector2> draw_function = null) { if (registeredCurrencyDisplays.ContainsKey(key)) { Unregister(key); } CurrencyDisplayType currency_type = new CurrencyDisplayType(); currency_type.key = key; currency_type.netIntDelta = net_int_delta; currency_type.playSound = sound_function; currency_type.drawSprite = draw_function; registeredCurrencyDisplays[key] = currency_type; registeredCurrencyDisplays[key].netIntDelta.fieldChangeVisibleEvent += OnCurrencyChange; }
private static void checkStoneForItems_Postfix(MineShaft __instance, int x, int y, Farmer who, ref NetPointDictionary <bool, NetBool> ___createLadderDownEvent, bool ___ladderHasSpawned, NetIntDelta ___netStonesLeftOnThisLevel) { if (!___createLadderDownEvent.ContainsKey(new Point(x, y))) { double chanceForLadderDown = 0.02 + 1.0 / (double)Math.Max(1, ___netStonesLeftOnThisLevel) + (double)who.LuckLevel / 100.0 + Game1.player.DailyLuck / 5.0; if (__instance.EnemyCount == 0) { chanceForLadderDown += 0.04; } chanceForLadderDown = chanceForLadderDown * Config.ChanceForLadderInStoneMultiplier - chanceForLadderDown; if (!__instance.mustKillAllMonstersToAdvance() && (___netStonesLeftOnThisLevel == 0 || Game1.random.NextDouble() < chanceForLadderDown) && __instance.shouldCreateLadderOnThisLevel()) { bool isShaft = !GotShaft && __instance.getMineArea(-1) == 121 && !__instance.mustKillAllMonstersToAdvance() && Game1.random.NextDouble() < 0.2 * Config.ChanceLadderIsShaftMultiplier; if (isShaft || !___ladderHasSpawned) { if (isShaft) { GotShaft = true; } ___createLadderDownEvent[new Point(x, y)] = isShaft; } } } else if (___createLadderDownEvent[new Point(x, y)]) { GotShaft = true; } }
static void Postfix(MineShaft __instance, int x, int y, bool ___ladderHasSpawned, NetIntDelta ___netStonesLeftOnThisLevel) { createLadderDown_Patch.hx = -1; // We don't really need this anymore createLadderDown_Patch.hy = -1; if (__instance == null || !MoreMineLadders.instance.config.Enabled || ___ladderHasSpawned) { return; } var cfg = MoreMineLadders.instance.config; if (___netStonesLeftOnThisLevel.Value == 0) { __instance.createLadderDown(x, y); return; } Random random = new Random(x * 1000 + y + __instance.mineLevel + (int)Game1.uniqueIDForThisGame / 2); // Game uses this to seed the ladder generation so I guess we will too. random.NextDouble(); // We'll make luck have a slightly bigger impact when enabled to compensate for the fact we're not checking for remaining stones. double chance = cfg.affectedByLuck ? cfg.dropLadderChance + (double)Game1.player.LuckLevel / 100.0 + Game1.dailyLuck / 3.5 : cfg.dropLadderChance; double num = random.NextDouble(); if (num < chance) { __instance.createLadderDown(x, y); } }