Files
wwdpublic/Content.Shared/TurretController/DeployableTurretControllerComponent.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

107 lines
3.0 KiB
C#

using Content.Shared.Access;
using Content.Shared.Turrets;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.TurretController;
/// <summary>
/// Attached to entities that can set data on linked turret-based entities
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedDeployableTurretControllerSystem))]
public sealed partial class DeployableTurretControllerComponent : Component
{
/// <summary>
/// The states of the turrets linked to this entity, indexed by their device address.
/// </summary>
[ViewVariables]
public Dictionary<string, DeployableTurretState> LinkedTurrets = new();
/// <summary>
/// The current armament state of the linked turrets.
/// [-1: Inactive, 0: weapon mode A, 1: weapon mode B, etc]
/// </summary>
[DataField, AutoNetworkedField]
public int ArmamentState = -1;
/// <summary>
/// Access levels that are known to the entity.
/// </summary>
[DataField]
public HashSet<ProtoId<AccessLevelPrototype>> AccessLevels = new();
/// <summary>
///Access groups that are known to the entity.
/// </summary>
[DataField]
public HashSet<ProtoId<AccessGroupPrototype>> AccessGroups = new();
/// <summary>
/// Sound to play when denied access.
/// </summary>
[DataField]
public SoundSpecifier AccessDeniedSound = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
}
[Serializable, NetSerializable]
public sealed class DeployableTurretControllerBoundInterfaceMessage : BoundUserInterfaceMessage
{
public List<(string, string)> TurretStates;
public DeployableTurretControllerBoundInterfaceMessage(List<(string, string)> turretStates)
{
TurretStates = turretStates;
}
}
[Serializable, NetSerializable]
public sealed class DeployableTurretControllerBoundInterfaceState : BoundUserInterfaceState
{
public List<(string, string)> TurretStates;
public DeployableTurretControllerBoundInterfaceState(List<(string, string)> turretStates)
{
TurretStates = turretStates;
}
}
[Serializable, NetSerializable]
public sealed class DeployableTurretArmamentSettingChangedMessage : BoundUserInterfaceMessage
{
public int ArmamentState;
public DeployableTurretArmamentSettingChangedMessage(int armamentState)
{
ArmamentState = armamentState;
}
}
[Serializable, NetSerializable]
public sealed class DeployableTurretExemptAccessLevelChangedMessage : BoundUserInterfaceMessage
{
public HashSet<ProtoId<AccessLevelPrototype>> AccessLevels;
public bool Enabled;
public DeployableTurretExemptAccessLevelChangedMessage(HashSet<ProtoId<AccessLevelPrototype>> accessLevels, bool enabled)
{
AccessLevels = accessLevels;
Enabled = enabled;
}
}
[Serializable, NetSerializable]
public enum TurretControllerVisuals : byte
{
ControlPanel,
}
[Serializable, NetSerializable]
public enum DeployableTurretControllerUiKey : byte
{
Key,
}