This commit is contained in:
2025-06-05 01:12:55 +02:00
parent 17c654d889
commit 96596e9c08
39 changed files with 1157 additions and 1350 deletions
+32 -33
View File
@@ -8,46 +8,45 @@ using UnityEngine;
using Logger = LabApi.Features.Console.Logger;
using TimedGrenadePickup = InventorySystem.Items.ThrowableProjectiles.TimedGrenadePickup;
namespace SensitiveGrenades
namespace SensitiveGrenades;
public class SensitiveGrenades : Plugin
{
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()
{
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);
Logger.Debug("starting...");
public override void Enable()
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)
{
Logger.Debug("starting...");
var itemPickup = hit.collider.GetComponent<ItemPickupBase>();
PlayerEvents.PlacedBulletHole += ShotWeapon;
}
var grenade = itemPickup as TimedGrenadePickup;
private static void ShotWeapon(PlayerPlacedBulletHoleEventArgs ev)
{
var direction = (ev.HitPosition - ev.RaycastStart).normalized;
var distance = Vector3.Distance(ev.RaycastStart, ev.HitPosition);
if (!grenade) continue;
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...");
itemPickup.DestroySelf();
TimedGrenadeProjectile.SpawnActive(itemPickup.Position, itemPickup.Info.ItemId, ev.Player);
break;
}
}
public override void Disable()
{
Logger.Debug("unloading...");
}
}
+2 -5
View File
@@ -30,15 +30,12 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Northwood.LabAPI" Version="1.0.2" />
<PackageReference Include="Northwood.LabAPI" Version="1.0.2"/>
</ItemGroup>
</Project>