Skip to content

Commit

Permalink
I'm going to find something better to do
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Dec 11, 2023
1 parent d4c4d0c commit d409134
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server.SimpleStation14.Weapons.Ranged.Components;

[RegisterComponent]
public sealed partial class RandomFireGunOnDropComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float FireOnDropChance = 0.1f;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.SimpleStation14.Weapons.Ranged.Components;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Random;
using Serilog;

namespace Content.Server.SimpleStation14.Weapons.Ranged.Systems;

public sealed class RandomFireGunOnDropSystem : EntitySystem
{
[Dependency] private readonly SharedGunSystem _gun = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IEntityManager _entity = default!;


public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RandomFireGunOnDropComponent, LandEvent>(HandleLand);
}


private void HandleLand(EntityUid uid, RandomFireGunOnDropComponent component, ref LandEvent args)
{
Log.Warning($"{args.User} firing {uid}");

if (!_entity.TryGetComponent<GunComponent>(uid, out var gun) ||
args.User == null)
return;

if (_random.Prob(component.FireOnDropChance))
// The gun fires itself (weird), with the target being its own position offset by its rotation as a point vector.
// The result being that it will always fire the direction that all gun sprites point in.
_gun.AttemptShoot(uid, uid, gun, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec()));
}
}

This file was deleted.

This file was deleted.

0 comments on commit d409134

Please sign in to comment.