Skip to content

Commit

Permalink
0.1.6, LightHack
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Nov 17, 2017
1 parent 8c1b883 commit 3530bff
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions HEROsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public static void LoadAddServices()
ServiceController.AddService(instance.miscOptions);
ServiceController.AddService(new SpawnPointSetter(instance.miscOptions.Hotbar));
ServiceController.AddService(new MapRevealer(instance.miscOptions.Hotbar));
ServiceController.AddService(new LightHack(instance.miscOptions.Hotbar));
ServiceController.AddService(new ItemBanner(instance.miscOptions.Hotbar));
ServiceController.AddService(new ToggleGravestones(instance.miscOptions.Hotbar));
ServiceController.AddService(new GroupInspector(instance.miscOptions.Hotbar));
Expand Down
1 change: 1 addition & 0 deletions HEROsMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<Compile Include="HEROsModServices\ItemBrowser.cs" />
<Compile Include="HEROsModServices\ItemClearer.cs" />
<Compile Include="HEROsModServices\KeybindController.cs" />
<Compile Include="HEROsModServices\LightHack.cs" />
<Compile Include="HEROsModServices\Login.cs" />
<Compile Include="HEROsModServices\MapRevealer.cs" />
<Compile Include="HEROsModServices\MobSpawner.cs" />
Expand Down
1 change: 1 addition & 0 deletions HEROsModNetwork/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Group
new PermissionInfo("Flycam", "Fly Camera"),
new PermissionInfo("ClearItems", "Clear Items on Ground"),
new PermissionInfo("RevealMap", "Reveal Map"),
new PermissionInfo("LightHack", "Light Hack"),
new PermissionInfo("SpawnNPCs", "Spawn NPCs"),
new PermissionInfo("Kick", "Kick Players"),
new PermissionInfo("Ban", "Ban Players"),
Expand Down
62 changes: 62 additions & 0 deletions HEROsModServices/LightHack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using HEROsMod.UIKit;
using HEROsMod.UIKit.UIComponents;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;

namespace HEROsMod.HEROsModServices
{
/// <summary>
/// A service that hacks the lighting values for the player
/// </summary>
class LightHack : HEROsModService
{
internal static int LightStrength;
internal static float[] LightStrengthValues = new float[] { 0, .25f, .5f, 1f };
private static string[] LightStrengthStrings = new string[] { "LightHack: Disabled", "LightHack: 25%", "LightHack: 50%", "LightHack: 100%" };

public LightHack(UIHotbar hotbar)
{
IsInHotbar = true;
HotbarParent = hotbar;
this._name = "Light Hack";
this._hotbarIcon = new UIImage(HEROsMod.instance.GetTexture("Images/lighthack"));
this._hotbarIcon.onLeftClick += (s, e) =>
{
buttonLogic(true);
};
this._hotbarIcon.onRightClick += (s, e) =>
{
buttonLogic(false);
};
this.HotbarIcon.Tooltip = LightStrengthStrings[LightStrength];
_hotbarIcon.Opacity = 0.5f;
}

public override void MyGroupUpdated()
{
this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack");
}

public void buttonLogic(bool leftMouse)
{
LightStrength = leftMouse ? (LightStrength + 1) % LightStrengthStrings.Length : (LightStrength + LightStrengthStrings.Length - 1) % LightStrengthStrings.Length;
HotbarIcon.Tooltip = LightStrengthStrings[LightStrength];
_hotbarIcon.Opacity = (LightStrengthValues[LightStrength] + 1f) / 2;
}
}

public class LightHackGlobalWall : GlobalWall
{
public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
{
if (LightHack.LightStrength > 0)
{
r = MathHelper.Clamp(r + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
g = MathHelper.Clamp(g + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
b = MathHelper.Clamp(b + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
}
}
}
}
1 change: 1 addition & 0 deletions HEROsModServices/MiscOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public override void MyGroupUpdated()
{
this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleBannedItems") ||
HEROsModNetwork.LoginService.MyGroup.HasPermission("RevealMap") ||
HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack") ||
HEROsModNetwork.LoginService.MyGroup.IsAdmin ||
HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleHardmodeEnemies") ||
HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleGravestones");
Expand Down
Binary file added Images/lighthack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = HERO, jopojelly
version = 0.1.5.8
version = 0.1.6
displayName = HERO's Mod
homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore
Expand Down

0 comments on commit 3530bff

Please sign in to comment.