From d6b89e771cd8469ecb306ded6685e4998fc32081 Mon Sep 17 00:00:00 2001 From: FN <37689533+FireNameFN@users.noreply.github.com> Date: Sat, 21 Dec 2024 05:20:54 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=B0=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D0=BC=D1=8B=D0=B5=20=D1=82=D1=83=D1=80=D0=B5?= =?UTF-8?q?=D0=BB=D0=B8=20(#174)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Start * Done --- Content.Shared/Verbs/VerbCategory.cs | 2 + .../TurretControl/TurretControlComponent.cs | 4 ++ .../TurretControl/TurretControlSystem.cs | 64 +++++++++++++++++++ .../ru-RU/_corvaxnext/turret-control.ftl | 3 + Resources/Locale/ru-RU/_corvaxnext/verbs.ftl | 1 + .../entities/objects/weapons/guns/turrets.ftl | 3 + .../Entities/Objects/Weapons/Guns/turrets.yml | 9 +++ .../Prototypes/_CorvaxNext/ai_factions.yml | 24 +++++++ 8 files changed, 110 insertions(+) create mode 100644 Content.Shared/_CorvaxNext/TurretControl/TurretControlComponent.cs create mode 100644 Content.Shared/_CorvaxNext/TurretControl/TurretControlSystem.cs create mode 100644 Resources/Locale/ru-RU/_corvaxnext/turret-control.ftl create mode 100644 Resources/Locale/ru-RU/_corvaxnext/verbs.ftl create mode 100644 Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/weapons/guns/turrets.ftl create mode 100644 Resources/Prototypes/_CorvaxNext/Entities/Objects/Weapons/Guns/turrets.yml create mode 100644 Resources/Prototypes/_CorvaxNext/ai_factions.yml diff --git a/Content.Shared/Verbs/VerbCategory.cs b/Content.Shared/Verbs/VerbCategory.cs index 9b9197249a9..052530aa83c 100644 --- a/Content.Shared/Verbs/VerbCategory.cs +++ b/Content.Shared/Verbs/VerbCategory.cs @@ -85,5 +85,7 @@ public VerbCategory(string text, string? icon, bool iconsOnly = false) public static readonly VerbCategory SelectType = new("verb-categories-select-type", null); public static readonly VerbCategory PowerLevel = new("verb-categories-power-level", null); + + public static readonly VerbCategory TurretControlMode = new("verb-categories-turret-control-mode", null); // Corvax-Next-TurretControl } } diff --git a/Content.Shared/_CorvaxNext/TurretControl/TurretControlComponent.cs b/Content.Shared/_CorvaxNext/TurretControl/TurretControlComponent.cs new file mode 100644 index 00000000000..aa1ad0fa7e1 --- /dev/null +++ b/Content.Shared/_CorvaxNext/TurretControl/TurretControlComponent.cs @@ -0,0 +1,4 @@ +namespace Content.Shared._CorvaxNext.TurretControl; + +[RegisterComponent] +public sealed partial class TurretControlComponent : Component; diff --git a/Content.Shared/_CorvaxNext/TurretControl/TurretControlSystem.cs b/Content.Shared/_CorvaxNext/TurretControl/TurretControlSystem.cs new file mode 100644 index 00000000000..9e9c8289962 --- /dev/null +++ b/Content.Shared/_CorvaxNext/TurretControl/TurretControlSystem.cs @@ -0,0 +1,64 @@ +using Content.Shared.NPC.Components; +using Content.Shared.NPC.Prototypes; +using Content.Shared.NPC.Systems; +using Content.Shared.Tag; +using Content.Shared.Verbs; + +namespace Content.Shared._CorvaxNext.TurretControl; + +public sealed class TurretControlSystem : EntitySystem +{ + [Dependency] private readonly NpcFactionSystem _faction = default!; + [Dependency] private readonly TagSystem _tag = default!; + + [ValidatePrototypeId] + private const string ControlTag = "StationAi"; + + [ValidatePrototypeId] + private const string Passive = "TurretPassive"; + + [ValidatePrototypeId] + private const string Peace = "TurretPeace"; + + [ValidatePrototypeId] + private const string Hostile = "TurretHostile"; + + public override void Initialize() + { + SubscribeLocalEvent>(OnGetVerbs); + } + + private void OnGetVerbs(Entity entity, ref GetVerbsEvent e) + { + if (!_tag.HasTag(e.User, ControlTag)) + return; + + if (!TryComp(entity, out var factionMember)) + return; + + e.Verbs.Add(CreateVerb((entity, factionMember), "turret-control-mode-nobody", Passive, 3)); + e.Verbs.Add(CreateVerb((entity, factionMember), "turret-control-mode-hostile", Peace, 2)); + e.Verbs.Add(CreateVerb((entity, factionMember), "turret-control-mode-everybody", Hostile, 1)); + } + + private Verb CreateVerb(Entity entity, string text, string faction, int priority) + { + return new() + { + Text = Loc.GetString(text), + Disabled = _faction.IsMember(entity, faction), + Category = VerbCategory.TurretControlMode, + Priority = priority, + Act = () => SetFaction(entity, faction) + }; + } + + private void SetFaction(Entity entity, string faction) + { + _faction.RemoveFaction(entity, Passive); + _faction.RemoveFaction(entity, Peace); + _faction.RemoveFaction(entity, Hostile); + + _faction.AddFaction(entity, faction); + } +} diff --git a/Resources/Locale/ru-RU/_corvaxnext/turret-control.ftl b/Resources/Locale/ru-RU/_corvaxnext/turret-control.ftl new file mode 100644 index 00000000000..b0d818e45e4 --- /dev/null +++ b/Resources/Locale/ru-RU/_corvaxnext/turret-control.ftl @@ -0,0 +1,3 @@ +turret-control-mode-nobody = Никто +turret-control-mode-hostile = Враждебные +turret-control-mode-everybody = Все diff --git a/Resources/Locale/ru-RU/_corvaxnext/verbs.ftl b/Resources/Locale/ru-RU/_corvaxnext/verbs.ftl new file mode 100644 index 00000000000..ec0bbccd48d --- /dev/null +++ b/Resources/Locale/ru-RU/_corvaxnext/verbs.ftl @@ -0,0 +1 @@ +verb-categories-turret-control-mode = Задать цель diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/weapons/guns/turrets.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/weapons/guns/turrets.ftl new file mode 100644 index 00000000000..8c08336fd05 --- /dev/null +++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/weapons/guns/turrets.ftl @@ -0,0 +1,3 @@ +ent-WeaponTurretControl = { ent-BaseWeaponTurret } + .desc = { ent-BaseWeaponTurret.desc } + .suffix = Управляемая diff --git a/Resources/Prototypes/_CorvaxNext/Entities/Objects/Weapons/Guns/turrets.yml b/Resources/Prototypes/_CorvaxNext/Entities/Objects/Weapons/Guns/turrets.yml new file mode 100644 index 00000000000..c5a9b583c3c --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Entities/Objects/Weapons/Guns/turrets.yml @@ -0,0 +1,9 @@ +- type: entity + parent: BaseWeaponTurret + id: WeaponTurretControl + suffix: Control + components: + - type: NpcFactionMember + factions: + - TurretPeace + - type: TurretControl diff --git a/Resources/Prototypes/_CorvaxNext/ai_factions.yml b/Resources/Prototypes/_CorvaxNext/ai_factions.yml new file mode 100644 index 00000000000..7ffa327886a --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/ai_factions.yml @@ -0,0 +1,24 @@ +- type: npcFaction + id: TurretPassive + +- type: npcFaction + id: TurretPeace + hostile: + - Dragon + - SimpleHostile + - Xeno + +- type: npcFaction + id: TurretHostile + hostile: + - Dragon + - NanoTrasen + - Mouse + - Passive + - PetsNT + - SimpleHostile + - SimpleNeutral + - Syndicate + - Xeno + - Zombie + - Revolutionary