/// <summary> /// Call this in <see cref="Mod.PostSetupContent"/> or <see cref="ModItem.SetStaticDefaults"/> to register this click effect /// </summary> /// <param name="mod">The mod this effect belongs to. ONLY USE YOUR OWN MOD INSTANCE FOR THIS!</param> /// <param name="internalName">The internal name of the effect. Turns into the unique name combined with the associated mod</param> /// <param name="displayName">The name of the effect, null if you use lang keys (Defaults to ClickEffect.[internalName].Name)</param> /// <param name="description">The basic description of the effect, string.Empty for none, null if you use lang keys (Defaults to ClickEffect.[internalName].Description)</param> /// <param name="amount">The amount of clicks required to trigger the effect</param> /// <param name="action">The method that runs when the effect is triggered</param> /// <returns>The unique identifier</returns> /// <exception cref="InvalidOperationException"/> public static string RegisterClickEffect(Mod mod, string internalName, string displayName, string description, int amount, Color color, Action <Player, Vector2, int, int, float> action) { if (ClickerClass.finalizedRegisterCompat) { throw new InvalidOperationException("Tried to register a click effect at the wrong time, do so in Mod.PostSetupContent or ModItem.SetStaticDefaults"); } if (string.IsNullOrEmpty(internalName)) { throw new InvalidOperationException($"internalName is either null or empty. Give it a proper value"); } string uniqueName = UniqueEffectName(mod, internalName); ClickEffect effect = new ClickEffect(mod, internalName, displayName, description, amount, color, action); if (!IsClickEffect(uniqueName, out _)) { ClickEffectsByName.Add(uniqueName, effect); return(uniqueName); } else { throw new InvalidOperationException($"The effect '{uniqueName}' has already been registered, duplicate detected"); } }
/// <summary> /// Checks if the player has a click effect enabled /// </summary> /// <param name="name">The unique effect name</param> /// <param name="effect">The effect associated with the name</param> /// <returns><see langword="true"/> if enabled</returns> public bool HasClickEffect(string name, out ClickEffect effect) { effect = null; if (HasClickEffect(name)) { return(ClickerSystem.IsClickEffect(name, out effect)); } return(false); }
/// <summary> /// Checks if an effect of this name exists, and assigns it /// </summary> /// <param name="name">The unique name</param> /// <param name="effect">The <see cref="ClickEffect"/> associated with this name</param> /// <returns><see langword="true"/> if valid</returns> public static bool IsClickEffect(string name, out ClickEffect effect) { effect = null; if (ClickEffectsByName.TryGetValue(name, out ClickEffect other)) { effect = (ClickEffect)other.Clone(); return(true); } return(false); }
public override void Unload() { finalizedRegisterCompat = false; ShaderManager.Unload(); ClickerSystem.Unload(); ClickEffect.Unload(); ClickerInterfaceResources.Unload(); AutoClickKey = null; mod = null; }
public override void Unload() { finalizedRegisterCompat = false; ShaderManager.Unload(); ClickerSystem.Unload(); ClickEffect.Unload(); NetHandler.Unload(); ClickerInterfaceResources.Unload(); AutoClickKey = null; AimAssistKey = null; BossBuffImmunity = null; mod = null; }
public override void Load() { finalizedRegisterCompat = false; mod = this; AutoClickKey = RegisterHotKey("Clicker Accessory", "G"); //Can't localize this ClickerSystem.Load(); ClickEffect.LoadMiscEffects(); if (!Main.dedServ) { LoadClient(); } }
public override void Load() { finalizedRegisterCompat = false; mod = this; BossBuffImmunity = new HashSet <int>(); AutoClickKey = KeybindLoader.RegisterKeybind(this, "Clicker Accessory", "G"); //Can't localize this AimAssistKey = KeybindLoader.RegisterKeybind(this, "Clicker Aim Assist", "Mouse3"); //Can't localize this ClickerSystem.Load(); ClickEffect.LoadMiscEffects(); NetHandler.Load(); if (!Main.dedServ) { LoadClient(); } }