Essence collector (#952)

* collector attract essence

* collector

* Update magic-essence.yml

* Update essence_collelctor.yml
This commit is contained in:
Ed
2025-02-28 15:55:47 +03:00
committed by GitHub
parent f2c9fb6503
commit 3fd47443ae
27 changed files with 483 additions and 24 deletions

View File

@@ -1,8 +1,8 @@
using Content.Server._CP14.Alchemy.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Shared.Audio;
namespace Content.Server._CP14.Alchemy;
namespace Content.Server._CP14.Alchemy.Components;
/// <summary>
/// gradually rounds down all reagents in the specified solution

View File

@@ -1,7 +1,4 @@
using Content.Server._CP14.MagicEnergy;
using Content.Server.Audio;
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared.Audio;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
@@ -9,7 +6,7 @@ using Content.Shared.FixedPoint;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
namespace Content.Server._CP14.Alchemy;
namespace Content.Server._CP14.Alchemy.EntitySystems;
public sealed partial class CP14SolutionNormalizerSystem : EntitySystem
{
@@ -17,26 +14,12 @@ public sealed partial class CP14SolutionNormalizerSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly CP14MagicEnergyCrystalSlotSystem _magicSlot = default!;
[Dependency] private readonly AmbientSoundSystem _ambient = default!;
public override void Initialize()
{
SubscribeLocalEvent<CP14SolutionNormalizerComponent,CP14SlotCrystalPowerChangedEvent>(OnSlotPowerChanged);
}
private void OnSlotPowerChanged(Entity<CP14SolutionNormalizerComponent> ent, ref CP14SlotCrystalPowerChangedEvent args)
{
if (TryComp<AmbientSoundComponent>(ent, out var ambient))
{
_ambient.SetAmbience(ent, args.Powered);
}
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<CP14SolutionNormalizerComponent, SolutionContainerManagerComponent>();
var query = EntityQueryEnumerator<Components.CP14SolutionNormalizerComponent, SolutionContainerManagerComponent>();
while (query.MoveNext(out var uid, out var normalizer, out var containerManager))
{
if (_timing.CurTime <= normalizer.NextUpdateTime)

View File

@@ -0,0 +1,13 @@
using Content.Shared._CP14.MagicRitual.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicEssence;
/// <summary>
/// Turn on and off the ambient sound if entity magic powered
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class CP14MagicEnergyAmbientSoundComponent : Component
{
}

View File

@@ -1,5 +1,7 @@
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared._CP14.MagicEssence;
using Content.Shared.Alert;
using Content.Shared.Audio;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.Rounding;
@@ -9,13 +11,24 @@ namespace Content.Shared._CP14.MagicEnergy;
public partial class SharedCP14MagicEnergySystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambient = default!;
public override void Initialize()
{
SubscribeLocalEvent<CP14MagicEnergyAmbientSoundComponent, CP14SlotCrystalPowerChangedEvent>(OnSlotPowerChanged);
SubscribeLocalEvent<CP14MagicEnergyContainerComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<CP14MagicEnergyContainerComponent, ComponentShutdown>(OnComponentShutdown);
}
private void OnSlotPowerChanged(Entity<CP14MagicEnergyAmbientSoundComponent> ent, ref CP14SlotCrystalPowerChangedEvent args)
{
if (TryComp<AmbientSoundComponent>(ent, out var ambient))
{
_ambient.SetAmbience(ent, args.Powered);
}
}
private void OnComponentStartup(Entity<CP14MagicEnergyContainerComponent> ent, ref ComponentStartup args)
{
UpdateMagicAlert(ent);

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
namespace Content.Shared._CP14.MagicEssence;
/// <summary>
/// Reflects the amount of essence stored in this item. The item can be destroyed to release the essence from it.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class CP14MagicEssenceAttractorComponent : Component
{
}

View File

@@ -0,0 +1,20 @@
using Robust.Shared.GameStates;
namespace Content.Shared._CP14.MagicEssence;
/// <summary>
/// Reflects the amount of essence stored in this item. The item can be destroyed to release the essence from it.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(CP14MagicEssenceSystem))]
public sealed partial class CP14MagicEssenceCollectorComponent : Component
{
[DataField]
public float CollectRange = 1f;
[DataField]
public float AttractRange = 5f;
[DataField]
public string Solution = "collector";
}

View File

@@ -0,0 +1,20 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
namespace Content.Shared._CP14.MagicEssence;
/// <summary>
///
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class CP14MagicEssenceComponent : Component
{
[DataField]
public string Solution = "essence";
[DataField]
public SoundSpecifier ConsumeSound = new SoundPathSpecifier("/Audio/_CP14/Effects/essence_consume.ogg")
{
Params = AudioParams.Default.WithVolume(-2f).WithVariation(0.2f),
};
}

View File

@@ -1,11 +1,15 @@
using System.Text;
using Content.Shared._CP14.MagicEnergy;
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.Throwing;
using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
using Robust.Shared.Physics.Events;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -21,6 +25,8 @@ public partial class CP14MagicEssenceSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedCP14MagicEnergySystem _magicEnergy = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
@@ -32,6 +38,41 @@ public partial class CP14MagicEssenceSystem : EntitySystem
SubscribeLocalEvent<CP14MagicEssenceScannerComponent, InventoryRelayedEvent<CP14MagicEssenceScanEvent>>((e, c, ev) => OnMagicScanAttempt(e, c, ev.Args));
SubscribeLocalEvent<CP14MagicEssenceSplitterComponent, CP14MagicEnergyOverloadEvent>(OnEnergyOverload);
SubscribeLocalEvent<CP14MagicEssenceCollectorComponent, CP14SlotCrystalPowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<CP14MagicEssenceCollectorComponent, StartCollideEvent>(OnCollectorCollide);
}
private void OnPowerChanged(Entity<CP14MagicEssenceCollectorComponent> ent, ref CP14SlotCrystalPowerChangedEvent args)
{
if (args.Powered)
EnsureComp<CP14MagicEssenceAttractorComponent>(ent);
else
RemCompDeferred<CP14MagicEssenceAttractorComponent>(ent);
}
private void OnCollectorCollide(Entity<CP14MagicEssenceCollectorComponent> ent, ref StartCollideEvent args)
{
if (!TryComp<CP14MagicEssenceComponent>(args.OtherEntity, out var essenceComp))
return;
if (!TryComp<SolutionContainerManagerComponent>(args.OtherEntity, out var essenceSolutionManager))
return;
if (!TryComp<SolutionContainerManagerComponent>(ent, out var collectorSolutionManager))
return;
if (!_solution.TryGetSolution((args.OtherEntity, essenceSolutionManager), essenceComp.Solution, out var essenceSoln, out var essenceSolution))
return;
if (!_solution.TryGetSolution((ent, collectorSolutionManager), ent.Comp.Solution, out var collectorSoln, out var collectorSolution))
return;
_solution.TryTransferSolution(collectorSoln.Value, essenceSolution, essenceSolution.Volume);
_audio.PlayPvs(essenceComp.ConsumeSound, ent);
if (_net.IsServer)
QueueDel(args.OtherEntity);
}
private void OnEnergyOverload(Entity<CP14MagicEssenceSplitterComponent> ent, ref CP14MagicEnergyOverloadEvent args)

View File

@@ -62,3 +62,9 @@
license: "CC-BY-4.0"
copyright: 'by SpaceLife on Freesound.org'
source: "https://freesound.org/people/SpaceLife/sounds/545938/"
- files: ["essence_consume.ogg"]
license: "CC0-1.0"
copyright: 'by DustyWind on Freesound.org'
source: "https://freesound.org/people/DustyWind/sounds/715784/"

Binary file not shown.

View File

@@ -0,0 +1,23 @@
cp14-reagent-name-essence-earth = Essence of earth
cp14-reagent-desc-essence-earth = Liquid embodiment of the element earth
cp14-reagent-name-essence-fire = Essence of fire
cp14-reagent-desc-essence-fire = Liquid embodiment of the element fire
cp14-reagent-name-essence-life = Essence of life
cp14-reagent-desc-essence-life = Liquid embodiment of the element life
cp14-reagent-name-essence-water = Essence of water
cp14-reagent-desc-essence-water = Liquid embodiment of the element water
cp14-reagent-name-essence-light = Essence of light
cp14-reagent-desc-essence-light = Liquid embodiment of the element light
cp14-reagent-name-essence-dimension = Essence of dimension
cp14-reagent-desc-essence-dimension = Liquid embodiment of the element dimension
cp14-reagent-name-essence-death = Essence of death
cp14-reagent-desc-essence-death = Liquid embodiment of the element death
cp14-reagent-name-essence-electric = Essence of electric
cp14-reagent-desc-essence-electric = Liquid embodiment of the element electric

View File

@@ -0,0 +1,23 @@
cp14-reagent-name-essence-earth = Эссенция земли
cp14-reagent-desc-essence-earth = Жидкое воплощение стихии земли
cp14-reagent-name-essence-fire = Эссенция огня
cp14-reagent-desc-essence-fire = Жидкое воплощение стихии огня
cp14-reagent-name-essence-life = Эссенция жизни
cp14-reagent-desc-essence-life = Жидкое воплощение стихии жизни
cp14-reagent-name-essence-water = Эссенция воды
cp14-reagent-desc-essence-water = Жидкое воплощение стихии воды
cp14-reagent-name-essence-light = Эссенция света
cp14-reagent-desc-essence-light = Жидкое воплощение стихии света
cp14-reagent-name-essence-dimension = Эссенция пространства
cp14-reagent-desc-essence-dimension = Жидкое воплощение стихии пространства
cp14-reagent-name-essence-death = Эссенция смерти
cp14-reagent-desc-essence-death = Жидкое воплощение стихии смерти
cp14-reagent-name-essence-electric = Эссенция молний
cp14-reagent-desc-essence-electric = Жидкое воплощение стихии молнии

View File

@@ -17,8 +17,8 @@
lifetime: 60
- type: CanMoveInAir
- type: RandomWalk
minSpeed: 0.5
maxSpeed: 1
minSpeed: 0.25
maxSpeed: 0.75
- type: Physics
bodyType: Dynamic
bodyStatus: InAir
@@ -34,6 +34,13 @@
- Impassable
restitution: 0.3 # fite me
friction: 0.2
- type: ChasingWalk
maxChaseRadius: 5
minSpeed: 0.5
maxSpeed: 1
chasingComponent:
- type: CP14MagicEssenceAttractor
- type: CP14MagicEssence
- type: entity
parent: CP14BaseEssence
@@ -42,6 +49,13 @@
components:
- type: Sprite
color: "#70533f"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceEarth
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -50,6 +64,13 @@
components:
- type: Sprite
color: "#d9741c"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceFire
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -58,6 +79,13 @@
components:
- type: Sprite
color: "#89e04f"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceLife
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -66,6 +94,13 @@
components:
- type: Sprite
color: "#1c94d9"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceWater
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -74,6 +109,13 @@
components:
- type: Sprite
color: "#ba97b8"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceLight
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -82,6 +124,13 @@
components:
- type: Sprite
color: "#391c57"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceDimension
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -90,6 +139,13 @@
components:
- type: Sprite
color: "#55877a"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceDeath
Quantity: 1
- type: entity
parent: CP14BaseEssence
@@ -97,4 +153,11 @@
name: electric essence
components:
- type: Sprite
color: "#caed72"
color: "#caed72"
- type: SolutionContainerManager
solutions:
essence:
maxVol: 1
reagents:
- ReagentId: CP14EssenceElectric
Quantity: 1

View File

@@ -67,6 +67,7 @@
solution: normalizer
- type: CP14SolutionNormalizer
solution: normalizer
- type: CP14MagicEnergyAmbientSound
- type: AmbientSound
enabled: false
range: 6

View File

@@ -0,0 +1,86 @@
- type: entity
id: CP14EssenceCollector
parent:
- BaseStructureDynamic
- CP14BaseCrystalSlot
name: essence collector
description: Being powered by the energy crystal, it will start sucking in all the essence floating in the air and converting it into useful liquid.
categories: [ ForkFiltered ]
components:
- type: Physics
bodyType: Static
- type: Transform
anchored: true
- type: InteractionOutline
- type: Sprite
drawdepth: Mobs
noRot: true
offset: 0, 0.2
sprite: _CP14/Structures/Specific/Thaumaturgy/essence_collector.rsi
layers:
- state: liq-1
map: ["enum.SolutionContainerLayers.Fill"]
visible: false
- state: base
- state: crystal
shader: unshaded
map: ["crystal"]
visible: false
- state: active
map: ["power"]
visible: false
shader: unshaded
- type: GenericVisualizer
visuals:
enum.CP14MagicSlotVisuals.Inserted:
crystal:
True: { visible: true }
False: { visible: false }
enum.CP14MagicSlotVisuals.Powered:
power:
True: { visible: true }
False: { visible: false }
- type: Fixtures
fixtures:
fix1:
hard: false
shape:
!type:PhysShapeAabb
bounds: "-0.25,-0.25,0.25,0.25"
density: 125
mask:
- TabletopMachineMask
layer:
- WallLayer
- type: SolutionContainerManager
solutions:
collector:
maxVol: 50
- type: CP14SolutionTemperature
- type: DrainableSolution
solution: collector
- type: ExaminableSolution
solution: collector
- type: MixableSolution
solution: collector
- type: RefillableSolution
solution: collector
- type: DrawableSolution
solution: collector
- type: DumpableSolution
solution: collector
- type: CP14MagicEnergyAmbientSound
- type: AmbientSound
enabled: false
range: 6
volume: 3
sound:
path: /Audio/Ambience/Objects/gravity_gen_hum.ogg
- type: Appearance
- type: SolutionContainerVisuals
maxFillLevels: 7
fillBaseName: liq-
- type: CP14MagicEnergyDraw
energy: -1
delay: 1
- type: CP14MagicEssenceCollector

View File

@@ -0,0 +1,103 @@
- type: reagent
id: CP14EssenceEarth
name: cp14-reagent-name-essence-earth
desc: cp14-reagent-desc-essence-earth
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#70533f"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceEarth
- type: reagent
id: CP14EssenceFire
name: cp14-reagent-name-essence-fire
desc: cp14-reagent-desc-essence-fire
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#d9741c"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceFire
- type: reagent
id: CP14EssenceLife
name: cp14-reagent-name-essence-life
desc: cp14-reagent-desc-essence-life
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#89e04f"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceLife
- type: reagent
id: CP14EssenceWater
name: cp14-reagent-name-essence-water
desc: cp14-reagent-desc-essence-water
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#1c94d9"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceWater
- type: reagent
id: CP14EssenceLight
name: cp14-reagent-name-essence-light
desc: cp14-reagent-desc-essence-light
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#ba97b8"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceLight
- type: reagent
id: CP14EssenceDimension
name: cp14-reagent-name-essence-dimension
desc: cp14-reagent-desc-essence-dimension
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#391c57"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceDimension
- type: reagent
id: CP14EssenceDeath
name: cp14-reagent-name-essence-death
desc: cp14-reagent-desc-essence-death
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#55877a"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceDeath
- type: reagent
id: CP14EssenceElectric
name: cp14-reagent-name-essence-electric
desc: cp14-reagent-desc-essence-electric
group: CP14MagicEssence
flavor: CP14Bitterly
recognizable: true
physicalDesc: cp14-reagent-physical-desc-sparkling
color: "#caed72"
tileReactions:
- !type:CreateEntityTileReaction
entity: CP14EssenceElectric

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

View File

@@ -0,0 +1,53 @@
{
"version": 1,
"license": "All right reserved",
"copyright": "Created by TheShuEd for CrystallEdge",
"size": {
"x": 32,
"y": 48
},
"states": [
{
"name": "base"
},
{
"name": "active",
"delays": [
[
0.2,
0.2,
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
]
]
},
{
"name": "crystal"
},
{
"name": "liq-1"
},
{
"name": "liq-2"
},
{
"name": "liq-3"
},
{
"name": "liq-4"
},
{
"name": "liq-5"
},
{
"name": "liq-6"
},
{
"name": "liq-7"
}
]
}