Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DroppingAmmo, DroppedAmmo and InteractingDoor #371

Merged
merged 8 commits into from
Jan 8, 2025

Conversation

CosmosZvezdo4kin
Copy link

@CosmosZvezdo4kin CosmosZvezdo4kin commented Jan 3, 2025

Description

Describe the changes

  • Added OnDroppingAmmo override in CustomItem
    Triggers if player requests to drop item which ItemType equals to the ItemType specified by CustomItem

  • ⚠️ Renamed OnDropping to OnDroppingItem override in CustomItem (the only breaking change)

  • Added ItemType property to DroppingAmmoEventArgs and DroppedAmmoEventArg
    Will allow normal interaction with custom items (see in the screenshots below)
    Example of custom item
    New behavior with custom items
    New behavior with ammo

  • Added ColliderId and Collider property to InteractingDoorEventArgs
    Allows you to identify the Collider by ColliderId of the door/gate the player is interacting with.
    For example: Door button, left part of door and etc.
    New behavior example 1
    New behavior example 2
    Bugged SCP-106 door colliders

What is the current behavior? (You can also link to an open issue here)
:)

What is the new behavior? (if this is a feature change)
Described in Description

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No

Other information:
No


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

Added ItemType property to DroppingAmmoEventArgs and DroppedAmmoEventArgs
Added ColliderId propperty to InteractingDoorEventArgs
@CosmosZvezdo4kin
Copy link
Author

Forgot to mention. The DroppedAmmo event will not be triggered with custom items for obvious reasons

@@ -36,14 +39,21 @@ public class DroppingAmmoEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public DroppingAmmoEventArgs(Player player, AmmoType ammoType, ushort amount, bool isAllowed = true)
public DroppingAmmoEventArgs(Player player, byte itemType, AmmoType ammoType, ushort amount, bool isAllowed = true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public DroppingAmmoEventArgs(Player player, byte itemType, AmmoType ammoType, ushort amount, bool isAllowed = true)
public DroppingAmmoEventArgs(Player player, ItemTypeitemType, ushort amount, bool isAllowed = true)

(require to sligly change Transpiller to remove GetAmmoType)

@@ -60,7 +63,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// true
new(OpCodes.Ldc_I4_1),

// DroppingAmmoEventArgs ev = new(Player, AmmoType, ushort, bool)
// DroppingAmmoEventArgs ev = new(Player, ItemType, AmmoType, ushort, bool)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// DroppingAmmoEventArgs ev = new(Player, ItemType, AmmoType, ushort, bool)
// DroppingAmmoEventArgs ev = new(Player, ItemType, ushort, bool)

Comment on lines 53 to 58
// itemType
new(OpCodes.Ldarg_1),

// ammoType
new(OpCodes.Ldarg_1),
new(OpCodes.Call, Method(typeof(API.Extensions.ItemExtensions), nameof(API.Extensions.ItemExtensions.GetAmmoType))),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// itemType
new(OpCodes.Ldarg_1),
// ammoType
new(OpCodes.Ldarg_1),
new(OpCodes.Call, Method(typeof(API.Extensions.ItemExtensions), nameof(API.Extensions.ItemExtensions.GetAmmoType))),
// itemType
new(OpCodes.Ldarg_1),

Comment on lines 94 to 96
// ev.AmmoType
new(OpCodes.Ldloc_S, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(DroppingAmmoEventArgs), nameof(DroppingAmmoEventArgs.AmmoType))),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ev.AmmoType
new(OpCodes.Ldloc_S, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(DroppingAmmoEventArgs), nameof(DroppingAmmoEventArgs.AmmoType))),

@@ -36,14 +39,20 @@ public class DroppedAmmoEventArgs : IPlayerEvent
/// <param name="ammoPickups">
/// <inheritdoc cref="AmmoPickups" />
/// </param>
public DroppedAmmoEventArgs(Player player, AmmoType ammoType, ushort amount, List<InventorySystem.Items.Firearms.Ammo.AmmoPickup> ammoPickups)
public DroppedAmmoEventArgs(Player player, ItemType itemType, AmmoType ammoType, ushort amount, List<InventorySystem.Items.Firearms.Ammo.AmmoPickup> ammoPickups)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public DroppedAmmoEventArgs(Player player, ItemType itemType, AmmoType ammoType, ushort amount, List<InventorySystem.Items.Firearms.Ammo.AmmoPickup> ammoPickups)
public DroppedAmmoEventArgs(Player player, ItemType itemType, ushort amount, List<InventorySystem.Items.Firearms.Ammo.AmmoPickup> ammoPickups)

Comment on lines 33 to 35
/// <param name="ammoType">
/// <inheritdoc cref="AmmoType" />
/// </param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="ammoType">
/// <inheritdoc cref="AmmoType" />
/// </param>

Comment on lines 33 to 35
/// <param name="ammoType">
/// <inheritdoc cref="AmmoType" />
/// </param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="ammoType">
/// <inheritdoc cref="AmmoType" />
/// </param>

@louis1706
Copy link

louis1706 commented Jan 4, 2025

Forgot to mention. The DroppedAmmo event will not be triggered with custom items for obvious reasons

because CustomItem put IsAllowed to false (it's should be added a call to the event inside CustomItem overide)

@CosmosZvezdo4kin
Copy link
Author

@louis1706
Is there an option instead of completely removing AmmoType to add an Obsolete attribute to it, so that those using these events can fix things ?

@louis1706
Copy link

@louis1706
Is there an option instead of completely removing AmmoType to add an Obsolete attribute to it, so that those using these events can fix things ?

I didn't said to remove it just use ItemType.GetAmmoType()

@CosmosZvezdo4kin
Copy link
Author

Okay. I'll tweak it tonight and finalize the changes with ColliderId as well.

Added support for DroppingAmmo in Exiled.CustomItems
Shorten some of *AmmoEventArgs constructors
@CosmosZvezdo4kin
Copy link
Author

Description for pull request is updated

I don't know exactly if I did what you meant by changes for CustomItem. If you have any suggestions, it would be better to commit directly to Customitem (I have no idea how to implement it there)

public DroppingAmmoEventArgs(Player player, AmmoType ammoType, ushort amount, bool isAllowed = true)
public DroppingAmmoEventArgs(Player player, byte itemType, ushort amount, bool isAllowed = true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use byte for itemtype

Fixed summary for ItemType in DroppedAmmoEventArgs.
CustomItem.OnDroppingAmmo now triggers when CustomItem.Type equals dropped ItemType.
@CosmosZvezdo4kin
Copy link
Author

Checked my own changes, works fine on version 14.0.1

@CosmosZvezdo4kin
Copy link
Author

Description for pull request is updated

{
if (!Check(ev.Item))
return;

OnDroppingItem(ev);

// Don't forget to remove this with next update

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a Todo and supress error

(put your IDE as build as Release not Debug)

@VALERA771 VALERA771 merged commit 4e7bef5 into ExMod-Team:dev Jan 8, 2025
6 checks passed
VALERA771 added a commit that referenced this pull request Jan 10, 2025
* feat: ``Lift::Get(ElevatorGroup)`` (#372)

Lift::Get(ElevatorGroup)

* fix: PlacingBulletHoleEventArgs::Position (#377)

Fix

* fix: DryFiring fired constantly (#378)

Fix DryFiring fired constantly

* feat: Unbanned event addition (#185)

* Option A

* Style cop happy

* Sigh stylecop

* For Yamato

* Done, not tested

* Stylecop

---------

Co-authored-by: Yamato <[email protected]>

* feat: Adding CustomKeycard for CustomItems (#98)

* uwu

* itemtype check

* bruh bruh brrr ☠

* fix

* fix

* fix no.2

* some events

* ExMod Team copyright

---------

Co-authored-by: Yamato <[email protected]>
Co-authored-by: Yamato <[email protected]>

* feat: ShadowType (#382)

More features for the Light wrapper

* fix: remove var & fix FF for explosions

* feat: DroppingAmmo, DroppedAmmo and InteractingDoor (#371)

* fix: DoorType and RoomType for Checkpoint (#379)

Fix DoorType and RoomType for Checkpoint

* feat: CustomStats (#363)

* CustomStats

* replace Mathf.Clamp01 by Mathf.Clamp

* Remove CustomStaminaStat.cs

---------

Co-authored-by: Yamato <[email protected]>

* fix: NPC Spawn using wrong SpawnType (#375)

Update Npc.cs

* fix: Fix FF for explosions (#383)

* fix: nre fix

* fix: respawningteam event fix

* fix: fix explosion ff

* feat: LockerType extension (#384)

* feat: LockerType extension

* fix: fix of fix

* fix: init fix for play gun sound

* Revert "fix: init fix for play gun sound"

This reverts commit f4d5541.

* feat: Fix OnInternalSpawning & Added ChargingJailbird setter (by BlackSerperior6) (#368)

BlackSerperior6

Co-authored-by: BlackSerperior6 <[email protected]>

* feat: `ExplodingGrenadeEventArgs::ExplosionType` (#385)

* ExplosionType

* ExplodingGrenadeEventArgs::ExplosionType

---------

Co-authored-by: Yamato <[email protected]>
Co-authored-by: scp252arc <[email protected]>
Co-authored-by: X <[email protected]>
Co-authored-by: Yamato <[email protected]>
Co-authored-by: Trevlouw <[email protected]>
Co-authored-by: Misfiy <[email protected]>
Co-authored-by: Cosmos Zvezdochkin <[email protected]>
Co-authored-by: Rysik5318 <[email protected]>
Co-authored-by: BlackSerperior6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants