mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Axes the easy IMapManager references * Axes the references to unported (obsolete) IMapManager methods * Converts salvageruler command to a LocalizedEntityCommand so it can use SharedMapSystem * Removes IMapManager from GameTicker This required axing the map nuke during restart, but that should be fine? Maps are entities so EntityManager.FlushEntities should delete them all and that's the preceding line * submodule update(?) --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using Content.Server.Fluids.EntitySystems;
|
|
using Content.Server.Spreader;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Coordinates.Helpers;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Trigger;
|
|
using Content.Shared.Trigger.Components.Effects;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Trigger.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles creating smoke when <see cref="SmokeOnTriggerComponent"/> is triggered.
|
|
/// </summary>
|
|
public sealed partial class SmokeOnTriggerSystem : EntitySystem
|
|
{
|
|
[Dependency] private MapSystem _map = default!;
|
|
[Dependency] private SmokeSystem _smoke = default!;
|
|
[Dependency] private TransformSystem _transform = default!;
|
|
[Dependency] private SpreaderSystem _spreader = default!;
|
|
[Dependency] private TurfSystem _turf = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SmokeOnTriggerComponent, TriggerEvent>(OnTrigger);
|
|
}
|
|
|
|
private void OnTrigger(Entity<SmokeOnTriggerComponent> ent, ref TriggerEvent args)
|
|
{
|
|
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
|
|
return;
|
|
|
|
var target = ent.Comp.TargetUser ? args.User : ent.Owner;
|
|
|
|
if (target == null)
|
|
return;
|
|
|
|
// TODO: move all of this into an API function in SmokeSystem
|
|
var xform = Transform(target.Value);
|
|
var mapCoords = _transform.GetMapCoordinates(target.Value, xform);
|
|
if (!_map.TryFindGridAt(mapCoords, out var gridUid, out var gridComp) ||
|
|
!_map.TryGetTileRef(gridUid, gridComp, xform.Coordinates, out var tileRef) ||
|
|
tileRef.Tile.IsEmpty)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (_spreader.RequiresFloorToSpread(ent.Comp.SmokePrototype.ToString()) && _turf.IsSpace(tileRef))
|
|
return;
|
|
|
|
var coords = _map.MapToGrid(gridUid, mapCoords);
|
|
var smoke = Spawn(ent.Comp.SmokePrototype, coords.SnapToGrid());
|
|
if (!TryComp<SmokeComponent>(smoke, out var smokeComp))
|
|
{
|
|
Log.Error($"Smoke prototype {ent.Comp.SmokePrototype} was missing SmokeComponent");
|
|
Del(smoke);
|
|
return;
|
|
}
|
|
|
|
_smoke.StartSmoke(smoke, ent.Comp.Solution, (float)ent.Comp.Duration.TotalSeconds, ent.Comp.SpreadAmount, smokeComp);
|
|
|
|
args.Handled = true;
|
|
}
|
|
}
|