Skip to content

Commit

Permalink
Merge branch 'dev' into DisruptorEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfr0676 authored Jan 13, 2025
2 parents 80fe620 + 5dc7ad5 commit 8a231fd
Show file tree
Hide file tree
Showing 23 changed files with 401 additions and 41 deletions.
63 changes: 63 additions & 0 deletions EXILED/Exiled.API/Enums/LockerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Exiled.API.Enums
{
using System;

/// <summary>
/// Unique identifier for different types of <see cref="Features.Lockers.Locker"/>s.
/// </summary>
Expand All @@ -15,6 +17,7 @@ public enum LockerType
/// <summary>
/// The pedestal used by SCP items.
/// </summary>
[Obsolete("This value is not used.")]
Pedestal,

/// <summary>
Expand Down Expand Up @@ -46,5 +49,65 @@ public enum LockerType
/// Unknow type of locker.
/// </summary>
Unknow,

/// <summary>
/// MircoHid pedestal.
/// </summary>
MicroHid,

/// <summary>
/// Experimental weapon locker.
/// </summary>
ExperimentalWeapon,

/// <summary>
/// SCP-500 pedestal.
/// </summary>
Scp500Pedestal,

/// <summary>
/// SCP-207? (Anti SCP-207) pedestal.
/// </summary>
AntiScp207Pedestal,

/// <summary>
/// SCP-207 pedestal.
/// </summary>
Scp207Pedestal,

/// <summary>
/// SCP-268 pedestal.
/// </summary>
Scp268Pedestal,

/// <summary>
/// SCP-1344 pedestal.
/// </summary>
Scp1344Pedestal,

/// <summary>
/// SCP-018 pedestal.
/// </summary>
Scp018Pedestal,

/// <summary>
/// SCP-1576 pedestal.
/// </summary>
Scp1576Pedestal,

/// <summary>
/// SCP-244 pedestal.
/// </summary>
Scp244Pedestal,

/// <summary>
/// SCP-2176 pedestal.
/// </summary>
Scp2176Pedestal,

/// <summary>
/// SCP-1853 pedestal.
/// </summary>
Scp1853Pedestal,
}
}
15 changes: 13 additions & 2 deletions EXILED/Exiled.API/Extensions/LockerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,25 @@ public static class LockerExtensions
/// </summary>
/// <param name="name">The name to check.</param>
/// <returns>The corresponding <see cref="LockerType"/>.</returns>
public static LockerType GetLockerTypeByName(this string name) => name.Replace("(Clone)", string.Empty) switch
public static LockerType GetLockerTypeByName(this string name) => name.Split('(')[0].Trim() switch
{
"Scp500PedestalStructure Variant" => LockerType.Pedestal,
"Scp500PedestalStructure Variant" => LockerType.Scp500Pedestal,
"AntiScp207PedestalStructure Variant" => LockerType.AntiScp207Pedestal,
"Scp207PedestalStructure Variant" => LockerType.Scp207Pedestal,
"Experimental Weapon Locker" => LockerType.ExperimentalWeapon,
"Scp1344PedestalStructure Variant" => LockerType.Scp1344Pedestal,
"Scp1576PedestalStructure Variant" => LockerType.Scp1576Pedestal,
"Scp2176PedestalStructure Variant" => LockerType.Scp2176Pedestal,
"Scp1853PedestalStructure Variant" => LockerType.Scp1853Pedestal,
"Scp268PedestalStructure Variant" => LockerType.Scp268Pedestal,
"Scp244PedestalStructure Variant" => LockerType.Scp244Pedestal,
"Scp018PedestalStructure Variant" => LockerType.Scp018Pedestal,
"LargeGunLockerStructure" => LockerType.LargeGun,
"RifleRackStructure" => LockerType.RifleRack,
"MiscLocker" => LockerType.Misc,
"RegularMedkitStructure" => LockerType.Medkit,
"AdrenalineMedkitStructure" => LockerType.Adrenaline,
"MicroHIDpedestal" => LockerType.MicroHid,
_ => LockerType.Unknow,
};
}
Expand Down
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Features/CustomHealthStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Exiled.API.Features

/// <summary>
/// A custom version of <see cref="HealthStat"/> which allows the player's max amount of health to be changed.
/// TODO: Move to Features.CustomStats.
/// </summary>
public class CustomHealthStat : HealthStat
{
Expand Down
79 changes: 79 additions & 0 deletions EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// -----------------------------------------------------------------------
// <copyright file="CustomHumeShieldStat.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Features.CustomStats
{
using Mirror;
using PlayerRoles.PlayableScps.HumeShield;
using PlayerStatsSystem;
using UnityEngine;
using Utils.Networking;

/// <summary>
/// A custom version of <see cref="HumeShieldStat"/> which allows the player's max amount of HumeShield to be changed.
/// </summary>
public class CustomHumeShieldStat : HumeShieldStat
{
/// <inheritdoc />
public override float MaxValue => CustomMaxValue == -1 ? base.MaxValue : CustomMaxValue;

/// <summary>
/// Gets or sets the multiplier for gaining HumeShield.
/// </summary>
public float ShieldRegenerationMultiplier { get; set; } = 1;

/// <summary>
/// Gets or sets the maximum amount of HumeShield the player can have.
/// </summary>
public float CustomMaxValue { get; set; } = -1;

private float ShieldRegeneration => TryGetHsModule(out HumeShieldModuleBase controller) ? controller.HsRegeneration * ShieldRegenerationMultiplier : 0;

/// <inheritdoc/>
public override void Update()
{
if (MaxValue == -1 && ShieldRegenerationMultiplier is 1)
{
base.Update();
return;
}

if (!NetworkServer.active)
return;

if (_valueDirty)
{
new SyncedStatMessages.StatMessage()
{
Stat = this,
SyncedValue = CurValue,
}.SendToHubsConditionally(CanReceive);
_lastSent = CurValue;
_valueDirty = false;
}

if (ShieldRegeneration == 0)
return;

float delta = ShieldRegeneration * Time.deltaTime;

if (delta > 0)
{
if (CurValue >= MaxValue)
return;

CurValue = Mathf.MoveTowards(CurValue, MaxValue, delta);
return;
}

if (CurValue <= 0)
return;

CurValue += delta;
}
}
}
8 changes: 7 additions & 1 deletion EXILED/Exiled.API/Features/Doors/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,13 @@ private DoorType GetDoorType()
// Doors contains the DoorNameTagExtension component
"CHECKPOINT_LCZ_A" => DoorType.CheckpointLczA,
"CHECKPOINT_LCZ_B" => DoorType.CheckpointLczB,
"CHECKPOINT_EZ_HCZ_A" => DoorType.CheckpointEzHczA,

// TODO: Remove when it's fix https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/782
"CHECKPOINT_EZ_HCZ_A" => Room?.Type switch
{
RoomType.HczEzCheckpointA => DoorType.CheckpointEzHczA,
_ => DoorType.CheckpointEzHczB,
},
"CHECKPOINT_EZ_HCZ_B" => DoorType.CheckpointEzHczB,
"106_PRIMARY" => DoorType.Scp106Primary,
"106_SECONDARY" => DoorType.Scp106Secondary,
Expand Down
11 changes: 9 additions & 2 deletions EXILED/Exiled.API/Features/Lockers/Locker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Vector3 RandomChamberPosition
Chamber randomChamber = Chambers.GetRandomValue();

// Determine if the chamber uses multiple spawn points and has at least one available spawn point.
if (randomChamber.UseMultipleSpawnpoints && randomChamber.Spawnpoints.Count() > 0)
if (randomChamber.UseMultipleSpawnpoints && randomChamber.Spawnpoints.Any())
{
// Return the position of a random spawn point within the chamber.
return randomChamber.Spawnpoints.GetRandomValue().position;
Expand All @@ -136,11 +136,18 @@ public Vector3 RandomChamberPosition
/// <returns>The <see cref="Locker"/> with the given <see cref="ZoneType"/> or <see langword="null"/> if not found.</returns>
public static IEnumerable<Locker> Get(ZoneType zoneType) => Get(room => room.Zone.HasFlag(zoneType));

/// <summary>
/// Gets an <see cref="IEnumerable{T}"/> of <see cref="Locker"/> given the specified <see cref="LockerType"/>.
/// </summary>
/// <param name="lockerType">The <see cref="LockerType"/> to search for.</param>
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="Locker"/> which contains elements that satisfy the condition.</returns>
public static IEnumerable<Locker> Get(LockerType lockerType) => Get(x => x.Type == lockerType);

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of <see cref="Locker"/> filtered based on a predicate.
/// </summary>
/// <param name="predicate">The condition to satify.</param>
/// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Locker"/> which contains elements that satify the condition.</returns>
/// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Locker"/> which contains elements that satisfy the condition.</returns>
public static IEnumerable<Locker> Get(Func<Locker, bool> predicate) => List.Where(predicate);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ign

Timing.CallDelayed(0.5f, () =>
{
npc.Role.Set(role, SpawnReason.RoundStart, position is null ? RoleSpawnFlags.All : RoleSpawnFlags.AssignInventory);
npc.Role.Set(role, SpawnReason.ForceClass, position is null ? RoleSpawnFlags.All : RoleSpawnFlags.AssignInventory);

if (position is not null)
npc.Position = position.Value;
Expand Down
24 changes: 23 additions & 1 deletion EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Exiled.API.Features
using DamageHandlers;
using Enums;
using Exiled.API.Features.Core.Interfaces;
using Exiled.API.Features.CustomStats;
using Exiled.API.Features.Doors;
using Exiled.API.Features.Hazards;
using Exiled.API.Features.Items;
Expand Down Expand Up @@ -96,6 +97,7 @@ public class Player : TypeCastObject<Player>, IEntity, IWorldSpace

private ReferenceHub referenceHub;
private CustomHealthStat healthStat;
private CustomHumeShieldStat humeShieldStat;
private Role role;

/// <summary>
Expand Down Expand Up @@ -177,6 +179,7 @@ private set
CameraTransform = value.PlayerCameraReference;

value.playerStats._dictionarizedTypes[typeof(HealthStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HealthStat))] = healthStat = new CustomHealthStat { Hub = value };
value.playerStats._dictionarizedTypes[typeof(HumeShieldStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HumeShieldStat))] = humeShieldStat = new CustomHumeShieldStat { Hub = value };
}
}

Expand Down Expand Up @@ -930,15 +933,34 @@ public float HumeShield
set => HumeShieldStat.CurValue = value;
}

/// <summary>
/// Gets or sets the players maximum Hume Shield.
/// </summary>
public float MaxHumeShield
{
get => humeShieldStat.MaxValue;
set => humeShieldStat.CustomMaxValue = value;
}

/// <summary>
/// Gets or sets the players multiplier for gaining HumeShield.
/// </summary>
public float HumeShieldRegenerationMultiplier
{
get => humeShieldStat.ShieldRegenerationMultiplier;
set => humeShieldStat.ShieldRegenerationMultiplier = value;
}

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of all active Artificial Health processes on the player.
/// </summary>
public IEnumerable<AhpStat.AhpProcess> ActiveArtificialHealthProcesses => ReferenceHub.playerStats.GetModule<AhpStat>()._activeProcesses;

/// <summary>
/// Gets the player's <see cref="PlayerStatsSystem.HumeShieldStat"/>.
/// TODO: Change to <see cref="CustomHumeShieldStat"/>.
/// </summary>
public HumeShieldStat HumeShieldStat => ReferenceHub.playerStats.GetModule<HumeShieldStat>();
public HumeShieldStat HumeShieldStat => humeShieldStat;

/// <summary>
/// Gets or sets the item in the player's hand. Value will be <see langword="null"/> if the player is not holding anything.
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,12 @@ private static RoomType FindType(GameObject gameObject)
"EZ_Shelter" => RoomType.EzShelter,
"EZ_HCZ_Checkpoint Part" => gameObject.transform.position.z switch
{
> 80 => RoomType.EzCheckpointHallwayA,
> 95 => RoomType.EzCheckpointHallwayA,
_ => RoomType.EzCheckpointHallwayB,
},
"HCZ_EZ_Checkpoint Part" => gameObject.transform.position.z switch
{
> 80 => RoomType.HczEzCheckpointA,
> 95 => RoomType.HczEzCheckpointA,
_ => RoomType.HczEzCheckpointB
},
_ => RoomType.Unknown,
Expand Down
Loading

0 comments on commit 8a231fd

Please sign in to comment.