forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Content.Shared/_CorvaxNext/TurretControl/TurretControlComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Content.Shared._CorvaxNext.TurretControl; | ||
|
||
[RegisterComponent] | ||
public sealed partial class TurretControlComponent : Component; |
64 changes: 64 additions & 0 deletions
64
Content.Shared/_CorvaxNext/TurretControl/TurretControlSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TagPrototype>] | ||
private const string ControlTag = "StationAi"; | ||
|
||
[ValidatePrototypeId<NpcFactionPrototype>] | ||
private const string Passive = "TurretPassive"; | ||
|
||
[ValidatePrototypeId<NpcFactionPrototype>] | ||
private const string Peace = "TurretPeace"; | ||
|
||
[ValidatePrototypeId<NpcFactionPrototype>] | ||
private const string Hostile = "TurretHostile"; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<TurretControlComponent, GetVerbsEvent<Verb>>(OnGetVerbs); | ||
} | ||
|
||
private void OnGetVerbs(Entity<TurretControlComponent> entity, ref GetVerbsEvent<Verb> e) | ||
{ | ||
if (!_tag.HasTag(e.User, ControlTag)) | ||
return; | ||
|
||
if (!TryComp<NpcFactionMemberComponent>(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<NpcFactionMemberComponent?> 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<NpcFactionMemberComponent?> entity, string faction) | ||
{ | ||
_faction.RemoveFaction(entity, Passive); | ||
_faction.RemoveFaction(entity, Peace); | ||
_faction.RemoveFaction(entity, Hostile); | ||
|
||
_faction.AddFaction(entity, faction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
turret-control-mode-nobody = Никто | ||
turret-control-mode-hostile = Враждебные | ||
turret-control-mode-everybody = Все |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
verb-categories-turret-control-mode = Задать цель |
3 changes: 3 additions & 0 deletions
3
...ces/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/weapons/guns/turrets.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ent-WeaponTurretControl = { ent-BaseWeaponTurret } | ||
.desc = { ent-BaseWeaponTurret.desc } | ||
.suffix = Управляемая |
9 changes: 9 additions & 0 deletions
9
Resources/Prototypes/_CorvaxNext/Entities/Objects/Weapons/Guns/turrets.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- type: entity | ||
parent: BaseWeaponTurret | ||
id: WeaponTurretControl | ||
suffix: Control | ||
components: | ||
- type: NpcFactionMember | ||
factions: | ||
- TurretPeace | ||
- type: TurretControl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |