-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Station AI ability to electricute doors #32012
Changes from 26 commits
bc88447
60bd34f
130a3ea
8d33a04
136f19b
265fd07
a08fffc
a5967bb
9050743
846cf95
ac19543
fc889c4
43261a5
d899a5a
36ff0ee
28f27fb
9b2f203
9d8d5d4
67e6875
5dc4dfc
7483434
0b81947
96c46fc
1a7eac5
fdc01d3
64094f9
c1f9f60
269ed7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,75 @@ | ||
using Content.Shared.Doors.Components; | ||
using Content.Shared.Electrocution; | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
public sealed partial class StationAiSystem | ||
{ | ||
private readonly ResPath _aiActionsRsi = new ResPath("/Textures/Interface/Actions/actions_ai.rsi"); | ||
|
||
private void InitializeAirlock() | ||
{ | ||
SubscribeLocalEvent<DoorBoltComponent, GetStationAiRadialEvent>(OnDoorBoltGetRadial); | ||
SubscribeLocalEvent<AirlockComponent, GetStationAiRadialEvent>(OnEmergencyAccessGetRadial); | ||
SubscribeLocalEvent<ElectrifiedComponent, GetStationAiRadialEvent>(OnDoorElectrifiedGetRadial); | ||
} | ||
|
||
private void OnDoorBoltGetRadial(Entity<DoorBoltComponent> ent, ref GetStationAiRadialEvent args) | ||
{ | ||
args.Actions.Add(new StationAiRadial() | ||
{ | ||
Sprite = ent.Comp.BoltsDown ? | ||
new SpriteSpecifier.Rsi( | ||
new ResPath("/Textures/Structures/Doors/Airlocks/Standard/basic.rsi"), "open") : | ||
new SpriteSpecifier.Rsi( | ||
new ResPath("/Textures/Structures/Doors/Airlocks/Standard/basic.rsi"), "closed"), | ||
Tooltip = ent.Comp.BoltsDown ? Loc.GetString("bolt-open") : Loc.GetString("bolt-close"), | ||
Event = new StationAiBoltEvent() | ||
args.Actions.Add( | ||
new StationAiRadial | ||
{ | ||
Sprite = ent.Comp.BoltsDown | ||
? new SpriteSpecifier.Rsi(_aiActionsRsi, "unbolt_door") | ||
: new SpriteSpecifier.Rsi(_aiActionsRsi, "bolt_door"), | ||
Tooltip = ent.Comp.BoltsDown | ||
? Loc.GetString("bolt-open") | ||
: Loc.GetString("bolt-close"), | ||
Event = new StationAiBoltEvent | ||
{ | ||
Bolted = !ent.Comp.BoltsDown, | ||
} | ||
} | ||
); | ||
} | ||
|
||
private void OnEmergencyAccessGetRadial(Entity<AirlockComponent> ent, ref GetStationAiRadialEvent args) | ||
{ | ||
args.Actions.Add( | ||
new StationAiRadial | ||
{ | ||
Sprite = ent.Comp.EmergencyAccess | ||
? new SpriteSpecifier.Rsi(_aiActionsRsi, "emergency_off") | ||
: new SpriteSpecifier.Rsi(_aiActionsRsi, "emergency_on"), | ||
Tooltip = ent.Comp.EmergencyAccess | ||
? Loc.GetString("emergency-access-off") | ||
: Loc.GetString("emergency-access-on"), | ||
Event = new StationAiEmergencyAccessEvent | ||
{ | ||
EmergencyAccess = !ent.Comp.EmergencyAccess, | ||
} | ||
} | ||
); | ||
} | ||
|
||
private void OnDoorElectrifiedGetRadial(Entity<ElectrifiedComponent> ent, ref GetStationAiRadialEvent args) | ||
{ | ||
args.Actions.Add( | ||
new StationAiRadial | ||
{ | ||
Bolted = !ent.Comp.BoltsDown, | ||
Sprite = ent.Comp.Enabled | ||
? new SpriteSpecifier.Rsi(_aiActionsRsi, "door_overcharge_off") | ||
: new SpriteSpecifier.Rsi(_aiActionsRsi, "door_overcharge_on"), | ||
Tooltip = ent.Comp.Enabled | ||
? Loc.GetString("electrify-door-off") | ||
: Loc.GetString("electrify-door-on"), | ||
Event = new StationAiElectrifiedEvent | ||
{ | ||
Electrified = !ent.Comp.Enabled, | ||
} | ||
} | ||
}); | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using Content.Shared.DeviceLinking; | ||
using Content.Shared.Doors.Systems; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
|
@@ -23,6 +24,18 @@ public sealed partial class AirlockComponent : Component | |
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField, AutoNetworkedField] | ||
public bool EmergencyAccess = false; | ||
|
||
/// <summary> | ||
/// Sound to play when the airlock emergency access is turned on. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier EmergencyOnSound = new SoundPathSpecifier("/Audio/Machines/airlock_emergencyon.ogg"); | ||
|
||
/// <summary> | ||
/// Sound to play when the airlock emergency access is turned off. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier EmergencyOffSound = new SoundPathSpecifier("/Audio/Machines/airlock_emergencyoff.ogg"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VVRW is redundant with datafield. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
/// <summary> | ||
/// Pry modifier for a powered airlock. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Content.Shared.Doors.Components; | ||
using Robust.Shared.Audio.Systems; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Prying.Components; | ||
using Content.Shared.Wires; | ||
|
@@ -11,6 +12,7 @@ public abstract class SharedAirlockSystem : EntitySystem | |
[Dependency] protected readonly SharedDoorSystem DoorSystem = default!; | ||
[Dependency] protected readonly SharedPopupSystem Popup = default!; | ||
[Dependency] private readonly SharedWiresSystem _wiresSystem = default!; | ||
[Dependency] protected readonly SharedAudioSystem Audio = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
|
@@ -123,11 +125,23 @@ public void UpdateEmergencyLightStatus(EntityUid uid, AirlockComponent component | |
Appearance.SetData(uid, DoorVisuals.EmergencyLights, component.EmergencyAccess); | ||
} | ||
|
||
public void ToggleEmergencyAccess(EntityUid uid, AirlockComponent component) | ||
public void SetEmergencyAccess(Entity<AirlockComponent> ent, bool value, EntityUid? user = null, bool predicted = false) | ||
{ | ||
component.EmergencyAccess = !component.EmergencyAccess; | ||
Dirty(uid, component); // This only runs on the server apparently so we need this. | ||
UpdateEmergencyLightStatus(uid, component); | ||
if(!ent.Comp.Powered) | ||
return; | ||
|
||
if (ent.Comp.EmergencyAccess == value) | ||
return; | ||
|
||
ent.Comp.EmergencyAccess = value; | ||
Dirty(ent, ent.Comp); // This only runs on the server apparently so we need this. | ||
UpdateEmergencyLightStatus(ent, ent.Comp); | ||
|
||
var sound = ent.Comp.EmergencyAccess ? ent.Comp.EmergencyOnSound : ent.Comp.EmergencyOffSound; | ||
if (predicted) | ||
Audio.PlayPredicted(sound, ent, user: user); | ||
else | ||
Audio.PlayPvs(sound, ent); | ||
} | ||
Comment on lines
+148
to
154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do any of the callers even need this? This method is new... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AdminVerbSystem uses non-predicted version. is that wrong? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine for now. |
||
|
||
public void SetAutoCloseDelayModifier(AirlockComponent component, float value) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should guard these values behind equals checks to avoid dirtying if the value hasn't changed because dirtying is expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed