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

Commit

Permalink
a lot of smaller fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrafDimenzio committed Feb 26, 2023
1 parent 934e472 commit 3e5e940
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 64 deletions.
3 changes: 2 additions & 1 deletion Synapse3.SynapseModule/Config/SerializedObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public SerializedItem(uint id, float durability, uint weaponAttachment, Vector3
FireArm =
{
Attachments = WeaponAttachments
}
},
Scale = new Vector3(XSize, YSize, ZSize)
};

public static explicit operator SynapseItem(SerializedItem item) => item.Parse();
Expand Down
14 changes: 10 additions & 4 deletions Synapse3.SynapseModule/DebugService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
using Synapse3.SynapseModule.Events;
using Synapse3.SynapseModule.Teams;
using System;
using System.Linq;
using Synapse3.SynapseModule.Enums;
using Synapse3.SynapseModule.Map;
using Synapse3.SynapseModule.Player;
using UnityEngine;


Expand Down Expand Up @@ -52,7 +55,11 @@ public override void Enable()
reactor.Value.SubscribeUnsafe(this, method);
}
_player.KeyPress.Subscribe(OnKeyPress);
_player.Pickup.Subscribe(ev => ev.Allow = false);
_item.ConsumeItem.Subscribe(ev =>
{
if (ev.State == ItemInteractState.Finalize)
ev.Allow = false;
});
}

public void Event(IEvent ev)
Expand All @@ -65,12 +72,11 @@ private void OnKeyPress(KeyPressEvent ev)
switch (ev.KeyCode)
{
case KeyCode.Alpha1:
ev.Player.Invisible += 1;
if (ev.Player.Invisible > InvisibleMode.Full) ev.Player.Invisible = InvisibleMode.None;
Synapse.Get<NukeService>().StartDetonation();
break;

case KeyCode.Alpha2:
ev.Player.MaxHealth = 98;
Synapse.Get<NukeService>().InstantDetonation();

break;
case KeyCode.Alpha3:
Expand Down
1 change: 0 additions & 1 deletion Synapse3.SynapseModule/Enums/DoorType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public enum DoorType
Scp096,
Scp106Primary,
Scp106Secondary,
Scp106Bottom,
Scp173Armory,
Scp173Connector,
Scp173Gate,
Expand Down
2 changes: 1 addition & 1 deletion Synapse3.SynapseModule/Events/RoundEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class FirstSpawnEvent : IEvent
public Team[] HumanQueue { get; set; }
public bool EnableLateJoin { get; set; } = true;
public bool EnableNormalSpawning { get; set; } = true;
public bool CustomSpawning { get; set; } = false;
public List<SynapsePlayer> PlayersBlockedFromSpawning { get; set; } = new();
}

public class DecontaminationEvent : IEvent
Expand Down
4 changes: 1 addition & 3 deletions Synapse3.SynapseModule/Item/SynapseItemAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public partial class SynapseItem
{
public void EquipItem(SynapsePlayer player, bool dropWhenFull = true, bool provideFully = false)
{
if(player.RoleType is RoleTypeId.Spectator or RoleTypeId.None) return;

if (player.Inventory.Items.Count >= 8)
{
if (dropWhenFull)
Expand Down Expand Up @@ -96,7 +94,7 @@ public void Drop(Vector3 position)

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

if (owner is not null)
if (owner != null)
{
rot = owner.CameraReference.rotation * exampleBase.PickupDropModel.transform.rotation;
}
Expand Down
3 changes: 1 addition & 2 deletions Synapse3.SynapseModule/Map/MapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ public DoorType GetDoorByName(string doorName)

{ "106_PRIMARY", DoorType.Scp106Primary },
{ "106_SECONDARY", DoorType.Scp106Secondary },
{ "106_BOTTOM", DoorType.Scp106Bottom },


{ "Unsecured Pryable GateDoor", DoorType.Scp049Gate },
{ "049_ARMORY", DoorType.Scp049Armory },

Expand Down
13 changes: 6 additions & 7 deletions Synapse3.SynapseModule/Map/NukeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,17 @@ public NukeState State
WarheadController.CooldownEndTime <= NetworkTime.time && !WarheadController.IsLocked;

public void StartDetonation()
=> WarheadController.StartDetonation();
{
WarheadController.InstantPrepare();
WarheadController.StartDetonation();
}

public void CancelDetonation()
=> WarheadController.CancelDetonation();

public void Shake() => WarheadController.RpcShake(true);

public void InstantDetonation()
{
WarheadController.InstantPrepare();
WarheadController.StartDetonation(false, true);
}

public void InstantDetonation() => WarheadController.ForceTime(0f);

public class NukeInsidePanel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public static bool LockerInteract(Locker __instance, ReferenceHub ply, byte coll
{
if (colliderId >= __instance.Chambers.Length || !__instance.Chambers[colliderId].CanInteract) return false;
var player = ply.GetSynapsePlayer();
var hasPerms = __instance.Chambers[colliderId].RequiredPermissions.CheckPermission(player);
var hasPerms = __instance.Chambers[colliderId].RequiredPermissions.CheckPermission(player, true);
var locker = __instance.GetSynapseLocker();
var ev = new LockerUseEvent(player, hasPerms, locker, locker.Chambers[colliderId])
{
Expand Down
14 changes: 12 additions & 2 deletions Synapse3.SynapseModule/Patching/Patches/EventRoundPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static bool RoundSummaryOverride(RoundSummary __instance, ref IEnumerator
[SynapsePatch("FirstSpawn", PatchType.RoundEvent)]
public static class FirstSpawnPatch
{
internal static List<SynapsePlayer> _blockedPlayer = new();
private static readonly RoundEvents _round;
static FirstSpawnPatch() => _round = Synapse.Get<RoundEvents>();

Expand Down Expand Up @@ -98,10 +99,11 @@ public static bool OnRoundStarted()
HumanQueue = RoleAssigner._humanQueue
};
_round.FirstSpawn.RaiseSafely(ev);
_blockedPlayer = ev.PlayersBlockedFromSpawning;
if (ev.EnableLateJoin)
{
RoleAssigner._spawned = true;
RoleAssigner.LateJoinTimer.Reset();
RoleAssigner.LateJoinTimer.Restart();
}

if (!ev.EnableNormalSpawning) return false;
Expand All @@ -112,7 +114,7 @@ public static bool OnRoundStarted()
{
RoleAssigner.AlreadySpawnedPlayers.Add(hub.characterClassManager.UserId);
}

_blockedPlayer.Clear();
return false;
}
catch (Exception ex)
Expand All @@ -121,6 +123,14 @@ public static bool OnRoundStarted()
return true;
}
}

[HarmonyPostfix]
[HarmonyPatch(typeof(RoleAssigner), nameof(RoleAssigner.CheckPlayer))]
public static void CheckPlayer(ref bool __result, ReferenceHub hub)
{
if (_blockedPlayer.Any(x => x.Hub == hub))
__result = false;
}
}

[Automatic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,12 @@ private static string GenerateList(List<RemoteAdminPlayer> players, CommandSende
var colors = ServerService.Colors;
color = colors.ElementAt(Random.Range(0, colors.Count)).Value;
}
color = ServerService.GetColorHexCode(color);
else
{
color = ServerService.GetColorHexCode(color);
}

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

Expand Down
5 changes: 2 additions & 3 deletions Synapse3.SynapseModule/Permissions/PermissionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Synapse3.SynapseModule.Permissions;

public class PermissionService : Service
{
private uint _currentGroupId = 500;
private ConfigService _configService;
private ServerEvents _server;
public ConfigContainer Container { get; private set; }
Expand Down Expand Up @@ -123,10 +122,10 @@ private void LoadGroups()
}


_currentGroupId = 500;
var id = 1u;
foreach (var group in Groups)
{
group.Value.GroupId = _currentGroupId++;
group.Value.GroupId = id++;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
Name = "[ GodMode]",
Color = "#03f8fc",
Size = 20,
Id = 10003
Id = 103
)]
public class GodModeCategory : RemoteAdminCategory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
Name = "[ Invisible]",
Color = "#03f8fc",
Size = 20,
Id = 10002
Id = 102
)]
public class InvisibleCategory : RemoteAdminCategory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
Name = "[ NoClip]",
Color = "#03f8fc",
Size = 20,
Id = 10004
Id = 104
)]
public class NoClipCategory : RemoteAdminCategory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
Name = "[ OverWatch]",
Color = "#03f8fc",
Size = 20,
Id = 10001
Id = 101
)]
public class OverWatchCategory : RemoteAdminCategory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public RaCategoryAttribute(string name, uint id, Type categoryType)

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

public string RemoteAdminIdentifier { get; set; }

public uint Id { get; set; }

public Type CategoryType { get; internal set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Synapse3.SynapseModule.Permissions.RemoteAdmin;
[RaCategory(
Name = "[ Synapse 3]",
Color = "blue",
Id = 10000
Id = 100
)]
public class SynapseCategory : RemoteAdminCategory
{
Expand Down
42 changes: 27 additions & 15 deletions Synapse3.SynapseModule/Player/FakeRoleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ internal FakeRoleManager(SynapsePlayer player, MirrorService mirror, PlayerServi

public void Reset()
{
_ownVisibleRole = new RoleInfo(RoleTypeId.None, null, null);
_visibleRole = new RoleInfo(RoleTypeId.None, null, null);
_ownVisibleRoleInfo = new RoleInfo(RoleTypeId.None, null, null);
_visibleRoleInfo = new RoleInfo(RoleTypeId.None, null, null);
ToPlayerVisibleRole.Clear();
VisibleRoleCondition.Clear();
UpdateAll();
Expand All @@ -48,24 +48,36 @@ public void UpdateAll()
public void UpdatePlayer(SynapsePlayer player)
=> player.SendNetworkMessage(new RoleSyncInfo(_player, RoleTypeId.None, player));

private RoleInfo _ownVisibleRole = new(RoleTypeId.None, null, null);
public RoleInfo OwnVisibleRole
public RoleTypeId OwnVisibleRole
{
get => _ownVisibleRole;
get => OwnVisibleRoleInfo.RoleTypeId;
set => OwnVisibleRoleInfo = new RoleInfo(value, _player);
}

private RoleInfo _ownVisibleRoleInfo = new(RoleTypeId.None, null, null);
public RoleInfo OwnVisibleRoleInfo
{
get => _ownVisibleRoleInfo;
set
{
_ownVisibleRole = value;
_ownVisibleRoleInfo = value;
UpdatePlayer(_player);
}
}

public RoleTypeId VisibleRole
{
get => VisibleRoleInfo.RoleTypeId;
set => VisibleRoleInfo = new RoleInfo(value, _player);
}

private RoleInfo _visibleRole = new(RoleTypeId.None, null, null);
public RoleInfo VisibleRole
private RoleInfo _visibleRoleInfo = new(RoleTypeId.None, null, null);
public RoleInfo VisibleRoleInfo
{
get => _visibleRole;
get => _visibleRoleInfo;
set
{
_visibleRole = value;
_visibleRoleInfo = value;
foreach (var player in _playerService.Players)
{
if (player != _player)
Expand Down Expand Up @@ -93,9 +105,9 @@ public void WriteRoleSyncInfoFor(SynapsePlayer receiver, NetworkWriter writer)

public RoleInfo GetRoleInfo(SynapsePlayer receiver)
{
if (receiver == _player && OwnVisibleRole.RoleTypeId != RoleTypeId.None)
if (receiver == _player && OwnVisibleRoleInfo.RoleTypeId != RoleTypeId.None)
{
return OwnVisibleRole;
return OwnVisibleRoleInfo;
}

if (ToPlayerVisibleRole.ContainsKey(receiver))
Expand All @@ -109,9 +121,9 @@ public RoleInfo GetRoleInfo(SynapsePlayer receiver)
return condition.Value;
}

if (VisibleRole.RoleTypeId != RoleTypeId.None)
if (VisibleRoleInfo.RoleTypeId != RoleTypeId.None)
{
return VisibleRole;
return VisibleRoleInfo;
}

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

default:
if (typeof(HumanRole).IsAssignableFrom(FakeRoleManager.EnumToType[role]))
PrepareHumanRole(role, 0, player);
PrepareHumanRole(role, player.UnitNameId, player);
else if (typeof(FpcStandardRoleBase).IsAssignableFrom(FakeRoleManager.EnumToType[role]))
PrepareFpcRole(player);
break;
Expand Down
8 changes: 3 additions & 5 deletions Synapse3.SynapseModule/Player/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ public bool TryGetPlayers(string arg, out HashSet<SynapsePlayer> players, Synaps
{
if (int.TryParse(parameter, out var id))
{
id *= -1;
Logger.Warn(id);
//Check For SynapseGroupID
foreach (var player in GetPlayers(id, playerTypes))
{
Expand Down Expand Up @@ -330,11 +332,7 @@ private void Join(JoinEvent ev)
}

private void RoundRestart(RoundRestartEvent _)
{
JoinUpdates.Clear();
RecyclablePlayerId._autoIncrement = 0;
RecyclablePlayerId.FreeIds.Clear();
}
=> JoinUpdates.Clear();

private void ChangeClass(SetClassEvent ev)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public bool NoClipPermitted
/// </summary>
public bool OverWatch
{
get => ServerRoles.IsInOverwatch;
set => ServerRoles.IsInOverwatch = value;
get => CurrentRole is OverwatchRole;
set => SetRoleFlags(value ? RoleTypeId.Overwatch : RoleTypeId.Spectator, RoleSpawnFlags.All,
RoleChangeReason.RemoteAdmin);
}

/// <summary>
Expand Down
Loading

0 comments on commit 3e5e940

Please sign in to comment.