From 81af71436c02a6bde751ec822cd447e790606b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A5=D0=B8=D0=BB?= =?UTF-8?q?=D1=8E=D0=B2=D1=87=D0=B8=D1=86?= Date: Fri, 13 Sep 2024 22:12:54 +0300 Subject: [PATCH] Add cocoons objective --- .../CreateCocoonsConditionComponent.cs | 7 +++ .../Systems/CreateCocoonsConditionSystem.cs | 49 +++++++++++++++++++ .../objectives/conditions/create-cocoons.ftl | 12 +++++ .../ru-RU/ss220/spider-queen/spider-queen.ftl | 2 + .../SS220/GameRules/midround_antags.yml | 3 ++ .../SS220/Objectives/spider_queen.yml | 28 +++++++++++ 6 files changed, 101 insertions(+) create mode 100644 Content.Server/SS220/Objectives/Components/CreateCocoonsConditionComponent.cs create mode 100644 Content.Server/SS220/Objectives/Systems/CreateCocoonsConditionSystem.cs create mode 100644 Resources/Locale/ru-RU/ss220/objectives/conditions/create-cocoons.ftl create mode 100644 Resources/Prototypes/SS220/Objectives/spider_queen.yml diff --git a/Content.Server/SS220/Objectives/Components/CreateCocoonsConditionComponent.cs b/Content.Server/SS220/Objectives/Components/CreateCocoonsConditionComponent.cs new file mode 100644 index 000000000000..bd348a1608c0 --- /dev/null +++ b/Content.Server/SS220/Objectives/Components/CreateCocoonsConditionComponent.cs @@ -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 +{ +} diff --git a/Content.Server/SS220/Objectives/Systems/CreateCocoonsConditionSystem.cs b/Content.Server/SS220/Objectives/Systems/CreateCocoonsConditionSystem.cs new file mode 100644 index 000000000000..316f08a32d92 --- /dev/null +++ b/Content.Server/SS220/Objectives/Systems/CreateCocoonsConditionSystem.cs @@ -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 IsCompletedOnce = new(); + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnGetProgress); + } + + private void OnGetProgress(Entity 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(mobUid, out var spiderQueen)) + return 0f; + + if (spiderQueen.CocoonsList.Count >= target) + { + IsCompletedOnce.Add(mind, true); + return 1f; + } + else + { + return 0f; + } + } +} diff --git a/Resources/Locale/ru-RU/ss220/objectives/conditions/create-cocoons.ftl b/Resources/Locale/ru-RU/ss220/objectives/conditions/create-cocoons.ftl new file mode 100644 index 000000000000..a1d5c2932075 --- /dev/null +++ b/Resources/Locale/ru-RU/ss220/objectives/conditions/create-cocoons.ftl @@ -0,0 +1,12 @@ +objective-create-cocoons-title = + Создать { $count } { $count -> + [one] кокон + [few] кокона + *[other] коконов + }. +objective-create-cocoons-description = + Используйте действие «Окукливание» чтобы создать { $count } { $count -> + [one] кокон + [few] кокона + *[other] коконов + }. diff --git a/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl b/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl index 33e936764ad7..c74b8f10f901 100644 --- a/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl +++ b/Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl @@ -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] diff --git a/Resources/Prototypes/SS220/GameRules/midround_antags.yml b/Resources/Prototypes/SS220/GameRules/midround_antags.yml index ef6214babde5..3d37cd3a2c83 100644 --- a/Resources/Prototypes/SS220/GameRules/midround_antags.yml +++ b/Resources/Prototypes/SS220/GameRules/midround_antags.yml @@ -51,6 +51,9 @@ minimumPlayers: 30 - type: AntagSpawner prototype: MobSpiderSpaceQueen + - type: AntagObjectives + objectives: + - CreateCocoonsObjective - type: AntagSelection definitions: - prefRoles: [ SpiderQueen ] diff --git a/Resources/Prototypes/SS220/Objectives/spider_queen.yml b/Resources/Prototypes/SS220/Objectives/spider_queen.yml new file mode 100644 index 000000000000..bcf37becfd4f --- /dev/null +++ b/Resources/Prototypes/SS220/Objectives/spider_queen.yml @@ -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