Skip to content

Commit

Permalink
aaaaaaaaaaaaaaaaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
MilonPL committed Nov 26, 2024
1 parent 0a6d09e commit 75e5857
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Content.Server/Objectives/Systems/KillPersonConditionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<KillPersonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
SubscribeLocalEvent<PickRandomPersonComponent, ObjectiveAssignedEvent>(OnPersonAssigned);
SubscribeLocalEvent<PickRandomHeadComponent, ObjectiveAssignedEvent>(OnHeadAssigned);
SubscribeLocalEvent((Entity<KillPersonConditionComponent> ent, ref ObjectiveGetProgressEvent args) => OnGetProgress(ent, ref args));
SubscribeLocalEvent((Entity<PickRandomPersonComponent> ent, ref ObjectiveAssignedEvent args) => OnPersonAssigned(ent, ref args));
SubscribeLocalEvent((Entity<PickRandomHeadComponent> ent, ref ObjectiveAssignedEvent args) => OnHeadAssigned(ent, ref args));
}

private void OnGetProgress(EntityUid uid, KillPersonConditionComponent comp, ref ObjectiveGetProgressEvent args)
private void OnGetProgress(Entity<KillPersonConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
if (!_target.GetTarget(uid, out var target))
if (!_target.GetTarget(ent, out var target))
return;

args.Progress = GetProgress(target.Value, comp.RequireDead);
args.Progress = GetProgress(target.Value, ent.Comp.RequireDead);
}

private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref ObjectiveAssignedEvent args)
private void OnPersonAssigned(Entity<PickRandomPersonComponent> ent, ref ObjectiveAssignedEvent args)
{
AssignRandomTarget(uid, args, _ => true);
AssignRandomTarget(ent, args, _ => true);
}

private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref ObjectiveAssignedEvent args)
private void OnHeadAssigned(Entity<PickRandomHeadComponent> ent, ref ObjectiveAssignedEvent args)
{
AssignRandomTarget(uid, args, mind => HasComp<CommandStaffComponent>(uid));
AssignRandomTarget(ent, args, _ => HasComp<CommandStaffComponent>(ent));
}

private void AssignRandomTarget(EntityUid uid, ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true)
private void AssignRandomTarget<T>(Entity<T> ent, ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true) where T : IComponent
{
// invalid prototype
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
if (!TryComp<TargetObjectiveComponent>(ent, out var target))
{
args.Cancelled = true;
return;
Expand Down Expand Up @@ -84,7 +84,7 @@ private void AssignRandomTarget(EntityUid uid, ObjectiveAssignedEvent args, Pred
// Pick between humans matching our filter or fall back to all humans alive
var selectedHumans = filteredHumans.Count > 0 ? filteredHumans : allHumans;

_target.SetTarget(uid, _random.Pick(selectedHumans), target);
_target.SetTarget(ent, _random.Pick(selectedHumans), target);
}

private float GetProgress(EntityUid target, bool requireDead)
Expand Down

0 comments on commit 75e5857

Please sign in to comment.