Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 3e5e940

Browse files
committed
a lot of smaller fixes
1 parent 934e472 commit 3e5e940

24 files changed

+95
-64
lines changed

Synapse3.SynapseModule/Config/SerializedObjects.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public SerializedItem(uint id, float durability, uint weaponAttachment, Vector3
5050
FireArm =
5151
{
5252
Attachments = WeaponAttachments
53-
}
53+
},
54+
Scale = new Vector3(XSize, YSize, ZSize)
5455
};
5556

5657
public static explicit operator SynapseItem(SerializedItem item) => item.Parse();

Synapse3.SynapseModule/DebugService.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
using Synapse3.SynapseModule.Events;
55
using Synapse3.SynapseModule.Teams;
66
using System;
7+
using System.Linq;
78
using Synapse3.SynapseModule.Enums;
9+
using Synapse3.SynapseModule.Map;
10+
using Synapse3.SynapseModule.Player;
811
using UnityEngine;
912

1013

@@ -52,7 +55,11 @@ public override void Enable()
5255
reactor.Value.SubscribeUnsafe(this, method);
5356
}
5457
_player.KeyPress.Subscribe(OnKeyPress);
55-
_player.Pickup.Subscribe(ev => ev.Allow = false);
58+
_item.ConsumeItem.Subscribe(ev =>
59+
{
60+
if (ev.State == ItemInteractState.Finalize)
61+
ev.Allow = false;
62+
});
5663
}
5764

5865
public void Event(IEvent ev)
@@ -65,12 +72,11 @@ private void OnKeyPress(KeyPressEvent ev)
6572
switch (ev.KeyCode)
6673
{
6774
case KeyCode.Alpha1:
68-
ev.Player.Invisible += 1;
69-
if (ev.Player.Invisible > InvisibleMode.Full) ev.Player.Invisible = InvisibleMode.None;
75+
Synapse.Get<NukeService>().StartDetonation();
7076
break;
7177

7278
case KeyCode.Alpha2:
73-
ev.Player.MaxHealth = 98;
79+
Synapse.Get<NukeService>().InstantDetonation();
7480

7581
break;
7682
case KeyCode.Alpha3:

Synapse3.SynapseModule/Enums/DoorType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public enum DoorType
1111
Scp096,
1212
Scp106Primary,
1313
Scp106Secondary,
14-
Scp106Bottom,
1514
Scp173Armory,
1615
Scp173Connector,
1716
Scp173Gate,

Synapse3.SynapseModule/Events/RoundEvents.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class FirstSpawnEvent : IEvent
119119
public Team[] HumanQueue { get; set; }
120120
public bool EnableLateJoin { get; set; } = true;
121121
public bool EnableNormalSpawning { get; set; } = true;
122-
public bool CustomSpawning { get; set; } = false;
122+
public List<SynapsePlayer> PlayersBlockedFromSpawning { get; set; } = new();
123123
}
124124

125125
public class DecontaminationEvent : IEvent

Synapse3.SynapseModule/Item/SynapseItemAPI.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public partial class SynapseItem
1919
{
2020
public void EquipItem(SynapsePlayer player, bool dropWhenFull = true, bool provideFully = false)
2121
{
22-
if(player.RoleType is RoleTypeId.Spectator or RoleTypeId.None) return;
23-
2422
if (player.Inventory.Items.Count >= 8)
2523
{
2624
if (dropWhenFull)
@@ -96,7 +94,7 @@ public void Drop(Vector3 position)
9694

9795
if(!InventoryItemLoader.AvailableItems.TryGetValue(ItemType, out var exampleBase)) return;
9896

99-
if (owner is not null)
97+
if (owner != null)
10098
{
10199
rot = owner.CameraReference.rotation * exampleBase.PickupDropModel.transform.rotation;
102100
}

Synapse3.SynapseModule/Map/MapService.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ public DoorType GetDoorByName(string doorName)
202202

203203
{ "106_PRIMARY", DoorType.Scp106Primary },
204204
{ "106_SECONDARY", DoorType.Scp106Secondary },
205-
{ "106_BOTTOM", DoorType.Scp106Bottom },
206-
205+
207206
{ "Unsecured Pryable GateDoor", DoorType.Scp049Gate },
208207
{ "049_ARMORY", DoorType.Scp049Armory },
209208

Synapse3.SynapseModule/Map/NukeService.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,17 @@ public NukeState State
6262
WarheadController.CooldownEndTime <= NetworkTime.time && !WarheadController.IsLocked;
6363

6464
public void StartDetonation()
65-
=> WarheadController.StartDetonation();
65+
{
66+
WarheadController.InstantPrepare();
67+
WarheadController.StartDetonation();
68+
}
6669

6770
public void CancelDetonation()
6871
=> WarheadController.CancelDetonation();
6972

7073
public void Shake() => WarheadController.RpcShake(true);
71-
72-
public void InstantDetonation()
73-
{
74-
WarheadController.InstantPrepare();
75-
WarheadController.StartDetonation(false, true);
76-
}
74+
75+
public void InstantDetonation() => WarheadController.ForceTime(0f);
7776

7877
public class NukeInsidePanel
7978
{

Synapse3.SynapseModule/Patching/Patches/EventPlayerPatches.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ public static bool LockerInteract(Locker __instance, ReferenceHub ply, byte coll
751751
{
752752
if (colliderId >= __instance.Chambers.Length || !__instance.Chambers[colliderId].CanInteract) return false;
753753
var player = ply.GetSynapsePlayer();
754-
var hasPerms = __instance.Chambers[colliderId].RequiredPermissions.CheckPermission(player);
754+
var hasPerms = __instance.Chambers[colliderId].RequiredPermissions.CheckPermission(player, true);
755755
var locker = __instance.GetSynapseLocker();
756756
var ev = new LockerUseEvent(player, hasPerms, locker, locker.Chambers[colliderId])
757757
{

Synapse3.SynapseModule/Patching/Patches/EventRoundPatches.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static bool RoundSummaryOverride(RoundSummary __instance, ref IEnumerator
5050
[SynapsePatch("FirstSpawn", PatchType.RoundEvent)]
5151
public static class FirstSpawnPatch
5252
{
53+
internal static List<SynapsePlayer> _blockedPlayer = new();
5354
private static readonly RoundEvents _round;
5455
static FirstSpawnPatch() => _round = Synapse.Get<RoundEvents>();
5556

@@ -98,10 +99,11 @@ public static bool OnRoundStarted()
9899
HumanQueue = RoleAssigner._humanQueue
99100
};
100101
_round.FirstSpawn.RaiseSafely(ev);
102+
_blockedPlayer = ev.PlayersBlockedFromSpawning;
101103
if (ev.EnableLateJoin)
102104
{
103105
RoleAssigner._spawned = true;
104-
RoleAssigner.LateJoinTimer.Reset();
106+
RoleAssigner.LateJoinTimer.Restart();
105107
}
106108

107109
if (!ev.EnableNormalSpawning) return false;
@@ -112,7 +114,7 @@ public static bool OnRoundStarted()
112114
{
113115
RoleAssigner.AlreadySpawnedPlayers.Add(hub.characterClassManager.UserId);
114116
}
115-
117+
_blockedPlayer.Clear();
116118
return false;
117119
}
118120
catch (Exception ex)
@@ -121,6 +123,14 @@ public static bool OnRoundStarted()
121123
return true;
122124
}
123125
}
126+
127+
[HarmonyPostfix]
128+
[HarmonyPatch(typeof(RoleAssigner), nameof(RoleAssigner.CheckPlayer))]
129+
public static void CheckPlayer(ref bool __result, ReferenceHub hub)
130+
{
131+
if (_blockedPlayer.Any(x => x.Hub == hub))
132+
__result = false;
133+
}
124134
}
125135

126136
[Automatic]

Synapse3.SynapseModule/Patching/Patches/RemoteAdminListPatches.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ private static string GenerateList(List<RemoteAdminPlayer> players, CommandSende
175175
var colors = ServerService.Colors;
176176
color = colors.ElementAt(Random.Range(0, colors.Count)).Value;
177177
}
178-
color = ServerService.GetColorHexCode(color);
178+
else
179+
{
180+
color = ServerService.GetColorHexCode(color);
181+
}
179182

180-
text += "<align=center><size=0>(" + group.GroupId + ")</size> <size=20><color=" + color + ">[" +
183+
text += "<align=center><size=0>(-" + group.GroupId + ")</size> <size=20><color=" + color + ">[" +
181184
group.Name +
182185
"]</color></size>\n</align>";
183186

Synapse3.SynapseModule/Permissions/PermissionService.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Synapse3.SynapseModule.Permissions;
1111

1212
public class PermissionService : Service
1313
{
14-
private uint _currentGroupId = 500;
1514
private ConfigService _configService;
1615
private ServerEvents _server;
1716
public ConfigContainer Container { get; private set; }
@@ -123,10 +122,10 @@ private void LoadGroups()
123122
}
124123

125124

126-
_currentGroupId = 500;
125+
var id = 1u;
127126
foreach (var group in Groups)
128127
{
129-
group.Value.GroupId = _currentGroupId++;
128+
group.Value.GroupId = id++;
130129
}
131130

132131

Synapse3.SynapseModule/Permissions/RemoteAdmin/GodModeCategory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
99
Name = "[ GodMode]",
1010
Color = "#03f8fc",
1111
Size = 20,
12-
Id = 10003
12+
Id = 103
1313
)]
1414
public class GodModeCategory : RemoteAdminCategory
1515
{

Synapse3.SynapseModule/Permissions/RemoteAdmin/InvisibleCategory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
99
Name = "[ Invisible]",
1010
Color = "#03f8fc",
1111
Size = 20,
12-
Id = 10002
12+
Id = 102
1313
)]
1414
public class InvisibleCategory : RemoteAdminCategory
1515
{

Synapse3.SynapseModule/Permissions/RemoteAdmin/NoClipCategory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
99
Name = "[ NoClip]",
1010
Color = "#03f8fc",
1111
Size = 20,
12-
Id = 10004
12+
Id = 104
1313
)]
1414
public class NoClipCategory : RemoteAdminCategory
1515
{

Synapse3.SynapseModule/Permissions/RemoteAdmin/OverWatchCategory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
99
Name = "[ OverWatch]",
1010
Color = "#03f8fc",
1111
Size = 20,
12-
Id = 10001
12+
Id = 101
1313
)]
1414
public class OverWatchCategory : RemoteAdminCategory
1515
{

Synapse3.SynapseModule/Permissions/RemoteAdmin/RaCategoryAttribute.cs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public RaCategoryAttribute(string name, uint id, Type categoryType)
2020

2121
public int Size { get; set; } = 20;
2222

23+
public string RemoteAdminIdentifier { get; set; }
24+
2325
public uint Id { get; set; }
2426

2527
public Type CategoryType { get; internal set; }

Synapse3.SynapseModule/Permissions/RemoteAdmin/SynapseCategory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
88
[RaCategory(
99
Name = "[ Synapse 3]",
1010
Color = "blue",
11-
Id = 10000
11+
Id = 100
1212
)]
1313
public class SynapseCategory : RemoteAdminCategory
1414
{

Synapse3.SynapseModule/Player/FakeRoleManager.cs

+27-15
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ internal FakeRoleManager(SynapsePlayer player, MirrorService mirror, PlayerServi
3030

3131
public void Reset()
3232
{
33-
_ownVisibleRole = new RoleInfo(RoleTypeId.None, null, null);
34-
_visibleRole = new RoleInfo(RoleTypeId.None, null, null);
33+
_ownVisibleRoleInfo = new RoleInfo(RoleTypeId.None, null, null);
34+
_visibleRoleInfo = new RoleInfo(RoleTypeId.None, null, null);
3535
ToPlayerVisibleRole.Clear();
3636
VisibleRoleCondition.Clear();
3737
UpdateAll();
@@ -48,24 +48,36 @@ public void UpdateAll()
4848
public void UpdatePlayer(SynapsePlayer player)
4949
=> player.SendNetworkMessage(new RoleSyncInfo(_player, RoleTypeId.None, player));
5050

51-
private RoleInfo _ownVisibleRole = new(RoleTypeId.None, null, null);
52-
public RoleInfo OwnVisibleRole
51+
public RoleTypeId OwnVisibleRole
5352
{
54-
get => _ownVisibleRole;
53+
get => OwnVisibleRoleInfo.RoleTypeId;
54+
set => OwnVisibleRoleInfo = new RoleInfo(value, _player);
55+
}
56+
57+
private RoleInfo _ownVisibleRoleInfo = new(RoleTypeId.None, null, null);
58+
public RoleInfo OwnVisibleRoleInfo
59+
{
60+
get => _ownVisibleRoleInfo;
5561
set
5662
{
57-
_ownVisibleRole = value;
63+
_ownVisibleRoleInfo = value;
5864
UpdatePlayer(_player);
5965
}
6066
}
67+
68+
public RoleTypeId VisibleRole
69+
{
70+
get => VisibleRoleInfo.RoleTypeId;
71+
set => VisibleRoleInfo = new RoleInfo(value, _player);
72+
}
6173

62-
private RoleInfo _visibleRole = new(RoleTypeId.None, null, null);
63-
public RoleInfo VisibleRole
74+
private RoleInfo _visibleRoleInfo = new(RoleTypeId.None, null, null);
75+
public RoleInfo VisibleRoleInfo
6476
{
65-
get => _visibleRole;
77+
get => _visibleRoleInfo;
6678
set
6779
{
68-
_visibleRole = value;
80+
_visibleRoleInfo = value;
6981
foreach (var player in _playerService.Players)
7082
{
7183
if (player != _player)
@@ -93,9 +105,9 @@ public void WriteRoleSyncInfoFor(SynapsePlayer receiver, NetworkWriter writer)
93105

94106
public RoleInfo GetRoleInfo(SynapsePlayer receiver)
95107
{
96-
if (receiver == _player && OwnVisibleRole.RoleTypeId != RoleTypeId.None)
108+
if (receiver == _player && OwnVisibleRoleInfo.RoleTypeId != RoleTypeId.None)
97109
{
98-
return OwnVisibleRole;
110+
return OwnVisibleRoleInfo;
99111
}
100112

101113
if (ToPlayerVisibleRole.ContainsKey(receiver))
@@ -109,9 +121,9 @@ public RoleInfo GetRoleInfo(SynapsePlayer receiver)
109121
return condition.Value;
110122
}
111123

112-
if (VisibleRole.RoleTypeId != RoleTypeId.None)
124+
if (VisibleRoleInfo.RoleTypeId != RoleTypeId.None)
113125
{
114-
return VisibleRole;
126+
return VisibleRoleInfo;
115127
}
116128

117129
var publicWriter = _player.CurrentRole as IPublicSpawnDataWriter;
@@ -190,7 +202,7 @@ public RoleInfo(RoleTypeId role, SynapsePlayer player)
190202

191203
default:
192204
if (typeof(HumanRole).IsAssignableFrom(FakeRoleManager.EnumToType[role]))
193-
PrepareHumanRole(role, 0, player);
205+
PrepareHumanRole(role, player.UnitNameId, player);
194206
else if (typeof(FpcStandardRoleBase).IsAssignableFrom(FakeRoleManager.EnumToType[role]))
195207
PrepareFpcRole(player);
196208
break;

Synapse3.SynapseModule/Player/PlayerService.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ public bool TryGetPlayers(string arg, out HashSet<SynapsePlayer> players, Synaps
291291
{
292292
if (int.TryParse(parameter, out var id))
293293
{
294+
id *= -1;
295+
Logger.Warn(id);
294296
//Check For SynapseGroupID
295297
foreach (var player in GetPlayers(id, playerTypes))
296298
{
@@ -330,11 +332,7 @@ private void Join(JoinEvent ev)
330332
}
331333

332334
private void RoundRestart(RoundRestartEvent _)
333-
{
334-
JoinUpdates.Clear();
335-
RecyclablePlayerId._autoIncrement = 0;
336-
RecyclablePlayerId.FreeIds.Clear();
337-
}
335+
=> JoinUpdates.Clear();
338336

339337
private void ChangeClass(SetClassEvent ev)
340338
{

Synapse3.SynapseModule/Player/SynapsePlayerCommonProperties.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public bool NoClipPermitted
9292
/// </summary>
9393
public bool OverWatch
9494
{
95-
get => ServerRoles.IsInOverwatch;
96-
set => ServerRoles.IsInOverwatch = value;
95+
get => CurrentRole is OverwatchRole;
96+
set => SetRoleFlags(value ? RoleTypeId.Overwatch : RoleTypeId.Spectator, RoleSpawnFlags.All,
97+
RoleChangeReason.RemoteAdmin);
9798
}
9899

99100
/// <summary>

0 commit comments

Comments
 (0)