Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supermatter Engine (Port From White Dream) #341

Merged
merged 47 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4043f1b
Initial Port
VMSolidus Apr 25, 2024
158b8d9
Should fix test fail
VMSolidus Apr 25, 2024
7527bdd
Edge with Experimental Supermatter Engine
VMSolidus Apr 26, 2024
4089288
Update edge.yml
VMSolidus Apr 26, 2024
a9d8b6b
New edge by Colintel
VMSolidus Apr 26, 2024
bf337fe
Update edge.yml
VMSolidus Apr 26, 2024
07d94cb
Update edge.yml
VMSolidus Apr 26, 2024
0b428dc
better sound looping
VMSolidus Apr 30, 2024
185a63b
Update edge.yml
VMSolidus May 4, 2024
79e9664
Update supermatter
VMSolidus May 10, 2024
259f714
Merge branch 'master' into Port-Of-Supermatter
VMSolidus May 30, 2024
c241559
Updating server Supermatter System
VMSolidus Jun 4, 2024
11e6530
Update supermatter.yml
VMSolidus Jun 21, 2024
d6d5707
Update supermatter.ftl
VMSolidus Jun 21, 2024
d94c07d
Delete edge.yml
VMSolidus Jun 21, 2024
d3ab5a2
Create edge.yml
VMSolidus Jun 21, 2024
4199493
what
Jun 22, 2024
2d1b16f
port from https://github.com/Goob-Station/Goob-Station/pull/344
Jun 22, 2024
ba27eee
fix doafter
Jun 22, 2024
b60949f
ok
Jun 22, 2024
13e6532
grab som more
Jun 22, 2024
96dbb7b
please god
Jun 22, 2024
24be76e
Merge branch 'Port-Of-Supermatter' of https://github.com/VMSolidus/Ei…
Jun 22, 2024
7699ed5
no more 0% integrity announcements
Jun 22, 2024
f287722
more tweaks
Jun 26, 2024
4570415
moar oopdates
Jun 26, 2024
e5de134
Merge branch 'master' into Port-Of-Supermatter
VMSolidus Jun 29, 2024
de91dbd
womp
Jul 1, 2024
b238628
Merge branch 'Port-Of-Supermatter' of https://github.com/VMSolidus/Ei…
Jul 1, 2024
b44cc4f
Merge branch 'master' into Port-Of-Supermatter
whateverusername0 Jul 2, 2024
f1675dc
Merge branch 'master' into Port-Of-Supermatter
DangerRevolution Jul 8, 2024
7a502c1
Merge branch 'master' into Port-Of-Supermatter
VMSolidus Jul 21, 2024
772997c
Update SupermatterSystem.cs
VMSolidus Jul 22, 2024
d67f005
Cleanup Deprecated VV Options
VMSolidus Jul 30, 2024
7d93298
Merge branch 'master' into Port-Of-Supermatter
VMSolidus Jul 30, 2024
89e7d27
Update SupermatterSystem.cs
VMSolidus Jul 30, 2024
af52d71
Update SupermatterFoodComponent.cs
VMSolidus Jul 30, 2024
c1a5c57
Update SupermatterComponent.cs
VMSolidus Jul 31, 2024
db97eda
Add job whitelist system (#28085)
VMSolidus Jul 31, 2024
c54c778
this is INTERESTING to learn
VMSolidus Jul 31, 2024
7ede349
Update SupermatterSystem.cs
VMSolidus Jul 31, 2024
f4f0d35
Apply suggestions from code review
VMSolidus Aug 2, 2024
d999564
Apply suggestions from code review
VMSolidus Aug 2, 2024
50ed86b
Apply suggestions from code review
VMSolidus Aug 2, 2024
7f63471
Apply suggestions from code review
VMSolidus Aug 2, 2024
1c76a1f
Final Update
VMSolidus Aug 2, 2024
10989f4
Update supermatter.yml
VMSolidus Aug 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 412 additions & 0 deletions Content.Server/Supermatter/Systems/SupermatterSystem.Processing.cs

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions Content.Server/Supermatter/Systems/SupermatterSystem.cs
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
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!;

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

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);
}

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

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);
}
}
}

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

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"))));
}
}
50 changes: 50 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Supermatter.Components;
using Robust.Shared;
using Robust.Shared.Configuration;

Expand Down Expand Up @@ -2347,5 +2348,54 @@ public static readonly CVarDef<float>
CVarDef.Create("contests.max_percentage", 0.25f, CVar.REPLICATED | CVar.SERVER);

#endregion

#region Supermatter System

/// <summary>
/// With completely default supermatter values, Singuloose delamination will occur if engineers inject at least 900 moles of coolant per tile
/// in the crystal chamber. For reference, a gas canister contains 1800 moles of air. This Cvar directly multiplies the amount of moles required to singuloose.
/// </summary>
public static readonly CVarDef<float> SupermatterSingulooseMolesModifier =
CVarDef.Create("supermatter.singuloose_moles_modifier", 1f, CVar.SERVER);

/// <summary>
/// Toggles whether or not Singuloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke.
/// </summary>
public static readonly CVarDef<bool> SupermatterDoSingulooseDelam =
CVarDef.Create("supermatter.do_singuloose", true, CVar.SERVER);

/// <summary>
/// By default, Supermatter will "Tesloose" if the conditions for Singuloose are not met, and the core's power is at least 4000.
/// The actual reasons for being at least this amount vary by how the core was screwed up, but traditionally it's caused by "The core is on fire".
/// This Cvar multiplies said power threshold for the purpose of determining if the delam is a Tesloose.
/// </summary>
public static readonly CVarDef<float> SupermatterTesloosePowerModifier =
CVarDef.Create("supermatter.tesloose_power_modifier", 1f, CVar.SERVER);

/// <summary>
/// Toggles whether or not Tesloose delaminations can occur. If both Singuloose and Tesloose are disabled, it will always delam into a Nuke.
/// </summary>
public static readonly CVarDef<bool> SupermatterDoTeslooseDelam =
CVarDef.Create("supermatter.do_tesloose", true, CVar.SERVER);

/// <summary>
/// When true, bypass the normal checks to determine delam type, and instead use the type chosen by supermatter.forced_delam_type
/// </summary>
public static readonly CVarDef<bool> SupermatterDoForceDelam =
CVarDef.Create("supermatter.do_force_delam", false, CVar.SERVER);

/// <summary>
/// If supermatter.do_force_delam is true, this determines the delamination type, bypassing the normal checks.
/// </summary>
public static readonly CVarDef<DelamType> SupermatterForcedDelamType =
CVarDef.Create("supermatter.forced_delam_type", DelamType.Singulo, CVar.SERVER);

/// <summary>
/// Directly multiplies the amount of rads put out by the supermatter. Be VERY conservative with this.
/// </summary>
public static readonly CVarDef<float> SupermatterRadsModifier =
CVarDef.Create("supermatter.rads_modifier", 1f, CVar.SERVER);

#endregion
}
}
Loading
Loading