separate loader and behaviour to get rid of static crap

This commit is contained in:
Magnus von Wachenfeldt 2017-12-07 00:10:19 +01:00
parent 97ceb7ebaf
commit e7699e7744
5 changed files with 27 additions and 14 deletions

View File

@ -1 +1 @@
injector64.exe --dll "D:\Projekt\tarkov-hax\TarkovHax\bin\Debug\TarkovHax.dll" --target EscapeFromTarkov.exe --namespace TarkovHax --class TarkovHaxBehaviour --method Load
injector64.exe --dll "D:\Projekt\tarkov-hax\TarkovHax\bin\Debug\TarkovHax.dll" --target EscapeFromTarkov.exe --namespace TarkovHax --class Loader --method Load

View File

@ -42,10 +42,10 @@ namespace TarkovHax
public static void DrawLineStretched(Vector2 lineStart, Vector2 lineEnd, Texture2D texture, int thickness)
{
var vector = lineEnd - lineStart;
float num = 57.29578f * Mathf.Atan(vector.y / vector.x);
float pivot = 57.29578f * Mathf.Atan(vector.y / vector.x);
if (vector.x < 0f)
{
num += 180f;
pivot += 180f;
}
if (thickness < 1)
@ -55,9 +55,9 @@ namespace TarkovHax
int yOffset = (int)Mathf.Ceil((float)(thickness / 2));
GUIUtility.RotateAroundPivot(num, lineStart);
GUIUtility.RotateAroundPivot(pivot, lineStart);
GUI.DrawTexture(new Rect(lineStart.x, lineStart.y - (float)yOffset, vector.magnitude, (float)thickness), texture);
GUIUtility.RotateAroundPivot(-num, lineStart);
GUIUtility.RotateAroundPivot(-pivot, lineStart);
}
public static void DrawLine(Vector2 lineStart, Vector2 lineEnd, Texture2D texture)

16
TarkovHax/Loader.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TarkovHax
{
public class Loader
{
private static void Load()
{
new TarkovHaxBehaviour().Load();
}
}
}

View File

@ -46,6 +46,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GuiHelper.cs" />
<Compile Include="Loader.cs" />
<Compile Include="TarkovHaxBehaviour.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -6,7 +6,7 @@ namespace TarkovHax
{
public class TarkovHaxBehaviour : MonoBehaviour
{
public static GameObject GameObjectHolder;
public GameObject GameObjectHolder;
private float _playerNextUpdateTime;
private float _lootNextUpdateTime;
@ -23,7 +23,7 @@ namespace TarkovHax
private float _maxDrawingDistance = 15000f;
private static void Load()
public void Load()
{
GameObjectHolder = new GameObject();
GameObjectHolder.AddComponent<TarkovHaxBehaviour>();
@ -31,13 +31,10 @@ namespace TarkovHax
DontDestroyOnLoad(GameObjectHolder);
}
public static void Unload()
public void Unload()
{
var component = GameObjectHolder.GetComponent<TarkovHaxBehaviour>();
if (component != null)
{
DestroyImmediate(component, true);
}
Destroy(GameObjectHolder);
Destroy(this);
}
private void Update()
@ -58,7 +55,6 @@ namespace TarkovHax
{
ToggleNightVision();
}
if (Input.GetKeyDown(KeyCode.KeypadPlus))
{
IncreaseFov();