Skip to content

Commit

Permalink
Fix AHP Process
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Sep 24, 2022
1 parent 4d9d705 commit d40c76a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
38 changes: 26 additions & 12 deletions EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using Interactables.Interobjects.DoorUtils;
using PlayerStatsSystem;
using Tesla = Exiled.API.Features.TeslaGate;
using Interactables.Interobjects;
using Exiled.API.Enums;

namespace FacilityManagement
{
public class EventHandlers
Expand Down Expand Up @@ -57,11 +60,11 @@ public void OnUsingRadioBattery(UsingRadioBatteryEventArgs ev)
ev.Drain *= plugin.Config.EnergyRadio;
}

public void OnSpawning(SpawningEventArgs ev)
public void OnSpawned(SpawnedEventArgs ev)
{
if (plugin.Config.RoleTypeHumeShield is not null && plugin.Config.RoleTypeHumeShield.TryGetValue(ev.Player.Role.Type, out AhpProccessBuild ahpProccessBuild))
{
ev.Player.ActiveArtificialHealthProcesses.ToList().RemoveAll(x => true);
((AhpStat)ev.Player.ReferenceHub.playerStats.StatModules[1])._activeProcesses.Clear();
ev.Player.AddAhp(ahpProccessBuild.Amount, ahpProccessBuild.Amount, -ahpProccessBuild.Regen, ahpProccessBuild.Efficacy, ahpProccessBuild.Sustain, ahpProccessBuild.Regen > 0);
}
}
Expand Down Expand Up @@ -158,20 +161,31 @@ public void CustomDoor()
{
foreach (Door door in Door.List)
{
if (plugin.Config.CustomDoors.TryGetValue(door.Type, out DoorBuild doorBuild))
if (door.Base is CheckpointDoor checkpoint)
{
if (doorBuild.Health is not null)
door.Health = doorBuild.Health.Value;
if (doorBuild.DamageTypeIgnored is not 0)
door.IgnoredDamageTypes = doorBuild.DamageTypeIgnored;
if (doorBuild.RequiredPermission is not 0)
door.RequiredPermissions.RequiredPermissions = doorBuild.RequiredPermission;
if (doorBuild.RequireAllPermission is not null)
door.RequiredPermissions.RequireAll = doorBuild.RequireAllPermission.Value;
foreach (DoorVariant checpointdoor in checkpoint._subDoors)
{
CustomDoorSet(Door.Get(checpointdoor), door.Type);
}
continue;
}
CustomDoorSet(door, door.Type);
}
}
public void CustomDoorSet(Door door, DoorType type)
{
if (plugin.Config.CustomDoors.TryGetValue(type, out DoorBuild doorBuild))
{
if (doorBuild.Health is not null)
door.Health = doorBuild.Health.Value;
if (doorBuild.DamageTypeIgnored is not 0)
door.IgnoredDamageTypes = doorBuild.DamageTypeIgnored;
if (doorBuild.RequiredPermission is not 0)
door.RequiredPermissions.RequiredPermissions = doorBuild.RequiredPermission;
if (doorBuild.RequireAllPermission is not null)
door.RequiredPermissions.RequireAll = doorBuild.RequireAllPermission.Value;
}
}

public void CustomLift()
{
foreach (Exiled.API.Features.Lift lift in Exiled.API.Features.Lift.List)
Expand Down
3 changes: 0 additions & 3 deletions FacilityManagement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
<Reference Include="Exiled.API">
<HintPath>C:\Users\louismonneyronpc\AppData\Roaming\EXILED\Plugins\dependencies\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.Bootstrap">
<HintPath>C:\Users\louismonneyronpc\AppData\Roaming\EXILED\Plugins\Exiled.Bootstrap.dll</HintPath>
</Reference>
<Reference Include="Exiled.CreditTags">
<HintPath>C:\Users\louismonneyronpc\AppData\Roaming\EXILED\Plugins\Exiled.CreditTags.dll</HintPath>
</Reference>
Expand Down
4 changes: 2 additions & 2 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void RegisterEvents()
Player.Shooting += EventHandlers.OnShooting;
Player.UsingMicroHIDEnergy += EventHandlers.OnUsingMicroHIDEnergy;
Player.UsingRadioBattery += EventHandlers.OnUsingRadioBattery;
Player.Spawning += EventHandlers.OnSpawning;
Player.Spawned += EventHandlers.OnSpawned;
Player.Hurting += EventHandlers.OnHurting;
Player.EnteringFemurBreaker += EventHandlers.OnEnteringFemurBreaker;

Expand All @@ -75,7 +75,7 @@ private void UnRegisterEvents()
Player.Shooting -= EventHandlers.OnShooting;
Player.UsingMicroHIDEnergy -= EventHandlers.OnUsingMicroHIDEnergy;
Player.UsingRadioBattery -= EventHandlers.OnUsingRadioBattery;
Player.Spawning -= EventHandlers.OnSpawning;
Player.Spawned -= EventHandlers.OnSpawned;
Player.Hurting -= EventHandlers.OnHurting;
Player.EnteringFemurBreaker -= EventHandlers.OnEnteringFemurBreaker;

Expand Down

0 comments on commit d40c76a

Please sign in to comment.