Fix all 7 Cut 5d Soul findings: GL3 Sion perf >=57fps, PVS death gating, crater dedupe, hit-marker filter, loadout baseline, remote dust yaw/speed, distance-gated death trauma

This commit is contained in:
Meta Vens 2026-12-05 10:48:54 +01:00
commit fcb91edb0d
16 changed files with 574 additions and 143 deletions

View file

@ -7,13 +7,13 @@ namespace RustToDust.Client;
/// <summary>
/// Single-draw-call GPU billboard particle pool (<see cref="MultiMeshInstance3D"/> backed by
/// <c>particle_billboard.gdshader</c>) plus the strictly capped <see cref="OmniLight3D"/>[4]
/// <c>particle_billboard.gdshader</c>) plus the strictly capped <see cref="OmniLight3D"/>[2]
/// dynamic combat flash pool for OpenGL 3.3 (<c>gl_compatibility</c>).
/// </summary>
public partial class ParticlePool : Node3D
{
public const int MaxParticles = 768;
public const int MaxFlashLights = 4;
public const int MaxParticles = 512;
public const int MaxFlashLights = 2;
public const float ModeDustSmoke = 0f;
public const float ModeMuzzleStarburst = 1f;
@ -65,6 +65,7 @@ public partial class ParticlePool : Node3D
private MultiMeshInstance3D _instanceNode = null!;
private ShaderMaterial _material = null!;
private int _writeCursor;
private int _warmupFramesRemaining;
private bool _initialized;
private uint _rng = 0x7A3B91E5u;
@ -132,7 +133,7 @@ public partial class ParticlePool : Node3D
Name = $"CombatFlashLight_{i}",
ShadowEnabled = false,
OmniAttenuation = 1.6f,
OmniRange = 10f,
OmniRange = 14f,
LightEnergy = 0f,
Visible = false
};
@ -141,6 +142,40 @@ public partial class ParticlePool : Node3D
}
}
/// <summary>
/// Pre-warms the pooled <see cref="OmniLight3D"/> nodes on startup for 1 rendered frame
/// with near-zero energy so OpenGL 3.3 compiles lit shader variants before combat begins.
/// </summary>
public void PrewarmFlashLights(Vector3 nearPos, Vector3 forwardHoriz)
{
EnsureInitialized();
_warmupFramesRemaining = 2;
Vector3 fwd = forwardHoriz.LengthSquared() > 1e-4f ? forwardHoriz.Normalized() : Vector3.Forward;
for (int i = 0; i < _flashLights.Length; i++)
{
ref FlashLightSlot slot = ref _flashLights[i];
slot.Active = false;
slot.Priority = 0;
slot.Age = 0f;
slot.Duration = 0f;
slot.StartEnergy = 0f;
slot.Range = 22f;
slot.Light.Position = i == 0 ? nearPos + new Vector3(0f, 2f, 0f) : nearPos + fwd * 72f + new Vector3(0f, 3f, 0f);
slot.Light.LightColor = Colors.White;
slot.Light.OmniRange = 22f;
slot.Light.OmniAttenuation = 1.6f;
slot.Light.LightEnergy = 0.001f;
slot.Light.Visible = true;
}
// Also pre-warm the particle billboard shader on frame 0 with 1 micro-quad
_multiMesh.SetInstanceTransform(0, new Transform3D(Basis.FromScale(new Vector3(0.01f, 0.01f, 1f)), nearPos));
_multiMesh.SetInstanceColor(0, new Color(1f, 1f, 1f, 0.01f));
_multiMesh.SetInstanceCustomData(0, new Color(ModeDustSmoke, 0f, 0f, 0f));
_multiMesh.VisibleInstanceCount = 1;
_instanceNode.Visible = true;
}
public void ClearAll()
{
EnsureInitialized();
@ -150,6 +185,7 @@ public partial class ParticlePool : Node3D
_recentShotCursor = 0;
_recentHitCursor = 0;
_writeCursor = 0;
_warmupFramesRemaining = 0;
ActiveParticleCount = 0;
PeakFlashLightCount = 0;
@ -167,13 +203,14 @@ public partial class ParticlePool : Node3D
}
public void ConsumeEvents(
IClientArenaSession session,
IReadOnlyList<ISimEvent> events,
MatchState state,
Vector3 camPos,
bool hasCam,
Func<float, float, Color> sampleGroundTint)
{
EnsureInitialized();
var state = session.ViewState;
for (int i = 0; i < events.Count; i++)
{
@ -192,7 +229,8 @@ public partial class ParticlePool : Node3D
break;
case ContenderEliminatedEvent elim:
if (elim.VictimId >= 0 && elim.VictimId < state.Contenders.Count)
if ((elim.VictimId == session.LocalContenderId || session.IsContenderVisible(elim.VictimId)) &&
elim.VictimId >= 0 && elim.VictimId < state.Contenders.Count)
{
var v = state.Contenders[elim.VictimId];
EmitChassisExplosion(new Vector3(v.X, v.Y + 0.6f, v.Z), v.Grid.Spec.MassKg, camPos, hasCam, sampleGroundTint);
@ -201,6 +239,10 @@ public partial class ParticlePool : Node3D
case SpectatorDestroyedEvent sdet:
{
if (!session.IsSpectatorVisible(sdet.SpectatorId))
{
break;
}
var specs = state.Spectators.Spectators;
for (int s = 0; s < specs.Count; s++)
{
@ -228,9 +270,9 @@ public partial class ParticlePool : Node3D
float massScale = Math.Clamp(pulse.MassKg / 2600f, 0.72f, 1.55f);
float loadScale = Math.Clamp(pulse.LoadG, 0.5f, 1.8f);
int count = pulse.MassKg >= 3600f ? 5 : 3;
int count = pulse.MassKg >= 3600f ? 3 : 2;
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.52f);
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.50f);
Color dustEnd = new(groundTint.R * 0.92f, groundTint.G * 0.92f, groundTint.B * 0.92f, 0.0f);
for (int i = 0; i < count; i++)
@ -246,15 +288,15 @@ public partial class ParticlePool : Node3D
Velocity = vel,
Gravity = 0.25f,
Drag = 2.8f,
StartSize = 0.65f * massScale,
EndSize = 2.35f * massScale,
StartSize = 0.55f * massScale,
EndSize = MathF.Min(2.2f, 1.55f * massScale),
AspectY = 1.0f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.4f,
Emissive = 0f,
ColorStart = dustStart,
ColorEnd = dustEnd,
Lifetime = 0.42f + NextFloat() * 0.24f
Lifetime = 0.35f + NextFloat() * 0.18f
});
}
}
@ -268,7 +310,7 @@ public partial class ParticlePool : Node3D
}
float scale = Math.Clamp(intensity, 0.5f, 1.5f);
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.44f);
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.42f);
Color dustEnd = new(groundTint.R * 0.95f, groundTint.G * 0.95f, groundTint.B * 0.95f, 0.0f);
SpawnParticle(new ParticleSlot
@ -279,15 +321,15 @@ public partial class ParticlePool : Node3D
Velocity = -vehicleVel * 0.15f + new Vector3(NextSigned() * 1.1f, 0.9f + NextFloat() * 0.8f, NextSigned() * 1.1f),
Gravity = 0.15f,
Drag = 2.4f,
StartSize = 0.55f * scale,
EndSize = 2.15f * scale,
StartSize = 0.50f * scale,
EndSize = MathF.Min(2.1f, 1.65f * scale),
AspectY = 1.0f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.2f,
Emissive = 0f,
ColorStart = dustStart,
ColorEnd = dustEnd,
Lifetime = 0.45f + NextFloat() * 0.20f
Lifetime = 0.36f + NextFloat() * 0.16f
});
}
@ -308,15 +350,15 @@ public partial class ParticlePool : Node3D
Velocity = new Vector3(NextSigned() * 0.9f, 2.2f + NextFloat() * 1.5f, NextSigned() * 0.9f),
Gravity = -0.35f,
Drag = 1.6f,
StartSize = 0.42f,
EndSize = 1.45f + heatT * 0.45f,
StartSize = 0.40f,
EndSize = 1.25f + heatT * 0.35f,
AspectY = 1.0f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.8f,
Emissive = 0.35f + heatT * 0.85f,
ColorStart = new Color(0.95f, 0.88f - heatT * 0.32f, 0.78f - heatT * 0.50f, 0.65f),
ColorStart = new Color(0.95f, 0.88f - heatT * 0.32f, 0.78f - heatT * 0.50f, 0.62f),
ColorEnd = new Color(0.65f, 0.58f, 0.54f, 0.0f),
Lifetime = 0.42f + NextFloat() * 0.18f
Lifetime = 0.36f + NextFloat() * 0.16f
});
if (heatT > 0.35f)
@ -359,15 +401,15 @@ public partial class ParticlePool : Node3D
Velocity = new Vector3(NextSigned() * 0.8f, 2.4f + NextFloat() * 1.4f, NextSigned() * 0.8f),
Gravity = -0.35f,
Drag = 1.2f,
StartSize = 0.65f,
EndSize = 2.25f + dmgT * 0.8f,
StartSize = 0.58f,
EndSize = MathF.Min(2.2f, 1.65f + dmgT * 0.55f),
AspectY = 1.0f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.1f,
Emissive = 0f,
ColorStart = new Color(0.18f, 0.16f, 0.15f, 0.72f),
ColorStart = new Color(0.18f, 0.16f, 0.15f, 0.70f),
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
Lifetime = 0.70f + NextFloat() * 0.30f
Lifetime = 0.55f + NextFloat() * 0.25f
});
if (dmgT > 0.3f && NextFloat() < 0.65f)
@ -446,7 +488,7 @@ public partial class ParticlePool : Node3D
_multiMesh.VisibleInstanceCount = visibleCount;
_instanceNode.Visible = visibleCount > 0;
// 2. Advance pooled OmniLight3D[4] dynamic flashes
// 2. Advance pooled OmniLight3D[2] dynamic flashes
int activeLights = 0;
for (int i = 0; i < _flashLights.Length; i++)
{
@ -479,6 +521,21 @@ public partial class ParticlePool : Node3D
activeLights++;
}
}
if (_warmupFramesRemaining > 0)
{
_warmupFramesRemaining--;
if (_warmupFramesRemaining == 0)
{
for (int i = 0; i < _flashLights.Length; i++)
{
if (!_flashLights[i].Active)
{
_flashLights[i].Light.Visible = false;
_flashLights[i].Light.LightEnergy = 0f;
}
}
}
}
if (activeLights > PeakFlashLightCount)
{
PeakFlashLightCount = activeLights;
@ -506,7 +563,7 @@ public partial class ParticlePool : Node3D
Vector3 start = new(shot.StartX, shot.StartY, shot.StartZ);
Vector3 end = new(shot.EndX, shot.EndY, shot.EndZ);
if (hasCam && start.DistanceSquaredTo(camPos) > 160f * 160f)
if (hasCam && start.DistanceSquaredTo(camPos) > 120f * 120f)
{
return;
}
@ -536,10 +593,6 @@ public partial class ParticlePool : Node3D
ColorEnd = new Color(0.95f, 0.55f, 0.16f, 0.0f),
Lifetime = 0.065f
});
if (!hasCam || start.DistanceSquaredTo(camPos) <= 95f * 95f)
{
SpawnFlashLight(start, new Color(1.0f, 0.82f, 0.45f), 1.45f, 6.5f, 0.08f, priority: 1);
}
break;
}
@ -581,7 +634,7 @@ public partial class ParticlePool : Node3D
Lifetime = 0.32f
});
}
if (!hasCam || start.DistanceSquaredTo(camPos) <= 120f * 120f)
if (!hasCam || start.DistanceSquaredTo(camPos) <= 45f * 45f)
{
SpawnFlashLight(start, new Color(1.0f, 0.68f, 0.24f), 2.8f, 10.5f, 0.10f, priority: 3);
}
@ -638,7 +691,7 @@ public partial class ParticlePool : Node3D
});
}
if (!hasCam || start.DistanceSquaredTo(camPos) <= 140f * 140f)
if (!hasCam || start.DistanceSquaredTo(camPos) <= 65f * 65f)
{
SpawnFlashLight(start, new Color(1.0f, 0.58f, 0.18f), isRecoilless ? 4.2f : 2.6f, isRecoilless ? 14f : 10f, 0.13f, priority: 5);
}
@ -665,9 +718,9 @@ public partial class ParticlePool : Node3D
ColorEnd = beamCol with { A = 0f },
Lifetime = 0.09f
});
if (!hasCam || start.DistanceSquaredTo(camPos) <= 130f * 130f)
if (!hasCam || start.DistanceSquaredTo(camPos) <= 45f * 45f)
{
SpawnFlashLight(start, beamCol with { A = 1f }, isLance ? 3.5f : 2.6f, 11.5f, 0.12f, priority: 4);
SpawnFlashLight(start, beamCol with { A = 1f }, isLance ? 3.5f : 2.6f, 11f, 0.12f, priority: 4);
}
break;
}
@ -694,7 +747,7 @@ public partial class ParticlePool : Node3D
}
Vector3 pos = new(hit.HitX, hit.HitY, hit.HitZ);
if (hasCam && pos.DistanceSquaredTo(camPos) > 165f * 165f)
if (hasCam && pos.DistanceSquaredTo(camPos) > 125f * 125f)
{
return;
}
@ -715,17 +768,17 @@ public partial class ParticlePool : Node3D
Mode = ModeSteamFire,
Position = pos,
Velocity = Vector3.Zero,
StartSize = 0.55f,
EndSize = 2.45f,
StartSize = 0.50f,
EndSize = 2.15f,
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.5f,
Emissive = 1.6f,
ColorStart = new Color(1.0f, 0.55f, 0.16f, 0.90f),
ColorEnd = new Color(0.24f, 0.16f, 0.12f, 0.0f),
Lifetime = 0.28f
Lifetime = 0.35f
});
SpawnSparkBurst(pos, normal, 4, new Color(1.0f, 0.68f, 0.24f, 0.98f), 10f);
SpawnSparkBurst(pos, normal, 3, new Color(1.0f, 0.68f, 0.24f, 0.98f), 10f);
return;
}
@ -743,18 +796,14 @@ public partial class ParticlePool : Node3D
break;
case WeaponVisualClass.Autocannon:
EmitImpactDustPlume(pos, normal, groundTint, count: 2, size: 1.55f);
SpawnSparkBurst(pos, normal, 4, new Color(1.0f, 0.72f, 0.26f, 0.98f), 11.5f);
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 130f * 130f)
{
SpawnFlashLight(pos + normal * 0.3f, new Color(1.0f, 0.68f, 0.24f), 2.8f, 9.5f, 0.10f, priority: 4);
}
EmitImpactDustPlume(pos, normal, groundTint, count: 2, size: 1.45f);
SpawnSparkBurst(pos, normal, 3, new Color(1.0f, 0.72f, 0.26f, 0.98f), 11.5f);
break;
case WeaponVisualClass.Explosive:
{
bool isRecoilless = string.Equals(hit.WeaponId, "recoilless", StringComparison.Ordinal);
EmitImpactDustPlume(pos, normal, groundTint, count: isRecoilless ? 5 : 3, size: isRecoilless ? 2.6f : 1.7f);
EmitImpactDustPlume(pos, normal, groundTint, count: isRecoilless ? 4 : 2, size: isRecoilless ? 1.85f : 1.35f);
for (int f = 0; f < (isRecoilless ? 3 : 2); f++)
{
SpawnParticle(new ParticleSlot
@ -765,21 +814,21 @@ public partial class ParticlePool : Node3D
Velocity = normal * (1.8f + NextFloat() * 1.8f) + new Vector3(NextSigned(), 1.2f, NextSigned()),
Gravity = -0.3f,
Drag = 1.6f,
StartSize = isRecoilless ? 1.1f : 0.7f,
EndSize = isRecoilless ? 3.5f : 2.1f,
StartSize = isRecoilless ? 0.95f : 0.65f,
EndSize = isRecoilless ? 3.1f : 2.0f,
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.4f,
Emissive = 2.6f,
ColorStart = new Color(1.0f, 0.64f, 0.18f, 0.95f),
ColorEnd = new Color(0.28f, 0.16f, 0.12f, 0.0f),
Lifetime = isRecoilless ? 0.36f : 0.26f
Lifetime = isRecoilless ? 0.38f : 0.35f
});
}
SpawnSparkBurst(pos, normal, isRecoilless ? 6 : 4, new Color(1.0f, 0.64f, 0.20f, 0.98f), 14f);
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 155f * 155f)
SpawnSparkBurst(pos, normal, isRecoilless ? 5 : 3, new Color(1.0f, 0.64f, 0.20f, 0.98f), 14f);
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 75f * 75f)
{
SpawnFlashLight(pos + normal * 0.45f, new Color(1.0f, 0.55f, 0.16f), isRecoilless ? 4.8f : 3.2f, isRecoilless ? 16f : 11f, 0.16f, priority: 7);
SpawnFlashLight(pos + normal * 0.45f, new Color(1.0f, 0.55f, 0.16f), isRecoilless ? 4.8f : 3.2f, isRecoilless ? 14.5f : 11f, 0.14f, priority: 7);
}
break;
}
@ -791,20 +840,16 @@ public partial class ParticlePool : Node3D
Mode = ModeSteamFire,
Position = pos,
Velocity = normal * 1.4f,
StartSize = 0.65f,
EndSize = 1.85f,
StartSize = 0.60f,
EndSize = 1.75f,
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
Emissive = 2.8f,
ColorStart = new Color(0.45f, 0.94f, 1.0f, 0.94f),
ColorEnd = new Color(0.95f, 0.52f, 0.16f, 0.0f),
Lifetime = 0.24f
Lifetime = 0.35f
});
SpawnSparkBurst(pos, normal, 5, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 135f * 135f)
{
SpawnFlashLight(pos + normal * 0.3f, new Color(0.45f, 0.90f, 1.0f), 3.2f, 10.5f, 0.12f, priority: 5);
}
SpawnSparkBurst(pos, normal, 4, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
break;
}
}
@ -816,7 +861,7 @@ public partial class ParticlePool : Node3D
bool hasCam,
Func<float, float, Color> sampleGroundTint)
{
if (hasCam && pos.DistanceSquaredTo(camPos) > 220f * 220f)
if (hasCam && pos.DistanceSquaredTo(camPos) > 160f * 160f)
{
return;
}
@ -824,7 +869,7 @@ public partial class ParticlePool : Node3D
float sizeScale = Math.Clamp(massKg / 2800f, 0.85f, 1.55f);
Color gTint = sampleGroundTint(pos.X, pos.Z);
for (int i = 0; i < 5; i++)
for (int i = 0; i < 4; i++)
{
SpawnParticle(new ParticleSlot
{
@ -834,19 +879,19 @@ public partial class ParticlePool : Node3D
Velocity = new Vector3(NextSigned() * 2.4f, 2.2f + NextFloat() * 2.8f, NextSigned() * 2.4f),
Gravity = -0.35f,
Drag = 1.4f,
StartSize = 1.3f * sizeScale,
EndSize = 4.2f * sizeScale,
StartSize = 1.1f * sizeScale,
EndSize = MathF.Min(3.8f, 2.7f * sizeScale),
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.5f,
Emissive = 3.0f,
ColorStart = new Color(1.0f, 0.62f, 0.16f, 0.98f),
ColorEnd = new Color(0.22f, 0.12f, 0.08f, 0.0f),
Lifetime = 0.46f + NextFloat() * 0.22f
Lifetime = 0.42f + NextFloat() * 0.18f
});
}
for (int i = 0; i < 6; i++)
for (int i = 0; i < 5; i++)
{
SpawnParticle(new ParticleSlot
{
@ -856,26 +901,30 @@ public partial class ParticlePool : Node3D
Velocity = new Vector3(NextSigned() * 2.8f, 3.0f + NextFloat() * 2.8f, NextSigned() * 2.8f),
Gravity = -0.35f,
Drag = 1.1f,
StartSize = 1.4f * sizeScale,
EndSize = 4.8f * sizeScale,
StartSize = 1.0f * sizeScale,
EndSize = MathF.Min(2.2f, 1.55f * sizeScale),
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.1f,
Emissive = 0f,
ColorStart = new Color(0.20f * 0.6f + gTint.R * 0.2f, 0.18f * 0.6f + gTint.G * 0.2f, 0.16f * 0.6f + gTint.B * 0.2f, 0.82f),
ColorStart = new Color(0.20f * 0.6f + gTint.R * 0.2f, 0.18f * 0.6f + gTint.G * 0.2f, 0.16f * 0.6f + gTint.B * 0.2f, 0.80f),
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
Lifetime = 0.95f + NextFloat() * 0.45f
Lifetime = 0.72f + NextFloat() * 0.30f
});
}
SpawnSparkBurst(pos, Vector3.Up, 8, new Color(1.0f, 0.68f, 0.22f, 0.98f), 17f);
SpawnFlashLight(pos + new Vector3(0f, 1.2f, 0f), new Color(1.0f, 0.56f, 0.14f), 6.2f, 22f, 0.22f, priority: 10);
SpawnSparkBurst(pos, Vector3.Up, 6, new Color(1.0f, 0.68f, 0.22f, 0.98f), 17f);
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 95f * 95f)
{
SpawnFlashLight(pos + new Vector3(0f, 1.2f, 0f), new Color(1.0f, 0.56f, 0.14f), 6.2f, 16f, 0.18f, priority: 10);
}
}
private void EmitImpactDustPlume(Vector3 pos, Vector3 normal, Color groundTint, int count, float size)
{
Color c0 = new(groundTint.R, groundTint.G, groundTint.B, 0.62f);
Color c0 = new(groundTint.R, groundTint.G, groundTint.B, 0.60f);
Color c1 = new(groundTint.R * 0.88f, groundTint.G * 0.88f, groundTint.B * 0.88f, 0.0f);
float endSize = MathF.Min(2.2f, size * 1.15f);
for (int i = 0; i < count; i++)
{
Vector3 vel = normal * (1.8f + NextFloat() * 2.4f) + new Vector3(NextSigned() * 1.6f, 0.8f + NextFloat() * 1.2f, NextSigned() * 1.6f);
@ -887,15 +936,15 @@ public partial class ParticlePool : Node3D
Velocity = vel,
Gravity = 0.45f,
Drag = 2.0f,
StartSize = size * 0.42f,
EndSize = size * 1.35f,
StartSize = size * 0.40f,
EndSize = endSize,
AspectY = 1f,
Rotation = NextFloat() * MathF.Tau,
AngularVel = NextSigned() * 1.4f,
Emissive = 0f,
ColorStart = c0,
ColorEnd = c1,
Lifetime = 0.38f + NextFloat() * 0.20f
Lifetime = 0.35f + NextFloat() * 0.16f
});
}
}
@ -965,17 +1014,18 @@ public partial class ParticlePool : Node3D
}
}
float clampedRange = Math.Clamp(range, 6.5f, 22f);
ref FlashLightSlot slot = ref _flashLights[targetIdx];
slot.Active = true;
slot.Priority = priority;
slot.Age = 0f;
slot.Duration = MathF.Max(0.04f, duration);
slot.StartEnergy = energy;
slot.Range = range;
slot.Range = clampedRange;
slot.Color = color;
slot.Light.Position = pos;
slot.Light.LightColor = color;
slot.Light.OmniRange = range;
slot.Light.OmniRange = clampedRange;
slot.Light.LightEnergy = energy;
slot.Light.Visible = true;