Add sun shadows (planet lighting stage 2) (#35145)
* Implements a Dynamic Lighting System on maps. * Edit: the night should be a little bit brighter and blue now. * Major edit: everything must be done on the client side now, with certain datafield replicated. Changes were outlined in the salvage to accommodate the new lighting system. * Edit: The offset is now serverside, this makes the time accurate in all situations. * Removing ununsed import * Minor tweaks * Tweak in time precision * Minor tweak + Unused import removed * Edit: apparently RealTime is better for what I'm looking for * Fix: Now the time is calculated correctly. * Minor tweaks * Adds condition for when the light should be updated * Add planet lighting * she * close-ish * c * bittersweat * Fixes * Revert "Merge branch '22719' into 2024-09-29-planet-lighting" This reverts commit 9f2785bb16aee47d794aa3eed8ae15004f97fc35, reversing changes made to 19649c07a5fb625423e08fc18d91c9cb101daa86. * Europa and day-night * weh * rooves working * Clean * Remove Europa * Fixes * fix * Update * Fix caves * Update for engine * Add sun shadows (planet lighting v2) For now mostly targeting walls and having the shadows change over time. Got the basic proof-of-concept working just needs a hell of a lot of polish. * Documentation * a * Fixes * Move blur to an overlay * Slughands * Fixes * Apply RoofOverlay per-grid not per-map * Fix light render scales * sangas * Juice it a bit * Better angle * Fixes * Add color support * Rounding bandaid * Wehs * Better * Remember I forgot to do this when writing docs --------- Co-authored-by: DoutorWhite <thedoctorwhite@gmail.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using Content.Shared.Light.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Shared.Map;
|
||||
@@ -18,6 +19,7 @@ public abstract class SharedRoofSystem : EntitySystem
|
||||
/// Returns whether the specified tile is roof-occupied.
|
||||
/// </summary>
|
||||
/// <returns>Returns false if no data or not rooved.</returns>
|
||||
[Pure]
|
||||
public bool IsRooved(Entity<MapGridComponent, RoofComponent> grid, Vector2i index)
|
||||
{
|
||||
var roof = grid.Comp2;
|
||||
@@ -49,6 +51,40 @@ public abstract class SharedRoofSystem : EntitySystem
|
||||
return false;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public Color? GetColor(Entity<MapGridComponent, RoofComponent> grid, Vector2i index)
|
||||
{
|
||||
var roof = grid.Comp2;
|
||||
var chunkOrigin = SharedMapSystem.GetChunkIndices(index, RoofComponent.ChunkSize);
|
||||
|
||||
if (roof.Data.TryGetValue(chunkOrigin, out var bitMask))
|
||||
{
|
||||
var chunkRelative = SharedMapSystem.GetChunkRelative(index, RoofComponent.ChunkSize);
|
||||
var bitFlag = (ulong) 1 << (chunkRelative.X + chunkRelative.Y * RoofComponent.ChunkSize);
|
||||
|
||||
var isRoof = (bitMask & bitFlag) == bitFlag;
|
||||
|
||||
// Early out, otherwise check for components on tile.
|
||||
if (isRoof)
|
||||
{
|
||||
return roof.Color;
|
||||
}
|
||||
}
|
||||
|
||||
_roofSet.Clear();
|
||||
_lookup.GetLocalEntitiesIntersecting(grid.Owner, index, _roofSet);
|
||||
|
||||
foreach (var isRoofEnt in _roofSet)
|
||||
{
|
||||
if (!isRoofEnt.Comp.Enabled)
|
||||
continue;
|
||||
|
||||
return isRoofEnt.Comp.Color ?? roof.Color;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetRoof(Entity<MapGridComponent?, RoofComponent?> grid, Vector2i index, bool value)
|
||||
{
|
||||
if (!Resolve(grid, ref grid.Comp1, ref grid.Comp2, false))
|
||||
|
||||
Reference in New Issue
Block a user