-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supermatter Engine (Port From White Dream) (#341)
# Description ![SM boom](https://github.com/Simple-Station/Einstein-Engines/assets/16548818/6937c520-0963-437c-a9a6-49afe6c8b787) ![New edge supermatter](https://github.com/Simple-Station/Einstein-Engines/assets/16548818/e8305536-b777-41f8-b9bf-295d402dc1bf) This PR has been produced in collaboration with coders from White Dream, with written permission given by the relevant code owners to port this specific slice of content to Einstein-Engines. Supermatter Engines are a form of nuclear reactor, which produces energy in the form of radioactive particles, while also decaying into Phoron when excited by an external energy source. Power can be obtained from the engine via radiation collectors, which like those of a singularity engine, must be periodically refueled. In addition, the engine must also be actively cooled via aid from Atmospherics, and for undesirable gasses to be extracted from the reactor chamber. If not cooled, the crystal will begin to destabilize and eventually collapse into one of three different situations depending on the source of its instability. 1. A nuclear blast. 2. A gravitational singularity 3. A Tesla ball # Changelog :cl: VMSolidus, White Dream, Colin-Tel - add: Supermatter Engines have been implemented. --------- Signed-off-by: VMSolidus <[email protected]> Co-authored-by: whateverusername0 <whateveremail> Co-authored-by: username <[email protected]> Co-authored-by: Danger Revolution! <[email protected]> Co-authored-by: Pieter-Jan Briers <[email protected]> Co-authored-by: DEATHB4DEFEAT <[email protected]>
- Loading branch information
1 parent
b9b3868
commit 80e48a5
Showing
29 changed files
with
1,348 additions
and
2 deletions.
There are no files selected for viewing
412 changes: 412 additions & 0 deletions
412
Content.Server/Supermatter/Systems/SupermatterSystem.Processing.cs
Large diffs are not rendered by default.
Oops, something went wrong.
212 changes: 212 additions & 0 deletions
212
Content.Server/Supermatter/Systems/SupermatterSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Events; | ||
using Robust.Server.GameObjects; | ||
using Content.Shared.Atmos; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Projectiles; | ||
using Content.Shared.Mobs.Components; | ||
using Content.Server.Atmos.EntitySystems; | ||
using Content.Server.Chat.Systems; | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Shared.Supermatter.Components; | ||
using Content.Server.Lightning; | ||
using Content.Server.AlertLevel; | ||
using Content.Server.Station.Systems; | ||
using Content.Server.Kitchen.Components; | ||
using Content.Shared.DoAfter; | ||
using Content.Shared.Examine; | ||
using Content.Server.DoAfter; | ||
using Content.Server.Popups; | ||
using Content.Shared.Audio; | ||
|
||
namespace Content.Server.Supermatter.Systems; | ||
|
||
public sealed partial class SupermatterSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly AtmosphereSystem _atmosphere = default!; | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
[Dependency] private readonly SharedContainerSystem _container = default!; | ||
[Dependency] private readonly ExplosionSystem _explosion = default!; | ||
[Dependency] private readonly TransformSystem _xform = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
[Dependency] private readonly SharedAmbientSoundSystem _ambient = default!; | ||
[Dependency] private readonly LightningSystem _lightning = default!; | ||
[Dependency] private readonly AlertLevelSystem _alert = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
[Dependency] private readonly DoAfterSystem _doAfter = default!; | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly PopupSystem _popup = default!; | ||
[Dependency] private readonly IConfigurationManager _config = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SupermatterComponent, MapInitEvent>(OnMapInit); | ||
|
||
SubscribeLocalEvent<SupermatterComponent, StartCollideEvent>(OnCollideEvent); | ||
SubscribeLocalEvent<SupermatterComponent, InteractHandEvent>(OnHandInteract); | ||
SubscribeLocalEvent<SupermatterComponent, InteractUsingEvent>(OnItemInteract); | ||
SubscribeLocalEvent<SupermatterComponent, ExaminedEvent>(OnExamine); | ||
SubscribeLocalEvent<SupermatterComponent, SupermatterDoAfterEvent>(OnGetSliver); | ||
} | ||
|
||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
foreach (var sm in EntityManager.EntityQuery<SupermatterComponent>()) | ||
{ | ||
if (!sm.Activated) | ||
return; | ||
|
||
var uid = sm.Owner; | ||
sm.UpdateAccumulator += frameTime; | ||
|
||
if (sm.UpdateAccumulator >= sm.UpdateTimer) | ||
{ | ||
sm.UpdateAccumulator -= sm.UpdateTimer; | ||
Cycle(uid, sm); | ||
} | ||
} | ||
} | ||
|
||
|
||
public void Cycle(EntityUid uid, SupermatterComponent sm) | ||
{ | ||
sm.ZapAccumulator++; | ||
sm.YellAccumulator++; | ||
|
||
ProcessAtmos(uid, sm); | ||
HandleDamage(uid, sm); | ||
|
||
if (sm.Damage >= sm.DamageDelaminationPoint || sm.Delamming) | ||
HandleDelamination(uid, sm); | ||
|
||
HandleSoundLoop(uid, sm); | ||
|
||
if (sm.ZapAccumulator >= sm.ZapTimer) | ||
{ | ||
sm.ZapAccumulator -= sm.ZapTimer; | ||
SupermatterZap(uid, sm); | ||
} | ||
|
||
if (sm.YellAccumulator >= sm.YellTimer) | ||
{ | ||
sm.YellAccumulator -= sm.YellTimer; | ||
AnnounceCoreDamage(uid, sm); | ||
} | ||
} | ||
|
||
private void OnMapInit(EntityUid uid, SupermatterComponent sm, MapInitEvent args) | ||
{ | ||
// Set the Sound | ||
_ambient.SetAmbience(uid, true); | ||
|
||
// Add Air to the initialized SM in the Map so it doesn't delam on its' own | ||
var mix = _atmosphere.GetContainingMixture(uid, true, true); | ||
mix?.AdjustMoles(Gas.Oxygen, Atmospherics.OxygenMolesStandard); | ||
mix?.AdjustMoles(Gas.Nitrogen, Atmospherics.NitrogenMolesStandard); | ||
} | ||
|
||
private void OnCollideEvent(EntityUid uid, SupermatterComponent sm, ref StartCollideEvent args) | ||
{ | ||
if (!sm.Activated) | ||
sm.Activated = true; | ||
|
||
var target = args.OtherEntity; | ||
if (args.OtherBody.BodyType == BodyType.Static | ||
|| HasComp<SupermatterImmuneComponent>(target) | ||
|| _container.IsEntityInContainer(uid)) | ||
return; | ||
|
||
if (!HasComp<ProjectileComponent>(target)) | ||
{ | ||
EntityManager.SpawnEntity(sm.CollisionResultPrototype, Transform(target).Coordinates); | ||
_audio.PlayPvs(sm.DustSound, uid); | ||
sm.Power += args.OtherBody.Mass; | ||
} | ||
|
||
EntityManager.QueueDeleteEntity(target); | ||
|
||
if (TryComp<SupermatterFoodComponent>(target, out var food)) | ||
sm.Power += food.Energy; | ||
else if (TryComp<ProjectileComponent>(target, out var projectile)) | ||
sm.Power += (float) projectile.Damage.GetTotal(); | ||
else | ||
sm.Power++; | ||
|
||
sm.MatterPower += HasComp<MobStateComponent>(target) ? 200 : 0; | ||
} | ||
|
||
private void OnHandInteract(EntityUid uid, SupermatterComponent sm, ref InteractHandEvent args) | ||
{ | ||
if (!sm.Activated) | ||
sm.Activated = true; | ||
|
||
var target = args.User; | ||
|
||
if (HasComp<SupermatterImmuneComponent>(target)) | ||
return; | ||
|
||
sm.MatterPower += 200; | ||
|
||
EntityManager.SpawnEntity(sm.CollisionResultPrototype, Transform(target).Coordinates); | ||
_audio.PlayPvs(sm.DustSound, uid); | ||
EntityManager.QueueDeleteEntity(target); | ||
} | ||
|
||
private void OnItemInteract(EntityUid uid, SupermatterComponent sm, ref InteractUsingEvent args) | ||
{ | ||
if (!sm.Activated) | ||
sm.Activated = true; | ||
|
||
if (sm.SliverRemoved) | ||
return; | ||
|
||
if (!HasComp<SharpComponent>(args.Used)) | ||
return; | ||
|
||
var dae = new DoAfterArgs(EntityManager, args.User, 30f, new SupermatterDoAfterEvent(), args.Target) | ||
{ | ||
BreakOnDamage = true, | ||
BreakOnHandChange = false, | ||
BreakOnTargetMove = true, | ||
BreakOnUserMove = true, | ||
BreakOnWeightlessMove = false, | ||
NeedHand = true, | ||
RequireCanInteract = true, | ||
}; | ||
|
||
_doAfter.TryStartDoAfter(dae); | ||
_popup.PopupClient(Loc.GetString("supermatter-tamper-begin"), uid, args.User); | ||
} | ||
|
||
private void OnGetSliver(EntityUid uid, SupermatterComponent sm, ref SupermatterDoAfterEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
// Your criminal actions will not go unnoticed | ||
sm.Damage += sm.DamageDelaminationPoint / 10; | ||
|
||
var integrity = GetIntegrity(sm).ToString("0.00"); | ||
SendSupermatterAnnouncement(uid, Loc.GetString("supermatter-announcement-cc-tamper", ("integrity", integrity)), true, "Central Command"); | ||
|
||
Spawn(sm.SliverPrototype, _transform.GetMapCoordinates(args.User)); | ||
_popup.PopupClient(Loc.GetString("supermatter-tamper-end"), uid, args.User); | ||
|
||
sm.DelamTimer /= 2; | ||
} | ||
|
||
private void OnExamine(EntityUid uid, SupermatterComponent sm, ref ExaminedEvent args) | ||
{ | ||
if (args.IsInDetailsRange) | ||
args.PushMarkup(Loc.GetString("supermatter-examine-integrity", ("integrity", GetIntegrity(sm).ToString("0.00")))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.