-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ee/master' into upstream-merge-02-07-25
- Loading branch information
Showing
21 changed files
with
439 additions
and
3 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyWeldableOperator.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,83 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Content.Server.NPC.Pathfinding; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Emag.Components; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Silicons.Bots; | ||
using Content.Shared.Tag; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific; | ||
|
||
public sealed partial class PickNearbyWeldableOperator : HTNOperator | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
private EntityLookupSystem _lookup = default!; | ||
private WeldbotSystem _weldbot = default!; | ||
private PathfindingSystem _pathfinding = default!; | ||
private TagSystem _tagSystem = default!; | ||
|
||
[DataField] public string RangeKey = NPCBlackboard.WeldbotWeldRange; | ||
|
||
/// <summary> | ||
/// Target entity to weld | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string TargetKey = string.Empty; | ||
|
||
/// <summary> | ||
/// Target entitycoordinates to move to. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string TargetMoveKey = string.Empty; | ||
|
||
public override void Initialize(IEntitySystemManager sysManager) | ||
{ | ||
base.Initialize(sysManager); | ||
_lookup = sysManager.GetEntitySystem<EntityLookupSystem>(); | ||
_weldbot = sysManager.GetEntitySystem<WeldbotSystem>(); | ||
_pathfinding = sysManager.GetEntitySystem<PathfindingSystem>(); | ||
_tagSystem = sysManager.GetEntitySystem<TagSystem>(); | ||
} | ||
|
||
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard, | ||
CancellationToken cancelToken) | ||
{ | ||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
|
||
if (!blackboard.TryGetValue<float>(RangeKey, out var range, _entManager) || !_entManager.TryGetComponent<WeldbotComponent>(owner, out var weldbot)) | ||
return (false, null); | ||
|
||
var damageQuery = _entManager.GetEntityQuery<DamageableComponent>(); | ||
var emagged = _entManager.HasComponent<EmaggedComponent>(owner); | ||
|
||
foreach (var target in _lookup.GetEntitiesInRange(owner, range)) | ||
{ | ||
if (!damageQuery.TryGetComponent(target, out var damage)) | ||
continue; | ||
|
||
var tagPrototype = _prototypeManager.Index<TagPrototype>(WeldbotWeldOperator.SiliconTag); | ||
|
||
if (!_entManager.TryGetComponent<TagComponent>(target, out var tagComponent) || !_tagSystem.HasTag(tagComponent, tagPrototype) || !emagged && damage.DamagePerGroup["Brute"].Value == 0) | ||
continue; | ||
|
||
//Needed to make sure it doesn't sometimes stop right outside it's interaction range | ||
var pathRange = SharedInteractionSystem.InteractionRange - 1f; | ||
var path = await _pathfinding.GetPath(owner, target, pathRange, cancelToken); | ||
|
||
if (path.Result == PathResult.NoPath) | ||
continue; | ||
|
||
return (true, new Dictionary<string, object>() | ||
{ | ||
{TargetKey, target}, | ||
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(target).Coordinates}, | ||
{NPCBlackboard.PathfindKey, path}, | ||
}); | ||
} | ||
|
||
return (false, null); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/WeldbotWeldOperator.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,91 @@ | ||
using Content.Server.Chat.Systems; | ||
using Content.Shared.Chat; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Damage.Prototypes; | ||
using Content.Shared.Emag.Components; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Silicons.Bots; | ||
using Content.Shared.Tag; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific; | ||
|
||
public sealed partial class WeldbotWeldOperator : HTNOperator | ||
{ | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
private ChatSystem _chat = default!; | ||
private WeldbotSystem _weldbot = default!; | ||
private SharedAudioSystem _audio = default!; | ||
private SharedInteractionSystem _interaction = default!; | ||
private SharedPopupSystem _popup = default!; | ||
private DamageableSystem _damageableSystem = default!; | ||
private TagSystem _tagSystem = default!; | ||
|
||
public const string SiliconTag = "SiliconMob"; | ||
|
||
/// <summary> | ||
/// Target entity to inject. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string TargetKey = string.Empty; | ||
|
||
public override void Initialize(IEntitySystemManager sysManager) | ||
{ | ||
base.Initialize(sysManager); | ||
_chat = sysManager.GetEntitySystem<ChatSystem>(); | ||
_weldbot = sysManager.GetEntitySystem<WeldbotSystem>(); | ||
_audio = sysManager.GetEntitySystem<SharedAudioSystem>(); | ||
_interaction = sysManager.GetEntitySystem<SharedInteractionSystem>(); | ||
_popup = sysManager.GetEntitySystem<SharedPopupSystem>(); | ||
_damageableSystem = sysManager.GetEntitySystem<DamageableSystem>(); | ||
_tagSystem = sysManager.GetEntitySystem<TagSystem>(); | ||
} | ||
|
||
public override void TaskShutdown(NPCBlackboard blackboard, HTNOperatorStatus status) | ||
{ | ||
base.TaskShutdown(blackboard, status); | ||
blackboard.Remove<EntityUid>(TargetKey); | ||
} | ||
|
||
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime) | ||
{ | ||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
|
||
if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entMan) || _entMan.Deleted(target)) | ||
return HTNOperatorStatus.Failed; | ||
|
||
var tagPrototype = _prototypeManager.Index<TagPrototype>(SiliconTag); | ||
|
||
if (!_entMan.TryGetComponent<TagComponent>(target, out var tagComponent) || !_tagSystem.HasTag(tagComponent, tagPrototype) | ||
|| !_entMan.TryGetComponent<WeldbotComponent>(owner, out var botComp) | ||
|| !_entMan.TryGetComponent<DamageableComponent>(target, out var damage) | ||
|| !_interaction.InRangeUnobstructed(owner, target) | ||
|| (damage.DamagePerGroup["Brute"].Value == 0 && !_entMan.HasComponent<EmaggedComponent>(owner))) | ||
return HTNOperatorStatus.Failed; | ||
|
||
if (botComp.IsEmagged) | ||
{ | ||
if (!_prototypeManager.TryIndex<DamageGroupPrototype>("Burn", out var prototype)) | ||
return HTNOperatorStatus.Failed; | ||
|
||
_damageableSystem.TryChangeDamage(target, new DamageSpecifier(prototype, 10), true, false, damage); | ||
} | ||
else | ||
{ | ||
if (!_prototypeManager.TryIndex<DamageGroupPrototype>("Brute", out var prototype)) | ||
return HTNOperatorStatus.Failed; | ||
|
||
_damageableSystem.TryChangeDamage(target, new DamageSpecifier(prototype, -50), true, false, damage); | ||
} | ||
|
||
_audio.PlayPvs(botComp.WeldSound, target); | ||
|
||
if(damage.DamagePerGroup["Brute"].Value == 0) //only say "all done if we're actually done!" | ||
_chat.TrySendInGameICMessage(owner, Loc.GetString("weldbot-finish-weld"), InGameICChatType.Speak, hideChat: true, hideLog: true); | ||
|
||
return HTNOperatorStatus.Finished; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Shared.Silicons.Bots; | ||
|
||
/// <summary> | ||
/// Used by the server for NPC Weldbot welding. | ||
/// Currently no clientside prediction done, only exists in shared for emag handling. | ||
/// </summary> | ||
[RegisterComponent] | ||
[Access(typeof(WeldbotSystem))] | ||
public sealed partial class WeldbotComponent : Component | ||
{ | ||
/// <summary> | ||
/// Sound played after welding a patient. | ||
/// </summary> | ||
[DataField] | ||
public SoundSpecifier WeldSound = new SoundPathSpecifier("/Audio/Items/welder2.ogg"); | ||
|
||
[DataField] | ||
public SoundSpecifier EmagSparkSound = new SoundCollectionSpecifier("sparks") | ||
{ | ||
Params = AudioParams.Default.WithVolume(8f) | ||
}; | ||
|
||
public bool IsEmagged = false; | ||
} |
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,27 @@ | ||
using Content.Shared.Emag.Systems; | ||
using Robust.Shared.Audio.Systems; | ||
|
||
namespace Content.Shared.Silicons.Bots; | ||
|
||
/// <summary> | ||
/// Handles emagging Weldbots | ||
/// </summary> | ||
public sealed class WeldbotSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<WeldbotComponent, GotEmaggedEvent>(OnEmagged); | ||
} | ||
|
||
private void OnEmagged(EntityUid uid, WeldbotComponent comp, ref GotEmaggedEvent args) | ||
{ | ||
_audio.PlayPredicted(comp.EmagSparkSound, uid, args.UserUid); | ||
|
||
comp.IsEmagged = true; | ||
args.Handled = 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
weldbot-start-weld = Hold still, please. | ||
weldbot-finish-weld = All done. |
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 |
---|---|---|
|
@@ -223,6 +223,7 @@ | |
- FootstepSound | ||
- CanPilot | ||
- SiliconEmotes | ||
- SiliconMob | ||
- type: Emoting | ||
- type: GuideHelp | ||
guides: | ||
|
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ | |
- type: Tag | ||
tags: | ||
- DoorBumpOpener | ||
- SiliconMob | ||
- type: MobState | ||
allowedStates: | ||
- Alive | ||
|
Oops, something went wrong.