Skip to content

Instantly share code, notes, and snippets.

@Micrologist
Created August 30, 2021 05:35
Show Gist options
  • Save Micrologist/61b5f188266dba1a83c3e6c2e41d9ba3 to your computer and use it in GitHub Desktop.
Save Micrologist/61b5f188266dba1a83c3e6c2e41d9ba3 to your computer and use it in GitHub Desktop.
state("Warcry-Win64-Shipping")
{
float xVel : 0x043DC6D0, 0x30, 0x250, 0x288, 0x25C;
float yVel : 0x043DC6D0, 0x30, 0x250, 0x288, 0x260;
float lastJumpStrength : 0x043DC6D0, 0x30, 0x250, 0x288, 0x6C0;
float igt : 0x043F2750, 0x128, 0x3C0;
}
startup
{
vars.SetTextComponent = (Action<string, string>)((id, text) =>
{
var textSettings = timer.Layout.Components.Where(x => x.GetType().Name == "TextComponent").Select(x => x.GetType().GetProperty("Settings").GetValue(x, null));
var textSetting = textSettings.FirstOrDefault(x => (x.GetType().GetProperty("Text1").GetValue(x, null) as string) == id);
if (textSetting == null)
{
var textComponentAssembly = Assembly.LoadFrom("Components\\LiveSplit.Text.dll");
var textComponent = Activator.CreateInstance(textComponentAssembly.GetType("LiveSplit.UI.Components.TextComponent"), timer);
timer.Layout.LayoutComponents.Add(new LiveSplit.UI.Components.LayoutComponent("LiveSplit.Text.dll", textComponent as LiveSplit.UI.Components.IComponent));
textSetting = textComponent.GetType().GetProperty("Settings", BindingFlags.Instance | BindingFlags.Public).GetValue(textComponent, null);
textSetting.GetType().GetProperty("Text1").SetValue(textSetting, id);
}
if (textSetting != null)
textSetting.GetType().GetProperty("Text2").SetValue(textSetting, text);
});
vars.UpdateSpeedometer = (Action<float, float, bool>)((x, y, round) =>
{
double hvel = Math.Floor(Math.Sqrt(x*x + y*y)+0.5);
if(round)
vars.SetTextComponent("Speed", Math.Floor(hvel/100).ToString("") + " m/s");
else
vars.SetTextComponent("Speed", (hvel/100).ToString("0.00") + " m/s");
});
}
update
{
float x = current.xVel;
float y = current.yVel;
current.hVel = Math.Floor(Math.Sqrt(x*x + y*y)+0.5);
vars.SetTextComponent("Timer", current.igt.ToString("0.000")+ " s");
vars.UpdateSpeedometer(current.xVel, current.yVel, false);
vars.SetTextComponent("Last Jump", (current.lastJumpStrength/100).ToString("0.00") + " m/s");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment