Files
wwdpublic/Content.Server/Construction/NodeEntities/BoardNodeEntity.cs
Solaris a64b5164e3 Port AI Sentry Turrets (#1990)
# Description

I am trying to port over the AI turrets being implemented into wizden
made by chromiumboy. It looks fantastic and would like to port this now
and work on any issues that might show.

---

# Original PRs
https://github.com/space-wizards/space-station-14/issues/35223

https://github.com/space-wizards/space-station-14/pull/35025
https://github.com/space-wizards/space-station-14/pull/35031
https://github.com/space-wizards/space-station-14/pull/35058
https://github.com/space-wizards/space-station-14/pull/35123
https://github.com/space-wizards/space-station-14/pull/35149
https://github.com/space-wizards/space-station-14/pull/35235
https://github.com/space-wizards/space-station-14/pull/35236
---

# TODO

- [x] Port all related PRs to EE.
- [x] Patch any bugs with turrets or potential issues.
- [x] Cleanup my shitcode or changes.
---

# Changelog

🆑
- add: Added recharging sentry turrets, one is AI-based or the other is
Sec can make.
- add: The sentry turrets can be made after researching in T3 arsenal.
The boards are made in the sec fab.
- add: New ID permissions for borgs and minibots for higher turret
options.
- tweak: Turrets stop shooting after someone goes crit.

---------

Co-authored-by: Nathaniel Adams <60526456+Nathaniel-Adams@users.noreply.github.com>

(cherry picked from commit 209d0537401cbda448a03e910cca9a898c9d566f)
2025-03-21 18:28:40 +03:00

45 lines
1.5 KiB
C#

using Content.Shared.Construction;
using Content.Shared.Construction.Components;
using JetBrains.Annotations;
using Robust.Server.Containers;
namespace Content.Server.Construction.NodeEntities;
/// <summary>
/// Works for both <see cref="ComputerBoardComponent"/> and <see cref="MachineBoardComponent"/>
/// because duplicating code just for this is really stinky.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public sealed partial class BoardNodeEntity : IGraphNodeEntity
{
[DataField]
public string Container { get; private set; } = string.Empty;
public string? GetId(EntityUid? uid, EntityUid? userUid, GraphNodeEntityArgs args)
{
if (uid == null)
return null;
var containerSystem = args.EntityManager.EntitySysManager.GetEntitySystem<ContainerSystem>();
if (!containerSystem.TryGetContainer(uid.Value, Container, out var container)
|| container.ContainedEntities.Count == 0)
return null;
var board = container.ContainedEntities[0];
// There should not be a case where more than one of these components exist on the same entity...
if (args.EntityManager.TryGetComponent(board, out MachineBoardComponent? machine))
return machine.Prototype;
if (args.EntityManager.TryGetComponent(board, out ComputerBoardComponent? computer))
return computer.Prototype;
if (args.EntityManager.TryGetComponent(board, out ElectronicsBoardComponent? electronics))
return electronics.Prototype;
return null;
}
}