forked from Simple-Station/Einstein-Engines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherrypick "Shoot Over Bodies" And Related PRs (Simple-Station#479)
# Description This is a manual cherry-pick of the following PRs: space-wizards/space-station-14#27905 space-wizards/space-station-14#28072 space-wizards/space-station-14#28571 I REQUIRE these for my work in PR Simple-Station#11 , and cannot complete said PR without these cherry-picks. This set of PRs from Wizden adds a feature where entities can selectively opt-out of being shot at unless a player intentionally targets them, which I can use as a simple and elegant solution to one of the largest glaring issues for Segmented Entities. I could simply give Lamia segments the new RequireProjectileTargetComponent, which adds them to the system. Future segmented entities such as the hypothetical "Heretic Worm" may or may not use this feature, depending on their intended implementation. --------- Co-authored-by: Danger Revolution! <[email protected]>
- Loading branch information
1 parent
287f33c
commit 40d411b
Showing
34 changed files
with
167 additions
and
22 deletions.
There are no files selected for viewing
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
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
14 changes: 14 additions & 0 deletions
14
Content.Shared/Damage/Components/RequireProjectileTargetComponent.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,14 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Damage.Components; | ||
|
||
/// <summary> | ||
/// Prevent the object from getting hit by projetiles unless you target the object. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[Access(typeof(RequireProjectileTargetSystem))] | ||
public sealed partial class RequireProjectileTargetComponent : Component | ||
{ | ||
[DataField, AutoNetworkedField] | ||
public bool Active = true; | ||
} |
51 changes: 51 additions & 0 deletions
51
Content.Shared/Damage/Systems/RequireProjectileTargetSystem.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,51 @@ | ||
using Content.Shared.Projectiles; | ||
using Content.Shared.Weapons.Ranged.Components; | ||
using Content.Shared.Standing; | ||
using Robust.Shared.Physics.Events; | ||
|
||
namespace Content.Shared.Damage.Components; | ||
|
||
public sealed class RequireProjectileTargetSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<RequireProjectileTargetComponent, PreventCollideEvent>(PreventCollide); | ||
SubscribeLocalEvent<RequireProjectileTargetComponent, StoodEvent>(StandingBulletHit); | ||
SubscribeLocalEvent<RequireProjectileTargetComponent, DownedEvent>(LayingBulletPass); | ||
} | ||
|
||
private void PreventCollide(Entity<RequireProjectileTargetComponent> ent, ref PreventCollideEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
if (!ent.Comp.Active) | ||
return; | ||
|
||
var other = args.OtherEntity; | ||
if (HasComp<ProjectileComponent>(other) && | ||
CompOrNull<TargetedProjectileComponent>(other)?.Target != ent) | ||
{ | ||
args.Cancelled = true; | ||
} | ||
} | ||
|
||
private void SetActive(Entity<RequireProjectileTargetComponent> ent, bool value) | ||
{ | ||
if (ent.Comp.Active == value) | ||
return; | ||
|
||
ent.Comp.Active = value; | ||
Dirty(ent); | ||
} | ||
|
||
private void StandingBulletHit(Entity<RequireProjectileTargetComponent> ent, ref StoodEvent args) | ||
{ | ||
SetActive(ent, false); | ||
} | ||
|
||
private void LayingBulletPass(Entity<RequireProjectileTargetComponent> ent, ref DownedEvent args) | ||
{ | ||
SetActive(ent, true); | ||
} | ||
} |
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
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
12 changes: 12 additions & 0 deletions
12
Content.Shared/Weapons/Ranged/Components/TargetedProjectileComponent.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,12 @@ | ||
using Content.Shared.Weapons.Ranged.Systems; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Weapons.Ranged.Components; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[Access(typeof(SharedGunSystem))] | ||
public sealed partial class TargetedProjectileComponent : Component | ||
{ | ||
[DataField, AutoNetworkedField] | ||
public EntityUid Target; | ||
} |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Structures/Dispensers/base_structuredispensers.yml
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
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 |
---|---|---|
|
@@ -60,3 +60,4 @@ | |
ents: [] | ||
- type: LightningTarget | ||
priority: 1 | ||
- type: RequireProjectileTarget |
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Structures/Machines/Medical/chemistry_machines.yml
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
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
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 |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
containers: | ||
machine_board: !type:Container | ||
machine_parts: !type:Container | ||
- type: RequireProjectileTarget |
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
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
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
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
4 changes: 2 additions & 2 deletions
4
Resources/Prototypes/Entities/Structures/Machines/microwave.yml
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
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Structures/Machines/reagent_grinder.yml
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml
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
4 changes: 2 additions & 2 deletions
4
Resources/Prototypes/Entities/Structures/Power/Generation/portable_generator.yml
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
Oops, something went wrong.