-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm going to find something better to do
- Loading branch information
1 parent
d4c4d0c
commit d409134
Showing
4 changed files
with
46 additions
and
37 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
Content.Server/SimpleStation14/Weapons/Ranged/Components/RandomFireGunOnDropComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
38 changes: 38 additions & 0 deletions
38
Content.Server/SimpleStation14/Weapons/Ranged/Systems/RandomFireGunOnDropSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
Content.Shared/SimpleStation14/Weapons/Ranged/Components/GunComponent.cs
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
Content.Shared/SimpleStation14/Weapons/Ranged/Systems/FireOnDropSystem.cs
This file was deleted.
Oops, something went wrong.