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 8 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
21 changes: 21 additions & 0 deletions Content.Client/Supermatter/Systems/SupermatterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Shared.Supermatter.Components;
using Content.Shared.Supermatter.Systems;
using Robust.Shared.GameStates;

namespace Content.Client.Supermatter.Systems;

public sealed class SupermatterSystem : SharedSupermatterSystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SupermatterComponent, ComponentHandleState>(HandleSupermatterState);
}

private void HandleSupermatterState(EntityUid uid, SupermatterComponent comp, ref ComponentHandleState args)
{
if (args.Current is not SupermatterComponentState state)
return;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component state can be handled automatically

546 changes: 546 additions & 0 deletions Content.Server/Supermatter/Systems/SupermatterSystem.cs
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

370 changes: 370 additions & 0 deletions Content.Shared/Supermatter/Components/SupermatterComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,370 @@
using Robust.Shared.GameStates;
using Robust.Shared.Audio;
using Content.Shared.Atmos;
using Content.Shared.Supermatter.Systems;
using Content.Shared.Whitelist;

namespace Content.Shared.Supermatter.Components;

[RegisterComponent, NetworkedComponent]
public sealed partial class SupermatterComponent : Component
{
#region SM Base

[DataField("whitelist")] public EntityWhitelist Whitelist = new();
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
public string IdTag = "EmitterBolt";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be hardcoded, shouldn't be a string, and should be at the top of the Component if it's a constant.


[ViewVariables(VVAccess.ReadWrite)]
[DataField("power")]
public float Power;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This either needs a better name and docs, or more likely shouldn't be a datafield. (Probably both)


/// <summary>
/// The amount of damage we have currently
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("damage")]
public float Damage = 0f;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

[ViewVariables(VVAccess.ReadWrite)]
[DataField("matterPower")]
public float MatterPower;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

[ViewVariables(VVAccess.ReadWrite)]
[DataField("matterPowerConversion")]
public float MatterPowerConversion = 10f;

public SharedSupermatterSystem.DelamType DelamType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be here


/// <summary>
/// The portion of the gasmix we're on
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("gasEfficiency")]
public float GasEfficiency = 0.15f;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// The amount of heat we apply scaled
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("heatThreshold")]
public float HeatThreshold = 2500f;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

#endregion SM Base

#region SM Sound
/// <summary>
/// Current stream of SM audio.
/// </summary>
public EntityUid? AudioStream;

public SharedSupermatterSystem.SuperMatterSound? SmSound;

[DataField("dustSound")]
public SoundSpecifier DustSound = new SoundPathSpecifier("/Audio/Supermatter/dust.ogg");

[DataField("delamSound")]
public SoundSpecifier DelamSound = new SoundPathSpecifier("/Audio/Supermatter/delamming.ogg");

[DataField("delamAlarm")]
public SoundSpecifier DelamAlarm = new SoundPathSpecifier("/Audio/Machines/alarm.ogg");

#endregion SM Sound

#region SM Calculation

/// <summary>
/// Based on co2 percentage, slowly moves between
/// 0 and 1. We use it to calc the powerloss_inhibitor
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("powerlossdynamicScaling")]
public float PowerlossDynamicScaling;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Affects the amount of damage and minimum point
/// at which the sm takes heat damage
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("dynamicheatResistance")]
public float DynamicHeatResistance = 1;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Used to increase or lessen the amount of damage the sm takes
/// from heat based on molar counts.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("moleheatPenalty")]
public float MoleHeatPenalty = 350f;

/// <summary>
/// Higher == more overall power
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("reactionpowerModefier")]
public float ReactionPowerModefier = 0.55f;

/// <summary>
/// Higher == less heat released during reaction
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("thermalreleaseModifier")]
public float ThermalReleaseModifier = 5f;

/// <summary>
/// Higher == less plasma released by reaction
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("plasmareleaseModifier")]
public float PlasmaReleaseModifier = 750f;

/// <summary>
/// Higher == less oxygen released at high temperature/power
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("oxygenreleaseModifier")]
public float OxygenReleaseModifier = 325f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These numbers are strange for defaults, modifiers should generally default to '1' since the implication is that adjusting it will adjust away from default behavior by the modifier.
Large modifiers like this can be multiplied in code so they make more sense. Remember that these numbers only actually exist to be user-facing, they don't need to be literals.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making PlasmaReleaseModifier larger should not release less plasma. Invert the modifier or rename to PlasmaReleaseEfficienyModifier or something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say shorten these all to 'Mod' rather than 'Modifier' for brevity, and also remove the explicit datafields, but wait till I'm around for that


#endregion SM Calculation

#region SM Timer

/// <summary>
/// The point at which we should start sending messeges
/// about the damage to the engi channels.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("WarningPoint")]
public float WarningPoint = 50;

/// <summary>
/// The point at which we start sending messages to the common channel
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("emergencyPoint")]
public float EmergencyPoint = 500;

/// <summary>
/// we yell if over 50 damage every YellTimer Seconds
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("yellTimer")]
public float YellTimer = 30f;

/// <summary>
/// set to YellTimer at first so it doesnt yell a minute after being hit
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("yellAccumulator")]
public float YellAccumulator = 30f;

/// <summary>
/// YellTimer before the SM is about the delam
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("yellDelam")]
public float YellDelam = 5f;

/// <summary>
/// Timer for Damage
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("damageupdateAccumulator")]
public float DamageUpdateAccumulator;

/// <summary>
/// update environment damage every 1 second
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("damageupdateTimer")]
public float DamageUpdateTimer = 1f;

/// <summary>
/// Timer for delam
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("delamtimerAccumulator")]
public float DelamTimerAccumulator;

/// <summary>
/// updates delam
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("delamtimerTimer")]
public int DelamTimerTimer = 30;

/// <summary>
/// The message timer
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("speakaccumulator")]
public float SpeakAccumulator = 5f;

/// <summary>
/// Atmos update timer
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("atmosupdateAccumulator")]
public float AtmosUpdateAccumulator;

/// <summary>
/// update atmos every 1 second
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("atmosupdateTimer")]
public float AtmosUpdateTimer = 1f;
Copy link
Member

@Pspritechologist Pspritechologist May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Don't use the word 'timer' to refer to a variable amount of time to be set, it's unclear.
  • These should all be Timestamps.
  • Should use Timestamps instead of accumulators.
  • None of these account for the game being paused, but Timestamps can auto-calculate that anyway.
  • A huge number of these shouldn't be datafields.
  • Docs shouldn't reference hardcoded values.


#endregion SM Timer

#region SM Threshold

/// <summary>
/// Higher == Higher percentage of inhibitor gas needed
/// before the charge inertia chain reaction effect starts.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("powerlossinhibitiongasThreshold")]
public float PowerlossInhibitionGasThreshold = 0.20f;

/// <summary>
/// Higher == More moles of the gas are needed before the charge
/// inertia chain reaction effect starts.
/// Scales powerloss inhibition down until this amount of moles is reached
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("powerlossinhibitionmoleThreshold")]
public float PowerlossInhibitionMoleThreshold = 20f;

/// <summary>
/// bonus powerloss inhibition boost if this amount of moles is reached
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("powerlossinhibitionmoleboostThreshold")]
public float PowerlossInhibitionMoleBoostThreshold = 500f;

/// <summary>
/// Above this value we can get lord singulo and independent mol damage,
/// below it we can heal damage
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("molepenaltyThreshold")]
public float MolePenaltyThreshold = 1800f;

/// <summary>
/// more moles of gases are harder to heat than fewer,
/// so let's scale heat damage around them
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("moleheatpenaltyThreshold")]
public float MoleHeatPenaltyThreshold;

/// <summary>
/// The cutoff on power properly doing damage, pulling shit around,
/// and delamming into a tesla. Low chance of pyro anomalies, +2 bolts of electricity
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("powerPenaltyThreshold")]
public float PowerPenaltyThreshold = 5000f;

/// <summary>
/// Higher == Crystal safe operational temperature is higher.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("heatpenaltyThreshold")]
public float HeatPenaltyThreshold = 40f;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// The damage we had before this cycle. Used to limit the damage we can take each cycle, and for safe alert
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("damagearchived")]
public float DamageArchived = 0f;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// is multiplied by ExplosionPoint to cap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is referencing a Field it should do so with a cref

/// evironmental damage per cycle
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("damageHardcap")]
public float DamageHardcap = 0.002f;

/// <summary>
/// environmental damage is scaled by this
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("damageincreaseMultiplier")]
public float DamageIncreaseMultiplier = 0.25f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a multiplier is doing something objective (such as scaling incoming damage), defaulting to non-1 values is fine. What I said is more to do with internal arbitrary numbers that don't translate directly to something real, there's no reason for those to be user facing.


/// <summary>
/// if spaced sm wont take more than 2 damage per cycle
/// </summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded value.
Also this comment is unclear, I'm not sure if it's capping damage or causing it.

[ViewVariables(VVAccess.ReadOnly)]
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
[DataField("maxspaceexposureDamage")]
public float MaxSpaceExposureDamage = 2;

#endregion SM Threshold

#region SM Delamm

/// <summary>
/// The point at which we delamm
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("explosionPoint")]
public int ExplosionPoint = 900;

//Are we delamming?
[ViewVariables(VVAccess.ReadOnly)] public bool Delamming = false;

//it's the final countdown
[ViewVariables(VVAccess.ReadOnly)] public bool FinalCountdown = false;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

//Explosion totalIntensity value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("totalIntensity")]
public float TotalIntensity= 500000f;

//Explosion radius value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("radius")]
public float Radius = 500f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Are we delamming?
[ViewVariables(VVAccess.ReadOnly)] public bool Delamming = false;
//it's the final countdown
[ViewVariables(VVAccess.ReadOnly)] public bool FinalCountdown = false;
//Explosion totalIntensity value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("totalIntensity")]
public float TotalIntensity= 500000f;
//Explosion radius value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("radius")]
public float Radius = 500f;
// Are we delamming?
[ViewVariables(VVAccess.ReadOnly)] public bool Delamming = false;
// It's the final countdown
[ViewVariables(VVAccess.ReadOnly)] public bool FinalCountdown = false;
// Explosion totalIntensity value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("totalIntensity")]
public float TotalIntensity= 500000f;
// Explosion radius value
[ViewVariables(VVAccess.ReadOnly)]
[DataField("radius")]
public float Radius = 500f;

These should all be proper docs


/// <summary>
/// These would be what you would get at point blank, decreases with distance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// These would be what you would get at point blank, decreases with distance
/// This is what you would get at point blank, decreases with distance

/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("detonationRads")]
public float DetonationRads = 200f;

#endregion SM Delamm

#region SM Gas
/// <summary>
/// Is used to store gas
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("gasStorage")]
public Dictionary<Gas, float> GasStorage = new Dictionary<Gas, float>()
{
{Gas.Oxygen, 0f},
{Gas.Nitrogen, 0f},
{Gas.CarbonDioxide, 0f},
{Gas.Plasma, 0f},
{Gas.Tritium, 0f},
{Gas.WaterVapor, 0f}
};

/// <summary>
/// Stores each gases calculation
/// </summary>
public readonly Dictionary<Gas, (float TransmitModifier, float HeatPenalty, float PowerMixRatio)> GasDataFields = new()
{
[Gas.Oxygen] = (TransmitModifier: 1.5f, HeatPenalty: 1f, PowerMixRatio: 1f),
[Gas.Nitrogen] = (TransmitModifier: 0f, HeatPenalty: -1.5f, PowerMixRatio: -1f),
[Gas.CarbonDioxide] = (TransmitModifier: 0f, HeatPenalty: 0.1f, PowerMixRatio: 1f),
[Gas.Plasma] = (TransmitModifier: 4f, HeatPenalty: 15f, PowerMixRatio: 1f),
[Gas.Tritium] = (TransmitModifier: 30f, HeatPenalty: 10f, PowerMixRatio: 1f),
[Gas.WaterVapor] = (TransmitModifier: 2f, HeatPenalty: 12f, PowerMixRatio: 1f)
};

#endregion SM Gas
}
Loading
Loading