Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -58,7 +58,7 @@ namespace Content.Client.Light.Components
_random = random;
_parent = parent;
if (Enabled && _parent.TryGetComponent(out PointLightComponent? light))
if (Enabled && IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{
light.Enabled = true;
}
@@ -68,7 +68,7 @@ namespace Content.Client.Light.Components
public void UpdatePlaybackValues(Animation owner)
{
if (_parent.TryGetComponent(out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{
light.Enabled = true;
}
@@ -99,7 +99,7 @@ namespace Content.Client.Light.Components
throw new InvalidOperationException("Property parameter is null! Check the prototype!");
}
if (_parent.TryGetComponent(out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{
AnimationHelper.SetAnimatableProperty(light, Property, value);
}
@@ -395,7 +395,7 @@ namespace Content.Client.Light.Components
// TODO: Do NOT ensure component here. And use eventbus events instead...
Owner.EnsureComponent<AnimationPlayerComponent>();
if (Owner.TryGetComponent(out AnimationPlayerComponent? animation))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{
#pragma warning disable 618
animation.AnimationCompleted += OnAnimationCompleted;
@@ -430,7 +430,7 @@ namespace Content.Client.Light.Components
{
container.LightBehaviour.UpdatePlaybackValues(container.Animation);
if (Owner.TryGetComponent(out AnimationPlayerComponent? animation))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{
animation.Play(container.Animation, container.FullKey);
}
@@ -442,7 +442,7 @@ namespace Content.Client.Light.Components
/// </summary>
private void CopyLightSettings()
{
if (Owner.TryGetComponent(out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
{
_originalColor = light.Color;
_originalEnabled = light.Enabled;
@@ -463,7 +463,7 @@ namespace Content.Client.Light.Components
/// </summary>
public void StartLightBehaviour(string id = "")
{
if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{
return;
}
@@ -491,7 +491,7 @@ namespace Content.Client.Light.Components
/// <param name="resetToOriginalSettings">Should the light have its original settings applied?</param>
public void StopLightBehaviour(string id = "", bool removeBehaviour = false, bool resetToOriginalSettings = false)
{
if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{
return;
}
@@ -519,7 +519,7 @@ namespace Content.Client.Light.Components
_animations.Remove(container);
}
if (resetToOriginalSettings && Owner.TryGetComponent(out PointLightComponent? light))
if (resetToOriginalSettings && IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
{
light.Color = _originalColor;
light.Enabled = _originalEnabled;