Use conditions to store progress for Ninja objectives (#20254)

* TryGetObjectiveComp

* helper function to get objective

* store N of jacked doors in condition

* store called in threat bool in condition

* store techs in steal research condition

* fix access

* remove unused transform system

* use popup from shared system

* fix formatting

* condition => obj everywhere

* i fogror to remove downloaded nodes from role

* change signature

* use query

* View Variables

* spider charge detonated => condition
This commit is contained in:
Slava0135
2023-10-10 09:32:10 +03:00
committed by GitHub
parent c35a018cad
commit 6f8c2b7e52
11 changed files with 76 additions and 88 deletions

View File

@@ -292,6 +292,33 @@ public abstract class SharedMindSystem : EntitySystem
return true;
}
public bool TryGetObjectiveComp<T>(EntityUid uid, [NotNullWhen(true)] out T? objective) where T : Component
{
if (TryGetMind(uid, out var mindId, out var mind) && TryGetObjectiveComp(mindId, out objective, mind))
{
return true;
}
objective = default;
return false;
}
public bool TryGetObjectiveComp<T>(EntityUid mindId, [NotNullWhen(true)] out T? objective, MindComponent? mind = null) where T : Component
{
if (Resolve(mindId, ref mind))
{
var query = GetEntityQuery<T>();
foreach (var uid in mind.AllObjectives)
{
if (query.TryGetComponent(uid, out objective))
{
return true;
}
}
}
objective = default;
return false;
}
public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out ICommonSession? session)
{
session = null;