2022-07-20 17:50:01 +08:00
|
|
|
|
using GTA;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
using GTA.Math;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
using System;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
using System.Drawing;
|
2022-05-27 14:33:33 +08:00
|
|
|
|
using System.Threading;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
using System.Windows.Forms;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
|
|
|
|
|
namespace RageCoop.Client
|
|
|
|
|
{
|
2022-07-20 17:50:01 +08:00
|
|
|
|
internal class DevTool : Script
|
2022-05-26 17:11:37 +08:00
|
|
|
|
{
|
2022-05-27 14:33:33 +08:00
|
|
|
|
public static Vehicle ToMark;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
public static bool UseSecondary = false;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
public static int Current = 0;
|
2022-05-27 14:33:33 +08:00
|
|
|
|
public static int Secondary = 0;
|
|
|
|
|
public static MuzzleDir Direction = MuzzleDir.Forward;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
public DevTool()
|
|
|
|
|
{
|
|
|
|
|
Tick+=OnTick;
|
2022-05-27 14:33:33 +08:00
|
|
|
|
KeyDown+=OnKeyDown;
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-27 14:33:33 +08:00
|
|
|
|
private void OnKeyDown(object sender, KeyEventArgs e)
|
2022-05-26 17:11:37 +08:00
|
|
|
|
{
|
2022-05-27 14:33:33 +08:00
|
|
|
|
if (ToMark==null||(!ToMark.Exists())) { return; }
|
2022-07-20 17:50:01 +08:00
|
|
|
|
if (DevToolMenu.Menu.SelectedItem==DevToolMenu.boneIndexItem)
|
|
|
|
|
{
|
2022-05-27 14:33:33 +08:00
|
|
|
|
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
Current++;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Left:
|
|
|
|
|
Current--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (DevToolMenu.Menu.SelectedItem==DevToolMenu.secondaryBoneIndexItem)
|
2022-05-26 17:11:37 +08:00
|
|
|
|
{
|
2022-05-27 14:33:33 +08:00
|
|
|
|
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
Secondary++;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Left:
|
|
|
|
|
Secondary--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
2022-05-27 14:33:33 +08:00
|
|
|
|
Update();
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
2022-05-27 14:33:33 +08:00
|
|
|
|
private static void Update()
|
|
|
|
|
{
|
2022-05-26 17:11:37 +08:00
|
|
|
|
|
2022-05-27 14:33:33 +08:00
|
|
|
|
if (Current>ToMark.Bones.Count-1)
|
|
|
|
|
{
|
|
|
|
|
Current=0;
|
|
|
|
|
}
|
|
|
|
|
else if (Current< 0)
|
|
|
|
|
{
|
|
|
|
|
Current=ToMark.Bones.Count-1;
|
|
|
|
|
}
|
|
|
|
|
DevToolMenu.boneIndexItem.AltTitle= Current.ToString();
|
|
|
|
|
if (Secondary>ToMark.Bones.Count-1)
|
|
|
|
|
{
|
|
|
|
|
Secondary=0;
|
|
|
|
|
}
|
|
|
|
|
else if (Secondary< 0)
|
|
|
|
|
{
|
|
|
|
|
Secondary=ToMark.Bones.Count-1;
|
|
|
|
|
}
|
|
|
|
|
DevToolMenu.secondaryBoneIndexItem.AltTitle= Secondary.ToString();
|
|
|
|
|
}
|
|
|
|
|
private static void OnTick(object sender, EventArgs e)
|
2022-05-26 17:11:37 +08:00
|
|
|
|
{
|
2022-07-20 17:50:01 +08:00
|
|
|
|
if (ToMark == null || !ToMark.Exists()) { return; }
|
2022-05-27 14:33:33 +08:00
|
|
|
|
Update();
|
|
|
|
|
Draw(Current);
|
|
|
|
|
if (UseSecondary)
|
|
|
|
|
{
|
|
|
|
|
Draw(Secondary);
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
2022-05-27 14:33:33 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private static void Draw(int boneindex)
|
|
|
|
|
{
|
|
|
|
|
var bone = ToMark.Bones[boneindex];
|
2022-05-26 17:11:37 +08:00
|
|
|
|
World.DrawLine(bone.Position, bone.Position+2*bone.ForwardVector, Color.Blue);
|
|
|
|
|
World.DrawLine(bone.Position, bone.Position+2*bone.UpVector, Color.Green);
|
|
|
|
|
World.DrawLine(bone.Position, bone.Position+2*bone.RightVector, Color.Yellow);
|
2022-05-27 14:33:33 +08:00
|
|
|
|
Vector3 todraw = bone.ForwardVector;
|
|
|
|
|
switch ((byte)Direction)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
todraw=bone.ForwardVector;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
todraw=bone.RightVector;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
todraw=bone.UpVector;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
todraw=bone.ForwardVector*-1;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
todraw=bone.RightVector*-1;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
todraw=bone.UpVector*-1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
World.DrawLine(bone.Position, bone.Position+10*todraw, Color.Red);
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
2022-05-27 14:33:33 +08:00
|
|
|
|
public static void CopyToClipboard(MuzzleDir dir)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (ToMark!=null)
|
|
|
|
|
{
|
|
|
|
|
string s;
|
|
|
|
|
if (UseSecondary)
|
|
|
|
|
{
|
|
|
|
|
if ((byte)dir<3)
|
|
|
|
|
{
|
|
|
|
|
s=$@"
|
|
|
|
|
// {ToMark.DisplayName}
|
|
|
|
|
case {ToMark.Model.Hash}:
|
2022-06-02 13:52:18 +08:00
|
|
|
|
i=BulletsShot%2==0 ? {Current} : {Secondary};
|
2022-05-27 14:33:33 +08:00
|
|
|
|
return new MuzzleInfo(v.Bones[i].Position, v.Bones[i].{dir}Vector);
|
|
|
|
|
";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s=$@"
|
|
|
|
|
// {ToMark.DisplayName}
|
|
|
|
|
case {ToMark.Model.Hash}:
|
2022-06-02 13:52:18 +08:00
|
|
|
|
i=BulletsShot%2==0 ? {Current} : {Secondary};
|
2022-05-27 14:33:33 +08:00
|
|
|
|
return new MuzzleInfo(v.Bones[i].Position, v.Bones[i].{((MuzzleDir)(dir-3)).ToString()}Vector*-1);
|
|
|
|
|
";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((byte)dir<3)
|
|
|
|
|
{
|
|
|
|
|
s=$@"
|
|
|
|
|
// {ToMark.DisplayName}
|
|
|
|
|
case {ToMark.Model.Hash}:
|
|
|
|
|
return new MuzzleInfo(v.Bones[{Current}].Position, v.Bones[{Current}].{dir}Vector);
|
|
|
|
|
";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s=$@"
|
|
|
|
|
// {ToMark.DisplayName}
|
|
|
|
|
case {ToMark.Model.Hash}:
|
|
|
|
|
return new MuzzleInfo(v.Bones[{Current}].Position, v.Bones[{Current}].{((MuzzleDir)(dir-3)).ToString()}Vector*-1);
|
|
|
|
|
";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread thread = new Thread(() => Clipboard.SetText(s));
|
|
|
|
|
thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
|
|
|
|
|
thread.Start();
|
|
|
|
|
thread.Join();
|
|
|
|
|
GTA.UI.Notification.Show("Copied to clipboard, please paste it on the GitHub issue page!");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-20 17:50:01 +08:00
|
|
|
|
|
2022-05-27 14:33:33 +08:00
|
|
|
|
}
|
2022-07-20 17:50:01 +08:00
|
|
|
|
internal enum MuzzleDir : byte
|
2022-05-27 14:33:33 +08:00
|
|
|
|
{
|
2022-07-20 17:50:01 +08:00
|
|
|
|
Forward = 0,
|
2022-05-27 14:33:33 +08:00
|
|
|
|
Right = 1,
|
2022-07-20 17:50:01 +08:00
|
|
|
|
Up = 2,
|
|
|
|
|
Backward = 3,
|
2022-05-27 14:33:33 +08:00
|
|
|
|
Left = 4,
|
2022-07-20 17:50:01 +08:00
|
|
|
|
Down = 5,
|
2022-05-26 17:11:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|