using Content.Server.Fluids.EntitySystems; using Content.Server.Light.EntitySystems; using Content.Server.Light.Components; using Content.Server.Spreader; using Content.Server.Store.Systems; using Content.Shared._DV.Silicons; using Content.Shared.Chemistry.Components; using Content.Shared.Coordinates.Helpers; using Content.Shared.Light.Components; using Content.Shared.Maps; using Robust.Shared.GameObjects; using Robust.Shared.Map; namespace Content.Server._DV.Silicons; public sealed class StationAiShopSystem : SharedStationAiShopSystem { [Dependency] private readonly StoreSystem _store = default!; [Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly SmokeSystem _smoke = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SpreaderSystem _spreader = default!; [Dependency] private readonly PoweredLightSystem _poweredLight = default!; [Dependency] private readonly TurfSystem _turf = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnShopAction); SubscribeLocalEvent(OnLightSynthesizer); SubscribeLocalEvent(OnEmergencySealant); } private void OnShopAction(Entity ent, ref StationAiShopActionEvent args) { _store.ToggleUi(args.Performer, ent); } private void OnLightSynthesizer(Entity ent, ref StationAiLightSynthesizerActionEvent args) { // Grab what light exists on the fixture, delete it. Then add light with respect to fixture. var fixture = CompOrNull(args.Target); if (fixture is null) return; var lightProto = fixture.BulbType switch { LightBulbType.Bulb => args.BulbPrototype, LightBulbType.Tube => args.TubePrototype, _ => args.BulbPrototype }; if (_poweredLight.EjectBulb(args.Target) is { } oldBulb) Del(oldBulb); var bulb = Spawn(lightProto); if (!_poweredLight.InsertBulb(args.Target, bulb)) { Del(bulb); return; } args.Handled = true; } private void OnEmergencySealant(Entity ent, ref StationAiSmokeActionEvent args) { var mapCoords = _transform.ToMapCoordinates(args.Target); if (!_map.TryFindGridAt(mapCoords, out _, out var grid) || !grid.TryGetTileRef(args.Target, out var tileRef) || tileRef.Tile.IsEmpty) { return; } if (_spreader.RequiresFloorToSpread(args.SmokePrototype.ToString()) && _turf.IsSpace(tileRef.Tile)) return; var coords = grid.MapToGrid(mapCoords); var uid = Spawn(args.SmokePrototype, coords.SnapToGrid()); _smoke.StartSmoke(uid, args.Solution, args.Duration, args.SpreadAmount); args.Handled = true; } }