mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Remove a ton of lighting system cruft.
Basically just kills the light manager. Clyde was already using the ECS anyways.
This commit is contained in:
@@ -9,7 +9,6 @@ using Robust.Client.Interfaces.GameObjects;
|
||||
using Robust.Client.Interfaces.GameStates;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.Graphics.ClientEye;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Client.Interfaces.Graphics.Overlays;
|
||||
using Robust.Client.Interfaces.Input;
|
||||
using Robust.Client.Interfaces.Placement;
|
||||
@@ -54,7 +53,6 @@ namespace Robust.Client
|
||||
[Dependency] private readonly IBaseClient _client;
|
||||
[Dependency] private readonly IInputManager _inputManager;
|
||||
[Dependency] private readonly IClientConsole _console;
|
||||
[Dependency] private readonly ILightManager _lightManager;
|
||||
[Dependency] private readonly ITimerManager _timerManager;
|
||||
[Dependency] private readonly IClientEntityManager _entityManager;
|
||||
[Dependency] private readonly IEyeManager _eyeManager;
|
||||
@@ -153,7 +151,6 @@ namespace Robust.Client
|
||||
_prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
|
||||
_prototypeManager.Resync();
|
||||
_mapManager.Initialize();
|
||||
_lightManager.Initialize();
|
||||
_entityManager.Initialize();
|
||||
_gameStateManager.Initialize();
|
||||
_placementManager.Initialize();
|
||||
@@ -233,7 +230,6 @@ namespace Robust.Client
|
||||
var eventArgs = new RenderFrameEventArgs(delta);
|
||||
_clyde.FrameProcess(eventArgs);
|
||||
_modLoader.BroadcastUpdate(ModUpdateLevel.FramePreEngine, eventArgs.Elapsed);
|
||||
_lightManager.FrameUpdate(eventArgs);
|
||||
_stateManager.FrameUpdate(eventArgs);
|
||||
_overlayManager.FrameUpdate(eventArgs);
|
||||
_userInterfaceManager.FrameUpdate(eventArgs);
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
using System;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using ObjectSerializer = Robust.Shared.Serialization.ObjectSerializer;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
{
|
||||
@@ -21,44 +14,36 @@ namespace Robust.Client.GameObjects
|
||||
public override uint? NetID => NetIDs.POINT_LIGHT;
|
||||
public override Type StateType => typeof(PointLightComponentState);
|
||||
|
||||
private ILight Light;
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ILightManager lightManager;
|
||||
[Dependency] private readonly IResourceCache _resourceCache;
|
||||
#pragma warning restore 649
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Color Color
|
||||
{
|
||||
get => Light.Color;
|
||||
set => Light.Color = value;
|
||||
get => _color;
|
||||
set => _color = value;
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Vector2 Offset
|
||||
{
|
||||
get => Light.Offset;
|
||||
set => Light.Offset = value;
|
||||
get => _offset;
|
||||
set => _offset = value;
|
||||
}
|
||||
|
||||
private LightState state = LightState.On;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public LightState State
|
||||
public bool Enabled
|
||||
{
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
Light.Enabled = state == LightState.On;
|
||||
}
|
||||
get => _enabled;
|
||||
set => _enabled = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the light mask should automatically rotate with the entity. (like a flashlight)
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool MaskAutoRotate { get; set; }
|
||||
public bool MaskAutoRotate
|
||||
{
|
||||
get => _maskAutoRotate;
|
||||
set => _maskAutoRotate = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Local rotation of the light mask around the center origin
|
||||
@@ -66,15 +51,15 @@ namespace Robust.Client.GameObjects
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle Rotation
|
||||
{
|
||||
get => Light.Rotation;
|
||||
set => Light.Rotation = value;
|
||||
get => _rotation;
|
||||
set => _rotation = value;
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Energy
|
||||
{
|
||||
get => Light.Energy;
|
||||
set => Light.Energy = value;
|
||||
get => _energy;
|
||||
set => _energy = value;
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
@@ -100,9 +85,15 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
private float radius = 5;
|
||||
private float _radius = 5;
|
||||
private bool _visibleNested = true;
|
||||
private bool _lightOnParent = false;
|
||||
private Color _color = Color.White;
|
||||
private Vector2 _offset;
|
||||
private bool _enabled = true;
|
||||
private bool _maskAutoRotate;
|
||||
private Angle _rotation;
|
||||
private float _energy;
|
||||
|
||||
/// <summary>
|
||||
/// Radius, in meters.
|
||||
@@ -110,16 +101,8 @@ namespace Robust.Client.GameObjects
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Radius
|
||||
{
|
||||
get => radius;
|
||||
set
|
||||
{
|
||||
radius = FloatMath.Clamp(value, 2, 10);
|
||||
//var tex = _resourceCache.GetResource<TextureResource>(new ResourcePath("/Textures/Effects/Light/") /
|
||||
// $"lighting_falloff_{(int) radius}.png");
|
||||
|
||||
|
||||
//Light.Texture = tex.Texture;
|
||||
}
|
||||
get => _radius;
|
||||
set => _radius = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -154,27 +137,15 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
// First in the init stack so...
|
||||
// FIXME: This is terrible.
|
||||
Light?.Dispose();
|
||||
Light = lightManager.MakeLight();
|
||||
serializer.DataReadWriteFunction("offset", Vector2.Zero, vec => Offset = vec, () => Offset);
|
||||
serializer.DataReadWriteFunction("radius", 5f, radius => Radius = radius, () => Radius);
|
||||
serializer.DataReadWriteFunction("color", Color.White, col => Color = col, () => Color);
|
||||
serializer.DataReadWriteFunction("state", LightState.On, state => State = state, () => State);
|
||||
serializer.DataReadWriteFunction("energy", 1f, energy => Energy = energy, () => Energy);
|
||||
serializer.DataReadWriteFunction("autoRot", false, rot => MaskAutoRotate = rot, () => MaskAutoRotate);
|
||||
serializer.DataFieldCached(ref _offset, "offset", Vector2.Zero);
|
||||
serializer.DataFieldCached(ref _radius, "radius", 5f);
|
||||
serializer.DataFieldCached(ref _color, "color", Color.White);
|
||||
serializer.DataFieldCached(ref _enabled, "enabled", true);
|
||||
serializer.DataFieldCached(ref _energy, "energy", 1f);
|
||||
serializer.DataFieldCached(ref _maskAutoRotate, "autoRot", false);
|
||||
serializer.DataFieldCached(ref _visibleNested, "nestedvisible", true);
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
Light.Dispose();
|
||||
Light = null;
|
||||
|
||||
base.OnRemove();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
@@ -182,9 +153,10 @@ namespace Robust.Client.GameObjects
|
||||
return;
|
||||
|
||||
var newState = (PointLightComponentState) curState;
|
||||
State = newState.State;
|
||||
Enabled = newState.Enabled;
|
||||
Radius = newState.Radius;
|
||||
Offset = newState.Offset;
|
||||
Color = newState.Color;
|
||||
Light.ModeClass = newState.Mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Client.Graphics.ClientEye;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Client.Graphics.ClientEye;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
@@ -31,7 +31,7 @@ namespace Robust.Client.GameObjects
|
||||
// TODO: Unhardcode SideSize. Should be based on grid size.
|
||||
const float SideSize = 1;
|
||||
bool _enabled = true;
|
||||
private IOccluder[] occluders = new IOccluder[4];
|
||||
//private IOccluder[] occluders = new IOccluder[4];
|
||||
private OccluderComponent[] neighbors = new OccluderComponent[4];
|
||||
private SnapGridComponent SnapGrid;
|
||||
[Dependency]
|
||||
@@ -53,6 +53,7 @@ namespace Robust.Client.GameObjects
|
||||
var sw = new Vector2(-halfSize, halfSize);
|
||||
var nw = new Vector2(-halfSize, -halfSize);
|
||||
|
||||
/*
|
||||
// North occluder.
|
||||
var occluder = lightManager.MakeOccluder();
|
||||
occluder.CullMode = OccluderCullMode.Clockwise;
|
||||
@@ -80,6 +81,7 @@ namespace Robust.Client.GameObjects
|
||||
occluder.SetPolygon(new Vector2[] { sw, nw });
|
||||
occluders[(int)OccluderDir.West] = occluder;
|
||||
occluder.ParentTo(transform);
|
||||
*/
|
||||
|
||||
UpdateConnections(true);
|
||||
}
|
||||
@@ -88,6 +90,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
base.OnRemove();
|
||||
|
||||
/*
|
||||
foreach (var occluder in occluders)
|
||||
{
|
||||
occluder.Dispose();
|
||||
@@ -96,6 +99,7 @@ namespace Robust.Client.GameObjects
|
||||
occluders = null;
|
||||
SnapGrid.OnPositionChanged -= SnapGridPositionChanged;
|
||||
SayGoodbyes();
|
||||
*/
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
@@ -107,10 +111,12 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
void UpdateEnabled()
|
||||
{
|
||||
/*
|
||||
occluders[0].Enabled = Enabled && neighbors[0] == null;
|
||||
occluders[1].Enabled = Enabled && neighbors[1] == null;
|
||||
occluders[2].Enabled = Enabled && neighbors[2] == null;
|
||||
occluders[3].Enabled = Enabled && neighbors[3] == null;
|
||||
*/
|
||||
}
|
||||
|
||||
void SnapGridPositionChanged()
|
||||
|
||||
@@ -12,7 +12,6 @@ using Robust.Client.Graphics.Shaders;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -297,7 +296,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
foreach (var component in _componentManager.GetAllComponents<PointLightComponent>())
|
||||
{
|
||||
if (component.State != LightState.On || component.Owner.Transform.MapID != map)
|
||||
if (!component.Enabled || component.Owner.Transform.MapID != map)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Maths;
|
||||
using System;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
|
||||
namespace Robust.Client.Graphics.Lighting
|
||||
{
|
||||
partial class LightManager
|
||||
{
|
||||
sealed class Light : ILight
|
||||
{
|
||||
public Vector2 Offset
|
||||
{
|
||||
get => default;
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public Angle Rotation
|
||||
{
|
||||
get => default;
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private Color color;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get => color;
|
||||
set
|
||||
{
|
||||
if (value == color)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
color = value;
|
||||
}
|
||||
}
|
||||
|
||||
private float textureScale;
|
||||
|
||||
public float TextureScale
|
||||
{
|
||||
get => textureScale;
|
||||
set
|
||||
{
|
||||
if (value == textureScale)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
textureScale = value;
|
||||
}
|
||||
}
|
||||
|
||||
private float energy;
|
||||
|
||||
public float Energy
|
||||
{
|
||||
get => energy;
|
||||
set
|
||||
{
|
||||
if (value == energy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
energy = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ILightMode Mode { get; private set; }
|
||||
|
||||
public LightModeClass ModeClass
|
||||
{
|
||||
get => Mode.ModeClass;
|
||||
set
|
||||
{
|
||||
if (value == ModeClass)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// In this order so IF something blows up making the new instance,
|
||||
// this light doesn't corrupt completely and throw exceptions everywhere.
|
||||
var newMode = GetModeInstance(value);
|
||||
Mode.Shutdown();
|
||||
Mode = newMode;
|
||||
Mode.Start(this);
|
||||
}
|
||||
}
|
||||
|
||||
private Texture texture;
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => texture;
|
||||
set
|
||||
{
|
||||
if (texture == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
texture = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool enabled;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => enabled;
|
||||
set
|
||||
{
|
||||
enabled = value;
|
||||
UpdateEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
private LightManager Manager;
|
||||
private LightingSystem System => Manager.System;
|
||||
|
||||
public Light(LightManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
Mode = new LightModeConstant();
|
||||
Mode.Start(this);
|
||||
}
|
||||
|
||||
public void DeParent()
|
||||
{
|
||||
UpdateEnabled();
|
||||
}
|
||||
|
||||
public void ParentTo(ITransformComponent node)
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Already disposed.
|
||||
if (Disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Manager.RemoveLight(this);
|
||||
|
||||
Disposed = true;
|
||||
}
|
||||
|
||||
private static ILightMode GetModeInstance(LightModeClass modeClass)
|
||||
{
|
||||
switch (modeClass)
|
||||
{
|
||||
case LightModeClass.Constant:
|
||||
return new LightModeConstant();
|
||||
|
||||
default:
|
||||
throw new NotImplementedException("Light modes outside Constant are not implemented yet.");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEnabled()
|
||||
{
|
||||
}
|
||||
|
||||
public void FrameProcess(FrameEventArgs args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.Graphics.Lighting
|
||||
{
|
||||
partial class LightManager
|
||||
{
|
||||
sealed class Occluder : IOccluder
|
||||
{
|
||||
private bool visible = true;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => visible;
|
||||
set
|
||||
{
|
||||
visible = value;
|
||||
UpdateEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
private LightManager Manager;
|
||||
|
||||
private bool Deferred => Manager.System == LightingSystem.Deferred;
|
||||
|
||||
public OccluderCullMode CullMode
|
||||
{
|
||||
get => default;
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public Occluder(LightManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Already disposed.
|
||||
if (Disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Manager.RemoveOccluder(this);
|
||||
Disposed = true;
|
||||
}
|
||||
|
||||
public void SetPolygon(Vector2[] polygon)
|
||||
{
|
||||
}
|
||||
|
||||
public void DeParent()
|
||||
{
|
||||
}
|
||||
|
||||
public void ParentTo(ITransformComponent node)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void UpdateEnabled()
|
||||
{
|
||||
}
|
||||
|
||||
public void FrameProcess(FrameEventArgs args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Interfaces;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
// Ok let me just quickly explain how deferred lighting works.
|
||||
// So for some reason, Godot's Light2D has performance issues on some computers. Why? No clue. Anyways.
|
||||
// So to fix this, we do "deferred lighting"!
|
||||
// We have a config option to enable it because my shitty implementation doesn't look as good as normal Godot lighting.
|
||||
// When enabled, each light is put into a separate Viewport. Said viewport contains the CanvasModulate and a white background.
|
||||
// This means the viewport will have light rendering happen in it, onto a white canvas.
|
||||
// The Viewport's output texture is then basically a lightmap we can blend over the rest of the game,
|
||||
// which we do using a Sprite on its own canvas layer set to multiply blend in it CanvasMaterial.
|
||||
// This performs better because we forgo the O(nlights + 1) drawing complexity of canvas items.
|
||||
namespace Robust.Client.Graphics.Lighting
|
||||
{
|
||||
public sealed partial class LightManager : ILightManager, IDisposable, IPostInjectInit
|
||||
public sealed class LightManager : ILightManager
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] readonly IConfigurationManager configManager;
|
||||
[Dependency] private readonly IConfigurationManager _configManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private bool enabled = true;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => enabled;
|
||||
set
|
||||
{
|
||||
if (value == Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Light> lights = new List<Light>();
|
||||
private List<Occluder> occluders = new List<Occluder>();
|
||||
|
||||
private LightingSystem System = LightingSystem.Normal;
|
||||
|
||||
private bool disposed = false;
|
||||
|
||||
public void PostInject()
|
||||
{
|
||||
configManager.RegisterCVar("display.lighting_system", LightingSystem.Normal,
|
||||
Shared.Configuration.CVar.ARCHIVE);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
System = configManager.GetCVar<LightingSystem>("display.lighting_system");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var localLights = new List<ILight>(lights);
|
||||
foreach (var light in localLights)
|
||||
{
|
||||
light.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public ILight MakeLight()
|
||||
{
|
||||
var light = new Light(this);
|
||||
lights.Add(light);
|
||||
light.UpdateEnabled();
|
||||
return light;
|
||||
}
|
||||
|
||||
private void RemoveLight(Light light)
|
||||
{
|
||||
// TODO: This removal is O(n) because it's a regualar list,
|
||||
// and might become a performance issue.
|
||||
// Use some smarter datastructure maybe?
|
||||
lights.Remove(light);
|
||||
}
|
||||
|
||||
public IOccluder MakeOccluder()
|
||||
{
|
||||
var occluder = new Occluder(this);
|
||||
occluders.Add(occluder);
|
||||
return occluder;
|
||||
}
|
||||
|
||||
private void RemoveOccluder(Occluder occluder)
|
||||
{
|
||||
// TODO: This removal is O(n) because it's a regualar list,
|
||||
// and might become a performance issue.
|
||||
// Use some smarter datastructure maybe?
|
||||
occluders.Remove(occluder);
|
||||
}
|
||||
|
||||
public void FrameUpdate(RenderFrameEventArgs args)
|
||||
{
|
||||
foreach (var light in lights)
|
||||
{
|
||||
light.FrameProcess(args);
|
||||
}
|
||||
|
||||
foreach (var occluder in occluders)
|
||||
{
|
||||
occluder.FrameProcess(args);
|
||||
}
|
||||
}
|
||||
|
||||
public enum LightingSystem
|
||||
{
|
||||
Normal = 0,
|
||||
Deferred = 1,
|
||||
Disabled = 2,
|
||||
}
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using Robust.Client.Interfaces.Graphics.Lighting;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Enums;
|
||||
|
||||
namespace Robust.Client.Graphics.Lighting
|
||||
{
|
||||
class LightModeConstant : ILightMode
|
||||
{
|
||||
public LightModeClass ModeClass => LightModeClass.Constant;
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public void Start(ILight owner)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public void Update(FrameEventArgs args)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
|
||||
namespace Robust.Client.Interfaces.Graphics.Lighting
|
||||
{
|
||||
public interface ILight : IDisposable
|
||||
{
|
||||
Vector2 Offset { get; set; }
|
||||
Angle Rotation { get; set; }
|
||||
Color Color { get; set; }
|
||||
float TextureScale { get; set; }
|
||||
float Energy { get; set; }
|
||||
ILightMode Mode { get; }
|
||||
LightModeClass ModeClass { get; set; }
|
||||
Texture Texture { get; set; }
|
||||
bool Enabled { get; set; }
|
||||
|
||||
void ParentTo(ITransformComponent node);
|
||||
void DeParent();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared;
|
||||
|
||||
namespace Robust.Client.Interfaces.Graphics.Lighting
|
||||
namespace Robust.Client.Interfaces.Graphics.Lighting
|
||||
{
|
||||
public interface ILightManager
|
||||
{
|
||||
void Initialize();
|
||||
|
||||
bool Enabled { get; set; }
|
||||
|
||||
ILight MakeLight();
|
||||
IOccluder MakeOccluder();
|
||||
void FrameUpdate(RenderFrameEventArgs args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Enums;
|
||||
|
||||
namespace Robust.Client.Interfaces.Graphics.Lighting
|
||||
{
|
||||
public interface ILightMode
|
||||
{
|
||||
void Start(ILight owner);
|
||||
void Shutdown();
|
||||
void Update(FrameEventArgs args);
|
||||
|
||||
LightModeClass ModeClass { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.Interfaces.Graphics.Lighting
|
||||
{
|
||||
public interface IOccluder : IDisposable
|
||||
{
|
||||
bool Enabled { get; set; }
|
||||
|
||||
OccluderCullMode CullMode { get; set; }
|
||||
|
||||
void SetPolygon(Vector2[] polygon);
|
||||
|
||||
void ParentTo(ITransformComponent node);
|
||||
void DeParent();
|
||||
}
|
||||
|
||||
public enum OccluderCullMode
|
||||
{
|
||||
// These match Godot's OccluderPolygon2D.CullMode
|
||||
Disabled = 0,
|
||||
Clockwise = 1,
|
||||
CounterClockwise = 2
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -9,8 +8,7 @@ namespace Robust.Server.GameObjects
|
||||
public class PointLightComponent : Component
|
||||
{
|
||||
private Color _color;
|
||||
private LightModeClass _mode;
|
||||
private LightState _state;
|
||||
private bool _enabled;
|
||||
private int _radius;
|
||||
private Vector2 _offset;
|
||||
|
||||
@@ -29,23 +27,12 @@ namespace Robust.Server.GameObjects
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
public LightModeClass Mode
|
||||
public bool Enabled
|
||||
{
|
||||
get => _mode;
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
_mode = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
public LightState State
|
||||
{
|
||||
get => _state;
|
||||
set
|
||||
{
|
||||
_state = value;
|
||||
_enabled = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
@@ -77,16 +64,15 @@ namespace Robust.Server.GameObjects
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _state, "state", LightState.On);
|
||||
serializer.DataField(ref _enabled, "enabled", true);
|
||||
serializer.DataField(ref _color, "color", new Color(200, 200, 200));
|
||||
serializer.DataField(ref _mode, "mode", LightModeClass.Constant);
|
||||
serializer.DataField(ref _radius, "radius", 512);
|
||||
serializer.DataField(ref _offset, "offset", Vector2.Zero);
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new PointLightComponentState(State, Color, Mode, Radius, Offset);
|
||||
return new PointLightComponentState(Enabled, Color, Radius, Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace Robust.Shared.Enums
|
||||
{
|
||||
public enum LightState
|
||||
{
|
||||
On,
|
||||
Off,
|
||||
}
|
||||
|
||||
public enum LightModeClass
|
||||
{
|
||||
Constant,
|
||||
Alarm,
|
||||
Flicker,
|
||||
Flash,
|
||||
Strobe,
|
||||
BrokenFlicker
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -9,18 +8,16 @@ namespace Robust.Shared.GameObjects
|
||||
public class PointLightComponentState : ComponentState
|
||||
{
|
||||
public readonly Color Color;
|
||||
public readonly LightModeClass Mode;
|
||||
public readonly LightState State;
|
||||
public readonly bool Enabled;
|
||||
|
||||
public readonly float Radius;
|
||||
public readonly Vector2 Offset;
|
||||
|
||||
public PointLightComponentState(LightState state, Color color, LightModeClass mode, float radius, Vector2 offset)
|
||||
public PointLightComponentState(bool enabled, Color color, float radius, Vector2 offset)
|
||||
: base(NetIDs.POINT_LIGHT)
|
||||
{
|
||||
State = state;
|
||||
Enabled = enabled;
|
||||
Color = color;
|
||||
Mode = mode;
|
||||
Radius = radius;
|
||||
Offset = offset;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Robust.Shared.GameObjects.Components.Transform
|
||||
namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
internal class TransformComponent : Component, ITransformComponent, IComponentDebug
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user