mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
# 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)
80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using Content.Shared.Access;
|
|
using Content.Shared.TurretController;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.TurretController;
|
|
|
|
public sealed class TurretControllerBoundUserInterface : BoundUserInterface
|
|
{
|
|
[ViewVariables]
|
|
private TurretControllerWindow? _window;
|
|
|
|
public TurretControllerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }
|
|
|
|
protected override void Open()
|
|
{
|
|
if (UiKey is not DeployableTurretControllerUiKey)
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
_window = this.CreateWindow<TurretControllerWindow>();
|
|
_window.SetOwner(Owner);
|
|
_window.OpenCentered();
|
|
|
|
_window.OnAccessLevelsChangedEvent += OnAccessLevelChanged;
|
|
_window.OnArmamentSettingChangedEvent += OnArmamentSettingChanged;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update state in this context is for when users open the controller it will populate with the last interfacestate
|
|
/// </summary>
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (_window == null)
|
|
return;
|
|
|
|
if (state is not DeployableTurretControllerBoundInterfaceState { } cast)
|
|
return;
|
|
|
|
_window.UpdateState(cast);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ReceiveMessage is for live turret data to be updated continuously to the client UI.
|
|
/// </summary>
|
|
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
|
{
|
|
base.ReceiveMessage(message);
|
|
|
|
if (_window == null)
|
|
return;
|
|
|
|
if (message is not DeployableTurretControllerBoundInterfaceMessage { } cast)
|
|
return;
|
|
|
|
// Update the turret states
|
|
_window.UpdateMessage(cast);
|
|
}
|
|
|
|
/// <summary>
|
|
/// When changed access level in UI send message to shared.
|
|
/// </summary>
|
|
private void OnAccessLevelChanged(HashSet<ProtoId<AccessLevelPrototype>> accessLevels, bool enabled)
|
|
{
|
|
SendPredictedMessage(new DeployableTurretExemptAccessLevelChangedMessage(accessLevels, enabled));
|
|
}
|
|
|
|
/// <summary>
|
|
/// When changed armamentsettings in UI send message to shared.
|
|
/// </summary>
|
|
private void OnArmamentSettingChanged(int setting)
|
|
{
|
|
SendPredictedMessage(new DeployableTurretArmamentSettingChangedMessage(setting));
|
|
}
|
|
}
|