Skip to content

Commit

Permalink
Dont generate spawns on SD or if invulnerable
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Aug 24, 2024
1 parent a608476 commit e718016
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mod/Jailbreak.Zones/RandomZoneGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
using CounterStrikeSharp.API.Modules.Timers;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
using Jailbreak.Public.Mod.Zones;
using Jailbreak.Public.Utils;
using Microsoft.Extensions.DependencyInjection;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;

namespace Jailbreak.Zones;

public class RandomZoneGenerator(IZoneManager zoneManager, IZoneFactory factory)
: IPluginBehavior {
public class RandomZoneGenerator(IZoneManager zoneManager, IZoneFactory factory,
IServiceProvider provider) : IPluginBehavior {
private IZone? cells;
private string? currentMap;
private IList<IZone>? manualSpawnPoints;
Expand Down Expand Up @@ -44,13 +46,17 @@ private void reload() {
private void tick() {
if (currentMap != Server.MapName) reload();
currentMap = Server.MapName;

var sdManager = provider.GetService<ISpecialDayManager>();
if (sdManager is { IsSDRunning: true }) return;

foreach (var player in PlayerUtil.GetAlive()) tick(player);
}

private void tick(CCSPlayerController player) {
var pawn = player.PlayerPawn.Value;
if (pawn == null) return;
if (!pawn.OnGroundLastTick) return;
if (!pawn.OnGroundLastTick || !pawn.TakesDamage) return;
var pos = pawn.AbsOrigin;
if (pos == null) return;
pos = pos.Clone();
Expand Down

0 comments on commit e718016

Please sign in to comment.