Change some data definitions to not do IoC resolve in their constructors.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Content.Client.Light.Components
|
|||||||
[ImplicitDataDefinitionForInheritors]
|
[ImplicitDataDefinitionForInheritors]
|
||||||
public abstract class LightBehaviourAnimationTrack : AnimationTrackProperty
|
public abstract class LightBehaviourAnimationTrack : AnimationTrackProperty
|
||||||
{
|
{
|
||||||
protected readonly IRobustRandom _random = IoCManager.Resolve<IRobustRandom>();
|
protected IRobustRandom _random = default!;
|
||||||
|
|
||||||
[DataField("id")] [ViewVariables] public string ID { get; set; } = string.Empty;
|
[DataField("id")] [ViewVariables] public string ID { get; set; } = string.Empty;
|
||||||
|
|
||||||
@@ -53,8 +53,9 @@ namespace Content.Client.Light.Components
|
|||||||
private float _maxTime = default;
|
private float _maxTime = default;
|
||||||
private IEntity _parent = default!;
|
private IEntity _parent = default!;
|
||||||
|
|
||||||
public void Initialize(IEntity parent)
|
public void Initialize(IEntity parent, IRobustRandom random)
|
||||||
{
|
{
|
||||||
|
_random = random;
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
||||||
if (Enabled && _parent.TryGetComponent(out PointLightComponent? light))
|
if (Enabled && _parent.TryGetComponent(out PointLightComponent? light))
|
||||||
@@ -399,7 +400,7 @@ namespace Content.Client.Light.Components
|
|||||||
|
|
||||||
foreach (var container in _animations)
|
foreach (var container in _animations)
|
||||||
{
|
{
|
||||||
container.LightBehaviour.Initialize(Owner);
|
container.LightBehaviour.Initialize(Owner, IoCManager.Resolve<IRobustRandom>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to initialize all behaviours before starting any
|
// we need to initialize all behaviours before starting any
|
||||||
@@ -541,7 +542,7 @@ namespace Content.Client.Light.Components
|
|||||||
AnimationTracks = {behaviour}
|
AnimationTracks = {behaviour}
|
||||||
};
|
};
|
||||||
|
|
||||||
behaviour.Initialize(Owner);
|
behaviour.Initialize(Owner, IoCManager.Resolve<IRobustRandom>());
|
||||||
|
|
||||||
var container = new AnimationContainer(key, animation, behaviour);
|
var container = new AnimationContainer(key, animation, behaviour);
|
||||||
_animations.Add(container);
|
_animations.Add(container);
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ using Content.Shared.Audio;
|
|||||||
using Content.Shared.Chemistry.Reaction;
|
using Content.Shared.Chemistry.Reaction;
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
namespace Content.Server.Chemistry.ReactionEffects
|
namespace Content.Server.Chemistry.ReactionEffects
|
||||||
@@ -21,7 +21,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
[ImplicitDataDefinitionForInheritors]
|
[ImplicitDataDefinitionForInheritors]
|
||||||
public abstract class AreaReactionEffect : IReactionEffect
|
public abstract class AreaReactionEffect : IReactionEffect, ISerializationHooks
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("sound", required: true)] private SoundSpecifier _sound = default!;
|
[DataField("sound", required: true)] private SoundSpecifier _sound = default!;
|
||||||
|
|
||||||
protected AreaReactionEffect()
|
void ISerializationHooks.AfterDeserialization()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user