Remove component.Initialize calls (#18230)
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Animations
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class AnimationsTestComponent : Component
|
||||
{
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var animations = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(Owner);
|
||||
animations.Play(new Animation
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(20),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackComponentProperty
|
||||
{
|
||||
ComponentType = typeof(TransformComponent),
|
||||
Property = nameof(TransformComponent.LocalRotation),
|
||||
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(Angle.Zero, 0),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(1440), 20)
|
||||
}
|
||||
},
|
||||
new AnimationTrackComponentProperty
|
||||
{
|
||||
ComponentType = typeof(SpriteComponent),
|
||||
Property = "layer/0/texture",
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame("Objects/toolbox_r.png", 0),
|
||||
new AnimationTrackProperty.KeyFrame("Objects/Toolbox_b.png", 5),
|
||||
new AnimationTrackProperty.KeyFrame("Objects/Toolbox_y.png", 5),
|
||||
new AnimationTrackProperty.KeyFrame("Objects/toolbox_r.png", 5),
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Spawners
|
||||
{
|
||||
/// <summary>
|
||||
/// Spawns a set of entities on the client only, and removes them when this component is removed.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentProtoName("ClientEntitySpawner")]
|
||||
public sealed class ClientEntitySpawnerComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
[DataField("prototypes")] private List<string> _prototypes = new() { "HVDummyWire" };
|
||||
|
||||
private readonly List<EntityUid> _entity = new();
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SpawnEntities();
|
||||
}
|
||||
|
||||
protected override void OnRemove()
|
||||
{
|
||||
RemoveEntities();
|
||||
base.OnRemove();
|
||||
}
|
||||
|
||||
private void SpawnEntities()
|
||||
{
|
||||
foreach (var proto in _prototypes)
|
||||
{
|
||||
var entity = _entMan.SpawnEntity(proto, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
_entity.Add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveEntities()
|
||||
{
|
||||
foreach (var entity in _entity)
|
||||
{
|
||||
_entMan.DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user