Carp wave spawner and dragons as an actual event (#10254)

This commit is contained in:
metalgearsloth
2022-08-08 10:18:14 +10:00
committed by GitHub
parent 3d850c6592
commit a29d8b9fa2
60 changed files with 1264 additions and 569 deletions

View File

@@ -0,0 +1,9 @@
using Content.Shared.Dragon;
namespace Content.Client.Dragon;
[RegisterComponent]
public sealed class DragonRiftComponent : SharedDragonRiftComponent
{
}

View File

@@ -0,0 +1,51 @@
using Content.Shared.Dragon;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;
namespace Content.Client.Dragon;
public sealed class DragonSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DragonRiftComponent, ComponentHandleState>(OnRiftHandleState);
}
private void OnRiftHandleState(EntityUid uid, DragonRiftComponent component, ref ComponentHandleState args)
{
if (args.Current is not DragonRiftComponentState state)
return;
if (component.State == state.State) return;
component.State = state.State;
TryComp<SpriteComponent>(uid, out var sprite);
TryComp<PointLightComponent>(uid, out var light);
if (sprite == null && light == null)
return;
switch (state.State)
{
case DragonRiftState.Charging:
sprite?.LayerSetColor(0, Color.FromHex("#569fff"));
if (light != null)
light.Color = Color.FromHex("#366db5");
break;
case DragonRiftState.AlmostFinished:
sprite?.LayerSetColor(0, Color.FromHex("#cf4cff"));
if (light != null)
light.Color = Color.FromHex("#9e2fc1");
break;
case DragonRiftState.Finished:
sprite?.LayerSetColor(0, Color.FromHex("#edbc36"));
if (light != null)
light.Color = Color.FromHex("#cbaf20");
break;
}
}
}

View File

@@ -0,0 +1,58 @@
using Content.Shared.Sprite;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Reflection;
namespace Content.Client.Sprite;
public sealed class RandomSpriteSystem : SharedRandomSpriteSystem
{
[Dependency] private readonly IReflectionManager _reflection = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomSpriteComponent, ComponentHandleState>(OnHandleState);
}
private void OnHandleState(EntityUid uid, RandomSpriteComponent component, ref ComponentHandleState args)
{
if (args.Current is not RandomSpriteColorComponentState state)
return;
if (state.Selected.Equals(component.Selected))
return;
component.Selected.Clear();
component.Selected.EnsureCapacity(state.Selected.Count);
foreach (var layer in state.Selected)
{
component.Selected.Add(layer.Key, layer.Value);
}
UpdateAppearance(uid, component);
}
private void UpdateAppearance(EntityUid uid, RandomSpriteComponent component, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref sprite, false))
return;
foreach (var layer in component.Selected)
{
object key;
if (_reflection.TryParseEnumReference(layer.Key, out var @enum))
{
key = @enum;
}
else
{
key = layer.Key;
}
sprite.LayerSetState(key, layer.Value.State);
sprite.LayerSetColor(key, layer.Value.Color ?? Color.White);
}
}
}