Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -408,9 +408,9 @@ namespace Content.Client.Light.Components
|
||||
/// <summary>
|
||||
/// If we disable all the light behaviours we want to be able to revert the light to its original state.
|
||||
/// </summary>
|
||||
private void CopyLightSettings(string property)
|
||||
private void CopyLightSettings(EntityUid uid, string property)
|
||||
{
|
||||
if (_entMan.TryGetComponent(Owner, out PointLightComponent? light))
|
||||
if (_entMan.TryGetComponent(uid, out PointLightComponent? light))
|
||||
{
|
||||
var propertyValue = AnimationHelper.GetAnimatableProperty(light, property);
|
||||
if (propertyValue != null)
|
||||
@@ -420,7 +420,7 @@ namespace Content.Client.Light.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning($"{_entMan.GetComponent<MetaDataComponent>(Owner).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
|
||||
Logger.Warning($"{_entMan.GetComponent<MetaDataComponent>(uid).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Content.Client.Light.Components
|
||||
{
|
||||
if (!animations.HasRunningAnimation(uid, animation, KeyPrefix + container.Key))
|
||||
{
|
||||
CopyLightSettings(container.LightBehaviour.Property);
|
||||
CopyLightSettings(uid, container.LightBehaviour.Property);
|
||||
container.LightBehaviour.UpdatePlaybackValues(container.Animation);
|
||||
animations.Play(uid, animation, container.Animation, KeyPrefix + container.Key);
|
||||
}
|
||||
|
||||
@@ -170,11 +170,12 @@ namespace Content.Client.Light
|
||||
|
||||
public override void FrameUpdate(float frameTime)
|
||||
{
|
||||
foreach (var (rgb, light, sprite) in EntityManager.EntityQuery<RgbLightControllerComponent, PointLightComponent, SpriteComponent>())
|
||||
var lightQuery = EntityQueryEnumerator<RgbLightControllerComponent, PointLightComponent, SpriteComponent>();
|
||||
while (lightQuery.MoveNext(out var uid, out var rgb, out var light, out var sprite))
|
||||
{
|
||||
var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, rgb);
|
||||
var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, (uid, rgb));
|
||||
|
||||
_lights.SetColor(light.Owner, color, light);
|
||||
_lights.SetColor(uid, color, light);
|
||||
|
||||
if (rgb.Layers != null)
|
||||
{
|
||||
@@ -196,17 +197,18 @@ namespace Content.Client.Light
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (map, rgb) in EntityQuery<MapLightComponent, RgbLightControllerComponent>())
|
||||
var mapQuery = EntityQueryEnumerator<MapLightComponent, RgbLightControllerComponent>();
|
||||
while (mapQuery.MoveNext(out var uid, out var map, out var rgb))
|
||||
{
|
||||
var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, rgb);
|
||||
var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, (uid, rgb));
|
||||
map.AmbientLightColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, RgbLightControllerComponent rgb)
|
||||
public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, Entity<RgbLightControllerComponent> rgb)
|
||||
{
|
||||
return Color.FromHsv(new Vector4(
|
||||
(float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1),
|
||||
(float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.Comp.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1),
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f
|
||||
|
||||
Reference in New Issue
Block a user