Skip to content

Commit

Permalink
Create cocoons conditoin fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Sep 14, 2024
1 parent 7f013b3 commit 8a02278
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Server.Objectives.Systems;
using Content.Server.SS220.Objectives.Components;
using Content.Server.SS220.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.SS220.SpiderQueen.Components;
Expand All @@ -11,8 +12,6 @@ public sealed partial class CreateCocoonsConditionSystem : EntitySystem
{
[Dependency] private readonly NumberObjectiveSystem _number = default!;

private Dictionary<MindComponent, bool> IsCompletedOnce = new();

public override void Initialize()
{
base.Initialize();
Expand All @@ -22,13 +21,15 @@ public override void Initialize()

private void OnGetProgress(Entity<CreateCocoonsConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
args.Progress = GetProgress(args.Mind, _number.GetTarget(ent.Owner));
args.Progress = GetProgress(args.MindId, args.Mind, _number.GetTarget(ent.Owner));
}

private float GetProgress(MindComponent mind, int target)
private float GetProgress(EntityUid mindId, MindComponent mind, int target)
{
if (IsCompletedOnce.TryGetValue(mind, out var comleted) &&
comleted)
if (!TryComp<SpiderQueenRoleComponent>(mindId, out var spiderQueenRole))
return 0f;

if (spiderQueenRole.IsCreateCocoonsCompletedOnce)
return 1f;

var mobUid = mind.CurrentEntity;
Expand All @@ -38,7 +39,7 @@ private float GetProgress(MindComponent mind, int target)

if (spiderQueen.CocoonsList.Count >= target)
{
IsCompletedOnce.Add(mind, true);
spiderQueenRole.IsCreateCocoonsCompletedOnce = true;
return 1f;
}
else
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/SS220/Roles/SpiderQueenRoleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ namespace Content.Server.SS220.Roles;
[RegisterComponent, ExclusiveAntagonist]
public sealed partial class SpiderQueenRoleComponent : AntagonistRoleComponent
{
[ViewVariables]
public bool IsCreateCocoonsCompletedOnce = false;
}

0 comments on commit 8a02278

Please sign in to comment.