Skip to content

Commit

Permalink
Add cocoons objective
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Sep 13, 2024
1 parent c815f98 commit 81af714
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
namespace Content.Server.SS220.Objectives.Components;

[RegisterComponent]
public sealed partial class CreateCocoonsConditionComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// © 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.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.SS220.SpiderQueen.Components;

namespace Content.Server.SS220.Objectives.Systems;

public sealed partial class CreateCocoonsConditionSystem : EntitySystem
{
[Dependency] private readonly NumberObjectiveSystem _number = default!;

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

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<CreateCocoonsConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
}

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

private float GetProgress(MindComponent mind, int target)
{
if (IsCompletedOnce.TryGetValue(mind, out var comleted) &&
comleted)
return 1f;

var mobUid = mind.CurrentEntity;
if (mobUid is null ||
!TryComp<SpiderQueenComponent>(mobUid, out var spiderQueen))
return 0f;

if (spiderQueen.CocoonsList.Count >= target)
{
IsCompletedOnce.Add(mind, true);
return 1f;
}
else
{
return 0f;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
objective-create-cocoons-title =
Создать { $count } { $count ->
[one] кокон
[few] кокона
*[other] коконов
}.
objective-create-cocoons-description =
Используйте действие «Окукливание» чтобы создать { $count } { $count ->
[one] кокон
[few] кокона
*[other] коконов
}.
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ spider-queen-not-enough-mana = Недостаточно маны
cocooning-target-not-dead = Цель должна быть мертва
cocooning-target-not-humanoid = Цель должна быть гуманоидом
objective-issuer-spider-queen = [color=#7567b6]Spider Queen[/color]
3 changes: 3 additions & 0 deletions Resources/Prototypes/SS220/GameRules/midround_antags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
minimumPlayers: 30
- type: AntagSpawner
prototype: MobSpiderSpaceQueen
- type: AntagObjectives
objectives:
- CreateCocoonsObjective
- type: AntagSelection
definitions:
- prefRoles: [ SpiderQueen ]
Expand Down
28 changes: 28 additions & 0 deletions Resources/Prototypes/SS220/Objectives/spider_queen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- type: entity
abstract: true
parent: BaseObjective
id: BaseSpiderQueenObjective
components:
- type: Objective
difficulty: 1.5
issuer: objective-issuer-spider-queen
- type: RoleRequirement
roles:
components:
- SpiderQueenRole

- type: entity
parent: BaseSpiderQueenObjective
id: CreateCocoonsObjective
components:
- type: Objective
icon:
sprite: SS220/Structures/Specific/cocoon.rsi
state: cocoon2
- type: NumberObjective
# dragon can only spawn 3 rifts so keep objective the same
min: 2
max: 2
title: objective-create-cocoons-title
description: objective-create-cocoons-description
- type: CreateCocoonsCondition

0 comments on commit 81af714

Please sign in to comment.