Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Enums/EffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public enum EffectType
/// <summary>
/// Makes you a marshmallow guy.
/// </summary>
[Obsolete("Not functional in-game")]
// [Obsolete("Not functional in-game")]
Marshmallow,

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Exiled.API.Features.Items
using InventorySystem.Items.Firearms.Ammo;
using InventorySystem.Items.Jailbird;
using InventorySystem.Items.Keycards;
using InventorySystem.Items.MarshmallowMan;
using InventorySystem.Items.MicroHID;
using InventorySystem.Items.Pickups;
using InventorySystem.Items.Radio;
Expand Down Expand Up @@ -260,6 +261,7 @@ public static Item Get(ItemBase itemBase)
_ => new Throwable(throwable),
},
Scp1509Item scp1509 => new Scp1509(scp1509),
MarshmallowItem marshmallow => new Marshmallow(marshmallow),
_ => new(itemBase),
};
}
Expand Down Expand Up @@ -364,6 +366,7 @@ public static T Get<T>(ushort serial)
_ => new Throwable(type, owner),
},
Scp1509Item => new Scp1509(),
MarshmallowItem => new Marshmallow(type, owner),
_ => new(type),
};

Expand Down
102 changes: 102 additions & 0 deletions EXILED/Exiled.API/Features/Items/Marshmallow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// -----------------------------------------------------------------------
// <copyright file="Marshmallow.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.Items
{
using CustomPlayerEffects;
using Exiled.API.Interfaces;
using InventorySystem.Items.MarshmallowMan;
using PlayerStatsSystem;
using UnityEngine;

/// <summary>
/// A wrapper class for <see cref="MarshmallowItem"/>.
/// </summary>
public class Marshmallow : Item, IWrapper<MarshmallowItem>
{
/// <summary>
/// Initializes a new instance of the <see cref="Marshmallow"/> class.
/// </summary>
/// <param name="itemBase">The base <see cref="MarshmallowItem"/> class.</param>
public Marshmallow(MarshmallowItem itemBase)
: base(itemBase)
{
Base = itemBase;
}

/// <summary>
/// Initializes a new instance of the <see cref="Marshmallow"/> class.
/// </summary>
/// <param name="type">The <see cref="ItemType"/> of the marshmallow item.</param>
/// <param name="owner">The owner of the marshmallow item. Leave <see langword="null"/> for no owner.</param>
internal Marshmallow(ItemType type, Player owner = null)
: base((MarshmallowItem)(owner ?? Server.Host).Inventory.CreateItemInstance(new(type, 0), false))
{
}

/// <summary>
/// Gets the <see cref="MarshmallowItem"/> that this class is encapsulating.
/// </summary>
public new MarshmallowItem Base { get; }

/// <summary>
/// Gets a value indicating whether this marshmallow man is evil.
/// </summary>
/// <remarks>See <see cref="MakeEvil"/> in regards to making a marshmallow evil.</remarks>
public bool Evil => Base.EvilMode;

/// <summary>
/// Gets or sets the <see cref="AhpStat.AhpProcess"/> of the marshmallow man that would be used if he was evil.
/// </summary>
public AhpStat.AhpProcess EvilAhpProcess
{
get => Base.EvilAHPProcess;
set
{
if (Evil && value is null)
return;

Base.EvilAHPProcess = value;
}
}

/// <summary>
/// Cackles for the owner even if they are not evil.
/// </summary>
/// <param name="cooldown">How long until the player can cackle again (negative values do not affect current cooldown).</param>
/// <param name="duration">How long players near the marshmallow man get effected by <see cref="TraumatizedByEvil"/>.</param>
public void Cackle(double cooldown = -1, float duration = 5)
{
if (cooldown >= 0)
Base._cackleCooldown.Trigger(cooldown);

Base.ServerSendPublicRpc(writer =>
{
writer.WriteByte(4);
Base._cackleCooldown.WriteCooldown(writer);
});

foreach (Player player in Player.List)
{
if (Vector3.Distance(player.Position, Owner.Position) <= 5F && player.CurrentItem is not Marshmallow { Evil: true })
player.EnableEffect<TraumatizedByEvil>(duration);
}
}

/// <summary>
/// Makes the owner of this marshmallow evil. You CANNOT undo this without resetting the player.
/// </summary>
/// <param name="evilProcess">The <see cref="AhpStat.AhpProcess"/> of the new evil player.</param>
public void MakeEvil(AhpStat.AhpProcess evilProcess = null)
{
if (Evil)
return;

Base.ReleaseEvil(evilProcess ?? EvilAhpProcess ?? new AhpStat.AhpProcess(450F, 450F, 0F, 1F, 0F, true));
}
}
}
22 changes: 22 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Interfaces/IMarshmallowEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="IMarshmallowEvent.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Interfaces
{
using Exiled.API.Features.Items;

/// <summary>
/// Represents all events related to the marshmallow man.
/// </summary>
public interface IMarshmallowEvent : IItemEvent
{
/// <summary>
/// Gets the marshmallow item related to this event.
/// </summary>
public Marshmallow Marshmallow { get; }
}
}
51 changes: 51 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Item/CacklingEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// -----------------------------------------------------------------------
// <copyright file="CacklingEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Item
{
using Exiled.API.Features;
using Exiled.API.Features.Items;
using Exiled.Events.EventArgs.Interfaces;
using InventorySystem.Items.MarshmallowMan;

/// <summary>
/// Contains all information before a marshmallow man punches.
/// </summary>
public class CacklingEventArgs : IMarshmallowEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="CacklingEventArgs"/> class.
/// </summary>
/// <param name="player">The Player cackling.</param>
/// <param name="marshmallow">The marshmallow item of the player cackling.</param>
/// <param name="isAllowed">Whether the player is allowed to cackle.</param>
public CacklingEventArgs(Player player, MarshmallowItem marshmallow, bool isAllowed = true)
{
Player = player;
Marshmallow = Item.Get<Marshmallow>(marshmallow);
IsAllowed = isAllowed;
}

/// <summary>
/// Gets the player cackling.
/// </summary>
public Player Player { get; }

/// <inheritdoc />
public API.Features.Items.Item Item => Marshmallow;

/// <summary>
/// Gets the marshmallow item of the player cackling.
/// </summary>
public Marshmallow Marshmallow { get; }

/// <summary>
/// Gets or sets a value indicating whether the player is allowed to cackle.
/// </summary>
public bool IsAllowed { get; set; }
}
}
51 changes: 51 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Item/PunchingEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// -----------------------------------------------------------------------
// <copyright file="PunchingEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Item
{
using Exiled.API.Features;
using Exiled.API.Features.Items;
using Exiled.Events.EventArgs.Interfaces;
using InventorySystem.Items.MarshmallowMan;

/// <summary>
/// Contains all information before a marshmallow man punches.
/// </summary>
public class PunchingEventArgs : IMarshmallowEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="PunchingEventArgs"/> class.
/// </summary>
/// <param name="player">The Player attacking.</param>
/// <param name="marshmallow">The marshmallow item of the player attacking.</param>
/// <param name="isAllowed">Whether the player is allowed to punch.</param>
public PunchingEventArgs(Player player, MarshmallowItem marshmallow, bool isAllowed = true)
{
Player = player;
Marshmallow = Item.Get<Marshmallow>(marshmallow);
IsAllowed = isAllowed;
}

/// <summary>
/// Gets the player punching.
/// </summary>
public Player Player { get; }

/// <inheritdoc />
public Item Item => Marshmallow;

/// <summary>
/// Gets the marshmallow item of the player punching.
/// </summary>
public Marshmallow Marshmallow { get; }

/// <summary>
/// Gets or sets a value indicating whether the punch is allowed.
/// </summary>
public bool IsAllowed { get; set; }
}
}
40 changes: 40 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Scp2536/FoundPositionEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// -----------------------------------------------------------------------
// <copyright file="FoundPositionEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Scp2536
{
using Christmas.Scp2536;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Interfaces;

/// <summary>
/// Contains all information after SCP-2536 chooses target for spawning.
/// </summary>
public class FoundPositionEventArgs : IPlayerEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="FoundPositionEventArgs"/> class.
/// </summary>
/// <param name="player"><inheritdoc cref="Player"/></param>
/// <param name="spawnpoint"><inheritdoc cref="Spawnpoint"/></param>
public FoundPositionEventArgs(Player player, Scp2536Spawnpoint spawnpoint)
{
Player = player;
Spawnpoint = spawnpoint;
}

/// <summary>
/// Gets the player near whom SCP-2536 will spawn.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets or sets the spawn point where SCP will spawn.
/// </summary>
public Scp2536Spawnpoint Spawnpoint { get; set; }
}
}
22 changes: 22 additions & 0 deletions EXILED/Exiled.Events/Handlers/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public static class Item
/// </summary>
public static Event<JailbirdChangedWearStateEventArgs> JailbirdChangedWearState { get; set; } = new();

/// <summary>
/// Invoked before a marshmallow man punches.
/// </summary>
public static Event<PunchingEventArgs> Punching { get; set; } = new();

/// <summary>
/// Invoked before a marshmallow man cackles.
/// </summary>
public static Event<CacklingEventArgs> Cackling { get; set; } = new();

/// <summary>
/// Called before the Jailbird's <see cref="InventorySystem.Items.Jailbird.JailbirdWearState"/> is changed.
/// </summary>
Expand Down Expand Up @@ -173,5 +183,17 @@ public static class Item
/// </summary>
/// <param name="ev">The <see cref="InspectedItemEventArgs"/> instance.</param>
public static void OnInspectedItem(InspectedItemEventArgs ev) => InspectedItem.InvokeSafely(ev);

/// <summary>
/// Called before a marshmallow man punches.
/// </summary>
/// <param name="ev">The <see cref="PunchingEventArgs"/> instance.</param>
public static void OnPunching(PunchingEventArgs ev) => Punching.InvokeSafely(ev);

/// <summary>
/// Called before a marshmallow man cackles.
/// </summary>
/// <param name="ev">The <see cref="CacklingEventArgs"/> instance.</param>
public static void OnCackling(CacklingEventArgs ev) => Cackling.InvokeSafely(ev);
}
}
11 changes: 11 additions & 0 deletions EXILED/Exiled.Events/Handlers/Scp2536.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public static class Scp2536
/// </summary>
public static Event<FindingPositionEventArgs> FindingPosition { get; set; } = new();

/// <summary>
/// Invoked once SCP-2536 has found a spawn location.
/// </summary>
public static Event<FoundPositionEventArgs> FoundPosition { get; set; } = new();

/// <summary>
/// Invoked before SCP-2536 gives a gift to a player.
/// </summary>
Expand All @@ -37,6 +42,12 @@ public static class Scp2536
/// <param name="ev">The <see cref="FindingPositionEventArgs"/> instance.</param>
public static void OnFindingPosition(FindingPositionEventArgs ev) => FindingPosition.InvokeSafely(ev);

/// <summary>
/// Called after SCP-2536 chooses a target.
/// </summary>
/// <param name="ev">The <see cref="FoundPositionEventArgs"/> instance.</param>
public static void OnFoundPosition(FoundPositionEventArgs ev) => FoundPosition.InvokeSafely(ev);

/// <summary>
/// Called before SCP-2536 gives a gift to a player.
/// </summary>
Expand Down
Loading
Loading