Skip to content

Commit

Permalink
halloween
Browse files Browse the repository at this point in the history
  • Loading branch information
xNexusACS committed Oct 22, 2024
1 parent f620d33 commit 1fa8659
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 22 deletions.
8 changes: 8 additions & 0 deletions Exiled.API/Enums/DamageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,13 @@ public enum DamageType
/// Damage caused by the marshmallow man.
/// </summary>
Marshmallow,

#pragma warning disable CS1591 // Missing XML documentation
#pragma warning disable SA1602 // Enumeration items should be documented
Silent,

MetalPipe,
#pragma warning restore SA1602 // Enumeration items should be documented
#pragma warning restore CS1591 // Missing XML documentation
}
}
26 changes: 25 additions & 1 deletion Exiled.API/Enums/EffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public enum EffectType
/// <summary>
/// Makes you a marshmallow guy.
/// </summary>
[Obsolete("Not functional in-game")]
Marshmallow,

/// <summary>
Expand All @@ -239,5 +238,30 @@ public enum EffectType
/// <see cref="CustomPlayerEffects.Slowness"/>.
/// </summary>
Slowness,

/// <summary>
/// Effect given when eating the orange candy.
/// </summary>
OrangeCandy,

#pragma warning disable CS1591 // Missing XML documentation
#pragma warning disable SA1602 // Enumeration items should be documented
Spicy,

SugarCrave,

SugarHigh,

SugarRush,

TraumatizedByEvil,

Metal,

Prismatic,

SlowMetabolism,
#pragma warning restore SA1602 // Enumeration items should be documented
#pragma warning restore CS1591 // Missing XML documentation
}
}
6 changes: 6 additions & 0 deletions Exiled.API/Extensions/DamageTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static class DamageTypeExtensions
{ DeathTranslations.MicroHID.Id, DamageType.MicroHid },
{ DeathTranslations.Hypothermia.Id, DamageType.Hypothermia },
{ DeathTranslations.MarshmallowMan.Id, DamageType.Marshmallow },
{ DeathTranslations.MetalPipe.Id, DamageType.MetalPipe },
};

private static readonly Dictionary<DeathTranslation, DamageType> TranslationConversionInternal = new()
Expand Down Expand Up @@ -80,6 +81,7 @@ public static class DamageTypeExtensions
{ DeathTranslations.MicroHID, DamageType.MicroHid },
{ DeathTranslations.Hypothermia, DamageType.Hypothermia },
{ DeathTranslations.MarshmallowMan, DamageType.Marshmallow },
{ DeathTranslations.MetalPipe, DamageType.MetalPipe },
};

private static readonly Dictionary<ItemType, DamageType> ItemConversionInternal = new()
Expand Down Expand Up @@ -164,6 +166,10 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase)
{
case CustomReasonDamageHandler:
return DamageType.Custom;
case SilentDamageHandler:
return DamageType.Silent;
case MetalPipeDamageHandler:
return DamageType.MetalPipe;
case WarheadDamageHandler:
return DamageType.Warhead;
case ExplosionDamageHandler:
Expand Down
11 changes: 9 additions & 2 deletions Exiled.API/Extensions/EffectTypeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ public static class EffectTypeExtension
{ EffectType.AntiScp207, typeof(AntiScp207) },
{ EffectType.Scanned, typeof(Scanned) },
{ EffectType.SilentWalk, typeof(SilentWalk) },
#pragma warning disable CS0618
{ EffectType.Marshmallow, typeof(MarshmallowEffect) },
#pragma warning restore CS0618
{ EffectType.Strangled, typeof(Strangled) },
{ EffectType.Ghostly, typeof(Ghostly) },
{ EffectType.FogControl, typeof(FogControl) },
{ EffectType.Slowness, typeof(Slowness) },
{ EffectType.OrangeCandy, typeof(OrangeCandy) },
{ EffectType.Spicy, typeof(Spicy) },
{ EffectType.SugarCrave, typeof(SugarCrave) },
{ EffectType.SugarHigh, typeof(SugarHigh) },
{ EffectType.SugarRush, typeof(SugarRush) },
{ EffectType.Metal, typeof(Metal) },
{ EffectType.TraumatizedByEvil, typeof(TraumatizedByEvil) },
{ EffectType.Prismatic, typeof(Prismatic) },
{ EffectType.SlowMetabolism, typeof(SlowMetabolism) },
});

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Exiled.API/Features/Hazards/Hazard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public static Hazard Get(EnvironmentalHazard environmentalHazard) =>
TantrumEnvironmentalHazard tantrumEnvironmentalHazard => new TantrumHazard(tantrumEnvironmentalHazard),
Scp939AmnesticCloudInstance scp939AmnesticCloudInstance => new AmnesticCloudHazard(scp939AmnesticCloudInstance),
SinkholeEnvironmentalHazard sinkholeEnvironmentalHazard => new SinkholeHazard(sinkholeEnvironmentalHazard),
PrismaticCloud prismaticCloudHazard => new PrismaticCloudHazard(prismaticCloudHazard),
global::Hazards.TemporaryHazard temporaryHazard => new TemporaryHazard(temporaryHazard),
_ => new Hazard(environmentalHazard)
};
Expand Down
42 changes: 42 additions & 0 deletions Exiled.API/Features/Hazards/PrismaticCloudHazard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// -----------------------------------------------------------------------
// <copyright file="PrismaticCloudHazard.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Features.Hazards
{
using global::Hazards;
using RelativePositioning;

/// <summary>
/// A wrapper for <see cref="PrismaticCloudHazard"/>.
/// </summary>
public class PrismaticCloudHazard : TemporaryHazard
{
/// <summary>
/// Initializes a new instance of the <see cref="PrismaticCloudHazard"/> class.
/// </summary>
/// <param name="hazard">The <see cref="PrismaticCloudHazard"/> instance.</param>
public PrismaticCloudHazard(PrismaticCloud hazard)
: base(hazard)
{
Base = hazard;
}

/// <summary>
/// Gets the <see cref="PrismaticCloudHazard"/>.
/// </summary>
public new PrismaticCloud Base { get; }

/// <summary>
/// Gets or sets the synced position.
/// </summary>
public RelativePosition SynchronisedPosition
{
get => Base.SynchronizedPosition;
set => Base.SynchronizedPosition = value;
}
}
}
10 changes: 10 additions & 0 deletions Exiled.API/Features/Hazards/TantrumHazard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.API.Features.Hazards
{
using global::Hazards;
using PlayerRoles;
using RelativePositioning;
using UnityEngine;

Expand Down Expand Up @@ -57,5 +58,14 @@ public Transform CorrectPosition
get => Base._correctPosition;
set => Base._correctPosition = value;
}

/// <summary>
/// Gets or sets the teams that will be affected by this Tantrum.
/// </summary>
public Team[] TargetedTeams
{
get => Base._targetedTeams;
set => Base._targetedTeams = value;
}
}
}
49 changes: 37 additions & 12 deletions Exiled.API/Features/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Exiled.API.Features
using MapGeneration;
using MapGeneration.Distributors;
using Mirror;
using Mirror.LiteNetLib4Mirror;
using PlayerRoles;
using PlayerRoles.PlayableScps.Scp173;
using PlayerRoles.PlayableScps.Scp939;
Expand Down Expand Up @@ -63,24 +64,48 @@ public static class Map

private static TantrumEnvironmentalHazard tantrumPrefab;
private static Scp939AmnesticCloudInstance amnesticCloudPrefab;
private static PrismaticCloud prismaticCloudPrefab;

private static AmbientSoundPlayer ambientSoundPlayer;

/// <summary>
/// Gets the tantrum prefab.
/// Gets the prismatic cloud prefab.
/// </summary>
public static TantrumEnvironmentalHazard TantrumPrefab
public static PrismaticCloud PrismaticCloud
{
get
{
if (tantrumPrefab == null)
if (prismaticCloudPrefab != null)
return prismaticCloudPrefab;

foreach (GameObject prefab in LiteNetLib4MirrorNetworkManager.singleton.spawnPrefabs)
{
Scp173GameRole scp173Role = (Scp173GameRole)RoleTypeId.Scp173.GetRoleBase();
if (!prefab.TryGetComponent(out PrismaticCloud prismaticCloud))
continue;

if (scp173Role.SubroutineModule.TryGetSubroutine(out Scp173TantrumAbility scp173TantrumAbility))
tantrumPrefab = scp173TantrumAbility._tantrumPrefab;
prismaticCloudPrefab = prismaticCloud;
break;
}

return prismaticCloudPrefab;
}
}

/// <summary>
/// Gets the tantrum prefab.
/// </summary>
public static TantrumEnvironmentalHazard TantrumPrefab
{
get
{
if (tantrumPrefab != null)
return tantrumPrefab;

Scp173GameRole scp173Role = (Scp173GameRole)RoleTypeId.Scp173.GetRoleBase();

if (scp173Role.SubroutineModule.TryGetSubroutine(out Scp173TantrumAbility scp173TantrumAbility))
tantrumPrefab = scp173TantrumAbility._tantrumPrefab;

return tantrumPrefab;
}
}
Expand All @@ -92,13 +117,13 @@ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab
{
get
{
if (amnesticCloudPrefab == null)
{
Scp939GameRole scp939Role = (Scp939GameRole)RoleTypeId.Scp939.GetRoleBase();
if (amnesticCloudPrefab != null)
return amnesticCloudPrefab;

if (scp939Role.SubroutineModule.TryGetSubroutine(out Scp939AmnesticCloudAbility ability))
amnesticCloudPrefab = ability._instancePrefab;
}
Scp939GameRole scp939Role = (Scp939GameRole)RoleTypeId.Scp939.GetRoleBase();

if (scp939Role.SubroutineModule.TryGetSubroutine(out Scp939AmnesticCloudAbility ability))
amnesticCloudPrefab = ability._instancePrefab;

return amnesticCloudPrefab;
}
Expand Down
11 changes: 4 additions & 7 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class Player : TypeCastObject<Player>, IEntity, IWorldSpace
private readonly HashSet<EActor> componentsInChildren = new();

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

/// <summary>
Expand Down Expand Up @@ -165,8 +164,6 @@ private set
HintDisplay = value.hints;
Inventory = value.inventory;
CameraTransform = value.PlayerCameraReference;

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

Expand Down Expand Up @@ -856,13 +853,13 @@ public DangerStackBase[] Dangers
/// </summary>
public float Health
{
get => healthStat.CurValue;
get => ReferenceHub.playerStats.GetModule<HealthStat>().CurValue;
set
{
if (value > MaxHealth)
MaxHealth = value;

healthStat.CurValue = value;
ReferenceHub.playerStats.GetModule<HealthStat>().CurValue = value;
}
}

Expand All @@ -871,8 +868,8 @@ public float Health
/// </summary>
public float MaxHealth
{
get => healthStat.MaxValue;
set => healthStat.CustomMaxValue = value;
get => ReferenceHub.playerStats.GetModule<MaxHealthStat>().CurValue;
set => ReferenceHub.playerStats.GetModule<MaxHealthStat>().CurValue = value;
}

/// <summary>
Expand Down

0 comments on commit 1fa8659

Please sign in to comment.