This commit is contained in:
davidon-top 2024-01-22 19:25:38 +01:00
parent d2176afff9
commit ecb2998462
Signed by: DavidOnTop
GPG key ID: FAB914DDC2F180EB
4 changed files with 53 additions and 12 deletions

View file

@ -9,6 +9,22 @@ namespace CruelMan.Modules {
public void Awake() {
instance = this;
AddModules();
new Terminal.ConsoleCommand($"cmbind", "binds a module to a key", delegate (Terminal.ConsoleEventArgs args) {
if (args.Args.Length < 2) {
args.Context.AddString("Usage: cmbind <module> <key>");
return;
}
string module = args.Args[1];
string key = args.Args[2];
foreach (Module m in modules) {
if (m.Command == module.ToLower()) {
m.bind = (KeyCode)System.Enum.Parse(typeof(KeyCode), key);
args.Context.AddString($"Bound {module} to {key}");
return;
}
}
args.Context.AddString($"Module {module} not found");
});
}
public void Update() {
@ -27,6 +43,7 @@ namespace CruelMan.Modules {
AddModule<Speed>();
AddModule<JumpHeight>();
AddModule<InstantDmg>();
AddModule<SwimSpeed>();
}
private void AddModule<T>() where T : Module, new() {

View file

@ -9,25 +9,17 @@ namespace CruelMan.Modules {
public override ModuleType Type => ModuleType.Stats;
protected override void Init() {
AddSetting<NoChange>();
AddSetting<Stamina>();
AddSetting<SetStamina>();
}
protected override void OnDisable() {}
protected override void OnEnable() {}
protected override void OnUpdate() {
if (GetSetting<NoChange>().Value) {
FieldInfo fi = typeof(Player).GetField("m_stamina", BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue(Player.m_localPlayer, GetSetting<Stamina>().Value);
}
FieldInfo fi = typeof(Player).GetField("m_stamina", BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue(Player.m_localPlayer, GetSetting<Stamina>().Value);
}
}
public class NoChange : BooleanSetting {
public override string Name => "No Change";
public override string Description => "Prevents stamina from changing";
}
public class Stamina : NumberSetting {
public override string Name => "Stamina";
public override string Description => "The amount of stamina to add";

View file

@ -0,0 +1,33 @@
using CruelMan.Modules.Settings;
namespace CruelMan.Modules {
public class SwimSpeed : Module {
public override string Name => "Swim Speed";
public override string Command => "swimspeed";
public override string Description => "Sets the swim speed of the player";
public override ModuleType Type => ModuleType.Movement;
public float oldSpeed = 0f;
protected override void Init() {
AddSetting<SSpeed>();
}
protected override void OnEnable() {
oldSpeed = Player.m_localPlayer.m_swimSpeed;
}
protected override void OnDisable() {
Player.m_localPlayer.m_swimSpeed = oldSpeed;
}
protected override void OnUpdate() {
Player.m_localPlayer.m_swimSpeed = GetSetting<SSpeed>().Value;
}
}
public class SSpeed : NumberSetting {
public override string Name => "Speed";
public override string Description => "The speed to set the player to";
public override float Min {get;set;} = 0;
public override float Max {get;set;} = 100;
public override float Value {get;set;} = 0;
}
}

View file

@ -10,7 +10,7 @@ namespace CruelMan.UI {
public List<Setting> openSettings = null;
public Module openSettingsModule = null;
public Rect settingsWindow = new Rect(140, 10, 220, 600);
public Rect settingsWindow = new Rect(880, 10, 220, 600);
public Rect ModuleMovementWindow = new Rect(10, 10, 200, 500);
public Rect ModuleStatsWindow = new Rect(220, 10, 200, 500);
@ -22,7 +22,6 @@ namespace CruelMan.UI {
return;
}
// windowRect = GUI.Window(0, windowRect, MainWindow, "CruelMan");
ModuleMovementWindow = GUI.Window(0, ModuleMovementWindow, MainWindow, "Movement");
ModuleStatsWindow = GUI.Window(1, ModuleStatsWindow, MainWindow, "Stats");
ModuleCombatWindow = GUI.Window(2, ModuleCombatWindow, MainWindow, "Combat");