idk
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using InventorySystem.Items.Pickups;
|
||||
using LabApi.Events.Arguments.PlayerEvents;
|
||||
using LabApi.Events.Handlers;
|
||||
using LabApi.Features;
|
||||
using LabApi.Features.Wrappers;
|
||||
using LabApi.Loader.Features.Plugins;
|
||||
using UnityEngine;
|
||||
using Logger = LabApi.Features.Console.Logger;
|
||||
using TimedGrenadePickup = InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup;
|
||||
|
||||
namespace SensitiveGrenades
|
||||
{
|
||||
public class SensitiveGrenades : Plugin
|
||||
{
|
||||
public override string Name => "SensitiveGrenades";
|
||||
public override string Author => "Code002Lover";
|
||||
public override Version Version { get; } = new(1, 0, 0);
|
||||
public override string Description => "Shoot grenades to blow them up!";
|
||||
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Logger.Debug("starting...");
|
||||
|
||||
PlayerEvents.PlacedBulletHole += ShotWeapon;
|
||||
}
|
||||
|
||||
private static void ShotWeapon(PlayerPlacedBulletHoleEventArgs ev)
|
||||
{
|
||||
var direction = (ev.HitPosition - ev.RaycastStart).normalized;
|
||||
var distance = Vector3.Distance(ev.RaycastStart, ev.HitPosition);
|
||||
|
||||
var hits = Physics.RaycastAll(ev.RaycastStart, direction, distance);
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var itemPickup = hit.collider.GetComponent<ItemPickupBase>();
|
||||
|
||||
var grenade = itemPickup as TimedGrenadePickup;
|
||||
|
||||
if (!grenade) continue;
|
||||
|
||||
itemPickup.DestroySelf();
|
||||
TimedGrenadeProjectile.SpawnActive(itemPickup.Position, itemPickup.Info.ItemId, ev.Player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
Logger.Debug("unloading...");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user