public static void Postfix(VacDisplayChanger __instance) { Console.Log("Awake with Vacpack enum: " + Values.VACPACK); bool flag = __instance.playerState.HasUpgrade(Ids.MOCHI_HACK); if (flag) { VACPACK_ENUMS flag1 = Values.VACPACK; switch (flag1) { case VACPACK_ENUMS.NIMBLE_VALLEY: __instance.SetDisplayMode(PlayerState.AmmoMode.NIMBLE_VALLEY); break; case VACPACK_ENUMS.DEFAULT: __instance.SetDisplayMode(PlayerState.AmmoMode.DEFAULT); break; case VACPACK_ENUMS.AUTOMATIC: ZoneDirector.Zone currentZone = SRSingleton <SceneContext> .Instance.PlayerZoneTracker.GetCurrentZone(); PlayerState.AmmoMode ammoMode = (currentZone == ZoneDirector.Zone.MOCHI_RANCH || currentZone == ZoneDirector.Zone.VALLEY) ? PlayerState.AmmoMode.NIMBLE_VALLEY : PlayerState.AmmoMode.DEFAULT; __instance.SetDisplayMode(ammoMode); break; } } }
// The code that the command runs. Requires you to return a bool. public override bool Execute(string[] args) { // Checks if the code has enough arguments. if (args == null || args.Length > 1) { Console.LogError("Incorrect amount of arguments!", true); return(false); } bool flag = SRSingleton <SceneContext> .Instance.PlayerState.HasUpgrade(Ids.MOCHI_HACK); if (flag) { Console.Log("Changed Vacpack renderer mode to: " + args[0], true); if (args[0].ToLower() == "automatic") { Console.Log("Not implemented yet"); return(true); } if (System.Enum.TryParse(args[0], out VACPACK_ENUMS vACPACK)) { PlayerState.AmmoMode ammoMode = (vACPACK == VACPACK_ENUMS.NIMBLE_VALLEY) ? PlayerState.AmmoMode.NIMBLE_VALLEY : PlayerState.AmmoMode.DEFAULT; UnityEngine.GameObject.FindObjectOfType <VacDisplayChanger>().SetDisplayMode(ammoMode); } //foreach (VACPACK_ENUMS vacPACK in System.Enum.GetValues(typeof(VACPACK_ENUMS))) {} } else { Console.Log("You have to first have bought the \"Gate Hack\" upgrade, else you can't use this command"); } return(true); }
/// <summary> /// Allow an <paramref name="id"/> to be put into a players inventory /// </summary> /// <param name="mode">Which inventory to allow the <paramref name="id"/> into</param> /// <param name="id">The <see cref="Identifiable.Id"/> to allow</param> public static void RegisterPlayerAmmo(PlayerState.AmmoMode mode, Identifiable.Id id) { if (!inventoryPrefabsToPatch.ContainsKey(mode)) { inventoryPrefabsToPatch[mode] = new HashSet <Identifiable.Id>(); } inventoryPrefabsToPatch[mode].Add(id); }
public static void RegisterAmmoPrefab(PlayerState.AmmoMode mode, GameObject prefab) { if (!inventoryPrefabsToPatch.ContainsKey(mode)) { inventoryPrefabsToPatch[mode] = new List <GameObject>(); } inventoryPrefabsToPatch[mode].Add(prefab); }
/// <summary> /// Registers a new ammo modes for the player /// </summary> /// <param name="mode">The mode to register</param> /// <param name="ammo">The ammo holder to contain the ammo for the mode</param> public static void RegisterAmmoMode(PlayerState.AmmoMode mode, Ammo ammo) { if (ModLoader.CurrentStep != LoadingState.REGISTER) { throw new Exception("You can only register things during the 'Register' step"); } NEW_AMMO_MODES[mode] = ammo; }
/// <summary> /// Checks if the upgrade is unlocked /// </summary> /// <param name="id">The ID to check</param> /// <param name="mode">The current ammo mode</param> /// <returns>True if unlocked, false otherwise</returns> public bool IsUnlocked(Identifiable.Id id, PlayerState.AmmoMode mode) { if (unlocked) { return(true); } unlocked = lockerCheck?.Invoke(id, mode) ?? true; return(unlocked); }
//+ REGISTRATION /// <summary> /// Registers a new ammo for the player's inventory /// </summary> /// <param name="mode">The mode to register to</param> /// <param name="id">The ID to register</param> public static void RegisterPlayerAmmo(PlayerState.AmmoMode mode, Identifiable.Id id) { if (ModLoader.CurrentStep != LoadingState.REGISTER) { throw new Exception("You can only register things during the 'Register' step"); } if (!INV_AMMO.ContainsKey(mode)) { INV_AMMO.Add(mode, new HashSet <Identifiable.Id>(Identifiable.idComparer)); } INV_AMMO[mode].Add(id); }
internal static int?RetrieveMaxAmmo(Identifiable.Id id, int slot, PlayerState.AmmoMode mode) { int?result = null; if (MAX_AMMO_IDENT.ContainsKey(id)) { result = MAX_AMMO_IDENT[id].Invoke(id, slot, mode); } if (result == null && MAX_AMMO_SLOT.ContainsKey(slot)) { result = MAX_AMMO_SLOT[slot].Invoke(id, slot, mode); } return(result); }
internal static bool CheckInventoryLocks(Identifiable.Id id, PlayerState.AmmoMode mode) { if (!INV_LOCKS.ContainsKey(id)) { return(true); } foreach (InventoryLocker locker in INV_LOCKS[id]) { if (!locker.IsUnlocked(id, mode)) { return(false); } } return(true); }
/// <summary> /// Register an ammo prefab to allow it to be put in a player's ammos (use <see cref="RegisterPlayerAmmo(PlayerState.AmmoMode, Identifiable.Id)"/>) /// </summary> /// <param name="mode"><see cref="PlayerState.AmmoMode"/> to register the prefab to</param> /// <param name="prefab"></param> public static void RegisterAmmoPrefab(PlayerState.AmmoMode mode, GameObject prefab) { RegisterPlayerAmmo(mode, Identifiable.GetId(prefab)); }
[UsedImplicitly] private static void SetAmmoMode_Postfix(PlayerState @this, PlayerState.AmmoMode mode) => EventHandler.Instance.OnSetAmmoMode_Trigger(@this, mode);
/// <summary>Retrieves the max ammo for an identifiable or inventory slot</summary> public static int GetMaxAmmo(Identifiable.Id id, int slot, PlayerState.AmmoMode mode) => AmmoRegistry.RetrieveMaxAmmo(id, slot, mode) ?? -1;
//+ LOCK CHECK /// <summary>Checks if a player can hold a specific item in a specific ammo mode</summary> public static bool CanPlayerHold(Identifiable.Id id, PlayerState.AmmoMode mode) => AmmoRegistry.CheckInventoryLocks(id, mode);
internal void OnSetAmmoMode_Trigger(PlayerState player, PlayerState.AmmoMode mode) => OnSetAmmoMode?.Handle(args: new object[] { player, mode }, unique: true);
//+ SAVE HANDLING internal static bool IsAmmoModeRegistered(PlayerState.AmmoMode mode) => NEW_AMMO_MODES.ContainsKey(mode);
public static bool Prefix(QuicksilverEnergyGenerator __instance, QuicksilverEnergyGenerator.State state, bool enableSFX) { Console.Log("Parameters are: " + state + " and " + enableSFX); Destroyer.Destroy(__instance.countdownUI, "QuicksilverEnergyGenerator.SetState"); Console.Log("CountdownUI destroyed"); __instance.model.state = state; Console.Log("model.state setted"); if (__instance.model.state == QuicksilverEnergyGenerator.State.COUNTDOWN) { Console.Log("if state is countdown"); __instance.model.timer = new double?(__instance.timeDirector.HoursFromNow(__instance.countdownMinutes * 0.016666668f)); Console.Log("Countdown: timer setted"); if (enableSFX) { Console.Log("Countdown: if enable SFX"); SECTR_AudioSystem.Play(__instance.onCountdownCue, __instance.transform.position, false); Console.Log("Audio played"); } if (SRSingleton <SceneContext> .Instance.PlayerState.HasUpgrade(Ids.MOCHI_HACK)) { VACPACK_ENUMS flag1 = Values.VACPACK; switch (flag1) { case VACPACK_ENUMS.NIMBLE_VALLEY: SRSingleton <SceneContext> .Instance.Player .GetComponentInChildren <WeaponVacuum>() .GetComponentInChildren <VacDisplayTimer>() .SetQuicksilverEnergyGenerator(__instance); break; case VACPACK_ENUMS.DEFAULT: break; case VACPACK_ENUMS.AUTOMATIC: ZoneDirector.Zone currentZone = SRSingleton <SceneContext> .Instance.PlayerZoneTracker.GetCurrentZone(); PlayerState.AmmoMode ammoMode = (currentZone == ZoneDirector.Zone.MOCHI_RANCH || currentZone == ZoneDirector.Zone.VALLEY) ? PlayerState.AmmoMode.NIMBLE_VALLEY : PlayerState.AmmoMode.DEFAULT; if (ammoMode == PlayerState.AmmoMode.NIMBLE_VALLEY) { SRSingleton <SceneContext> .Instance.Player .GetComponentInChildren <WeaponVacuum>() .GetComponentInChildren <VacDisplayTimer>() .SetQuicksilverEnergyGenerator(__instance); } break; } } else { SRSingleton <SceneContext> .Instance.Player .GetComponentInChildren <WeaponVacuum>() .GetComponentInChildren <VacDisplayTimer>() .SetQuicksilverEnergyGenerator(__instance); } Console.Log("Countdown: VacDisplayTimer generator setted"); __instance.countdownUI = UnityEngine.Object.Instantiate <GameObject>(__instance.countdownUIPrefab); Console.Log("Countdown: countdownUI created"); __instance.countdownUI.GetComponent <HUDCountdownUI>().SetCountdownTime(__instance.countdownMinutes); Console.Log("Countdown: Timer time setted"); } else if (__instance.model.state == QuicksilverEnergyGenerator.State.ACTIVE) { Console.Log("if state is active"); __instance.model.timer = new double?(__instance.timeDirector.HoursFromNow(__instance.activeHours)); Console.Log("Active: Timer setted"); } else if (__instance.model.state == QuicksilverEnergyGenerator.State.COOLDOWN) { Console.Log("if state is cooldown"); __instance.model.timer = new double?(__instance.timeDirector.HoursFromNow(__instance.cooldownHours)); Console.Log("Cooldown: timer setted"); if (enableSFX) { Console.Log("Cooldown: if enableSFX"); SECTR_AudioSystem.Play(__instance.onCooldownCue, __instance.transform.position, false); Console.Log("Cooldown: Play first audio"); SECTR_AudioSystem.Play(__instance.onCooldownCue2D, Vector3.zero, false); Console.Log("Cooldown: Play second audio"); } } else { Console.Log("if everything is null"); __instance.model.timer = null; Console.Log("Null: Timer setted"); if (enableSFX) { Console.Log("Null: if enableSFX"); SECTR_AudioSystem.Play(__instance.onInactiveCue, __instance.transform.position, false); Console.Log("Null: Play audio"); } } if (__instance.inactiveFX != null) { Console.Log("if inactive FX is null"); __instance.inactiveFX.SetActive(__instance.model.state == QuicksilverEnergyGenerator.State.INACTIVE); Console.Log("inactive FX setted"); } if (__instance.activeFX != null) { Console.Log("if activeFX is null"); __instance.activeFX.SetActive(__instance.model.state == QuicksilverEnergyGenerator.State.ACTIVE); Console.Log("activeFX setted"); } if (__instance.cooldownFX != null) { Console.Log("if cooldownFX is null"); __instance.cooldownFX.SetActive(__instance.model.state == QuicksilverEnergyGenerator.State.COOLDOWN); Console.Log("cooldownFX setted"); } if (__instance.onStateChanged != null) { Console.Log("if onstatechanged is null"); __instance.onStateChanged(); Console.Log("onstatechanged setted"); } return(false); }