Skip to content

Commit da63db3

Browse files
committed
Update to Synapse 2.5.3 and added Translation
1 parent 92d0e65 commit da63db3

6 files changed

+99
-78
lines changed

Scp035/EventHandlers.cs

+39-42
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,52 @@ public EventHandlers()
2020

2121
private void Death(Synapse.Api.Events.SynapseEventArguments.PlayerDeathEventArgs ev)
2222
{
23-
if (ev.Victim.RoleID == 35)
24-
Map.Get.AnnounceScpDeath("0 3 5");
25-
2623
if (ev.Victim != ev.Killer && ev.Killer?.RoleID == 35)
27-
ev.Victim.OpenReportWindow(PluginClass.GetTranslation("killedby035"));
24+
ev.Victim.OpenReportWindow(PluginClass.Translation.ActiveTranslation.KilledBy035);
2825
}
2926

3027
private void Use(Synapse.Api.Events.SynapseEventArguments.PlayerItemInteractEventArgs ev)
3128
{
3229
if (IsScp035Item(ev.CurrentItem))
3330
{
3431
ev.Allow = false;
35-
ev.Player.GiveTextHint(PluginClass.GetTranslation("035interact"));
32+
ev.Player.GiveTextHint(PluginClass.Translation.ActiveTranslation.InteractWith035);
33+
}
34+
}
35+
36+
private bool IsScp035Item(SynapseItem item) => item != null && item.Name.Contains("Scp035-Item-");
37+
38+
private void Pickup(Synapse.Api.Events.SynapseEventArguments.PlayerPickUpItemEventArgs ev)
39+
{
40+
if (IsScp035Item(ev.Item))
41+
{
42+
if(!SynapseExtensions.CanHarmScp(ev.Player) || ev.Player.RoleID == (int)RoleType.Tutorial)
43+
ev.Player.SendBroadcast(8, PluginClass.Translation.ActiveTranslation.ScpPickup035);
44+
else
45+
{
46+
ev.Allow = false;
47+
48+
var players = Server.Get.GetPlayers(x => x.RoleID == (int)RoleType.Spectator && !x.OverWatch);
49+
50+
if(players.Count == 0)
51+
{
52+
ev.Player.SendBroadcast(8, PluginClass.Translation.ActiveTranslation.Survived035);
53+
RemoveScp035Items(true);
54+
return;
55+
}
56+
57+
players = players.OrderBy(x => x.DeathTime).ToList();
58+
59+
Player player;
60+
61+
if (PluginClass.Config.DeathTime)
62+
player = players.FirstOrDefault();
63+
else
64+
player = players.ElementAt(UnityEngine.Random.Range(0, players.Count));
65+
66+
player.CustomRole = new Scp035PlayerScript(ev.Player);
67+
RemoveScp035Items(true);
68+
}
3669
}
3770
}
3871

@@ -44,16 +77,14 @@ private void Use(Synapse.Api.Events.SynapseEventArguments.PlayerItemInteractEven
4477

4578
private IEnumerator<float> Respawn035Items()
4679
{
47-
for(; ; )
80+
for (; ; )
4881
{
4982
if (!Server.Get.Players.Any(x => x.RoleID == 35))
5083
Spawn035Item();
5184
yield return Timing.WaitForSeconds(PluginClass.Config.PickupSpawnInterval);
5285
}
5386
}
5487

55-
private bool IsScp035Item(SynapseItem item) => item.Name.Contains("Scp035-Item-");
56-
5788
public void Spawn035Item()
5889
{
5990
RemoveScp035Items();
@@ -83,39 +114,5 @@ private void RemoveScp035Items(bool clearinventory = false)
83114
foreach (var item in Map.Get.Items.Where(x => IsScp035Item(x) && x.State == Synapse.Api.Enum.ItemState.Map).ToArray())
84115
item.Destroy();
85116
}
86-
87-
private void Pickup(Synapse.Api.Events.SynapseEventArguments.PlayerPickUpItemEventArgs ev)
88-
{
89-
if (IsScp035Item(ev.Item))
90-
{
91-
if(ev.Player.RealTeam == Team.SCP || ev.Player.RoleID == (int)RoleType.Tutorial)
92-
ev.Player.SendBroadcast(8, PluginClass.GetTranslation("035pickup"));
93-
else
94-
{
95-
ev.Allow = false;
96-
97-
var players = Server.Get.GetPlayers(x => x.RoleID == (int)RoleType.Spectator && !x.OverWatch);
98-
99-
if(players.Count == 0)
100-
{
101-
ev.Player.SendBroadcast(8, PluginClass.GetTranslation("survived035"));
102-
RemoveScp035Items(true);
103-
return;
104-
}
105-
106-
players = players.OrderBy(x => x.DeathTime).ToList();
107-
108-
Player player;
109-
110-
if (PluginClass.Config.DeathTime)
111-
player = players.FirstOrDefault();
112-
else
113-
player = players.ElementAt(UnityEngine.Random.Range(0, players.Count));
114-
115-
player.CustomRole = new Scp035PlayerScript(ev.Player);
116-
RemoveScp035Items(true);
117-
}
118-
}
119-
}
120117
}
121118
}

Scp035/PluginClass.cs

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Synapse;
22
using Synapse.Api.Plugin;
33
using System.Collections.Generic;
4+
using Synapse.Translation;
45

56
namespace Scp035
67
{
@@ -9,18 +10,19 @@ namespace Scp035
910
Author = "Dimenzio",
1011
Description = "Adds the Role Scp035 to the Game",
1112
LoadPriority = 1,
12-
SynapseMajor = SynapseController.SynapseMajor,
13-
SynapseMinor = SynapseController.SynapseMinor,
14-
SynapsePatch = SynapseController.SynapsePatch,
15-
Version = "v.1.0.2"
13+
SynapseMajor = 2,
14+
SynapseMinor = 5,
15+
SynapsePatch = 3,
16+
Version = "v.1.1.0"
1617
)]
1718
public class PluginClass : AbstractPlugin
1819
{
19-
private static Translation trans;
20-
2120
[Synapse.Api.Plugin.Config(section = "Scp035")]
2221
public static Config Config;
2322

23+
[SynapseTranslation]
24+
public static new SynapseTranslation<PluginTranslation> Translation { get; set; }
25+
2426
public override void Load()
2527
{
2628
Server.Get.RoleManager.RegisterCustomRole<Scp035PlayerScript>();
@@ -36,21 +38,18 @@ public override void Load()
3638
});
3739
}
3840

39-
var translation = new Dictionary<string, string>
41+
Translation.AddTranslation(new PluginTranslation());
42+
Translation.AddTranslation(new PluginTranslation
4043
{
41-
{"035pickup","This Item is an Scp035 Item, so if you drop it and a other Player takes it, Scp035 will take the player as his host" },
42-
{"survived035" , "This was Scp035 but you have survived it" },
43-
{"035interact","You can't use a Scp-035 Item for any interaction with it!" },
44-
{"pickup035","<b>You have picked up <color=red>Scp-035</color>.</b>" },
45-
{"spawn035","<b>You are <color=red>SCP-035</color></b>" },
46-
{"killedby035","<b>You was killed by <color=red>SCP</color>-035</b>" }
47-
};
48-
Translation.CreateTranslations(translation);
49-
trans = Translation;
44+
ScpPickup035 = "Du hast <color=red>SCP-035</color> aufgeboben. Gib es einem anderem Spieler damit er zu <color=red>SCP-035</color> wird",
45+
Survived035 = "Das war <color=red>SCP-035</color> aber du hast es überlebt",
46+
InteractWith035 = "Du kannst nicht mit einem <color=red>SCP-035</color> Item interagieren",
47+
Pickup035 = "<b>Du hast <color=red>SCP-035</color> aufgehoben</b>",
48+
Spawn035 = "<b>Du bist jetzt <color=red>SCP-035</color></b",
49+
KilledBy035 = "<b>Du wurdest von <color=red>SCP-035</color> umgebracht</b>"
50+
}, "GERMAN");
5051

5152
new EventHandlers();
5253
}
53-
54-
public static string GetTranslation(string key) => trans.GetTranslation(key);
5554
}
5655
}

Scp035/PluginTranslation.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Synapse.Translation;
2+
3+
namespace Scp035
4+
{
5+
public class PluginTranslation : IPluginTranslation
6+
{
7+
public string ScpPickup035 { get; set; } = "This Item is an Scp035 Item, so if you drop it and a other Player takes it, Scp035 will take the player as his host";
8+
9+
public string Survived035 { get; set; } = "This was Scp035 but you have survived it";
10+
11+
public string InteractWith035 { get; set; } = "You can't use a Scp-035 Item for any interaction with it!";
12+
13+
public string Pickup035 { get; set; } = "<b>You have picked up <color=red>Scp-035</color>.</b>";
14+
15+
public string Spawn035 { get; set; } = "<b>You are <color=red>SCP-035</color></b>";
16+
17+
public string KilledBy035 { get; set; } = "<b>You was killed by <color=red>SCP</color>-035</b>";
18+
}
19+
}

Scp035/Scp035.csproj

+12-8
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,40 @@
3535
<HintPath>..\packages\Lib.Harmony.2.0.4\lib\net472\0Harmony.dll</HintPath>
3636
</Reference>
3737
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
38-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp.dll</HintPath>
38+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\Assembly-CSharp.dll</HintPath>
3939
</Reference>
4040
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
41+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
4242
</Reference>
4343
<Reference Include="LiteDB, Version=5.0.9.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
4444
<HintPath>..\packages\LiteDB.5.0.9\lib\net45\LiteDB.dll</HintPath>
4545
</Reference>
4646
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
47-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Mirror.dll</HintPath>
47+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\Mirror.dll</HintPath>
4848
</Reference>
49-
<Reference Include="Synapse, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
50-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Synapse.dll</HintPath>
49+
<Reference Include="Synapse, Version=2.5.3.0, Culture=neutral, processorArchitecture=MSIL">
50+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\Synapse.dll</HintPath>
5151
</Reference>
5252
<Reference Include="System" />
5353
<Reference Include="System.Core" />
5454
<Reference Include="System.Runtime" />
55+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
56+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
57+
</Reference>
5558
<Reference Include="System.Xml.Linq" />
5659
<Reference Include="System.Data.DataSetExtensions" />
5760
<Reference Include="Microsoft.CSharp" />
5861
<Reference Include="System.Data" />
5962
<Reference Include="System.Net.Http" />
6063
<Reference Include="System.Xml" />
6164
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
62-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.dll</HintPath>
65+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\UnityEngine.dll</HintPath>
6366
</Reference>
6467
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
65-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.CoreModule.dll</HintPath>
68+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\UnityEngine.CoreModule.dll</HintPath>
6669
</Reference>
6770
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
68-
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
71+
<HintPath>..\packages\SynapseSL.2.5.3\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
6972
</Reference>
7073
<Reference Include="YamlDotNet, Version=8.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
7174
<HintPath>..\packages\YamlDotNet.8.1.2\lib\net45\YamlDotNet.dll</HintPath>
@@ -74,6 +77,7 @@
7477
<ItemGroup>
7578
<Compile Include="EventHandlers.cs" />
7679
<Compile Include="Config.cs" />
80+
<Compile Include="PluginTranslation.cs" />
7781
<Compile Include="Scp035PlayerScript.cs" />
7882
<Compile Include="PluginClass.cs" />
7983
<Compile Include="Properties\AssemblyInfo.cs" />

Scp035/Scp035PlayerScript.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Scp035
66
{
77
public class Scp035PlayerScript : Synapse.Api.Roles.Role
88
{
9-
private Player _target;
9+
private readonly Player _target;
1010

1111
public Scp035PlayerScript() { }
1212
public Scp035PlayerScript(Player target) => _target = target;
@@ -15,12 +15,9 @@ public Scp035PlayerScript() { }
1515

1616
public override string GetRoleName() => "Scp035";
1717

18-
public override List<Team> GetFriends()
19-
{
20-
return PluginClass.Config.ff ? new List<Team>() : new List<Team> { Team.SCP };
21-
}
18+
public override List<int> GetFriendsID() => PluginClass.Config.ff ? new List<int>() : new List<int> { (int)Team.SCP };
2219

23-
public override Team GetTeam() => Team.SCP;
20+
public override int GetTeamID() => (int)Team.SCP;
2421

2522
public override void Spawn()
2623
{
@@ -44,16 +41,20 @@ public override void Spawn()
4441

4542
_target.RoleID = (int)RoleType.Spectator;
4643

47-
_target.SendBroadcast(5, PluginClass.GetTranslation("pickup035"));
44+
_target.SendBroadcast(5, PluginClass.Translation.ActiveTranslation.Pickup035);
4845
}
4946

5047
Player.Health = PluginClass.Config.Scp035Health;
5148
Player.MaxHealth = PluginClass.Config.Scp035Health;
5249
Player.DisplayInfo = $"<color={PluginClass.Config.DisplayColor}>{PluginClass.Config.DisplayName}</color>";
5350

54-
Player.SendBroadcast(5, PluginClass.GetTranslation("spawn035"));
51+
Player.SendBroadcast(5, PluginClass.Translation.ActiveTranslation.Spawn035);
5552
}
5653

57-
public override void DeSpawn() => Player.DisplayInfo = "";
54+
public override void DeSpawn()
55+
{
56+
Player.DisplayInfo = "";
57+
Map.Get.AnnounceScpDeath("0 3 5");
58+
}
5859
}
5960
}

Scp035/packages.config

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<packages>
33
<package id="Lib.Harmony" version="2.0.4" targetFramework="net472" />
44
<package id="LiteDB" version="5.0.9" targetFramework="net472" />
5-
<package id="SynapseSL" version="2.3.0" targetFramework="net472" />
5+
<package id="SynapseSL" version="2.5.3" targetFramework="net472" />
6+
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
67
<package id="YamlDotNet" version="8.1.2" targetFramework="net472" />
78
</packages>

0 commit comments

Comments
 (0)