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

further supermatter adjustments #1359

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ public void UpdateEntry(SupermatterConsoleEntry entry, bool isFocus, Supermatter
// TODO: please don't define this dictionary every update you animal
var engineDictionary = new Dictionary<string, (Label label, ProgressBar bar, PanelContainer border, float value, float leftSize, float rightSize, Color leftColor, Color middleColor, Color rightColor)>()
{
{ "integrity", (IntegrityBarLabel, IntegrityBar, IntegrityBarBorder, focusData.Value.Integrity, 0.9f, 0.1f, red, orange, green) },
{ "power", (PowerBarLabel, PowerBar, PowerBarBorder, focusData.Value.Power, 0.9f, 0.1f, green, orange, red ) },
{ "radiation", (RadiationBarLabel, RadiationBar, RadiationBarBorder, focusData.Value.Radiation, 0.1f, 0.9f, green, orange, red ) },
{ "moles", (MolesBarLabel, MolesBar, MolesBarBorder, focusData.Value.AbsorbedMoles, 0.5f, 0.5f, green, orange, red ) },
{ "temperature", (TemperatureBarLabel, TemperatureBar, TemperatureBarBorder, focusData.Value.Temperature, 0.5f, 0.5f, turqoise, green, red ) },
{ "waste", (WasteBarLabel, WasteBar, WasteBarBorder, focusData.Value.WasteMultiplier, 0.5f, 0.5f, green, orange, red ) }
{ "integrity", (IntegrityBarLabel, IntegrityBar, IntegrityBarBorder, focusData.Value.Integrity, 0.9f, 0.1f, red, orange, green) },
{ "power", (PowerBarLabel, PowerBar, PowerBarBorder, focusData.Value.Power, 0.9f, 0.1f, green, orange, red ) },
{ "radiation", (RadiationBarLabel, RadiationBar, RadiationBarBorder, focusData.Value.Radiation, 0.1f, 0.9f, green, orange, red ) },
{ "moles", (MolesBarLabel, MolesBar, MolesBarBorder, focusData.Value.GasStorage.TotalMoles, 0.5f, 0.5f, green, orange, red ) },
{ "temperature", (TemperatureBarLabel, TemperatureBar, TemperatureBarBorder, focusData.Value.GasStorage.Temperature, 0.9f, 0.1f, turqoise, orange, red ) },
{ "waste", (WasteBarLabel, WasteBar, WasteBarBorder, focusData.Value.HeatModifier, 0.5f, 0.5f, green, orange, red ) }
};

// Special cases
Expand Down Expand Up @@ -142,7 +142,7 @@ public void UpdateEntry(SupermatterConsoleEntry entry, bool isFocus, Supermatter
{
var name = gas.Name;
var color = Color.FromHex("#" + gas.Color);
var value = GetStoredGas(gas, focusData) / focusData.Value.AbsorbedMoles * 100;
var value = GetStoredGas(gas, focusData) / focusData.Value.GasStorage.TotalMoles * 100;

UpdateGasBar(index, GasTable, name, color, value);
index++;
Expand All @@ -151,7 +151,7 @@ public void UpdateEntry(SupermatterConsoleEntry entry, bool isFocus, Supermatter
}
}

private string GetStatusLabel(SupermatterStatusType status)
private static string GetStatusLabel(SupermatterStatusType status)
{
switch (status)
{
Expand Down Expand Up @@ -180,7 +180,7 @@ private string GetStatusLabel(SupermatterStatusType status)
return "supermatter-console-window-error-status";
}

private Color GetStatusColor(SupermatterStatusType status)
private static Color GetStatusColor(SupermatterStatusType status)
{
switch (status)
{
Expand All @@ -203,17 +203,17 @@ private Color GetStatusColor(SupermatterStatusType status)
return StyleNano.DisabledFore;
}

private float GetStoredGas(GasPrototype gas, SupermatterFocusData? focusData)
private static float GetStoredGas(GasPrototype gas, SupermatterFocusData? focusData)
{
var id = int.Parse(gas.ID);

if (focusData == null)
return 0;
return 0f;

return focusData.Value.GasStorage[(Gas)id];
return focusData.Value.GasStorage.GetMoles((Gas)id);
}

private void UpdateEngineBar(ProgressBar bar, PanelContainer border, float value, float leftSize, float rightSize, Color leftColor, Color middleColor, Color rightColor)
private static void UpdateEngineBar(ProgressBar bar, PanelContainer border, float value, float leftSize, float rightSize, Color leftColor, Color middleColor, Color rightColor)
{
var clamped = Math.Clamp(value, bar.MinValue, bar.MaxValue);

Expand Down Expand Up @@ -256,7 +256,7 @@ private void UpdateEngineBar(ProgressBar bar, PanelContainer border, float value
bar.Value = clamped;
}

private void UpdateGasBar(int index, Control table, string name, Color color, float value)
private static void UpdateGasBar(int index, Control table, string name, Color color, float value)
{
// Make new UI entry if required
if (index >= table.ChildCount)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Beam/BeamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void CreateBeam(string prototype,
manager: manager,
body: physics);

_physics.SetBodyType(ent, BodyType.Dynamic, manager: manager, body: physics);
_physics.SetBodyType(ent, BodyType.KinematicController, manager: manager, body: physics);
_physics.SetCanCollide(ent, true, manager: manager, body: physics);
_broadphase.RegenerateContacts(ent, physics, manager);

Expand Down
60 changes: 39 additions & 21 deletions Content.Server/Singularity/EntitySystems/GravityWellSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,18 @@ private bool CanGravPulseAffect(EntityUid entity)
/// <param name="uid">The entity at the epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="baseMatrixDV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
/// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
/// <param name="xform">(optional) The transform of the entity at the epicenter of the gravitational pulse.</param>
public void GravPulse(EntityUid uid, float maxRange, float minRange, in Matrix3x2 baseMatrixDV, TransformComponent? xform = null)
public void GravPulse(EntityUid uid, float maxRange, float minRange, in Matrix3x2 baseMatrixDeltaV, TransformComponent? xform = null)
{
if (Resolve(uid, ref xform))
GravPulse(xform.Coordinates, maxRange, minRange, in baseMatrixDV);
{
GravPulse(xform.Coordinates, maxRange, minRange, in baseMatrixDeltaV);

// imp edit
var ev = new GravPulseEvent();
RaiseLocalEvent(uid, ref ev);
}
}

/// <summary>
Expand All @@ -153,13 +159,19 @@ public void GravPulse(EntityUid uid, float maxRange, float minRange, in Matrix3x
/// <param name="uid">The entity at the epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="baseRadialDV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
/// <param name="baseTangentialDV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
/// <param name="baseRadialDeltaV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
/// <param name="baseTangentialDeltaV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
/// <param name="xform">(optional) The transform of the entity at the epicenter of the gravitational pulse.</param>
public void GravPulse(EntityUid uid, float maxRange, float minRange, float baseRadialDV = 0.0f, float baseTangentialDV = 0.0f, TransformComponent? xform = null)
public void GravPulse(EntityUid uid, float maxRange, float minRange, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f, TransformComponent? xform = null)
{
if (Resolve(uid, ref xform))
GravPulse(xform.Coordinates, maxRange, minRange, baseRadialDV, baseTangentialDV);
{
GravPulse(xform.Coordinates, maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV);

// imp edit
var ev = new GravPulseEvent();
RaiseLocalEvent(uid, ref ev);
}
}

/// <summary>
Expand All @@ -168,29 +180,29 @@ public void GravPulse(EntityUid uid, float maxRange, float minRange, float baseR
/// <param name="entityPos">The epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="baseMatrixDV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, in Matrix3x2 baseMatrixDV)
=> GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, in baseMatrixDV);
/// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, in Matrix3x2 baseMatrixDeltaV)
=> GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, in baseMatrixDeltaV);

/// <summary>
/// Greates a gravitational pulse, shoving around all entities within some distance of an epicenter.
/// </summary>
/// <param name="entityPos">The epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="baseRadialDV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
/// <param name="baseTangentialDV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, float baseRadialDV = 0.0f, float baseTangentialDV = 0.0f)
=> GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, baseRadialDV, baseTangentialDV);
/// <param name="baseRadialDeltaV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
/// <param name="baseTangentialDeltaV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f)
=> GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV);

/// <summary>
/// Causes a gravitational pulse, shoving around all entities within some distance of an epicenter.
/// </summary>
/// <param name="mapPos">The epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse. Exists to prevent div/0 errors.</param>
/// <param name="baseMatrixDV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange, in Matrix3x2 baseMatrixDV)
/// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange, in Matrix3x2 baseMatrixDeltaV)
{
if (mapPos == MapCoordinates.Nullspace)
return; // No gravpulses in nullspace please.
Expand Down Expand Up @@ -220,7 +232,7 @@ public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange, in
continue;

var scaling = (1f / distance2) * physics.Mass; // TODO: Variable falloff gradiants.
_physics.ApplyLinearImpulse(entity, Vector2.TransformNormal(displacement, baseMatrixDV) * scaling, body: physics);
_physics.ApplyLinearImpulse(entity, Vector2.TransformNormal(displacement, baseMatrixDeltaV) * scaling, body: physics);
}
}

Expand All @@ -230,10 +242,10 @@ public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange, in
/// <param name="mapPos">The epicenter of the gravity pulse.</param>
/// <param name="maxRange">The maximum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse. Exists to prevent div/0 errors.</param>
/// <param name="baseRadialDV">The base amount of velocity that will be added to entities in range towards the epicenter of the pulse.</param>
/// <param name="baseTangentialDV">The base amount of velocity that will be added to entities in range counterclockwise relative to the epicenter of the pulse.</param>
public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange = 0.0f, float baseRadialDV = 0.0f, float baseTangentialDV = 0.0f)
=> GravPulse(mapPos, maxRange, minRange, new Matrix3x2(baseRadialDV, -baseTangentialDV, baseTangentialDV, baseRadialDV, 0.0f, 0.0f));
/// <param name="baseRadialDeltaV">The base amount of velocity that will be added to entities in range towards the epicenter of the pulse.</param>
/// <param name="baseTangentialDeltaV">The base amount of velocity that will be added to entities in range counterclockwise relative to the epicenter of the pulse.</param>
public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange = 0.0f, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f)
=> GravPulse(mapPos, maxRange, minRange, new Matrix3x2(baseRadialDeltaV, -baseTangentialDeltaV, baseTangentialDeltaV, baseRadialDeltaV, 0.0f, 0.0f));

#endregion GravPulse

Expand Down Expand Up @@ -280,3 +292,9 @@ public void OnGravityWellStartup(EntityUid uid, GravityWellComponent comp, Compo

#endregion Event Handlers
}

/// <summary>
/// Raised after each gravity pulse, imp edit
/// </summary>
[ByRefEvent]
public readonly record struct GravPulseEvent();
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;

namespace Content.Server._EinsteinEngines.ParacusiaProximity;

[RegisterComponent]
public sealed partial class ParacusiaProximityComponent : Component
{
// Most of this is matched to the values in ParacusiaComponent

/// <summary>
/// The range at which paracusia is attempted to be given to mobs.
/// </summary>
[DataField("range")]
public float Range;

/// <summary>
/// The maximum time between incidents in seconds.
/// </summary>
[DataField("maxTimeBetweenIncidents", required: true)]
public float MaxTimeBetweenIncidents = 60f;

/// <summary>
/// The minimum time between incidents in seconds.
/// </summary>
[DataField("minTimeBetweenIncidents", required: true)]
public float MinTimeBetweenIncidents = 30f;

/// <summary>
/// How far away at most can the sound be?
/// </summary>
[DataField("maxSoundDistance", required: true)]
public float MaxSoundDistance;

/// <summary>
/// The sounds to choose from.
/// </summary>
[DataField("sounds", required: true)]
public SoundSpecifier Sounds = default!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Content.Server.Examine;
using Content.Server.Traits.Assorted;
using Content.Shared._EinsteinEngines.ParacusiaProximity;
using Content.Shared.Mobs.Components;
using Content.Shared.Silicons.Laws.Components;
using Content.Shared.Traits.Assorted;

namespace Content.Server._EinsteinEngines.ParacusiaProximity;

public sealed partial class ParacusiaProximitySystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ParacusiaSystem _paracusia = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly IEntityManager _entity = default!;

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = _entity.EntityQueryEnumerator<ParacusiaProximityComponent>();

while (query.MoveNext(out var uid, out var proximity))
{
var coords = Transform(uid).Coordinates;
var lookup = _lookup.GetEntitiesInRange<MobStateComponent>(coords, proximity.Range);

foreach (var mob in lookup)
{
// Ignore silicons, paracusia proximity immunity, and occluded mobs
if (HasComp<SiliconLawBoundComponent>(mob) ||
HasComp<ParacusiaProximityImmuneComponent>(mob) ||
!_examine.InRangeUnOccluded(uid, mob, proximity.Range))
continue;

if (!EnsureComp<ParacusiaComponent>(mob, out var paracusia))
{
_paracusia.SetSounds(mob, proximity.Sounds, paracusia);
_paracusia.SetTime(mob, proximity.MinTimeBetweenIncidents, proximity.MaxTimeBetweenIncidents, paracusia);
_paracusia.SetDistance(mob, proximity.MaxSoundDistance, paracusia);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ private List<SupermatterConsoleEntry> GetSupermatterStateData(EntityUid gridUid)
if (focusSupermatter == null)
return null;

var focusSupermatterXform = Transform(focusSupermatter.Value);
if (!TryComp(focusSupermatter.Value, out TransformComponent? focusSupermatterXform))
return null;

if (!focusSupermatterXform.Anchored ||
focusSupermatterXform.GridUid != gridUid ||
Expand All @@ -181,20 +182,21 @@ private List<SupermatterConsoleEntry> GetSupermatterStateData(EntityUid gridUid)
if (!TryComp<RadiationSourceComponent>(focusSupermatter.Value, out var radiationComp))
return null;

var gases = sm.GasStorage;
var gases = GasMixture.SpaceGas;
if (sm.GasStorage != null)
gases = sm.GasStorage;

var tempThreshold = Atmospherics.T0C + sm.HeatPenaltyThreshold;

return new SupermatterFocusData(
GetNetEntity(focusSupermatter.Value),
gases,
GetIntegrity(sm),
sm.Power,
radiationComp.Intensity,
gases.Sum(gas => gases[gas.Key]),
sm.Temperature,
tempThreshold * sm.DynamicHeatResistance,
sm.WasteMultiplier,
sm.GasEfficiency * 100,
sm.GasStorage);
sm.HeatModifier,
sm.GasEfficiency * 100);
}

public float GetIntegrity(SupermatterComponent sm)
Expand Down
Loading
Loading