-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EntityWorldTargetAction (#29819)
* Add EntityWorldTargetAction initial implementation * Update obsolete methods * Partially working EntityWorldTargetAction * Fix entity selection * Move and clean up AfterInteract * Fix building new walls * Readd no entity or coordinates error * Consolidate action validation code * Add summaries to component --------- Co-authored-by: Ed <[email protected]>
- Loading branch information
1 parent
489efeb
commit 1df8451
Showing
7 changed files
with
266 additions
and
19 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
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
42 changes: 42 additions & 0 deletions
42
Content.Shared/Actions/EntityWorldTargetActionComponent.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,42 @@ | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.Actions; | ||
|
||
/// <summary> | ||
/// Used on action entities to define an action that triggers when targeting an entity or entity coordinates. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class EntityWorldTargetActionComponent : BaseTargetActionComponent | ||
{ | ||
public override BaseActionEvent? BaseEvent => Event; | ||
|
||
/// <summary> | ||
/// The local-event to raise when this action is performed. | ||
/// </summary> | ||
[DataField] | ||
[NonSerialized] | ||
public EntityWorldTargetActionEvent? Event; | ||
|
||
/// <summary> | ||
/// Determines which entities are valid targets for this action. | ||
/// </summary> | ||
/// <remarks>No whitelist check when null.</remarks> | ||
[DataField] public EntityWhitelist? Whitelist; | ||
|
||
/// <summary> | ||
/// Whether this action considers the user as a valid target entity when using this action. | ||
/// </summary> | ||
[DataField] public bool CanTargetSelf = true; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public sealed class EntityWorldTargetActionComponentState( | ||
EntityWorldTargetActionComponent component, | ||
IEntityManager entManager) | ||
: BaseActionComponentState(component, entManager) | ||
{ | ||
public EntityWhitelist? Whitelist = component.Whitelist; | ||
public bool CanTargetSelf = component.CanTargetSelf; | ||
} |
10 changes: 10 additions & 0 deletions
10
Content.Shared/Actions/Events/ValidateActionEntityWorldTargetEvent.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,10 @@ | ||
using Robust.Shared.Map; | ||
|
||
namespace Content.Shared.Actions.Events; | ||
|
||
[ByRefEvent] | ||
public record struct ValidateActionEntityWorldTargetEvent( | ||
EntityUid User, | ||
EntityUid? Target, | ||
EntityCoordinates? Coords, | ||
bool Cancelled = false); |
Oops, something went wrong.