mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 09:37:03 +02:00
* Add MapSystem.GetMapOrInvalid This is effectively the same exact behavior as IMapManager.GetMapEntityId. Adding this so I don't have to consider whether warning fixes using MapSystem.GetMap() instead would change behavior. * Warning fixes around IMapManager.GetMapEntityId * Fix tests
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Robust.Shared.GameObjects;
|
|
|
|
public abstract partial class SharedMapSystem
|
|
{
|
|
public void SetAmbientLight(MapId mapId, Color color)
|
|
{
|
|
var mapUid = GetMap(mapId);
|
|
var mapComp = EnsureComp<MapLightComponent>(mapUid);
|
|
|
|
if (mapComp.AmbientLightColor.Equals(color))
|
|
return;
|
|
|
|
mapComp.AmbientLightColor = color;
|
|
Dirty(mapUid, mapComp);
|
|
}
|
|
|
|
private void OnMapLightGetState(EntityUid uid, MapLightComponent component, ref ComponentGetState args)
|
|
{
|
|
args.State = new MapLightComponentState()
|
|
{
|
|
AmbientLightColor = component.AmbientLightColor,
|
|
};
|
|
}
|
|
|
|
private void OnMapLightHandleState(EntityUid uid, MapLightComponent component, ref ComponentHandleState args)
|
|
{
|
|
if (args.Current is not MapLightComponentState state)
|
|
return;
|
|
|
|
component.AmbientLightColor = state.AmbientLightColor;
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
private sealed class MapLightComponentState : ComponentState
|
|
{
|
|
public Color AmbientLightColor;
|
|
}
|
|
}
|