forked from Exiled-Official/EXILED
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readded the Placing Pickup Into Pocket Dimension Event (with Yamato's…
… Patch) into good Exiled
- Loading branch information
Snivy Films
committed
Oct 5, 2024
1 parent
244172f
commit 0e8e8f9
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
EXILED/Exiled.Events/EventArgs/Map/PlacingPickupIntoPocketDimensionEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="PlacingPickupIntoPocketDimensionEventArgs.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.Events.EventArgs.Map | ||
{ | ||
using Exiled.API.Features.Pickups; | ||
using Exiled.Events.EventArgs.Interfaces; | ||
using InventorySystem.Items.Pickups; | ||
|
||
using UnityEngine; | ||
|
||
using static PlayerRoles.PlayableScps.Scp106.Scp106PocketItemManager; | ||
|
||
/// <summary> | ||
/// Contains information about items in the pocket dimension. | ||
/// </summary> | ||
public class PlacingPickupIntoPocketDimensionEventArgs : IDeniableEvent, IPickupEvent | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PlacingPickupIntoPocketDimensionEventArgs"/> class. | ||
/// </summary> | ||
/// <param name="pickupBase"><inheritdoc cref="Pickup"/></param> | ||
/// <param name="pocketItem"><inheritdoc cref="PocketItem"/></param> | ||
/// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param> | ||
public PlacingPickupIntoPocketDimensionEventArgs(ItemPickupBase pickupBase, PocketItem pocketItem, bool isAllowed) | ||
{ | ||
Pickup = Pickup.Get(pickupBase); | ||
PocketItem = pocketItem; | ||
IsAllowed = isAllowed; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Pickup Pickup { get; } | ||
|
||
/// <summary> | ||
/// Gets the value of the PocketItem. | ||
/// </summary> | ||
public PocketItem PocketItem { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating when the Pickup will be dropped onto the map. | ||
/// </summary> | ||
public double DropTime | ||
{ | ||
get => PocketItem.TriggerTime; | ||
set => PocketItem.TriggerTime = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether the pickup should be removed from the Pocket Dimension. | ||
/// </summary> | ||
public bool ShouldRemove | ||
{ | ||
get => PocketItem.Remove; | ||
set => PocketItem.Remove = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether the warning sound for the pickup should be sent. | ||
/// </summary> | ||
public bool ShouldWarn | ||
{ | ||
get => !PocketItem.WarningSent; | ||
set => PocketItem.WarningSent = !value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the location where the pickup will drop onto the map. | ||
/// </summary> | ||
public Vector3 Position | ||
{ | ||
get => PocketItem.DropPosition.Position; | ||
set => PocketItem.DropPosition = new(value); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool IsAllowed { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
EXILED/Exiled.Events/Patches/Events/Map/PlacingPickupIntoPocketDimension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="PlacingPickupIntoPocketDimension.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.Events.Patches.Events.Map | ||
{ | ||
using System.Collections.Generic; | ||
|
||
using Exiled.Events.Attributes; | ||
using Exiled.Events.EventArgs.Map; | ||
using Handlers; | ||
using HarmonyLib; | ||
using InventorySystem.Items.Pickups; | ||
using Mirror; | ||
using PlayerRoles.PlayableScps.Scp106; | ||
|
||
using static PlayerRoles.PlayableScps.Scp106.Scp106PocketItemManager; | ||
|
||
/// <summary> | ||
/// Patches <see cref="Scp106PocketItemManager"/> | ||
/// Adds the <see cref="Map.PlacingPickupIntoPocketDimension" /> event. | ||
/// </summary> | ||
[EventPatch(typeof(Map), nameof(Map.PlacingPickupIntoPocketDimension))] | ||
[HarmonyPatch(typeof(Scp106PocketItemManager), nameof(Scp106PocketItemManager.OnAdded))] | ||
internal static class PlacingPickupIntoPocketDimension | ||
{ | ||
private static void Postfix(ItemPickupBase ipb) | ||
{ | ||
if (TrackedItems.TryGetValue(ipb, out PocketItem pocketItem)) | ||
{ | ||
PlacingPickupIntoPocketDimensionEventArgs ev = new(ipb, pocketItem, true); | ||
Map.OnPlacingPickupIntoPocketDimension(ev); | ||
|
||
if (!ev.IsAllowed) | ||
{ | ||
TrackedItems.Remove(ipb); | ||
} | ||
} | ||
} | ||
} | ||
} |