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