Skip to content

Commit 1f757ea

Browse files
committed
Synapse 1.2 beta nuget and added Scp Voice Chat
1 parent 2eac034 commit 1f757ea

7 files changed

+105
-52
lines changed

Scp056/EventHandler.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using PlayerRoles;
66
using PlayerRoles.RoleAssign;
77
using Synapse3.SynapseModule;
8+
using Synapse3.SynapseModule.Enums;
89
using Synapse3.SynapseModule.Events;
910
using Synapse3.SynapseModule.Player;
1011
using UnityEngine;
@@ -26,7 +27,7 @@ public void FirstSpawn(FirstSpawnEvent ev)
2627
if (!Plugin.Config.EnableDefaultSpawnBehaviour) return;
2728
if (Player.Players.Count < Plugin.Config.RequiredPlayers) return;
2829
if (Random.Range(1f, 100f) > Plugin.Config.SpawnChance) return;
29-
if(Plugin.Config.ReplaceScp && ev.AmountOfScpSpawns <= 0) return;
30+
if (Plugin.Config.ReplaceScp && ev.AmountOfScpSpawns <= 0) return;
3031

3132
var possiblePlayers = Player.Players.Where(x => RoleAssigner.CheckPlayer(x.Hub)).ToArray();
3233
if (!possiblePlayers.Any()) return;
@@ -48,27 +49,28 @@ public void Death(DeathEvent ev)
4849
ev.Player.SendWindowMessage(Plugin.Translation.Get(ev.Player).KilledBy056);
4950
}
5051

51-
//TODO: Implement SCP Chat ability
52-
/*
5352
[EventHandler]
54-
public void SpeakEvent(SpeakEvent ev)
53+
public void SpeakPlayerEvent(SpeakToPlayerEvent ev)
5554
{
56-
if (ev.Player.RoleID == 56 && (ev.Player.CustomRole as Scp056PlayerScript)?.ScpChat == true)
55+
if (ev.Player.RoleID == 56)
5756
{
58-
SynapseLogger<Scp056Plugin>.Warn("SpeakEvent");
59-
ev.Channel = VoiceChatChannel.ScpChat;
57+
ev.Channel = VoiceChatChannel.Proximity;
58+
if (ev.Player.CustomRole is Scp056PlayerScript { ScpChat: true })
59+
{
60+
ev.Channel = ev.Receiver.TeamID == 0 ? VoiceChatChannel.RoundSummary : VoiceChatChannel.None;
61+
}
62+
else if(ev.Player.FakeRoleManager.VisibleRole.GetTeam() == Team.SCPs)
63+
{
64+
if ((ev.Player.Position - ev.Receiver.Position).sqrMagnitude > 100)
65+
ev.Channel = VoiceChatChannel.None;
66+
}
6067
}
61-
}
6268

63-
[EventHandler]
64-
public void SpeakPlayerEvent(SpeakToPlayerEvent ev)
65-
{
66-
if (ev.Receiver.RoleID == 56 && ev.Player.Hub.IsSCP() &&
67-
(ev.Player.CustomRole as Scp056PlayerScript)?.ScpChat == true)
69+
if (ev.Receiver.RoleID == 56 && ev.OriginalChannel == VoiceChatChannel.ScpChat)
6870
{
69-
SynapseLogger<Scp056Plugin>.Warn("SpeakEventPlayer");
70-
ev.Channel = VoiceChatChannel.ScpChat;
71+
ev.Channel = VoiceChatChannel.Proximity;
7172
}
7273
}
73-
*/
74+
75+
//TODO: Add an HotKey for SCP-VoiceChat and make SCP-056 a Zombie for all SCP's
7476
}

Scp056/KeyBind/ScpVoiceChatBind.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Neuron.Core.Meta;
2+
using Ninject;
3+
using Synapse3.SynapseModule.KeyBind;
4+
using Synapse3.SynapseModule.Player;
5+
using UnityEngine;
6+
7+
namespace Scp056.KeyBind;
8+
9+
[Automatic]
10+
[KeyBind(
11+
Bind = KeyCode.V,
12+
CommandName = "Scp056 ScpVoiceChat",
13+
CommandDescription = "Toggles the SCP-Voice Chat for SCP-056"
14+
)]
15+
public class ScpVoiceChatBind : Synapse3.SynapseModule.KeyBind.KeyBind
16+
{
17+
[Inject]
18+
public Scp056Plugin Plugin { get; set; }
19+
20+
public override void Execute(SynapsePlayer player)
21+
{
22+
if (player.RoleID != 56 || player.CustomRole is not Scp056PlayerScript script) return;
23+
script.ScpChat = !script.ScpChat;
24+
var trans = player.GetTranslation(Plugin.Translation);
25+
player.SendHint(script.ScpChat ? trans.ActivatedScpChat : trans.DeactivatedScpChat);
26+
}
27+
}

Scp056/Scp056.csproj

+18-17
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3737
</PropertyGroup>
3838
<ItemGroup>
39-
<Reference Include="0Harmony, Version=2.10.0.0, Culture=neutral, processorArchitecture=MSIL">
40-
<HintPath>..\packages\HarmonyX.2.10.0\lib\net45\0Harmony.dll</HintPath>
39+
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Lib.Harmony.2.2.2\lib\net48\0Harmony.dll</HintPath>
4141
</Reference>
4242
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
43-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\Assembly-CSharp.dll</HintPath>
43+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\Assembly-CSharp.dll</HintPath>
4444
</Reference>
4545
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
46-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\Assembly-CSharp-firstpass.dll</HintPath>
46+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\Assembly-CSharp-firstpass.dll</HintPath>
4747
</Reference>
4848
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
4949
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
@@ -67,7 +67,7 @@
6767
<HintPath>..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
70-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\Mirror.dll</HintPath>
70+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\Mirror.dll</HintPath>
7171
</Reference>
7272
<Reference Include="Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
7373
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.dll</HintPath>
@@ -88,17 +88,17 @@
8888
<HintPath>..\packages\MonoMod.Utils.22.3.23.4\lib\net452\MonoMod.Utils.dll</HintPath>
8989
</Reference>
9090
<Reference Include="mscorlib" />
91-
<Reference Include="Neuron.Core, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
92-
<HintPath>..\packages\NeuronModding.Core.1.0.0.5\lib\netstandard2.0\Neuron.Core.dll</HintPath>
91+
<Reference Include="Neuron.Core, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
92+
<HintPath>..\packages\NeuronModding.Core.1.0.2\lib\netstandard2.0\Neuron.Core.dll</HintPath>
9393
</Reference>
94-
<Reference Include="Neuron.Modules.Commands, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
95-
<HintPath>..\packages\NeuronModding.Modules.Commands.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Commands.dll</HintPath>
94+
<Reference Include="Neuron.Modules.Commands, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
95+
<HintPath>..\packages\NeuronModding.Modules.Commands.1.0.2\lib\netstandard2.0\Neuron.Modules.Commands.dll</HintPath>
9696
</Reference>
97-
<Reference Include="Neuron.Modules.Configs, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
98-
<HintPath>..\packages\NeuronModding.Modules.Configs.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Configs.dll</HintPath>
97+
<Reference Include="Neuron.Modules.Configs, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
98+
<HintPath>..\packages\NeuronModding.Modules.Configs.1.0.2\lib\netstandard2.0\Neuron.Modules.Configs.dll</HintPath>
9999
</Reference>
100-
<Reference Include="Neuron.Modules.Patcher, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
101-
<HintPath>..\packages\NeuronModding.Modules.Patcher.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Patcher.dll</HintPath>
100+
<Reference Include="Neuron.Modules.Patcher, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
101+
<HintPath>..\packages\NeuronModding.Modules.Patcher.1.0.2\lib\netstandard2.0\Neuron.Modules.Patcher.dll</HintPath>
102102
</Reference>
103103
<Reference Include="Ninject, Version=3.3.6.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
104104
<HintPath>..\packages\Ninject.3.3.6\lib\net45\Ninject.dll</HintPath>
@@ -107,7 +107,7 @@
107107
<HintPath>..\packages\SYML.1.0.2\lib\netstandard2.0\SYML.dll</HintPath>
108108
</Reference>
109109
<Reference Include="Synapse3.SynapseModule, Version=3.0.0.0, Culture=neutral, processorArchitecture=Amd64">
110-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\Synapse3.SynapseModule.dll</HintPath>
110+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\Synapse3.SynapseModule.dll</HintPath>
111111
</Reference>
112112
<Reference Include="System" />
113113
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -136,19 +136,20 @@
136136
<Reference Include="System.Net.Http" />
137137
<Reference Include="System.Xml" />
138138
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
139-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.dll</HintPath>
139+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\UnityEngine.dll</HintPath>
140140
</Reference>
141141
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
142-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.CoreModule.dll</HintPath>
142+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\UnityEngine.CoreModule.dll</HintPath>
143143
</Reference>
144144
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
145-
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.PhysicsModule.dll</HintPath>
145+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.2\lib\net48\UnityEngine.PhysicsModule.dll</HintPath>
146146
</Reference>
147147
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
148148
<HintPath>..\packages\YamlDotNet.11.2.1\lib\net45\YamlDotNet.dll</HintPath>
149149
</Reference>
150150
</ItemGroup>
151151
<ItemGroup>
152+
<Compile Include="KeyBind\ScpVoiceChatBind.cs" />
152153
<Compile Include="KeyBind\SwapClasses.cs" />
153154
<Compile Include="KeyBind\Scp056SwapBind.cs" />
154155
<Compile Include="KeyBind\TargetBind.cs" />

Scp056/Scp056Command.cs

+26-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Neuron.Core.Meta;
33
using Neuron.Modules.Commands;
44
using Neuron.Modules.Commands.Command;
5+
using Ninject;
56
using PlayerRoles;
67
using Synapse3.SynapseModule.Command;
78
using Synapse3.SynapseModule.Player;
@@ -17,14 +18,11 @@ namespace Scp056;
1718
)]
1819
public class Scp056Command : SynapseCommand
1920
{
20-
private readonly PlayerService _player;
21-
private readonly Scp056Plugin _plugin;
22-
23-
public Scp056Command(PlayerService player, Scp056Plugin plugin)
24-
{
25-
_player = player;
26-
_plugin = plugin;
27-
}
21+
[Inject]
22+
public PlayerService Player { get; set; }
23+
24+
[Inject]
25+
public Scp056Plugin Plugin { get; set; }
2826

2927
public override void Execute(SynapseContext context, ref CommandResult result)
3028
{
@@ -33,18 +31,31 @@ public override void Execute(SynapseContext context, ref CommandResult result)
3331

3432
if (context.Player.RoleID != 56)
3533
{
36-
result.Response = _plugin.Translation.Get(context.Player).NotScp056;
34+
result.Response = Plugin.Translation.Get(context.Player).NotScp056;
3735
result.StatusCode = CommandStatusCode.Forbidden;
3836
return;
3937
}
4038

4139
switch (context.Arguments[0].ToLower())
4240
{
41+
case "voice":
42+
if (context.Player.CustomRole is not Scp056PlayerScript script)
43+
{
44+
result.StatusCode = CommandStatusCode.Error;
45+
result.Response =
46+
"Somehow you are SCP-056 without a Script? Please Report this to an administrator that he should check his Plugin files";
47+
return;
48+
}
49+
script.ScpChat = !script.ScpChat;
50+
var trans = context.Player.GetTranslation(Plugin.Translation);
51+
result.Response = script.ScpChat ? trans.ActivatedScpChat : trans.DeactivatedScpChat;
52+
return;
53+
4354
case "targets":
44-
var targets = _player
55+
var targets = Player
4556
.GetPlayers(x => x.TeamID is (uint)Team.FoundationForces or (uint)Team.ClassD or (uint)Team.Scientists).Count;
4657

47-
result.Response = _plugin.Translation.Get(context.Player).Targets
58+
result.Response = Plugin.Translation.Get(context.Player).Targets
4859
.Replace("%targets%", targets.ToString());
4960

5061
result.StatusCode = CommandStatusCode.Ok;
@@ -57,21 +68,22 @@ public override void Execute(SynapseContext context, ref CommandResult result)
5768
if (Enum.TryParse<RoleTypeId>(context.Arguments[1], out var role))
5869
{
5970
(context.Player.CustomRole as Scp056PlayerScript)?.SwapRole(role);
60-
result.Response = _plugin.Translation.Get(context.Player).ChangedRole
71+
result.Response = Plugin.Translation.Get(context.Player).ChangedRole
6172
.Replace("%role%", role.ToString());
6273
result.StatusCode = CommandStatusCode.Ok;
6374
return;
6475
}
6576
goto default;
6677

6778
default:
68-
result.Response = _plugin.Translation.Commands;
69-
foreach (var possibleRole in _plugin.Config.AllowedRoles)
79+
result.Response = Plugin.Translation.Commands;
80+
foreach (var possibleRole in Plugin.Config.AllowedRoles)
7081
{
7182
result.Response += "\n.056 class " + possibleRole;
7283
}
7384

7485
result.Response += "\n.056 targets";
86+
result.Response += "\n.056 voice";
7587
result.StatusCode = CommandStatusCode.Ok;
7688
return;
7789
}

Scp056/Scp056PlayerScript.cs

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using PlayerRoles;
44
using Synapse3.SynapseModule.Enums;
55
using Synapse3.SynapseModule.Map;
6+
using Synapse3.SynapseModule.Player;
67
using Synapse3.SynapseModule.Role;
78

89
namespace Scp056;
@@ -36,12 +37,15 @@ protected override void OnSpawn(IAbstractRoleConfig config)
3637
{
3738
Player.SendWindowMessage(_plugin.Translation.Get(Player).Spawn.Replace("\\n", "\n"));
3839
RemoveCustomDisplay();
40+
//This needs a Synapse update since it won't update enough
41+
//Player.FakeRoleManager.VisibleRoleCondition[SeeAsZombieCondition] = new RoleInfo(RoleTypeId.Scp0492, Player);
3942
}
4043

4144
protected override void OnDeSpawn(DeSpawnReason reason)
4245
{
4346
if (reason <= DeSpawnReason.Leave)
4447
_cassie.AnnounceScpDeath("056", CassieSettings.Glitched, CassieSettings.Noise);
48+
//Player.FakeRoleManager.VisibleRoleCondition.Remove(SeeAsZombieCondition);
4549
}
4650

4751
public void SwapRole(RoleTypeId role)
@@ -51,4 +55,6 @@ public void SwapRole(RoleTypeId role)
5155
Player.FakeRoleManager.VisibleRole = role;
5256
Player.SendHint(_plugin.Translation.ChangedRole.Replace("%role%", role.ToString()));
5357
}
58+
59+
public bool SeeAsZombieCondition(SynapsePlayer player) => player.TeamID == 0;
5460
}

Scp056/Scp056Translation.cs

+4
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ public class Scp056Translation : Translations<Scp056Translation>
2121
public string Commands { get; set; } = "You can use these commands:";
2222

2323
public string NotScp056 { get; set; } = "You are not SCP-056";
24+
25+
public string ActivatedScpChat { get; set; } = "You are now Speaking to all SCP's";
26+
27+
public string DeactivatedScpChat { get; set; } = "You are now Speaking to Players in your proximity";
2428
}

Scp056/packages.config

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="HarmonyX" version="2.10.0" targetFramework="net48" />
4+
<package id="Lib.Harmony" version="2.2.2" targetFramework="net48" />
45
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net48" />
56
<package id="Microsoft.Extensions.Caching.Abstractions" version="6.0.0" targetFramework="net48" />
67
<package id="Microsoft.Extensions.Caching.Memory" version="6.0.1" targetFramework="net48" />
@@ -11,13 +12,13 @@
1112
<package id="Mono.Cecil" version="0.11.4" targetFramework="net48" />
1213
<package id="MonoMod.RuntimeDetour" version="22.3.23.4" targetFramework="net48" />
1314
<package id="MonoMod.Utils" version="22.3.23.4" targetFramework="net48" />
14-
<package id="NeuronModding.Core" version="1.0.0.5" targetFramework="net48" />
15-
<package id="NeuronModding.Modules.Commands" version="1.0.0.5" targetFramework="net48" />
16-
<package id="NeuronModding.Modules.Configs" version="1.0.0.5" targetFramework="net48" />
17-
<package id="NeuronModding.Modules.Patcher" version="1.0.0.5" targetFramework="net48" />
15+
<package id="NeuronModding.Core" version="1.0.2" targetFramework="net48" />
16+
<package id="NeuronModding.Modules.Commands" version="1.0.2" targetFramework="net48" />
17+
<package id="NeuronModding.Modules.Configs" version="1.0.2" targetFramework="net48" />
18+
<package id="NeuronModding.Modules.Patcher" version="1.0.2" targetFramework="net48" />
1819
<package id="Ninject" version="3.3.6" targetFramework="net48" />
1920
<package id="SYML" version="1.0.2" targetFramework="net48" />
20-
<package id="SynapseSL" version="3.0.0-pre1.1" targetFramework="net48" />
21+
<package id="SynapseSL" version="3.0.0-pre1.2" targetFramework="net48" />
2122
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
2223
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
2324
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />

0 commit comments

Comments
 (0)