Anomaly Cores (#21306)

* add first anomaly core

* meme

* 5 min to 10 min
fix yml

* fix

* Update doc

* no static price
This commit is contained in:
Ed
2023-11-01 02:20:52 +03:00
committed by GitHub
parent 3a4c40c29b
commit 96ff529c82
31 changed files with 596 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
using Content.Server.Anomaly.Effects;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Anomaly.Components;
/// <summary>
/// This component exists for a limited time, and after it expires it modifies the entity, greatly reducing its value and changing its visuals
/// </summary>
[RegisterComponent, Access(typeof(AnomalyCoreSystem))]
public sealed partial class AnomalyCoreComponent : Component
{
/// <summary>
/// Amount of time required for the core to decompose into an inert core
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public double TimeToDecay = 600;
/// <summary>
/// The moment of core decay. It is set during entity initialization.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan DecayMoment;
/// <summary>
/// The starting value of the entity.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public double StartPrice = 10000;
/// <summary>
/// The value of the object sought during decaying
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public double EndPrice = 200;
/// <summary>
/// Has the core decayed?
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool IsDecayed;
}

View File

@@ -0,0 +1,56 @@
using Content.Server.Anomaly.Components;
using Content.Server.Cargo.Systems;
using Content.Shared.Anomaly;
using Robust.Shared.Timing;
namespace Content.Server.Anomaly.Effects;
/// <summary>
/// This component reduces the value of the entity during decay
/// </summary>
public sealed class AnomalyCoreSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{
SubscribeLocalEvent<AnomalyCoreComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<AnomalyCoreComponent, PriceCalculationEvent>(OnGetPrice);
}
private void OnMapInit(Entity<AnomalyCoreComponent> core, ref MapInitEvent args)
{
core.Comp.DecayMoment = _gameTiming.CurTime + TimeSpan.FromSeconds(core.Comp.TimeToDecay);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<AnomalyCoreComponent>();
while (query.MoveNext(out var uid, out var component))
{
if (component.IsDecayed)
continue;
//When time runs out, we completely decompose
if (component.DecayMoment < _gameTiming.CurTime)
Decay(uid, component);
}
}
private void OnGetPrice(Entity<AnomalyCoreComponent> core, ref PriceCalculationEvent args)
{
var timeLeft = core.Comp.DecayMoment - _gameTiming.CurTime;
var lerp = (double) (timeLeft.TotalSeconds / core.Comp.TimeToDecay);
lerp = Math.Clamp(lerp, 0, 1);
args.Price = MathHelper.Lerp(core.Comp.EndPrice, core.Comp.StartPrice, lerp);
}
private void Decay(EntityUid uid, AnomalyCoreComponent component)
{
_appearance.SetData(uid, AnomalyCoreVisuals.Decaying, false);
component.IsDecayed = true;
}
}

View File

@@ -0,0 +1,9 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Anomaly;
[Serializable, NetSerializable]
public enum AnomalyCoreVisuals : byte
{
Decaying
}

View File

@@ -2,6 +2,7 @@ using System.Numerics;
using Content.Shared.Damage; using Content.Shared.Damage;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Anomaly.Components; namespace Content.Shared.Anomaly.Components;
@@ -208,6 +209,18 @@ public sealed partial class AnomalyComponent : Component
[DataField] [DataField]
public SoundSpecifier AnomalyContactDamageSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg"); public SoundSpecifier AnomalyContactDamageSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");
/// <summary>
/// A prototype entity that appears when an anomaly supercrit collapse.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public EntProtoId? CorePrototype;
/// <summary>
/// A prototype entity that appears when an anomaly decays.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public EntProtoId? CoreInertPrototype;
#region Floating Animation #region Floating Animation
/// <summary> /// <summary>
/// How long it takes to go from the bottom of the animation to the top. /// How long it takes to go from the bottom of the animation to the top.

View File

@@ -1,4 +1,4 @@
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Anomaly.Components; using Content.Shared.Anomaly.Components;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Database; using Content.Shared.Database;
@@ -181,6 +181,9 @@ public abstract class SharedAnomalySystem : EntitySystem
if (Terminating(uid) || _net.IsClient) if (Terminating(uid) || _net.IsClient)
return; return;
Spawn(supercritical ? component.CorePrototype : component.CoreInertPrototype, Transform(uid).Coordinates);
QueueDel(uid); QueueDel(uid);
} }

View File

@@ -53,6 +53,9 @@
parent: BaseAnomaly parent: BaseAnomaly
suffix: Pyroclastic suffix: Pyroclastic
components: components:
- type: Anomaly
corePrototype: AnomalyCorePyroclastic
coreInertPrototype: AnomalyCorePyroclasticInert
- type: Sprite - type: Sprite
layers: layers:
- state: anom1 - state: anom1
@@ -81,6 +84,9 @@
parent: BaseAnomaly parent: BaseAnomaly
suffix: Gravity suffix: Gravity
components: components:
- type: Anomaly
corePrototype: AnomalyCoreGravity
coreInertPrototype: AnomalyCoreGravityInert
- type: Sprite - type: Sprite
layers: layers:
- state: anom2 - state: anom2
@@ -102,6 +108,9 @@
parent: BaseAnomaly parent: BaseAnomaly
suffix: Electricity suffix: Electricity
components: components:
- type: Anomaly
corePrototype: AnomalyCoreElectricity
coreInertPrototype: AnomalyCoreElectricityInert
- type: Sprite - type: Sprite
layers: layers:
- state: anom3 - state: anom3
@@ -122,6 +131,9 @@
parent: BaseAnomaly parent: BaseAnomaly
suffix: Flesh suffix: Flesh
components: components:
- type: Anomaly
corePrototype: AnomalyCoreFlesh
coreInertPrototype: AnomalyCoreFleshInert
- type: Sprite - type: Sprite
layers: layers:
- state: anom5 - state: anom5
@@ -186,6 +198,8 @@
- WallLayer - WallLayer
hard: false hard: false
- type: Anomaly - type: Anomaly
corePrototype: AnomalyCoreBluespace
coreInertPrototype: AnomalyCoreBluespaceInert
pulseSound: pulseSound:
collection: RadiationPulse collection: RadiationPulse
params: params:
@@ -214,6 +228,8 @@
color: "#befaff" color: "#befaff"
castShadows: false castShadows: false
- type: Anomaly - type: Anomaly
corePrototype: AnomalyCoreIce
coreInertPrototype: AnomalyCoreIceInert
anomalyContactDamage: anomalyContactDamage:
types: types:
Cold: 10 Cold: 10
@@ -238,6 +254,9 @@
parent: BaseAnomaly parent: BaseAnomaly
suffix: Rock suffix: Rock
components: components:
- type: Anomaly
corePrototype: AnomalyCoreRock
coreInertPrototype: AnomalyCoreRockInert
- type: Sprite - type: Sprite
layers: layers:
- state: anom6 - state: anom6
@@ -289,6 +308,8 @@
color: "#bbbbbb" color: "#bbbbbb"
- type: BadFood - type: BadFood
- type: Anomaly - type: Anomaly
corePrototype: AnomalyCoreLiquid
coreInertPrototype: AnomalyCoreLiquidInert
anomalyContactDamage: anomalyContactDamage:
types: types:
Slash: 1 Slash: 1

View File

@@ -0,0 +1,251 @@
- type: entity
parent: BaseItem
id: BaseAnomalyCore
abstract: true
name: anomaly core
description: The core of a detroyed incomprehensible object.
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/gravity_core.rsi
layers:
- state: core
- state: pulse
map: ["decay"]
- type: Appearance
- type: GenericVisualizer
visuals:
enum.AnomalyCoreVisuals.Decaying:
decay:
True: { visible: true }
False: { visible: false }
- type: Item
size: 10
- type: ItemCooldown
- type: EmitSoundOnUse #placeholder for future unical mechanic
sound:
collection: RadiationPulse
- type: UseDelay
delay: 2
- type: AnomalyCore
timeToDecay: 600
startPrice: 10000
endPrice: 200
- type: entity
parent: BaseAnomalyCore
id: AnomalyCorePyroclastic
suffix: Pyroclastic
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/pyro_core.rsi
- type: PointLight
radius: 1.5
energy: 1.5
color: "#fca3c0"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreGravity
suffix: Gravity
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/gravity_core.rsi
- type: PointLight
radius: 1.5
energy: 10
color: "#1e070e"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreIce
suffix: Ice
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/ice_core.rsi
- type: PointLight
radius: 1.5
energy: 1.5
color: "#befaff"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreFlesh
suffix: Flesh
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/flesh_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#cb5b7e"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreRock
suffix: Rock
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/rock_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#5ca8cb"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreLiquid
suffix: Liquid
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/liquid_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#ffffff"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreBluespace
suffix: Bluespace
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/bluespace_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#00ccff"
castShadows: false
- type: entity
parent: BaseAnomalyCore
id: AnomalyCoreElectricity
suffix: Electricity
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/electric_core.rsi
- type: PointLight
radius: 1.5
energy: 2.0
color: "#ffffaa"
castShadows: false
- type: Electrified
# Inert cores
- type: entity
parent: BaseAnomalyCore
id: BaseAnomalyInertCore
abstract: true
components:
- type: AnomalyCore
timeToDecay: 1 #decay very fast
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCorePyroclasticInert
suffix: Pyroclastic, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/pyro_core.rsi
- type: PointLight
radius: 1.5
energy: 1.5
color: "#fca3c0"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreGravityInert
suffix: Gravity, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/gravity_core.rsi
- type: PointLight
radius: 1.5
energy: 10
color: "#1e070e"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreIceInert
suffix: Ice, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/ice_core.rsi
- type: PointLight
radius: 1.5
energy: 1.5
color: "#befaff"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreFleshInert
suffix: Flesh, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/flesh_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#cb5b7e"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreRockInert
suffix: Rock, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/rock_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#5ca8cb"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreLiquidInert
suffix: Liquid, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/liquid_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#ffffff"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreBluespaceInert
suffix: Bluespace, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/bluespace_core.rsi
- type: PointLight
radius: 1.5
energy: 3.5
color: "#00ccff"
castShadows: false
- type: entity
parent: BaseAnomalyInertCore
id: AnomalyCoreElectricityInert
suffix: Electricity, Inert
components:
- type: Sprite
sprite: Structures/Specific/Anomalies/Cores/electric_core.rsi
- type: PointLight
radius: 1.5
energy: 2.0
color: "#ffffaa"
castShadows: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Created by TheShuEd (github) for ss14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "core"
},
{
"name": "pulse",
"delays": [
[
0.15625,
0.15625,
0.15625,
0.15625
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B