forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from TGRCdev/cyborg-self-exploding-fix
Fixed cyborgs being able to explode by clicking on themselves
- Loading branch information
Showing
3 changed files
with
36 additions
and
15 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
35 changes: 35 additions & 0 deletions
35
Content.Server/NPC/HTN/PrimitiveTasks/Operators/Interactions/StartTimerOperator.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,35 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Shared.Explosion.Components; | ||
|
||
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Interactions; | ||
|
||
public sealed partial class StartTimerOperator : HTNOperator | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
|
||
[DataField("idleKey")] | ||
public string IdleKey = "IdleTime"; | ||
|
||
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard, CancellationToken cancelToken) | ||
{ | ||
return new(true, new Dictionary<string, object>() | ||
{ | ||
{ IdleKey, 1f } | ||
}); | ||
} | ||
|
||
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime) | ||
{ | ||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
var trigger = _entManager.System<TriggerSystem>(); | ||
if (!_entManager.TryGetComponent<OnUseTimerTriggerComponent>(owner, out var timer)) | ||
return HTNOperatorStatus.Failed; | ||
|
||
trigger.StartTimer((owner, timer), owner); | ||
blackboard.SetValue(IdleKey, timer.Delay); | ||
|
||
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