This commit is contained in:
code002lover 2025-06-05 01:12:55 +02:00
parent 17c654d889
commit 96596e9c08
39 changed files with 1157 additions and 1350 deletions

View File

@ -1,32 +1,32 @@
using System.Collections;
using LabApi.Features;
using LabApi.Loader.Features.Plugins;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Wrappers;
using PlayerRoles;
using Logger = LabApi.Features.Console.Logger;
using Version = System.Version;
using LabApi.Loader.Features.Plugins;
using MEC;
using PlayerRoles;
using UnityEngine;
using Logger = LabApi.Features.Console.Logger;
using Random = UnityEngine.Random;
using Version = System.Version;
namespace AfkSwap;
public class AfkSwap : Plugin
{
private const float AfkTimeLimit = 60; // 1 minute in seconds
private readonly Dictionary<Player, DateTime> _afkPlayers = new();
private readonly object _lock = new();
private readonly Dictionary<Player, Vector3> _playerPositions = new();
private readonly Dictionary<Player, DateTime> _playerSpawnTimes = new();
public override string Name => "AfkSwap";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Swaps AFK players with spectators after one minute.";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
private readonly Dictionary<Player, DateTime> _playerSpawnTimes = new();
private readonly Dictionary<Player, Vector3> _playerPositions = new();
private readonly Dictionary<Player, DateTime> _afkPlayers = new();
private const float AfkTimeLimit = 60; // 1 minute in seconds
private readonly object _lock = new();
public override void Enable()
{
PlayerEvents.Spawned += OnPlayerSpawned;
@ -60,7 +60,6 @@ public class AfkSwap : Plugin
Logger.Debug($"Player {player.DisplayName} spawned");
});
}
private IEnumerator<float> CheckAfkPlayers()
@ -70,14 +69,17 @@ public class AfkSwap : Plugin
{
lock (_lock)
{
foreach (var playerTime in _playerSpawnTimes.ToList().Where(playerTime => (DateTime.Now - playerTime.Value).TotalSeconds >= AfkTimeLimit))
foreach (var playerTime in _playerSpawnTimes.ToList().Where(playerTime =>
(DateTime.Now - playerTime.Value).TotalSeconds >= AfkTimeLimit))
{
if (playerTime.Key.Role is RoleTypeId.Spectator or RoleTypeId.Destroyed or RoleTypeId.Overwatch or RoleTypeId.Tutorial)
if (playerTime.Key.Role is RoleTypeId.Spectator or RoleTypeId.Destroyed or RoleTypeId.Overwatch
or RoleTypeId.Tutorial)
{
_playerSpawnTimes.Remove(playerTime.Key);
_playerPositions.Remove(playerTime.Key);
continue;
}
if (!_playerPositions[playerTime.Key].Equals(playerTime.Key.Position))
{
_playerSpawnTimes.Remove(playerTime.Key);
@ -97,13 +99,15 @@ public class AfkSwap : Plugin
private void SwapWithSpectator(Player afkPlayer)
{
var spectators = Player.ReadyList.Where(p => p.Role == RoleTypeId.Spectator && (DateTime.Now - _afkPlayers[p]).TotalSeconds > 10).ToList();
var spectators = Player.ReadyList
.Where(p => p.Role == RoleTypeId.Spectator && (DateTime.Now - _afkPlayers[p]).TotalSeconds > 10).ToList();
if (!spectators.Any())
{
Logger.Warn("No spectators to swap to");
return;
}
var randomSpectator = spectators[UnityEngine.Random.Range(0, spectators.Count)];
var randomSpectator = spectators[Random.Range(0, spectators.Count)];
Logger.Debug($"Swapping {afkPlayer.DisplayName} with {randomSpectator.DisplayName}");
// Store the AFK player's position and role

View File

@ -26,12 +26,6 @@
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -19,21 +19,6 @@
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Northwood.LabAPI" Version="1.0.2"/>
</ItemGroup>

View File

@ -1,5 +1,4 @@
using CustomPlayerEffects;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Console;
@ -7,8 +6,6 @@ using LabApi.Features.Wrappers;
using LabApi.Loader.Features.Plugins;
using Mirror;
using PlayerRoles;
using PlayerRoles.PlayableScps.Scp3114;
using PlayerRoles.Ragdolls;
namespace CuffedFrenemies;
@ -33,10 +30,7 @@ public class CuffedFrenemies : Plugin
private static void OnCuff(PlayerCuffedEventArgs ev)
{
if (ev.Target.Team is Team.ClassD or Team.Scientists)
{
return;
}
if (ev.Target.Team is Team.ClassD or Team.Scientists) return;
if (ev.Target.Team == ev.Player.Team)
{
@ -44,10 +38,7 @@ public class CuffedFrenemies : Plugin
return;
}
if (ev.Target.Team is Team.SCPs or Team.Dead)
{
return;
}
if (ev.Target.Team is Team.SCPs or Team.Dead) return;
var newRole = ev.Target.Team == Team.ChaosInsurgency ? RoleTypeId.NtfPrivate : RoleTypeId.ChaosConscript;
Logger.Debug($"Setting role to {newRole}");
@ -62,12 +53,8 @@ public class CuffedFrenemies : Plugin
ev.Target.SetRole(newRole);
ev.Target.ClearItems();
foreach (var newItem in newItems)
{
ev.Target.Inventory.UserInventory.Items.Add(newItem.Serial,newItem.Base);
}
foreach (var newItem in newItems) ev.Target.Inventory.UserInventory.Items.Add(newItem.Serial, newItem.Base);
ev.Target.Position = newPos;
}
}

View File

@ -26,9 +26,6 @@
<Reference Include="Mirror">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -1,23 +1,24 @@
using System.Drawing;
using CommandSystem.Commands.RemoteAdmin.Inventory;
using Interactables.Interobjects.DoorUtils;
using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Arguments.ServerEvents;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Console;
using LabApi.Loader.Features.Plugins;
using PlayerRoles;
using LabApi.Features.Wrappers;
using LabApi.Loader.Features.Plugins;
using MapGeneration;
using Vector3 = UnityEngine.Vector3;
using MEC;
using PlayerRoles;
using UnityEngine;
using Logger = LabApi.Features.Console.Logger;
using Random = System.Random;
using Vector3 = UnityEngine.Vector3;
namespace CustomClasses;
public class CustomClasses : Plugin
{
private readonly CustomClassManager _classManager = new();
public override string Name => "CustomClasses";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
@ -28,8 +29,6 @@ public class CustomClasses : Plugin
public ResearchSubjectConfig ResearchSubjectConfig { get; set; } = new();
public HeadGuardConfig HeadGuardConfig { get; set; } = new();
private readonly CustomClassManager _classManager = new();
public override void Enable()
{
PlayerEvents.Spawned += OnPlayerSpawned;
@ -57,10 +56,10 @@ public class CustomClasses : Plugin
public class CustomClassManager
{
private readonly Dictionary<Type, ICustomClassHandler> _handlers = new();
private readonly object _lock = new();
private readonly Random _random = new();
private readonly Dictionary<Type, SpawnState> _spawnStates = new();
private readonly Dictionary<Type, ICustomClassHandler> _handlers = new();
public CustomClassManager()
{
@ -90,10 +89,7 @@ public class CustomClassManager
{
lock (_lock)
{
foreach (var key in _spawnStates.Keys.ToList())
{
_spawnStates[key] = new SpawnState();
}
foreach (var key in _spawnStates.Keys.ToList()) _spawnStates[key] = new SpawnState();
}
}
@ -121,10 +117,7 @@ public class CustomClassManager
Logger.Debug($"Player spawning {configType} - {player.Nickname} - {state.Spawns} / {config.MaxSpawns}");
if (_handlers.TryGetValue(configType, out var handler))
{
return handler.HandleSpawn(player, config, _random);
}
if (_handlers.TryGetValue(configType, out var handler)) return handler.HandleSpawn(player, config, _random);
}
return false;
@ -150,6 +143,7 @@ public class JanitorHandler(CustomClassManager manager) : ICustomClassHandler
player.AddItem(spawnItem, ItemAddReason.StartingItem);
Logger.Debug($"Gave player {player.Nickname} spawn item {spawnItem}");
}
player.SendBroadcast("You're a <color=#A0A0A0>Janitor</color>!", 3);
});
@ -171,6 +165,7 @@ public class ResearchSubjectHandler(CustomClassManager manager) : ICustomClassHa
player.AddItem(spawnItem, ItemAddReason.StartingItem);
Logger.Debug($"Gave player {player.Nickname} spawn item {spawnItem}");
}
player.SendBroadcast("You're a <color=#944710>Research Subject</color>!", 3);
});
@ -186,7 +181,8 @@ public class HeadGuardHandler(CustomClassManager manager) : ICustomClassHandler
{
player.RemoveItem(ItemType.KeycardGuard);
KeycardItem.CreateCustomKeycardTaskForce(player, "Head Guard Keycard", $"HG. {player.Nickname}", new KeycardLevels(1,1,2),UnityEngine.Color.blue,UnityEngine.Color.cyan, "1", 0);
KeycardItem.CreateCustomKeycardTaskForce(player, "Head Guard Keycard", $"HG. {player.Nickname}",
new KeycardLevels(1, 1, 2), Color.blue, Color.cyan, "1", 0);
player.AddItem(ItemType.Adrenaline, ItemAddReason.StartingItem);

View File

@ -32,9 +32,6 @@
<Reference Include="NorthwoodLib">
<HintPath>..\dependencies\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -11,14 +11,13 @@ namespace CustomItemSpawn;
public class CustomItemSpawn : Plugin<ItemConfig>
{
private static CustomItemSpawn _singleton;
public override string Name => "CustomItemSpawn";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Spawns items in a custom location.";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
private static CustomItemSpawn _singleton;
public override void Enable()
{
_singleton = this;

View File

@ -29,9 +29,6 @@
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -3,20 +3,22 @@ using LabApi.Features;
using LabApi.Features.Console;
using LabApi.Loader;
namespace GamblingCoin
{
namespace GamblingCoin;
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
{
public static Plugin Singleton;
private GamblingCoinEventHandler _eventHandler;
public GamblingCoinChancesConfig ConfigChances;
public GamblingCoinGameplayConfig ConfigGameplay;
public GamblingCoinMessages ConfigMessages;
public override string Name => "GamblingCoin";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Gamble your life away";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public GamblingCoinGameplayConfig ConfigGameplay;
public GamblingCoinMessages ConfigMessages;
public GamblingCoinChancesConfig ConfigChances;
public override void LoadConfigs()
{
base.LoadConfigs();
@ -26,10 +28,6 @@ namespace GamblingCoin
ConfigChances = this.LoadConfig<GamblingCoinChancesConfig>("chances.yml");
}
public static Plugin Singleton;
private GamblingCoinEventHandler _eventHandler;
public override void Enable()
{
Logger.Debug("starting...");
@ -45,4 +43,3 @@ namespace GamblingCoin
PlayerEvents.FlippedCoin -= _eventHandler.OnFlippedCoin;
}
}
}

View File

@ -1,7 +1,6 @@
using CustomPlayerEffects;
namespace GamblingCoin
{
namespace GamblingCoin;
public class GamblingCoinChancesConfig
{
@ -60,7 +59,8 @@ namespace GamblingCoin
public class ItemPoolConfig
{
public ItemType[] CommonItems { get; set; } = {
public ItemType[] CommonItems { get; set; } =
{
ItemType.KeycardJanitor,
ItemType.KeycardScientist,
ItemType.Medkit,
@ -69,7 +69,8 @@ namespace GamblingCoin
ItemType.Flashlight
};
public ItemType[] UncommonItems { get; set; } = {
public ItemType[] UncommonItems { get; set; } =
{
ItemType.KeycardZoneManager,
ItemType.KeycardGuard,
ItemType.KeycardResearchCoordinator,
@ -78,7 +79,8 @@ namespace GamblingCoin
ItemType.GrenadeFlash
};
public ItemType[] RareItems { get; set; } = {
public ItemType[] RareItems { get; set; } =
{
ItemType.KeycardMTFPrivate,
ItemType.KeycardContainmentEngineer,
ItemType.KeycardMTFOperative,
@ -89,14 +91,16 @@ namespace GamblingCoin
ItemType.GrenadeHE
};
public ItemType[] EpicItems { get; set; } = {
public ItemType[] EpicItems { get; set; } =
{
ItemType.KeycardFacilityManager,
ItemType.KeycardChaosInsurgency,
ItemType.KeycardMTFCaptain,
ItemType.SCP500
};
public ItemType[] LegendaryItems { get; set; } = {
public ItemType[] LegendaryItems { get; set; } =
{
ItemType.KeycardO5,
ItemType.MicroHID,
ItemType.Jailbird,
@ -132,8 +136,11 @@ namespace GamblingCoin
public AdvancedEffectSettings Negative { get; set; } = new()
{
Effects = new[] { nameof(Asphyxiated), nameof(AmnesiaVision), nameof(Bleeding), nameof(Blurred),
nameof(Concussed), nameof(Deafened), nameof(Disabled) },
Effects = new[]
{
nameof(Asphyxiated), nameof(AmnesiaVision), nameof(Bleeding), nameof(Blurred),
nameof(Concussed), nameof(Deafened), nameof(Disabled)
},
Settings = new Dictionary<string, EffectSettings>
{
{ nameof(Asphyxiated), new EffectSettings(1, 10f, true) },
@ -153,7 +160,7 @@ namespace GamblingCoin
{
{ nameof(InsufficientLighting), new EffectSettings(1, 30f, true) },
{ nameof(AmnesiaVision), new EffectSettings(3, 30f, true) },
{ nameof(Burned), new EffectSettings(3, 60f, true) },
{ nameof(Burned), new EffectSettings(3, 60f, true) }
}
};
}
@ -162,16 +169,10 @@ namespace GamblingCoin
{
public string[] Effects { get; set; }
public Dictionary<string, EffectSettings> Settings { get; set; }
public AdvancedEffectSettings(){}
}
public class EffectSettings
{
public byte Intensity { get; set; }
public float Duration { get; set; }
public bool AddDuration { get; set; }
public EffectSettings(byte intensity, float duration, bool addDuration)
{
Intensity = intensity;
@ -179,6 +180,11 @@ namespace GamblingCoin
AddDuration = addDuration;
}
public EffectSettings(){}
public EffectSettings()
{
}
public byte Intensity { get; set; }
public float Duration { get; set; }
public bool AddDuration { get; set; }
}

View File

@ -1,20 +1,15 @@
using System.Diagnostics;
using System.Numerics;
using CustomPlayerEffects;
using InventorySystem.Items;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Features.Wrappers;
using MapGeneration;
using Mirror;
using PlayerRoles;
using Respawning.Waves;
using Utils;
using Logger = LabApi.Features.Console.Logger;
using Respawning;
using UnityEngine;
using MicroHIDItem = InventorySystem.Items.MicroHID.MicroHIDItem;
using Random = UnityEngine.Random;
namespace GamblingCoin
{
namespace GamblingCoin;
public class GamblingCoinEventHandler
{
private readonly WeightedRandomExecutor<PlayerFlippedCoinEventArgs> _executor;
@ -37,9 +32,8 @@ namespace GamblingCoin
{
x.Player.SendBroadcast(configMessages.SpawnWaveMessage, configGameplay.BroadcastDuration);
if(GetPlayers().Any(player=>player.Role == RoleTypeId.Spectator)) {
Respawning.WaveManager.InitiateRespawn(Respawning.WaveManager.Waves[Random.Range(0, Respawning.WaveManager.Waves.Count)]);
}
if (GetPlayers().Any(player => player.Role == RoleTypeId.Spectator))
WaveManager.InitiateRespawn(WaveManager.Waves[Random.Range(0, WaveManager.Waves.Count)]);
}, configChances.SpawnWaveChance)
.AddAction(x =>
{
@ -71,7 +65,7 @@ namespace GamblingCoin
var itemIndex = Random.Range(0, items.Length);
var item = items[itemIndex];
var pickup = Pickup.Create(item, player.Position + new UnityEngine.Vector3(0,1,0));
var pickup = Pickup.Create(item, player.Position + new Vector3(0, 1, 0));
if (pickup == null) return;
if (item is ItemType.MicroHID)
@ -83,7 +77,7 @@ namespace GamblingCoin
microItem.EnergyManager.ServerSetEnergy(microItem.ItemId.SerialNumber, 100);
var newPickup = host.DropItem(micro);
newPickup.Position = player.Position + new UnityEngine.Vector3(0, 1, 0);
newPickup.Position = player.Position + new Vector3(0, 1, 0);
return;
}
@ -115,7 +109,8 @@ namespace GamblingCoin
var newPos = randomRoom.Position;
x.Player.Position = newPos + new UnityEngine.Vector3(0, configGameplay.TeleportHeightOffset, 0);;
x.Player.Position = newPos + new Vector3(0, configGameplay.TeleportHeightOffset, 0);
;
}, configChances.RandomTeleportChance)
.AddAction(x =>
{
@ -176,7 +171,8 @@ namespace GamblingCoin
var randomPlayer = players[Random.Range(0, GetPlayers().Length)];
while(randomPlayer.RoleBase.Team is Team.Dead or Team.SCPs) randomPlayer = players[Random.Range(0,GetPlayers().Length)];
while (randomPlayer.RoleBase.Team is Team.Dead or Team.SCPs)
randomPlayer = players[Random.Range(0, GetPlayers().Length)];
x.Player.SendBroadcast(configMessages.SwitchInventoryMessage, configGameplay.BroadcastDuration);
randomPlayer.SendBroadcast(configMessages.SwitchInventoryMessage, configGameplay.BroadcastDuration);
@ -186,21 +182,12 @@ namespace GamblingCoin
var items = x.Player.Items;
randomPlayer.ClearInventory();
foreach (var itemBase in items)
{
randomPlayer.AddItem(itemBase.Type);
}
foreach (var itemBase in items) randomPlayer.AddItem(itemBase.Type);
x.Player.ClearInventory();
foreach (var randomPlayerItem in randomPlayerItems)
{
x.Player.AddItem(randomPlayerItem.Type);
}
foreach (var randomPlayerItem in randomPlayerItems) x.Player.AddItem(randomPlayerItem.Type);
}, configChances.SwitchInventoryChance)
.AddAction(x =>
{
x.Player.CurrentItem?.DropItem().Destroy();
}, configChances.RemoveCoinChance);
.AddAction(x => { x.Player.CurrentItem?.DropItem().Destroy(); }, configChances.RemoveCoinChance);
return;
@ -209,12 +196,13 @@ namespace GamblingCoin
var effectChosen = settings.Effects[Random.Range(0, settings.Effects.Length)];
var effectSettings = settings.Settings[effectChosen];
player.ReferenceHub.playerEffectsController.ChangeState(effectChosen, effectSettings.Intensity, effectSettings.Duration, effectSettings.AddDuration);
player.ReferenceHub.playerEffectsController.ChangeState(effectChosen, effectSettings.Intensity,
effectSettings.Duration, effectSettings.AddDuration);
}
void SpawnItemAtPlayer(Player player, ItemType item)
{
var pickup = Pickup.Create(item, player.Position + new UnityEngine.Vector3(0,1,0));
var pickup = Pickup.Create(item, player.Position + new Vector3(0, 1, 0));
if (pickup == null) return;
pickup.Spawn();
@ -237,4 +225,3 @@ namespace GamblingCoin
_executor.Execute(ev);
}
}
}

View File

@ -2,24 +2,6 @@ namespace GamblingCoin;
public class WeightedRandomExecutor<TEvent>
{
private class WeightedAction
{
public Action<TEvent> Action { get; }
public double Weight { get; }
public WeightedAction(Action<TEvent> action, double weight)
{
if (weight <= 0)
throw new ArgumentOutOfRangeException(
nameof(weight),
"Weight must be positive."
);
Action = action ?? throw new ArgumentNullException(nameof(action));
Weight = weight;
}
}
private readonly List<WeightedAction> _actions = new();
private readonly Random _random = new();
private double _totalWeight;
@ -47,18 +29,14 @@ public class WeightedRandomExecutor<TEvent>
public void Execute(TEvent ev)
{
if (_actions.Count == 0)
{
throw new InvalidOperationException(
"No actions have been added to execute."
);
}
if (_totalWeight <= 0) // Should not happen if AddAction validates weight > 0
{
throw new InvalidOperationException(
"Total weight is zero or negative, cannot execute."
);
}
var randomNumber = _random.NextDouble() * _totalWeight;
double cumulativeWeight = 0;
@ -74,9 +52,24 @@ public class WeightedRandomExecutor<TEvent>
// Fallback in case of floating point inaccuracies,
// or if somehow randomNumber was exactly _totalWeight (NextDouble is < 1.0)
// This should ideally pick the last item if all weights were summed up.
if (_actions.Any())
if (_actions.Any()) _actions.Last().Action(ev);
}
private class WeightedAction
{
_actions.Last().Action(ev);
}
public WeightedAction(Action<TEvent> action, double weight)
{
if (weight <= 0)
throw new ArgumentOutOfRangeException(
nameof(weight),
"Weight must be positive."
);
Action = action ?? throw new ArgumentNullException(nameof(action));
Weight = weight;
}
public Action<TEvent> Action { get; }
public double Weight { get; }
}
}

View File

@ -1,25 +1,24 @@
using CustomPlayerEffects;
using LabApi.Events.Arguments.Scp0492Events;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Loader.Features.Plugins;
using InventorySystem.Items.Usables.Scp330;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Arguments.Scp0492Events;
using LabApi.Events.Arguments.ServerEvents;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Wrappers;
using LabApi.Loader.Features.Plugins;
namespace GrowingZombies;
public class GrowingZombies : Plugin
{
private readonly Dictionary<Player, int> _zombieCorpseCount = new();
public override string Name => "GrowingZombies";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Makes zombies grow stronger as they eat more";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
private readonly Dictionary<Player, int> _zombieCorpseCount = new();
public override void Enable()
{
Scp0492Events.ConsumedCorpse += OnZombieEat;
@ -65,9 +64,7 @@ public class GrowingZombies : Plugin
// Add damage resistance after eating multiple corpses
var damageResistance = (byte)Math.Min(0.5 - corpsesEaten * 0.5f, 2f);
if (corpsesEaten >= 3)
{
ev.Player.ReferenceHub.playerEffectsController.ChangeState<DamageReduction>(damageResistance, 20);
}
// Add regeneration effect after eating multiple corpses
if (corpsesEaten < 5) return;

View File

@ -23,18 +23,12 @@
<Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib">
<HintPath>..\dependencies\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -1,5 +1,4 @@
using System.Collections;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorButtons;
using Interactables.Interobjects.DoorUtils;
using LabApi.Events.Arguments.PlayerEvents;
@ -10,19 +9,19 @@ using UnityEngine;
using KeycardItem = InventorySystem.Items.Keycards.KeycardItem;
using Logger = LabApi.Features.Console.Logger;
namespace KeycardButModern
{
namespace KeycardButModern;
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
{
public static Plugin Singleton;
public DoorLockConfiguration DoorLockConfiguration;
public override string Name => "KeycardButModern";
public override string Description => "Ever thought you wanted your keycard implanted in your body? No? Same.";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public DoorLockConfiguration DoorLockConfiguration;
public static Plugin Singleton;
public override void LoadConfigs()
{
base.LoadConfigs();
@ -32,24 +31,15 @@ namespace KeycardButModern
private void OnInteractingDoor(PlayerInteractingDoorEventArgs ev)
{
if (ev.CanOpen)
{
return;
}
if (ev.CanOpen) return;
if (ev.Door.IsLocked)
{
return;
}
if (ev.Door.IsLocked) return;
foreach (var playerItem in ev.Player.Items)
{
//is keycard?
if (playerItem.Type is > ItemType.KeycardO5 and < ItemType.KeycardCustomTaskForce) continue;
if (playerItem.Base is not KeycardItem keycardItem)
{
continue;
}
if (playerItem.Base is not KeycardItem keycardItem) continue;
if (!ev.Door.Base.CheckPermissions(keycardItem, out _)) continue;
ev.Door.IsOpened = !ev.Door.IsOpened;
@ -60,34 +50,23 @@ namespace KeycardButModern
private void OnInteractingGenerator(PlayerInteractingGeneratorEventArgs ev)
{
if (!ev.IsAllowed)
{
return;
}
if (!ev.IsAllowed) return;
if (ev.Player.CurrentItem?.Base is KeycardItem keycard)
{
if (ev.Generator.Base.CheckPermissions(keycard, out _))
{
ev.Generator.IsUnlocked = true;
return;
}
}
if (ev.Generator.IsUnlocked)
{
return;
}
if (ev.Generator.IsUnlocked) return;
foreach (var playerItem in ev.Player.Items)
{
//is keycard?
if (playerItem.Type is > ItemType.KeycardO5 and < ItemType.KeycardCustomTaskForce) continue;
if (playerItem.Base is not KeycardItem keycardItem)
{
continue;
}
if (playerItem.Base is not KeycardItem keycardItem) continue;
if (!ev.Generator.Base.CheckPermissions(keycardItem, out _)) continue;
ev.Generator.IsOpen = !ev.Generator.IsOpen;
@ -99,29 +78,19 @@ namespace KeycardButModern
private void OnInteractingLocker(PlayerInteractingLockerEventArgs ev)
{
if (!ev.IsAllowed)
{
return;
}
if (!ev.IsAllowed) return;
if (ev.Chamber.Base.RequiredPermissions == DoorPermissionFlags.None)
{
return;
}
if (ev.Chamber.Base.RequiredPermissions == DoorPermissionFlags.None) return;
if (ev.Player.CurrentItem?.Base is KeycardItem keycard)
{
if (ev.Chamber.Base.CheckPermissions(keycard, out _)) return;
}
if (ev.Chamber.Base.CheckPermissions(keycard, out _))
return;
foreach (var playerItem in ev.Player.Items)
{
//is keycard?
if (playerItem.Type is > ItemType.KeycardO5 and < ItemType.KeycardCustomTaskForce) continue;
if (playerItem.Base is not KeycardItem keycardItem)
{
continue;
}
if (playerItem.Base is not KeycardItem keycardItem) continue;
if (!ev.Chamber.Base.CheckPermissions(keycardItem, out _)) continue;
ev.Chamber.IsOpen = !ev.Chamber.IsOpen;
@ -132,19 +101,13 @@ namespace KeycardButModern
private void OnUnlockingWarhead(PlayerUnlockingWarheadButtonEventArgs ev)
{
if (ev.IsAllowed)
{
return;
}
if (ev.IsAllowed) return;
foreach (var playerItem in ev.Player.Items)
{
//is keycard?
if (playerItem.Type is > ItemType.KeycardO5 and < ItemType.KeycardCustomTaskForce) continue;
if (playerItem.Base is not KeycardItem keycardItem)
{
continue;
}
if (playerItem.Base is not KeycardItem keycardItem) continue;
if (!AlphaWarheadActivationPanel.Instance.CheckPermissions(keycardItem, out _)) continue;
ev.IsAllowed = true;
@ -161,25 +124,14 @@ namespace KeycardButModern
foreach (var hit in hits)
{
ButtonVariant doorButton = hit.collider.GetComponent<LcdButton>();
if (!doorButton)
{
doorButton = hit.collider.GetComponent<CheckpointKeycardButton>();
}
if (!doorButton)
{
doorButton = hit.collider.GetComponent<KeycardButton>();
}
if (!doorButton)
{
doorButton = hit.collider.GetComponent<SimpleButton>();
}
if (!doorButton) doorButton = hit.collider.GetComponent<CheckpointKeycardButton>();
if (!doorButton) doorButton = hit.collider.GetComponent<KeycardButton>();
if (!doorButton) doorButton = hit.collider.GetComponent<SimpleButton>();
if (!doorButton)
{
continue;
}
if (!doorButton) continue;
var doorVariant = DoorVariant.AllDoors.AsEnumerable()!.First(x => x.Buttons.Any(c=>c.GetInstanceID() == doorButton.GetInstanceID()));
var doorVariant = DoorVariant.AllDoors.AsEnumerable()!.First(x =>
x.Buttons.Any(c => c.GetInstanceID() == doorButton.GetInstanceID()));
doorVariant.ServerInteract(ev.Player.ReferenceHub, doorButton.ColliderId);
StartDoorLockCoroutine(doorVariant);
@ -199,7 +151,6 @@ namespace KeycardButModern
PlayerEvents.UnlockingWarheadButton += OnUnlockingWarhead;
PlayerEvents.PlacedBulletHole += OnBulletHole;
}
private static void StartDoorLockCoroutine(DoorVariant door)
@ -230,4 +181,3 @@ namespace KeycardButModern
Singleton = null;
}
}
}

View File

@ -2,8 +2,8 @@
using LabApi.Features;
using LabApi.Loader.Features.Plugins;
namespace LogEvents
{
namespace LogEvents;
internal class LogPlugin : Plugin
{
public override string Name { get; } = "LogPlugin";
@ -12,9 +12,9 @@ namespace LogEvents
public override string Author { get; } = "Northwood";
public override Version Version { get; } = new Version(1, 0, 0, 0);
public override Version Version { get; } = new(1, 0, 0, 0);
public override Version RequiredApiVersion { get; } = new Version(LabApiProperties.CompiledVersion);
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public MyCustomEventsHandler Events { get; } = new();
@ -28,4 +28,3 @@ namespace LogEvents
CustomHandlersManager.UnregisterEventsHandler(Events);
}
}
}

View File

@ -723,7 +723,8 @@ internal class MyCustomEventsHandler : CustomEventsHandler
public override void OnPlayerStayingInHazard(PlayersStayingInHazardEventArgs ev)
{
Logger.Info($"{nameof(OnPlayerStayingInHazard)} triggered by {string.Join(", ", ev.AffectedPlayers.Select(x => x.UserId))}");
Logger.Info(
$"{nameof(OnPlayerStayingInHazard)} triggered by {string.Join(", ", ev.AffectedPlayers.Select(x => x.UserId))}");
}
public override void OnPlayerLeavingHazard(PlayerLeavingHazardEventArgs ev)
@ -1397,5 +1398,4 @@ internal class MyCustomEventsHandler : CustomEventsHandler
// }
#endregion
}

View File

@ -23,18 +23,6 @@
<Reference Include="Assembly-CSharp">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@ -1,5 +1,4 @@
using System.Runtime.Serialization;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features.Console;
@ -9,6 +8,11 @@ namespace RangeBan;
public class RangeBan : Plugin<RangeBanConfig>
{
public override string Name => "RangeBan";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Ban IP Ranges with ease";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public override void Enable()
{
@ -26,16 +30,11 @@ public class RangeBan: Plugin<RangeBanConfig>
{
Logger.Debug($"Ranges: {string.Join(" ; ", Config!.IpRanges)}");
if (!Config!.IpRanges.Any(configIpRange => IsInRange(configIpRange, ev.IpAddress))) return;
ev.RejectCustom("Your IP belongs to a banned player, please contact the server administrator for more information.");
ev.RejectCustom(
"Your IP belongs to a banned player, please contact the server administrator for more information.");
Logger.Warn($"Player with IP {ev.IpAddress} got kicked. UserId: {ev.UserId}");
}
public override string Name => "RangeBan";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Ban IP Ranges with ease";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public static bool IsInRange(string range, string ip)
{
@ -46,29 +45,24 @@ public class RangeBan: Plugin<RangeBanConfig>
if (!range.Contains("/"))
{
//We only handle direct IPs and CIDR
if (range.Split('.').Length != 4)
{
return false;
}
if (range.Split('.').Length != 4) return false;
return ip == range;
};
}
;
var parts = range.Split('/');
if (parts.Length != 2 || !int.TryParse(parts[1], out var cidrBits))
return false;
if (cidrBits > 32)
{
return false;
}
if (cidrBits > 32) return false;
var networkAddress = IPToUInt32(parts[0]);
var mask = uint.MaxValue << (32 - cidrBits);
var ipAddress = IPToUInt32(ip);
return (ipAddress & mask) == (networkAddress & mask);
}
private static uint IPToUInt32(string ipAddress)
@ -84,6 +78,7 @@ public class RangeBan: Plugin<RangeBanConfig>
throw new ArgumentException("Invalid IP address segment");
result = (result << 8) | part;
}
return result;
}
}

View File

@ -19,18 +19,6 @@
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Northwood.LabAPI" Version="1.0.2"/>
</ItemGroup>

View File

@ -12,20 +12,20 @@ using PlayerRoles.PlayableScps.Scp096;
using PlayerRoles.PlayableScps.Scp3114;
using Timer = System.Timers.Timer;
namespace SCPTeamHint
{
namespace SCPTeamHint;
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
{
private readonly object _hintsLock = new();
private readonly Dictionary<Player, Hint> _spectatorHints = new();
private Timer _timer;
public override string Name => "SCPTeamHint";
public override string Author => "HoherGeist, Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "Displays information about your SCP Teammates";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
private Timer _timer;
private readonly object _hintsLock = new();
private readonly Dictionary<Player,Hint> _spectatorHints = new();
public override void Enable()
{
Logger.Debug("Apple juice");
@ -52,8 +52,6 @@ namespace SCPTeamHint
lock (_hintsLock)
{
foreach (var player in Player.ReadyList.Where(x => !x.IsHost && !x.IsDummy && x.IsSCP))
{
var text =
@ -115,12 +113,10 @@ namespace SCPTeamHint
return;
}
Logger.Debug($"Player {player.Nickname} is on team {player.RoleBase.Team} | hide: {player.RoleBase.Team != Team.SCPs}");
Logger.Debug(
$"Player {player.Nickname} is on team {player.RoleBase.Team} | hide: {player.RoleBase.Team != Team.SCPs}");
hint.Hide = player.RoleBase.Team != Team.SCPs;
if (!hint.Hide)
{
hint.Text = hintText;
}
if (!hint.Hide) hint.Text = hintText;
}
private void OnJoin(PlayerJoinedEventArgs ev)
@ -139,7 +135,6 @@ namespace SCPTeamHint
{
_spectatorHints[ev.Player] = hint;
}
}
private void OnLeft(PlayerLeftEventArgs ev)
@ -152,4 +147,3 @@ namespace SCPTeamHint
}
}
}
}

View File

@ -20,17 +20,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Northwood.LabAPI" Version="1.0.2"/>
</ItemGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\dependencies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference>

View File

@ -1,5 +1,4 @@
using LabApi.Events.Handlers;
using LabApi.Features;
using LabApi.Features;
using LabApi.Loader.Features.Plugins;
namespace ScpSwap;
@ -18,6 +17,5 @@ public class ScpSwap : Plugin
public override void Disable()
{
}
}

View File

@ -40,7 +40,7 @@ public class SwapCommand : ICommand
"096",
"106",
"173",
"939",
"939"
];
var arg = arguments.First();
@ -51,7 +51,8 @@ public class SwapCommand : ICommand
return false;
}
if (Player.List.Where(x=>x.IsSCP).Select(x=>x.RoleBase).Any(playerRole => playerRole.RoleName == "SCP-" + arg))
if (Player.List.Where(x => x.IsSCP).Select(x => x.RoleBase)
.Any(playerRole => playerRole.RoleName == "SCP-" + arg))
{
response = "Already exists";
return false;

View File

@ -8,8 +8,8 @@ using UnityEngine;
using Logger = LabApi.Features.Console.Logger;
using TimedGrenadePickup = InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup;
namespace SensitiveGrenades
{
namespace SensitiveGrenades;
public class SensitiveGrenades : Plugin
{
public override string Name => "SensitiveGrenades";
@ -50,4 +50,3 @@ namespace SensitiveGrenades
Logger.Debug("unloading...");
}
}
}

View File

@ -30,9 +30,6 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>

View File

@ -36,16 +36,14 @@ public class ServerHints: Plugin
{
ServerEvents.RoundStarted -= OnRoundStarted;
}
private void OnRoundStarted()
{
var random = new Random();
var hint = Hints[random.Next(Hints.Length)];
Timing.CallDelayed(1, () =>
{
foreach (var player in Player.ReadyList)
{
player.SendBroadcast($"<color=grey>{hint}</color>", 3);
}
foreach (var player in Player.ReadyList) player.SendBroadcast($"<color=grey>{hint}</color>", 3);
});
}
}

View File

@ -26,15 +26,9 @@
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib">
<HintPath>..\dependencies\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>

View File

@ -1,5 +1,4 @@
using HintServiceMeow.Core.Enum;
using HintServiceMeow.Core.Models.HintContent;
using HintServiceMeow.Core.Models.Hints;
using HintServiceMeow.Core.Utilities;
using LabApi.Events.Arguments.PlayerEvents;
@ -9,75 +8,13 @@ using LabApi.Features.Console;
using LabApi.Features.Wrappers;
using LabApi.Loader.Features.Plugins;
using PlayerRoles;
using PlayerRoles.Spectating;
using Timer = System.Timers.Timer;
namespace VisibleSpectators
{
namespace VisibleSpectators;
public class Plugin : Plugin<SpectatorConfig>
{
public override string Name => "VisibleSpectators";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "See your spectators";
public override Version RequiredApiVersion { get; } = new (LabApiProperties.CompiledVersion);
public int YCoordinate { get; set; } = 100;
private static Plugin _singleton;
private Timer _timer;
private readonly Dictionary<Player,Hint> _spectatorHints = new();
public override void Enable()
{
Logger.Debug("starting...");
_singleton = this;
PlayerEvents.ChangedSpectator += OnSpectate;
PlayerEvents.Joined += OnJoin;
_timer = new Timer(1000);
_timer.Elapsed += (_, _) => UpdateSpectators();
_timer.Start();
}
public override void Disable()
{
Logger.Debug("unloading...");
_timer.Stop();
_timer.Dispose();
_timer = null;
PlayerEvents.Joined -= OnJoin;
PlayerEvents.ChangedSpectator -= OnSpectate;
_singleton = null;
}
private void UpdateSpectators()
{
foreach (var player in GetPlayers())
{
UpdateSpectators(player);
}
}
private void AddPlayerHint(Player player)
{
var hint = new Hint
{
Text = $"{Config!.HeaderMessage}\n{Config!.NoSpectatorsMessage}",
Alignment = HintAlignment.Right,
YCoordinate = YCoordinate,
Hide = true
};
var playerDisplay = PlayerDisplay.Get(player);
playerDisplay.AddHint(hint);
_spectatorHints[player] = hint;
}
private static readonly Dictionary<string, string> GetColorMap = new()
{
@ -113,6 +50,64 @@ namespace VisibleSpectators
{ "GOLD", "EFC01A" }
};
private readonly Dictionary<Player, Hint> _spectatorHints = new();
private Timer _timer;
public override string Name => "VisibleSpectators";
public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0);
public override string Description => "See your spectators";
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
public int YCoordinate { get; set; } = 100;
public override void Enable()
{
Logger.Debug("starting...");
_singleton = this;
PlayerEvents.ChangedSpectator += OnSpectate;
PlayerEvents.Joined += OnJoin;
_timer = new Timer(1000);
_timer.Elapsed += (_, _) => UpdateSpectators();
_timer.Start();
}
public override void Disable()
{
Logger.Debug("unloading...");
_timer.Stop();
_timer.Dispose();
_timer = null;
PlayerEvents.Joined -= OnJoin;
PlayerEvents.ChangedSpectator -= OnSpectate;
_singleton = null;
}
private void UpdateSpectators()
{
foreach (var player in GetPlayers()) UpdateSpectators(player);
}
private void AddPlayerHint(Player player)
{
var hint = new Hint
{
Text = $"{Config!.HeaderMessage}\n{Config!.NoSpectatorsMessage}",
Alignment = HintAlignment.Right,
YCoordinate = YCoordinate,
Hide = true
};
var playerDisplay = PlayerDisplay.Get(player);
playerDisplay.AddHint(hint);
_spectatorHints[player] = hint;
}
private static string PlayerToDisplay(Player player)
{
if (player == null) return "";
@ -127,7 +122,9 @@ namespace VisibleSpectators
if (string.IsNullOrEmpty(groupColor))
return $"<color=#{defaultColor}FF>{player.DisplayName}</color>";
return GetColorMap.TryGetValue(groupColor.ToUpper(), out var color) ? $"<color=#{color}FF>{player.DisplayName}</color>" : $"<color=#{defaultColor}FF>{player.DisplayName}</color>";
return GetColorMap.TryGetValue(groupColor.ToUpper(), out var color)
? $"<color=#{color}FF>{player.DisplayName}</color>"
: $"<color=#{defaultColor}FF>{player.DisplayName}</color>";
}
catch
{
@ -143,10 +140,7 @@ namespace VisibleSpectators
private void UpdateSpectators(Player player)
{
// Safety check - if player doesn't have a hint, create one
if (!_spectatorHints.ContainsKey(player))
{
AddPlayerHint(player);
}
if (!_spectatorHints.ContainsKey(player)) AddPlayerHint(player);
var spectators = Config!.NoSpectatorsMessage;
@ -159,15 +153,13 @@ namespace VisibleSpectators
: string.Join("\n",
player.CurrentlySpectating?.CurrentSpectators.Where(IsNotOverwatch)
.Select(PlayerToDisplay) ?? Array.Empty<string>());
} catch (Exception e)
}
catch (Exception e)
{
Logger.Error(e);
}
if (spectators.Length < 2)
{
spectators = Config!.NoSpectatorsMessage;
}
if (spectators.Length < 2) spectators = Config!.NoSpectatorsMessage;
_spectatorHints[player].Text = $"{Config!.HeaderMessage}\n{spectators}";
@ -200,4 +192,3 @@ namespace VisibleSpectators
public string HeaderMessage { get; set; } = "Spectators:";
public string NoSpectatorsMessage { get; set; } = "No spectators";
}
}

View File

@ -20,9 +20,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\dependencies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>

View File

@ -21,7 +21,6 @@ public class WarheadEvents : Plugin
public override void Disable()
{
}
private static void OnExplode(WarheadDetonatedEventArgs ev)

View File

@ -23,15 +23,9 @@
<Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\dependencies\Mirror.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>..\dependencies\Pooling.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
</Reference>