medibot toctou gaming (#22608)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-12-16 22:22:19 +00:00
committed by GitHub
parent d63a064682
commit 6496d99a32

View File

@@ -16,8 +16,9 @@ namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
public sealed partial class MedibotInjectOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entMan = default!;
private SharedAudioSystem _audio = default!;
private ChatSystem _chat = default!;
private MedibotSystem _medibot = default!;
private SharedAudioSystem _audio = default!;
private SharedInteractionSystem _interaction = default!;
private SharedPopupSystem _popup = default!;
private SolutionContainerSystem _solution = default!;
@@ -31,8 +32,9 @@ public sealed partial class MedibotInjectOperator : HTNOperator
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_audio = sysManager.GetEntitySystem<SharedAudioSystem>();
_chat = sysManager.GetEntitySystem<ChatSystem>();
_medibot = sysManager.GetEntitySystem<MedibotSystem>();
_audio = sysManager.GetEntitySystem<SharedAudioSystem>();
_interaction = sysManager.GetEntitySystem<SharedInteractionSystem>();
_popup = sysManager.GetEntitySystem<SharedPopupSystem>();
_solution = sysManager.GetEntitySystem<SolutionContainerSystem>();
@@ -75,8 +77,7 @@ public sealed partial class MedibotInjectOperator : HTNOperator
return HTNOperatorStatus.Failed;
var state = mobState.CurrentState;
var treatment = botComp.Treatments[mobState.CurrentState];
if (!treatment.IsValid(total))
if (!_medibot.TryGetTreatment(botComp, mobState.CurrentState, out var treatment) || !treatment.IsValid(total))
return HTNOperatorStatus.Failed;
_entMan.EnsureComponent<NPCRecentlyInjectedComponent>(target);