Changes the SingularitySystem to use generic visualizers (#15057)
This commit is contained in:
@@ -20,7 +20,6 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SingularityComponent, ComponentHandleState>(HandleSingularityState);
|
||||
SubscribeLocalEvent<SingularityComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,31 +35,4 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
|
||||
SetLevel(uid, state.Level, comp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles ensuring that the singularity has a sprite to see.
|
||||
/// </summary>
|
||||
protected override void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args)
|
||||
{
|
||||
base.OnSingularityStartup(uid, comp, args);
|
||||
if (TryComp<SpriteComponent>(uid, out var sprite))
|
||||
{
|
||||
sprite.LayerMapReserveBlank(comp.Layer);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles updating the visible state of the singularity to reflect its current level.
|
||||
/// </summary>
|
||||
private void OnAppearanceChange(EntityUid uid, SingularityComponent comp, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
if(!_appearanceSystem.TryGetData<byte>(uid, SingularityVisuals.Level, out var level, args.Component))
|
||||
return;
|
||||
|
||||
args.Sprite.LayerSetSprite(comp.Layer,
|
||||
new SpriteSpecifier.Rsi(new ResourcePath($"{comp.BaseSprite.RsiPath}_{level}.rsi"), $"{comp.BaseSprite.RsiState}_{level}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,22 +82,6 @@ public sealed class SingularityComponent : Component
|
||||
|
||||
#endregion Audio
|
||||
|
||||
#region Appearance
|
||||
|
||||
/// <summary>
|
||||
/// The sprite layer the singularity appearance is attached to.
|
||||
/// </summary>
|
||||
[DataField("layer")]
|
||||
public int Layer { get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The base sprite file and state of the singularity.
|
||||
/// </summary>
|
||||
[DataField("baseSprite")]
|
||||
public SpriteSpecifier.Rsi BaseSprite = new SpriteSpecifier.Rsi(new ResourcePath("Structures/Power/Generation/Singularity/singularity"), "singularity");
|
||||
|
||||
#endregion Appearance
|
||||
|
||||
#region Update Timing
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -126,7 +126,7 @@ public abstract class SharedSingularitySystem : EntitySystem
|
||||
|
||||
RaiseLocalEvent(uid, new SingularityLevelChangedEvent(singularity.Level, oldValue, singularity));
|
||||
if (singularity.Level <= 0)
|
||||
EntityManager.DeleteEntity(singularity.Owner);
|
||||
QueueDel(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -366,7 +366,7 @@ public abstract class SharedSingularitySystem : EntitySystem
|
||||
/// <param name="args">The event arguments.</param>
|
||||
private void UpdateAppearance(EntityUid uid, AppearanceComponent comp, SingularityLevelChangedEvent args)
|
||||
{
|
||||
_visualizer.SetData(uid, SingularityVisuals.Level, args.NewValue, comp);
|
||||
_visualizer.SetData(uid, SingularityAppearanceKeys.Singularity, args.NewValue, comp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Content.Shared.Singularity
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum SingularityVisuals
|
||||
public enum SingularityAppearanceKeys
|
||||
{
|
||||
Level
|
||||
Singularity
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,18 @@
|
||||
path: /Audio/Effects/singularity.ogg
|
||||
- type: Physics
|
||||
bodyType: Dynamic
|
||||
- type: EventHorizon # To make the singularity consume things.
|
||||
radius: 0.5
|
||||
canBreachContainment: false
|
||||
horizonFixtureId: EventHorizon
|
||||
- type: GravityWell # To make the singularity attract things.
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
- id: EventHorizon
|
||||
shape:
|
||||
!type:PhysShapeCircle
|
||||
radius: 0.5
|
||||
restitution: 0.9
|
||||
radius: 0.35
|
||||
restitution: 0.8
|
||||
density: 99999
|
||||
mask:
|
||||
- AllMask
|
||||
@@ -27,26 +32,53 @@
|
||||
energy: 180
|
||||
level: 1
|
||||
radsPerLevel: 2
|
||||
- type: GravityWell # To make the singularity attract things.
|
||||
- type: EventHorizon # To make the singularity consume things.
|
||||
radius: 0.5
|
||||
canBreachContainment: false
|
||||
horizonFixtureId: EventHorizon
|
||||
- type: RandomWalk # To make the singularity move around.
|
||||
- type: SingularityDistortion
|
||||
intensity: 20
|
||||
- type: RadiationSource
|
||||
slope: 0.2 # its emit really far away
|
||||
- type: Sprite
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_1.rsi
|
||||
state: singularity_1
|
||||
shader: unshaded
|
||||
netsync: false
|
||||
- type: PointLight
|
||||
enabled: true
|
||||
radius: 10
|
||||
- type: Appearance
|
||||
- type: GuideHelp
|
||||
guides: [ Singularity, Power ]
|
||||
guides: [ Singularity, Power ] # uhhh.. I would hoped they'd have read the manual before ever getting in viewing distance...
|
||||
- type: WarpPoint
|
||||
follow: true
|
||||
location: singularity
|
||||
- type: Sprite
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_1.rsi
|
||||
shader: unshaded
|
||||
netsync: false
|
||||
layers:
|
||||
- map: [ "VisualLevel" ]
|
||||
state: singularity_1
|
||||
- type: GenericVisualizer
|
||||
visuals:
|
||||
enum.SingularityAppearanceKeys.Singularity:
|
||||
VisualLevel:
|
||||
1:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_1.rsi
|
||||
state: singularity_1
|
||||
scale: 1.0,1.0
|
||||
2:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_2.rsi
|
||||
state: singularity_2
|
||||
scale: 1.0,1.0
|
||||
3:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_3.rsi
|
||||
state: singularity_3
|
||||
scale: 1.0,1.0
|
||||
4:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_4.rsi
|
||||
state: singularity_4
|
||||
scale: 1.0,1.0
|
||||
5:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_5.rsi
|
||||
state: singularity_5
|
||||
scale: 1.5,1.5
|
||||
6:
|
||||
sprite: Structures/Power/Generation/Singularity/singularity_6.rsi
|
||||
state: singularity_6
|
||||
scale: .9,.9
|
||||
|
||||
|
||||
Reference in New Issue
Block a user