Skip to content

Commit 245bcc9

Browse files
committed
Synapse 3 beta 1.2
1 parent c1cd425 commit 245bcc9

16 files changed

+140
-500
lines changed

AdvancedCustomRoles/AdvancedConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ namespace AdvancedCustomRoles;
66
public class AdvancedConfig : IDocumentSection
77
{
88
public List<string> CommandToExecuteAtSpawn = new();
9+
10+
public List<string> CommandToExecuteAtDeSpawn = new();
911
}

AdvancedCustomRoles/AdvancedCustomRoles.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ namespace AdvancedCustomRoles;
1010
Name = "AdvancedCustomRoles",
1111
Author = "Dimenzio",
1212
Description = "Allows to create new Role with just a few config files",
13-
Version = "1.0.0"
13+
Version = "3.0.0"
1414
)]
15+
[HeavyModded]
1516
public class AdvancedCustomRoles : ReloadablePlugin
1617
{
1718
public CustomRoleHandler RoleHandler { get; private set; }
@@ -21,12 +22,12 @@ public class AdvancedCustomRoles : ReloadablePlugin
2122

2223
public override void EnablePlugin()
2324
{
24-
RoleHandler = Synapse.GetAndBind<CustomRoleHandler>();
25+
RoleHandler = Synapse.GetOrCreate<CustomRoleHandler>();
2526
RoleHandler.Load();
2627

27-
PlayerHandler = Synapse.GetAndBind<PlayerHandler>();
28-
RoundHandler = Synapse.GetAndBind<RoundHandler>();
29-
ScpHandler = Synapse.GetAndBind<ScpHandler>();
28+
PlayerHandler = Synapse.GetOrCreate<PlayerHandler>();
29+
RoundHandler = Synapse.GetOrCreate<RoundHandler>();
30+
ScpHandler = Synapse.GetOrCreate<ScpHandler>();
3031

3132
Logger.Info("AdvancedCustomRoles Loaded");
3233
}

AdvancedCustomRoles/AdvancedCustomRoles.csproj

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>AdvancedCustomRoles</RootNamespace>
1111
<AssemblyName>AdvancedCustomRoles</AssemblyName>
12-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<Deterministic>true</Deterministic>
1515
<LangVersion>10</LangVersion>
@@ -36,11 +36,14 @@
3636
<PlatformTarget>x64</PlatformTarget>
3737
</PropertyGroup>
3838
<ItemGroup>
39-
<Reference Include="Assembly-CSharp">
40-
<HintPath>..\..\..\..\Synapse-synapse3\Synapse3.SynapseModule\bin\Debug\net472\Assembly-CSharp-Publicized.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>
42-
<Reference Include="Assembly-CSharp-firstpass">
43-
<HintPath>..\..\..\..\Synapse-synapse3\Synapse3.SynapseModule\bin\Debug\net472\Assembly-CSharp-firstpass.dll</HintPath>
42+
<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>
44+
</Reference>
45+
<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>
4447
</Reference>
4548
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
4649
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
@@ -63,24 +66,30 @@
6366
<Reference Include="Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
6467
<HintPath>..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
6568
</Reference>
69+
<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>
71+
</Reference>
6672
<Reference Include="mscorlib" />
67-
<Reference Include="Neuron.Core, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
68-
<HintPath>..\packages\NeuronModding.Core.1.0.0.5\lib\netstandard2.0\Neuron.Core.dll</HintPath>
73+
<Reference Include="Neuron.Core, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
74+
<HintPath>..\packages\NeuronModding.Core.1.0.2\lib\netstandard2.0\Neuron.Core.dll</HintPath>
75+
</Reference>
76+
<Reference Include="Neuron.Modules.Commands, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
77+
<HintPath>..\packages\NeuronModding.Modules.Commands.1.0.2\lib\netstandard2.0\Neuron.Modules.Commands.dll</HintPath>
6978
</Reference>
70-
<Reference Include="Neuron.Modules.Commands, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
71-
<HintPath>..\packages\NeuronModding.Modules.Commands.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Commands.dll</HintPath>
79+
<Reference Include="Neuron.Modules.Configs, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
80+
<HintPath>..\packages\NeuronModding.Modules.Configs.1.0.2\lib\netstandard2.0\Neuron.Modules.Configs.dll</HintPath>
7281
</Reference>
73-
<Reference Include="Neuron.Modules.Configs, Version=1.0.0.5, Culture=neutral, processorArchitecture=Amd64">
74-
<HintPath>..\packages\NeuronModding.Modules.Configs.1.0.0.5\lib\netstandard2.0\Neuron.Modules.Configs.dll</HintPath>
82+
<Reference Include="Neuron.Modules.Patcher, Version=1.0.2.0, Culture=neutral, processorArchitecture=Amd64">
83+
<HintPath>..\packages\NeuronModding.Modules.Patcher.1.0.2\lib\netstandard2.0\Neuron.Modules.Patcher.dll</HintPath>
7584
</Reference>
7685
<Reference Include="Ninject, Version=3.3.6.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
7786
<HintPath>..\packages\Ninject.3.3.6\lib\net45\Ninject.dll</HintPath>
7887
</Reference>
7988
<Reference Include="SYML, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
8089
<HintPath>..\packages\SYML.1.0.2\lib\netstandard2.0\SYML.dll</HintPath>
8190
</Reference>
82-
<Reference Include="Synapse3.SynapseModule">
83-
<HintPath>..\..\..\..\Synapse-synapse3\Synapse3.SynapseModule\bin\Debug\net472\Synapse3.SynapseModule.dll</HintPath>
91+
<Reference Include="Synapse3.SynapseModule, Version=3.0.0.0, Culture=neutral, processorArchitecture=Amd64">
92+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\Synapse3.SynapseModule.dll</HintPath>
8493
</Reference>
8594
<Reference Include="System" />
8695
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -108,8 +117,14 @@
108117
<Reference Include="System.Data" />
109118
<Reference Include="System.Net.Http" />
110119
<Reference Include="System.Xml" />
111-
<Reference Include="UnityEngine.CoreModule">
112-
<HintPath>..\..\..\..\Synapse-synapse3\Synapse3.SynapseModule\bin\Debug\net472\UnityEngine.CoreModule.dll</HintPath>
120+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
121+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.dll</HintPath>
122+
</Reference>
123+
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
124+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.CoreModule.dll</HintPath>
125+
</Reference>
126+
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
127+
<HintPath>..\packages\SynapseSL.3.0.0-pre1.1\lib\net48\UnityEngine.PhysicsModule.dll</HintPath>
113128
</Reference>
114129
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
115130
<HintPath>..\packages\YamlDotNet.11.2.1\lib\net45\YamlDotNet.dll</HintPath>
@@ -124,7 +139,6 @@
124139
<Compile Include="Handlers\PlayerHandler.cs" />
125140
<Compile Include="Handlers\RoundHandler.cs" />
126141
<Compile Include="Handlers\ScpHandler.cs" />
127-
<Compile Include="HumanConfig.cs" />
128142
<Compile Include="Properties\AssemblyInfo.cs" />
129143
<Compile Include="ScpConfig.cs" />
130144
</ItemGroup>
Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
using System.Collections.Generic;
2-
using Neuron.Core.Logging;
3-
using Synapse3.SynapseModule;
4-
using Synapse3.SynapseModule.Map;
52
using Synapse3.SynapseModule.Player;
63
using Synapse3.SynapseModule.Role;
74

@@ -11,13 +8,11 @@ public class AdvancedRoleScript : SynapseAbstractRole
118
public CustomRole RoleConfig;
129
private CustomInfoList.CustomInfoEntry _customInfo;
1310
private readonly CustomRoleHandler _roleHandler;
14-
private readonly MapService _map;
1511
private readonly PlayerService _player;
1612

17-
public AdvancedRoleScript(CustomRoleHandler roleHandler, MapService map, PlayerService player)
13+
public AdvancedRoleScript(CustomRoleHandler roleHandler, PlayerService player)
1814
{
1915
_roleHandler = roleHandler;
20-
_map = map;
2116
_player = player;
2217
}
2318

@@ -29,7 +24,9 @@ public override void Load()
2924
protected override IAbstractRoleConfig GetConfig() => RoleConfig;
3025
public override List<uint> GetEnemiesID() => RoleConfig.Enemies;
3126
public override List<uint> GetFriendsID() => RoleConfig.Friends;
32-
27+
28+
protected override bool CanSeeUnit(SynapsePlayer player) => RoleConfig.TeamsThatCanSeeUnit.Contains(player.TeamID);
29+
3330
protected override void OnSpawn(IAbstractRoleConfig _)
3431
{
3532
if (!string.IsNullOrWhiteSpace(RoleConfig.DisplayInfo))
@@ -39,17 +36,11 @@ protected override void OnSpawn(IAbstractRoleConfig _)
3936
Info = RoleConfig.DisplayInfo,
4037
EveryoneCanSee = true
4138
};
42-
Player.CustomInfo.Add(_customInfo);
39+
Player.CustomInfo.Insert(1,_customInfo);
4340
}
4441
if (RoleConfig.GodMode)
4542
Player.GodMode = true;
4643

47-
if (RoleConfig.Human != null)
48-
{
49-
Player.WalkSpeed = RoleConfig.Human.WalkSpeed;
50-
Player.SprintSpeed = RoleConfig.Human.SprintSpeed;
51-
}
52-
5344

5445
if (!string.IsNullOrWhiteSpace(RoleConfig.SpawnBroadcast))
5546
Player.SendBroadcast(RoleConfig.SpawnBroadcast.Replace("\\n", "\n"), RoleConfig.SpawnMessageTime);
@@ -59,15 +50,16 @@ protected override void OnSpawn(IAbstractRoleConfig _)
5950

6051
if (!string.IsNullOrWhiteSpace(RoleConfig.SpawnWindow))
6152
Player.SendWindowMessage(RoleConfig.SpawnWindow.Replace("\\n", "\n"));
62-
63-
NeuronLogger.For<Synapse>().Warn("Found Advanced");
53+
6454
if (RoleConfig.Advanced != null)
6555
{
66-
NeuronLogger.For<Synapse>().Warn("Found Advanced");
6756
foreach (var command in RoleConfig.Advanced.CommandToExecuteAtSpawn ?? new())
6857
{
69-
NeuronLogger.For<Synapse>().Warn("Executed Command " + command);
70-
_player.Host.ExecuteCommand(command.Replace("%player%", Player.PlayerId.ToString()));
58+
_player.Host.ExecuteCommand(command.Replace(new Dictionary<string, string>()
59+
{
60+
{ "%player%", Player.PlayerId.ToString() },
61+
{ "%playername%", Player.NickName }
62+
}));
7163
}
7264
}
7365
}
@@ -80,10 +72,16 @@ protected override void OnDeSpawn(DeSpawnReason reason)
8072
if (RoleConfig.GodMode)
8173
Player.GodMode = false;
8274

83-
if (RoleConfig.Human != null)
75+
if (RoleConfig.Advanced != null)
8476
{
85-
Player.WalkSpeed = _map.HumanWalkSpeed;
86-
Player.SprintSpeed = _map.HumanSprintSpeed;
77+
foreach (var command in RoleConfig.Advanced.CommandToExecuteAtDeSpawn ?? new())
78+
{
79+
_player.Host.ExecuteCommand(command.Replace(new Dictionary<string, string>()
80+
{
81+
{ "%player%", Player.PlayerId.ToString() },
82+
{ "%playername%", Player.NickName }
83+
}));
84+
}
8785
}
8886
}
8987
}

AdvancedCustomRoles/App.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
1010
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
1111
</dependentAssembly>
12+
<dependentAssembly>
13+
<assemblyIdentity name="Mono.Cecil" publicKeyToken="50cebf1cceb9d05e" culture="neutral" />
14+
<bindingRedirect oldVersion="0.0.0.0-0.11.4.0" newVersion="0.11.4.0" />
15+
</dependentAssembly>
16+
<dependentAssembly>
17+
<assemblyIdentity name="0Harmony" publicKeyToken="null" culture="neutral" />
18+
<bindingRedirect oldVersion="0.0.0.0-2.10.0.0" newVersion="2.10.0.0" />
19+
</dependentAssembly>
1220
</assemblyBinding>
1321
</runtime>
1422
</configuration>

AdvancedCustomRoles/CustomRole.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using PlayerRoles;
34
using Syml;
45
using Synapse3.SynapseModule.Config;
56
using Synapse3.SynapseModule.Map.Rooms;
@@ -17,27 +18,32 @@ public class CustomRole : IDocumentSection, IAbstractRoleConfig
1718
public List<uint> Enemies { get; set; } = new();
1819
public List<uint> Friends { get; set; } = new();
1920

20-
public RoleType Role { get; set; } = RoleType.ClassD;
21-
public RoleType VisibleRole { get; set; } = RoleType.None;
22-
public uint EscapeRole { get; set; } = 0;
21+
public RoleTypeId Role { get; set; } = RoleTypeId.ClassD;
22+
public RoleTypeId VisibleRole { get; set; } = RoleTypeId.None;
23+
public RoleTypeId OwnRole { get; set; } = RoleTypeId.None;
24+
public uint EscapeRole { get; set; } = uint.MaxValue;
2325
public float Health { get; set; } = 100;
2426
public float MaxHealth { get; set; } = 100;
2527
public float ArtificialHealth { get; set; } = 0;
2628
public float MaxArtificialHealth { get; set; } = 75;
2729
public RoomPoint[] PossibleSpawns { get; set; }
2830
public SerializedPlayerInventory[] PossibleInventories { get; set; }
29-
public byte UnitId { get; set; } = 0;
30-
public string Unit { get; set; } = "";
31-
public SerializedVector3 Scale { get; set; } = new(1f, 1.25f, 1f);
31+
public bool CustomDisplay { get; set; } = true;
32+
public bool Hierarchy { get; set; } = false;
33+
public bool UseCustomUnitName { get; set; } = false;
34+
public string CustomUnitName { get; set; } = "";
35+
public List<uint> TeamsThatCanSeeUnit { get; set; } = new List<uint>();
36+
public SerializedVector3 Scale { get; set; } = new(1f, 1f, 1f);
3237
public bool GodMode { get; set; } = false;
3338
public string DisplayInfo { get; set; } = "";
34-
3539
public ushort SpawnMessageTime { get; set; } = 5;
3640
public string SpawnBroadcast { get; set; } = "";
3741
public string SpawnHint { get; set; } = "";
3842
public string SpawnWindow { get; set; } = "";
3943

40-
public Dictionary<uint, float> RoundStartReplace { get; set; } = new();
44+
public float SetPlayerAtRoundStartChance { get; set; } = 1;
45+
46+
public bool SpawnOneScpLessOnSpawn { get; set; } = false;
4147

4248
public Dictionary<uint, float> RespawnReplace { get; set; } = new();
4349

@@ -46,9 +52,7 @@ public class CustomRole : IDocumentSection, IAbstractRoleConfig
4652
public int MaxRespawnAmount { get; set; } = -1;
4753

4854
public int MaxAmount { get; set; } = -1;
49-
50-
[YamlIgnore] public HumanConfig Human { get; set; }
51-
55+
5256
[YamlIgnore] public ScpConfig Scp { get; set; }
5357

5458
[YamlIgnore] public AdvancedConfig Advanced { get; set; }

AdvancedCustomRoles/CustomRoleHandler.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using Neuron.Core;
77
using Neuron.Core.Meta;
8+
using PlayerRoles;
89
using Syml;
910
using Synapse3.SynapseModule.Config;
1011
using Synapse3.SynapseModule.Map.Rooms;
@@ -54,7 +55,6 @@ public void Load()
5455
}
5556

5657
CustomRole role = null;
57-
HumanConfig human = null;
5858
ScpConfig scp = null;
5959
AdvancedConfig advanced = null;
6060
foreach (var documentSection in syml.Sections)
@@ -71,11 +71,7 @@ public void Load()
7171
role = null;
7272
}
7373
break;
74-
75-
case "human" when human == null:
76-
human = documentSection.Value.Export<HumanConfig>();
77-
break;
78-
74+
7975
case "scp" when scp == null:
8076
scp = documentSection.Value.Export<ScpConfig>();
8177
break;
@@ -86,7 +82,6 @@ public void Load()
8682
}
8783
}
8884
if (role == null) continue;
89-
role.Human = human;
9085
role.Scp = scp;
9186
role.Advanced = advanced;
9287

@@ -116,22 +111,17 @@ public void CreateExampleFile()
116111
MaxHealth = 150,
117112
RoleId = 101,
118113
TeamId = 2,
119-
RoundStartReplace = new()
120-
{
121-
{ (uint)RoleType.ClassD, 100 }
122-
},
114+
SetPlayerAtRoundStartChance = 100,
123115
RespawnReplace = new()
124116
{
125-
{ (uint)RoleType.NtfCaptain, 100 }
117+
{ (uint)RoleTypeId.NtfCaptain, 100 }
126118
},
127119
Health = 100,
128-
Role = RoleType.ClassD,
129-
VisibleRole = RoleType.None,
130-
Unit = "",
131-
UnitId = 0,
120+
Role = RoleTypeId.ClassD,
121+
VisibleRole = RoleTypeId.None,
132122
ArtificialHealth = 0,
133123
MaxArtificialHealth = 75,
134-
EscapeRole = 0,
124+
EscapeRole = uint.MaxValue,
135125
PossibleInventories = new[]
136126
{
137127
new SerializedPlayerInventory()
@@ -162,11 +152,6 @@ public void CreateExampleFile()
162152
MaxSpawnAmount = 10,
163153
SpawnHint = "Hello"
164154
});
165-
syml.Set("Human", new HumanConfig()
166-
{
167-
SprintSpeed = 2,
168-
WalkSpeed = 2
169-
});
170155
syml.Set("Scp",new ScpConfig()
171156
{
172157
ScpAttackDamage = 200
@@ -176,6 +161,10 @@ public void CreateExampleFile()
176161
CommandToExecuteAtSpawn = new List<string>()
177162
{
178163
"pbc %player% 5 Hello"
164+
},
165+
CommandToExecuteAtDeSpawn = new List<string>()
166+
{
167+
"pbc %player% %playername% you are now dead"
179168
}
180169
});
181170
var file = _neuronBase.RelativePath("CustomRoles", "ExampleRole.syml");

0 commit comments

Comments
 (0)