mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
will do map refactor tomorrow, for now, planet lighting 🆑 * add: Ported planet lighting for indoor / outdoor areas. * add: Ported day-night cycle functionality. * add: Ported some Storage UI v2 fixes. --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: DoutorWhite <thedoctorwhite@gmail.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> (cherry picked from commit 4efb0b3b328dd4eba3095cc3f0a95fad88b49661)
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Content.Shared.Light.Components;
|
|
using Content.Shared.Maps;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Shared.Light.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// Handles the roof flag for tiles that gets used for the RoofOverlay.
|
|
/// </summary>
|
|
public abstract class SharedRoofSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedMapSystem _maps = default!;
|
|
|
|
public void SetRoof(Entity<MapGridComponent?, RoofComponent?> grid, Vector2i index, bool value)
|
|
{
|
|
if (!Resolve(grid, ref grid.Comp1, ref grid.Comp2, false))
|
|
return;
|
|
|
|
if (!_maps.TryGetTile(grid.Comp1, index, out var tile))
|
|
return;
|
|
|
|
var mask = (tile.Flags & (byte)TileFlag.Roof);
|
|
var rooved = mask != 0x0;
|
|
|
|
if (rooved == value)
|
|
return;
|
|
|
|
Tile newTile;
|
|
|
|
if (value)
|
|
{
|
|
newTile = tile.WithFlag((byte)(tile.Flags | (ushort)TileFlag.Roof));
|
|
}
|
|
else
|
|
{
|
|
newTile = tile.WithFlag((byte)(tile.Flags & ~(ushort)TileFlag.Roof));
|
|
}
|
|
|
|
_maps.SetTile((grid.Owner, grid.Comp1), index, newTile);
|
|
}
|
|
}
|