Skip to content

Commit

Permalink
scp018projectile (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
IRacle1 authored Aug 24, 2024
1 parent f1c58ff commit 5fc1b14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Features/Pickups/Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ internal Pickup(ItemType type)
public PickupStandardPhysics PhysicsModule
{
get => Base.PhysicsModule as PickupStandardPhysics;
[Obsolete("Unsafe.")]
set
{
Base.PhysicsModule.DestroyModule();
Expand Down
20 changes: 18 additions & 2 deletions EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

namespace Exiled.API.Features.Pickups.Projectiles
{
using System;
using System.Reflection;

using Exiled.API.Interfaces;
using HarmonyLib;

using InventorySystem.Items.ThrowableProjectiles;

Expand All @@ -18,6 +22,9 @@ namespace Exiled.API.Features.Pickups.Projectiles
/// </summary>
public class Scp018Projectile : TimeGrenadeProjectile, IWrapper<BaseScp018Projectile>
{
private static FieldInfo maxVelocityField;
private static FieldInfo velocityPerBounceField;

/// <summary>
/// Initializes a new instance of the <see cref="Scp018Projectile"/> class.
/// </summary>
Expand Down Expand Up @@ -48,6 +55,7 @@ internal Scp018Projectile()
public new Scp018Physics PhysicsModule
{
get => Base.PhysicsModule as Scp018Physics;
[Obsolete("Unsafe.", true)]
set
{
Base.PhysicsModule.DestroyModule();
Expand All @@ -61,7 +69,11 @@ internal Scp018Projectile()
public float MaxVelocity
{
get => PhysicsModule._maxVel;
set => PhysicsModule = new Scp018Physics(Base, PhysicsModule._trail, PhysicsModule._radius, value, PhysicsModule._velPerBounce);
set
{
maxVelocityField ??= AccessTools.Field(typeof(Scp018Physics), nameof(Scp018Physics._maxVel));
maxVelocityField.SetValue(PhysicsModule, value);
}
}

/// <summary>
Expand All @@ -70,7 +82,11 @@ public float MaxVelocity
public float VelocityPerBounce
{
get => PhysicsModule._maxVel;
set => PhysicsModule = new Scp018Physics(Base, PhysicsModule._trail, PhysicsModule._radius, MaxVelocity, value);
set
{
velocityPerBounceField ??= AccessTools.Field(typeof(Scp018Physics), nameof(Scp018Physics._velPerBounce));
velocityPerBounceField.SetValue(PhysicsModule, value);
}
}

/// <summary>
Expand Down

0 comments on commit 5fc1b14

Please sign in to comment.