Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 157b7fc

Browse files
committed
Updated to 2.0. i forgo
1 parent fe16d68 commit 157b7fc

File tree

8 files changed

+104
-44
lines changed

8 files changed

+104
-44
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using CommandSystem;
2+
using Exiled.API.Features;
3+
using Mirror;
4+
using PlayerRoles.FirstPersonControl;
5+
using System;
6+
using UnityEngine;
7+
8+
namespace TestingDummies.Commands
9+
{
10+
[CommandHandler(typeof(RemoteAdminCommandHandler))]
11+
public class DummyLookAt : ICommand
12+
{
13+
public string Command => "DummyLookAt";
14+
15+
public string[] Aliases => new string[] { "devdummylook", "dummylookat", "dummylook" };
16+
17+
public string Description => "Makes the specified dummy look at the target player";
18+
19+
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
20+
{
21+
if (arguments.Count != 2)
22+
{
23+
response = "Incorrect arguments. Usage: DummyLookAt [dummyID] [TargetID]";
24+
return false;
25+
}
26+
Player dummy = Player.Get(arguments.At(0));
27+
Player target = Player.Get(arguments.At(1));
28+
29+
if (dummy == null)
30+
{
31+
response = $"The player with the specified ID, '{arguments.At(0)}', dosent exist!";
32+
return false;
33+
}
34+
if (target == null)
35+
{
36+
response = $"The player with the specified ID, '{arguments.At(1)}', dosent exist!";
37+
return false;
38+
}
39+
if (Plugin.Instance.DumRef.Contains(dummy.ReferenceHub))
40+
{
41+
Quaternion quat = Quaternion.LookRotation(target.Position - dummy.Position, Vector3.up);
42+
var mouseLook = ((IFpcRole)dummy.ReferenceHub.roleManager.CurrentRole).FpcModule.MouseLook;
43+
mouseLook.CurrentHorizontal = quat.eulerAngles.y;
44+
mouseLook.CurrentVertical = 0f;
45+
46+
response = $"Rotated {dummy.Nickname} to the target {target.Nickname}";
47+
return true;
48+
}
49+
else
50+
{
51+
52+
response = $"ID : '{dummy.Id}', Nickname : '{dummy.Nickname}' is not a dummy or you entered a incorrect ID!";
53+
return false;
54+
}
55+
}
56+
57+
}
58+
}
59+

TestingDummies/Commands/DummyStats.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,27 @@ public class DummyStats : ICommand
1616

1717
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
1818
{
19-
if (arguments.Count > 1 || arguments.Count < 1)
19+
if (arguments.Count != 1)
2020
{
21-
response = "Insufficient arguments. Usage: dummystats [dummyID]";
21+
response = "Incorrect arguments. Usage: dummystats [dummyID]";
2222
return false;
2323
}
24-
string dummyID = arguments.At(0);
24+
Player Dummy = Player.Get(arguments.At(0));
2525

26-
if (Player.Get(dummyID) == null)
26+
if (Dummy == null)
2727
{
28-
response = $"The player, '{dummyID}', dosent exist!";
28+
response = $"The player with the specified ID, '{arguments.At(0)}', dosent exist!";
2929
return false;
3030
}
31-
if (Plugin.Instance.DumRef.Contains(Player.Get(dummyID).ReferenceHub))
31+
if (Plugin.Instance.DumRef.Contains(Dummy.ReferenceHub))
3232
{
33-
Player dummy = Player.Get(dummyID);
34-
35-
response = $"Stats: Player ID : {dummy.Id}, Name : {dummy.Nickname}, Health : {dummy.Health}, Role : {dummy.Role.Name}";
33+
response = $"Stats: Player ID : {Dummy.Id}, Name : {Dummy.Nickname}, Health : {Dummy.Health}, Role : {Dummy.Role.Name}";
3634
return true;
3735
}
3836
else
3937
{
40-
Player InvalidDummy = Player.Get(dummyID);
4138

42-
response = $"ID : '{InvalidDummy.Id}', Nickname : '{InvalidDummy.Nickname}' is not a dummy or you entered a incorrect ID!";
39+
response = $"ID : '{Dummy.Id}', Nickname : '{Dummy.Nickname}' is not a dummy or you entered a incorrect ID!";
4340
return false;
4441
}
4542
}

TestingDummies/Commands/RemoveDummy.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,31 @@ public class RemoveDummy : ICommand
1616

1717
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
1818
{
19-
if (arguments.Count > 1 || arguments.Count < 1)
19+
if (arguments.Count != 1)
2020
{
2121
response = "Insufficient arguments. Usage: removedummy [dummyID]";
2222
return false;
2323
}
24-
string dummyID = arguments.At(0);
24+
Player Dummy = Player.Get(arguments.At(0));
2525

26-
if(Player.Get(dummyID) == null)
26+
if(Dummy == null)
2727
{
28-
response = $"The player ID, '{dummyID}', dosent exist!";
28+
response = $"The player with the specified ID, '{arguments.At(0)}', dosent exist!";
2929
return false;
3030
}
31-
if(Plugin.Instance.DumRef.Contains(Player.Get(dummyID).ReferenceHub))
31+
if(Plugin.Instance.DumRef.Contains(Dummy.ReferenceHub))
3232
{
33-
Player dummy = Player.Get(dummyID);
34-
35-
Player.Dictionary.Remove(Plugin.Instance.spawning.PlayerPrefabs[dummy]);
36-
Plugin.Instance.DumRef.Remove(dummy.ReferenceHub);
37-
dummy.Disconnect();
38-
NetworkServer.DestroyPlayerForConnection(Plugin.Instance.spawning.PlayerConnIDs[dummy]);
39-
NetworkServer.Destroy(dummy.GameObject);
40-
response = $"Removed {dummy.Nickname}!";
33+
Player.Dictionary.Remove(Plugin.Instance.spawning.PlayerPrefabs[Dummy]);
34+
Plugin.Instance.DumRef.Remove(Dummy.ReferenceHub);
35+
Dummy.Disconnect();
36+
NetworkServer.DestroyPlayerForConnection(Plugin.Instance.spawning.PlayerConnIDs[Dummy]);
37+
NetworkServer.Destroy(Dummy.GameObject);
38+
response = $"Removed {Dummy.Nickname}!";
4139
return true;
4240
}
4341
else
4442
{
45-
Player InvalidDummy = Player.Get(dummyID);
46-
47-
response = $"ID : '{InvalidDummy.Id}', Nickname : '{InvalidDummy.Nickname}' is not a dummy or you entered a incorrect ID!";
43+
response = $"ID : '{Dummy.Id}', Nickname : '{Dummy.Nickname}' is not a dummy or you entered a incorrect ID!";
4844
return false;
4945
}
5046
}

TestingDummies/Commands/SpawnDummy.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Exiled.Permissions.Extensions;
44
using PlayerRoles;
55
using System;
6+
using MEC;
67

78

89
namespace TestingDummies.Commands
@@ -18,26 +19,26 @@ public class SpawnDummy : ICommand
1819

1920
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
2021
{
21-
if (arguments.Count < 3)
22+
if (arguments.Count != 3)
2223
{
23-
response = "Insufficient arguments. Usage: spawndummy [name] [role] [playerID]";
24+
response = "Incorrect arguments. Usage: spawndummy [name] [role] [playerID] OR [playerNickname]";
2425
return false;
2526
}
2627
string name = arguments.At(0);
2728
string roleString = arguments.At(1);
28-
string playerID = arguments.At(2);
29+
Player playerID = Player.Get(arguments.At(2));
2930
if (!Enum.TryParse(roleString, out RoleTypeId role))
3031
{
3132
response = $"Invalid role: {roleString}";
3233
return false;
3334
}
34-
if (Player.Get(playerID) == null)
35+
if (playerID == null)
3536
{
36-
response = $"Invalid player: {playerID}";
37+
response = $"Invalid player with the specified ID OR Nickname: {arguments.At(2)}";
3738
return false;
3839
}
39-
MEC.MECExtensionMethods1.RunCoroutine(Plugin.Instance.spawning.SpawnDum(name, role, Player.Get(playerID)));
40-
response = $"Spawned dummy with name '{name}', role '{role}', for player '{Player.Get(playerID).Nickname}'";
40+
MECExtensionMethods1.RunCoroutine(Plugin.Instance.spawning.SpawnDum(name, role, playerID));
41+
response = $"Spawned dummy with name '{name}', role '{role}', for player '{playerID.Nickname}'";
4142
return true;
4243
}
4344

TestingDummies/Patches/RotationPatch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace TestingDummies.Patches
88
{
99
//Thank you to the SCP-575 Plugin that I st- borrowed this code from :3
1010
[HarmonyPatch(typeof(FpcMouseLook), nameof(FpcMouseLook.UpdateRotation))]
11-
public class AIRotation
11+
public class RotationPatch
1212
{
1313
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
1414
{

TestingDummies/Plugin.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,42 @@
33
using System;
44
using System.Collections.Generic;
55
using TestingDummies.SpawningHandler;
6+
using HarmonyLib;
67

78
namespace TestingDummies
89
{
910
public class Plugin : Plugin<Config>
1011
{
1112
public static Plugin Instance;
12-
public List<ReferenceHub> DumRef = new List<ReferenceHub>();
13+
public List<ReferenceHub> DumRef = new();
1314
public Spawn spawning;
15+
16+
private Harmony _harmony;
17+
1418
public override string Name => "Dev Dummies";
1519
public override string Prefix => "Dev Dum";
1620
public override string Author => "NotIntense";
1721
public override PluginPriority Priority => PluginPriority.Medium;
18-
public override Version Version => new(2, 0, 3);
22+
public override Version Version => new(2, 0, 4);
1923
public override Version RequiredExiledVersion => new(7, 0, 0);
2024

2125
public override void OnEnabled()
22-
{
26+
{
27+
2328
Instance = this;
2429
spawning = new Spawn();
30+
31+
_harmony = new("DevDummies-Rotation-Patch");
32+
_harmony.PatchAll();
33+
2534
base.OnEnabled();
2635
}
2736

2837
public override void OnDisabled()
2938
{
39+
_harmony.UnpatchAll();
40+
_harmony = null;
41+
3042
Instance = null;
3143
spawning = null;
3244
base.OnDisabled();

TestingDummies/SpawningHandler/Spawn.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using System.Collections.Generic;
66
using UnityEngine;
77
using MEC;
8-
using PlayerRoles.FirstPersonControl;
9-
using System.IO.Pipes;
108

119
namespace TestingDummies.SpawningHandler
1210
{
@@ -47,10 +45,6 @@ public IEnumerator<float> SpawnDum(string Name, RoleTypeId Role, Player targert)
4745
NewPlayer.Role.Set(Role, Exiled.API.Enums.SpawnReason.ForceClass);
4846
NewPlayer.Position = targert.Position;
4947
NewPlayer.SessionVariables.Add("npc", true);
50-
Quaternion quat = Quaternion.LookRotation(targert.Rotation, Vector3.up);
51-
var mouseLookInsameroom = ((IFpcRole)NewPlayer.ReferenceHub.roleManager.CurrentRole).FpcModule.MouseLook;
52-
mouseLookInsameroom.CurrentHorizontal = Quaternion.Slerp(Quaternion.Euler(0f, mouseLookInsameroom.CurrentHorizontal, 0f), quat, Time.deltaTime).eulerAngles.y;
53-
mouseLookInsameroom.CurrentVertical = 0;
5448
yield break;
5549
}
5650
}

TestingDummies/TestingDummies.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
</Reference>
6464
</ItemGroup>
6565
<ItemGroup>
66+
<Compile Include="Commands\DummyLookAt.cs" />
6667
<Compile Include="Commands\DummyStats.cs" />
6768
<Compile Include="Commands\RemoveDummy.cs" />
6869
<Compile Include="Commands\SpawnDummy.cs" />

0 commit comments

Comments
 (0)