|
| 1 | +using HEROsMod.UIKit; |
| 2 | +using HEROsMod.UIKit.UIComponents; |
| 3 | +using Microsoft.Xna.Framework; |
| 4 | +using System; |
| 5 | +using Terraria; |
| 6 | +using Terraria.ModLoader; |
| 7 | + |
| 8 | +namespace HEROsMod.HEROsModServices |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// A service that hacks the lighting values for the player |
| 12 | + /// </summary> |
| 13 | + class LightHack : HEROsModService |
| 14 | + { |
| 15 | + internal static int LightStrength; |
| 16 | + internal static float[] LightStrengthValues = new float[] { 0, .25f, .5f, 1f }; |
| 17 | + private static string[] LightStrengthStrings = new string[] { "LightHack: Disabled", "LightHack: 25%", "LightHack: 50%", "LightHack: 100%" }; |
| 18 | + |
| 19 | + public LightHack(UIHotbar hotbar) |
| 20 | + { |
| 21 | + IsInHotbar = true; |
| 22 | + HotbarParent = hotbar; |
| 23 | + this._name = "Light Hack"; |
| 24 | + this._hotbarIcon = new UIImage(HEROsMod.instance.GetTexture("Images/lighthack")); |
| 25 | + this._hotbarIcon.onLeftClick += (s, e) => |
| 26 | + { |
| 27 | + buttonLogic(true); |
| 28 | + }; |
| 29 | + this._hotbarIcon.onRightClick += (s, e) => |
| 30 | + { |
| 31 | + buttonLogic(false); |
| 32 | + }; |
| 33 | + this.HotbarIcon.Tooltip = LightStrengthStrings[LightStrength]; |
| 34 | + _hotbarIcon.Opacity = 0.5f; |
| 35 | + } |
| 36 | + |
| 37 | + public override void MyGroupUpdated() |
| 38 | + { |
| 39 | + this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack"); |
| 40 | + } |
| 41 | + |
| 42 | + public void buttonLogic(bool leftMouse) |
| 43 | + { |
| 44 | + LightStrength = leftMouse ? (LightStrength + 1) % LightStrengthStrings.Length : (LightStrength + LightStrengthStrings.Length - 1) % LightStrengthStrings.Length; |
| 45 | + HotbarIcon.Tooltip = LightStrengthStrings[LightStrength]; |
| 46 | + _hotbarIcon.Opacity = (LightStrengthValues[LightStrength] + 1f) / 2; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + public class LightHackGlobalWall : GlobalWall |
| 51 | + { |
| 52 | + public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) |
| 53 | + { |
| 54 | + if (LightHack.LightStrength > 0) |
| 55 | + { |
| 56 | + r = MathHelper.Clamp(r + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); |
| 57 | + g = MathHelper.Clamp(g + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); |
| 58 | + b = MathHelper.Clamp(b + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments