diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs index 77df4d8590..5e22ca46e4 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs @@ -40,6 +40,22 @@ private void OnAirlockBolt(EntityUid ent, DoorBoltComponent component, StationAi return; } + // Fire edit start + if (!TryGetCore(args.User, out var core) || + core.Comp == null) + return; + + if (_battery.GetCharge(core.Owner) < core.Comp.ControlDoorChargeCost) + { + ShowNotChargeEnoughPopup(args.User); + return; + } + + if (_net.IsServer) + if (!_battery.TryUseCharge(core.Owner, core.Comp.ControlDoorChargeCost)) + return; + // Fire edit end + var setResult = _doors.TrySetBoltDown((ent, component), args.Bolted, args.User, predicted: true); if (!setResult) { @@ -75,6 +91,22 @@ private void OnAirlockEmergencyAccess(EntityUid ent, AirlockComponent component, return; } + // Fire edit start + if (!TryGetCore(args.User, out var core) || + core.Comp == null) + return; + + if (_battery.GetCharge(core.Owner) < core.Comp.ControlDoorChargeCost) + { + ShowNotChargeEnoughPopup(args.User); + return; + } + + if (_net.IsServer) + if (!_battery.TryUseCharge(core.Owner, core.Comp.ControlDoorChargeCost)) + return; + // Fire edit end + _airlocks.SetEmergencyAccess((ent, component), args.EmergencyAccess, args.User, predicted: true); _adminLogger.Add(LogType.Action, $"{args.User} set emergency access status on {ent} to [{args.EmergencyAccess}] using the Station AI radial."); } @@ -104,6 +136,22 @@ private void OnElectrified(EntityUid ent, ElectrifiedComponent component, Statio return; } + // Fire edit start + if (!TryGetCore(args.User, out var core) || + core.Comp == null) + return; + + if (_battery.GetCharge(core.Owner) < core.Comp.ControlDoorChargeCost) + { + ShowNotChargeEnoughPopup(args.User); + return; + } + + if (_net.IsServer) + if (!_battery.TryUseCharge(core.Owner, core.Comp.ControlDoorChargeCost)) + return; + // Fire edit end + _adminLogger.Add(LogType.Action, $"{args.User} set electrified status on {ent} to [{args.Electrified}] using the Station AI radial."); _electrify.SetElectrified((ent, component), args.Electrified); var soundToPlay = component.Enabled diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs index 91dd61d334..d170652422 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs @@ -164,6 +164,40 @@ private void OnHeldInteraction(Entity ent, ref Interacti { ShowDeviceNotRespondingPopup(ent.Owner); } + + // Fire edit start + // TODO: Сейчас при нажатии Alt + по шлюзу энергия списывается дважды, за взаимодействие + использование открытой панельки, нужно будет это исправить + if (args.Cancelled || args.Target == null) + return; + + if (!TryGetCore(ent, out var core) || + core.Comp == null) + return; + + if (_whitelist.IsWhitelistPass(core.Comp.IncreasedChargeCostWhitelist, args.Target.Value)) + { + if (_battery.GetCharge(core.Owner) < core.Comp.IncreasedInteractionChargeCost) + { + ShowNotChargeEnoughPopup(ent); + args.Cancelled = true; + return; + } + + if (!_battery.TryUseCharge(core.Owner, core.Comp.IncreasedInteractionChargeCost)) + args.Cancelled = true; + return; + } + + if (_battery.GetCharge(core.Owner) < core.Comp.OtherInteractionsChargeCost) + { + ShowNotChargeEnoughPopup(ent); + args.Cancelled = true; + return; + } + + if (!_battery.TryUseCharge(core.Owner, core.Comp.OtherInteractionsChargeCost)) + args.Cancelled = true; + // Fire edit end } private void OnTargetVerbs(Entity ent, ref GetVerbsEvent args) @@ -211,6 +245,13 @@ private void ShowDeviceNoAccessPopup(EntityUid toEntity) { _popup.PopupClient(Loc.GetString("ai-device-no-access"), toEntity, PopupType.MediumCaution); } + + // Fire edit start + private void ShowNotChargeEnoughPopup(EntityUid toEntity) + { + _popup.PopupClient(Loc.GetString("ai-not-charge-enough"), toEntity, PopupType.MediumCaution); + } + // Fire edit end } /// diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index e43247fdb0..7441558323 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -33,6 +33,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Content.Shared.Whitelist; // Fire edit namespace Content.Shared.Silicons.StationAi; @@ -61,6 +62,8 @@ public abstract partial class SharedStationAiSystem : EntitySystem [Dependency] private readonly SharedPowerReceiverSystem PowerReceiver = default!; [Dependency] private readonly SharedTransformSystem _xforms = default!; [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly SharedBatterySystem _battery = default!; // Fire edit + [Dependency] private readonly EntityWhitelistSystem _whitelist = default!; // Fire edit [Dependency] private readonly StationAiVisionSystem _vision = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly MobStateSystem _mobState = default!; diff --git a/Content.Shared/Silicons/StationAi/StationAiCoreComponent.cs b/Content.Shared/Silicons/StationAi/StationAiCoreComponent.cs index ec3f308104..ae9b2ffa18 100644 --- a/Content.Shared/Silicons/StationAi/StationAiCoreComponent.cs +++ b/Content.Shared/Silicons/StationAi/StationAiCoreComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Whitelist; // Fire edit using Robust.Shared.GameStates; using Robust.Shared.Prototypes; @@ -47,6 +48,24 @@ public sealed partial class StationAiCoreComponent : Component /// Name of the container slot that holds the 'brain' used to construct the AI core /// public const string BrainContainer = "station_ai_brain_slot"; + + // Fire edit start + + [DataField] + public float ControlDoorChargeCost = 7500f; // Joule's + + [DataField] + public float IncreasedInteractionChargeCost = 10000f; // Joule's + + [DataField] + public float OtherInteractionsChargeCost = 1500f; // Joule's + + [DataField] + public EntityWhitelist IncreasedChargeCostWhitelist = new() + { + Components = ["SignalSwitch"] + }; + // Fire edit end } /// diff --git a/Resources/Locale/en-US/_strings/_scp/silicons/station-ai.ftl b/Resources/Locale/en-US/_strings/_scp/silicons/station-ai.ftl new file mode 100644 index 0000000000..10bb5a7f1d --- /dev/null +++ b/Resources/Locale/en-US/_strings/_scp/silicons/station-ai.ftl @@ -0,0 +1 @@ +ai-not-charge-enough = Charge not enough diff --git a/Resources/Locale/ru-RU/_strings/_scp/silicons/station-ai.ftl b/Resources/Locale/ru-RU/_strings/_scp/silicons/station-ai.ftl new file mode 100644 index 0000000000..dd2aa8d6de --- /dev/null +++ b/Resources/Locale/ru-RU/_strings/_scp/silicons/station-ai.ftl @@ -0,0 +1 @@ +ai-not-charge-enough = Недостаточно заряда diff --git a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml index bd4c9a1bbc..b52351263d 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml @@ -289,7 +289,7 @@ # Disable networking to prevent the battery getting continuously dirtied every tick as it interacts with the power network. # This can not be done by changing the charge rate as the power supply ramps up over time. # This disables prediction for this battery. - netsync: false + netsync: true # Fire edit maxCharge: 300000 startingCharge: 300000 - type: ApcPowerReceiverBattery diff --git a/Resources/Prototypes/_Scp/Entities/Mobs/Player/Scp/Events/scp079.yml b/Resources/Prototypes/_Scp/Entities/Mobs/Player/Scp/Events/scp079.yml index cc12662b68..652e1b7437 100644 --- a/Resources/Prototypes/_Scp/Entities/Mobs/Player/Scp/Events/scp079.yml +++ b/Resources/Prototypes/_Scp/Entities/Mobs/Player/Scp/Events/scp079.yml @@ -203,7 +203,7 @@ powerLoad: 500 - type: ExtensionCableReceiver - type: Battery - netsync: false + netsync: true maxCharge: 300000 startingCharge: 300000 - type: ApcPowerReceiverBattery