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

Новые предметы, фикс супер материи, правки #515

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
private string GetIdCardName(EntityUid senderUid)
{
var idCardTitle = Loc.GetString("chat-radio-no-id");
idCardTitle = GetIdCard(senderUid)?.JobTitle ?? idCardTitle;
idCardTitle = GetIdCard(senderUid)?.LocalizedJobTitle ?? idCardTitle;

var textInfo = CultureInfo.CurrentCulture.TextInfo;
idCardTitle = textInfo.ToTitleCase(idCardTitle);
Expand Down
75 changes: 44 additions & 31 deletions Content.Server/Supermatter/Components/SupermatterComponent.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
using Content.Shared.Atmos;
using Content.Shared.Atmos;
using Robust.Shared.Audio;

namespace Content.Server.Supermatter.Components;

[RegisterComponent]
public sealed partial class SupermatterComponent : Component
{
/// <summary>
/// The damage taken from direct hits, e.g. laser weapons
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public float AVExternalDamage = 0f;

//
[ViewVariables(VVAccess.ReadOnly)]
public float HeatAccumulatorRate = 0.5f;

[ViewVariables(VVAccess.ReadOnly)]
public float AVHeatAccumulator = 0f;

[ViewVariables(VVAccess.ReadOnly)]
public float RadiationAccumulatorRate = 0.3f;

[ViewVariables(VVAccess.ReadOnly)]
public float AVRadiationAccumulator = 0f;

[ViewVariables(VVAccess.ReadOnly)]
public float LightingAccumulatorThreshold = 2f;

[ViewVariables(VVAccess.ReadOnly)]
public float LightingAccumulatorRate = 0.1f;

[ViewVariables(VVAccess.ReadOnly)]
public float AVLightingAccumulator = 0f;

[ViewVariables(VVAccess.ReadOnly)]
public float InternalEnergyAccumulatorRate = 0.1f;
/// <summary>
/// Lightning prototype IDs that the supermatter should spit out.
/// </summary>
Expand Down Expand Up @@ -64,8 +94,6 @@ public sealed partial class SupermatterComponent : Component

public float UpdateTimerAccumulator = 0f;

public float ZapTimerAccumulator = 0f;

public float AnnouncementTimerAccumulator = 0f;

/// <summary>
Expand All @@ -74,12 +102,6 @@ public sealed partial class SupermatterComponent : Component
[DataField("updateTimer")]
public float UpdateTimer = 1f;

/// <summary>
/// Amount of seconds to pass before SM does it's zap.
/// </summary>
[DataField("zapTimer")]
public float ZapTimer = 10f;

/// <summary>
/// Amount of seconds to pass before makes an announcement.
/// </summary>
Expand Down Expand Up @@ -123,12 +145,6 @@ public sealed partial class SupermatterComponent : Component
/// </summary>
public float DamageArchive = 0f;

/// <summary>
/// The damage taken from direct hits, e.g. laser weapons
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public float ExternalDamage = 0f;

/// <summary>
/// The temperature at which the supermatter crystal will begin to take damage.
/// </summary>
Expand Down Expand Up @@ -168,11 +184,8 @@ public sealed partial class SupermatterComponent : Component
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public float GasPowerlossInhibition = 0f;
/// <summary>
/// Affects the amount of power the main SM zap makes.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public float PowerTransmissionRate = 0f;
public float ThermalСonductivity = 0f;
/// <summary>
/// Affects the power gain the SM experiences from heat.
/// </summary>
Expand All @@ -199,15 +212,15 @@ public sealed partial class SupermatterComponent : Component
[ViewVariables(VVAccess.ReadOnly)]
public GasFact[] GasFacts =
{
new (transmissionRate: .15f, heatPowerGeneration: 1f), // o2
new (heatModifier: -2.5f, heatPowerGeneration: -1), // n2
new (heatModifier: 1f, heatPowerGeneration: 1f, powerlossInhibition: 1f), // co2
new (transmissionRate: .4f, heatModifier: 14f, heatPowerGeneration: 1f), // plasma
new (transmissionRate: 3f, heatModifier: 9f, heatPowerGeneration: 1f), // tritium
new (transmissionRate: -.25f, heatModifier: 11f, heatPowerGeneration: 1f), // vapor
new (heatPowerGeneration: .5f), // ommonium
new (heatResistance: 5f), // n2o
new (transmissionRate: -3f, heatModifier: 9f, heatResistance: 1f, heatPowerGeneration: 1f), // frezon
new (thermalConductivity: 2.4f, heatPowerGeneration: 1f), // o2
new (thermalConductivity: 2.0f, heatModifier: -2.5f, heatPowerGeneration: -1), // n2
new (thermalConductivity: 1.2f, heatModifier: 1f, heatPowerGeneration: 1f, powerlossInhibition: 1f), // co2
new (thermalConductivity: 6.0f, heatModifier: 14f, heatPowerGeneration: 1f), // plasma
new (thermalConductivity: 3.0f, heatModifier: 9f, heatPowerGeneration: 1f), // tritium
new (thermalConductivity: 1.4f, heatModifier: 11f, heatPowerGeneration: 1f), // vapor
new (thermalConductivity: 1.6f, heatPowerGeneration: .5f), // ommonium
new (thermalConductivity: 1.3f, heatResistance: 5f), // n2o
new (thermalConductivity: 9.9f, heatModifier: 9f, heatResistance: 1f, heatPowerGeneration: 1f), // frezon
};
}

Expand All @@ -222,7 +235,7 @@ public sealed partial class GasFact
/// Affects the amount of power the main SM zap makes.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float PowerTransmissionRate;
public float ThermalСonductivity;
/// <summary>
/// Affects the heat SM makes.
/// </summary>
Expand All @@ -244,9 +257,9 @@ public sealed partial class GasFact
[ViewVariables(VVAccess.ReadWrite)]
public float PowerlossInhibition;

public GasFact(float? transmissionRate = null, float? heatModifier = null, float? heatResistance = null, float? heatPowerGeneration = null, float? powerlossInhibition = null)
public GasFact(float? thermalConductivity = null, float? heatModifier = null, float? heatResistance = null, float? heatPowerGeneration = null, float? powerlossInhibition = null)
{
PowerTransmissionRate = transmissionRate ?? 1;
ThermalСonductivity = thermalConductivity ?? 1;
HeatModifier = heatModifier ?? 1;
HeatResistance = heatResistance ?? 0;
HeatPowerGeneration = heatPowerGeneration ?? 0;
Expand Down
83 changes: 46 additions & 37 deletions Content.Server/Supermatter/EntitySystems/SupermatterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Supermatter.Components;
using Content.Shared.Atmos;
using Content.Server.Lightning;
Expand Down Expand Up @@ -26,6 +26,8 @@
using Content.Server.DoAfter;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Kitchen.Components;
using Content.Shared.Singularity.Components;
using System;

namespace Content.Server.Supermatter.EntitySystems;

Expand All @@ -39,6 +41,7 @@ public sealed class SupermatterSystem : EntitySystem
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly AmbientSoundSystem _ambience = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly AnomalySystem _anomaly = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
Expand Down Expand Up @@ -81,17 +84,10 @@ public override void Update(float frameTime)

public void Cycle(EntityUid uid, SupermatterComponent sm)
{
sm.ZapTimerAccumulator++;
sm.AnnouncementTimerAccumulator++;

ProcessAtmos(uid, sm);

if (sm.ZapTimerAccumulator >= sm.ZapTimer)
{
sm.ZapTimerAccumulator = 0f;
ProcessPower(uid, sm);
}

ProcessPower(uid, sm);
ProcessDamage(uid, sm);

// due to how damage calculation works, it will do the announcement only if sm is consistently taking damage
Expand All @@ -104,7 +100,7 @@ public void Cycle(EntityUid uid, SupermatterComponent sm)
if (sm.Damage > sm.DamageEmergencyPoint)
loc = "critical";

SupermatterAlert(uid, Loc.GetString($"supermatter-announcement-{loc}", ("integrity", Math.Round(sm.DelaminationPoint - sm.Damage, 1))));
SupermatterAlert(uid, Loc.GetString($"supermatter-announcement-{loc}", ("integrity", (int)(sm.DelaminationPoint - sm.Damage))));
}
}

Expand All @@ -127,7 +123,7 @@ private void ProcessAtmos(EntityUid uid, SupermatterComponent sm)
// calculate gases
var gasPercentages = new float[Enum.GetValues(typeof(Gas)).Length];

var powerTransmissionRate = 0f;
var thermalСonductivity = 0f;
var heatModifier = 0f;
var heatResistance = 0f;
var heatPowerGeneration = 0f;
Expand All @@ -148,7 +144,7 @@ private void ProcessAtmos(EntityUid uid, SupermatterComponent sm)
gasPercentages[i] = moleCount / moles;
var smGas = sm.GasFacts[i];

powerTransmissionRate += smGas.PowerTransmissionRate * gasPercentages[i];
thermalСonductivity += smGas.ThermalСonductivity * gasPercentages[i];
heatModifier += smGas.HeatModifier * gasPercentages[i];
heatResistance += smGas.HeatResistance * gasPercentages[i];
heatPowerGeneration += smGas.HeatPowerGeneration * gasPercentages[i];
Expand All @@ -159,7 +155,7 @@ private void ProcessAtmos(EntityUid uid, SupermatterComponent sm)
powerlossInhibition = Math.Clamp(powerlossInhibition, 0, 1);

sm.AbsorbedGasMix = absorbedMix;
sm.PowerTransmissionRate = powerTransmissionRate;
sm.ThermalСonductivity = thermalСonductivity;
sm.GasHeatModifier = heatModifier;
sm.GasHeatResistance = heatResistance;
sm.HeatPowerGeneration = heatPowerGeneration;
Expand All @@ -172,17 +168,32 @@ private void ProcessPower(EntityUid uid, SupermatterComponent sm)
{
var powerHeat = sm.HeatPowerGeneration * sm.AbsorbedGasMix.Temperature * SupermatterComponent.GasHeatPowerScaling;
var powerloss = -1 * sm.GasPowerlossInhibition;
var atmosStrength = Math.Clamp((powerHeat + powerloss) * sm.PowerTransmissionRate, 0, 2);
var atmosStrength = Math.Clamp((powerHeat + powerloss) * 0.2f, 0, 2);

var damageStrength = Math.Clamp(sm.Damage / sm.DelaminationPoint, 0, 1);
var strength = Math.Clamp(atmosStrength + damageStrength, 0, 4);
var damageExternal = sm.AVExternalDamage + strength;
sm.AVExternalDamage = 0f;

sm.InternalEnergy = strength;
var lightningProto = sm.LightningPrototypeIDs[(int) Math.Clamp(strength, 0, 3)];
sm.AVHeatAccumulator = Math.Clamp(sm.AVHeatAccumulator + (damageExternal * sm.HeatAccumulatorRate), 0, 10);
sm.AVRadiationAccumulator = Math.Clamp(sm.AVRadiationAccumulator + (damageExternal * sm.RadiationAccumulatorRate), 0, 10);
sm.AVLightingAccumulator = Math.Clamp(sm.AVLightingAccumulator + (damageExternal * sm.LightingAccumulatorRate), 0, 10);
sm.InternalEnergy = Math.Clamp(sm.InternalEnergy + (damageExternal * sm.InternalEnergyAccumulatorRate), 0, 10);

_sound.PlayPvs(SupermatterComponent.SupermatterZapSound, uid);
_lightning.ShootRandomLightnings(uid, 3, (int) strength < 1 ? 1 : (int) strength, lightningProto);
Comp<RadiationSourceComponent>(uid).Intensity = 1 + strength;
if (sm.AVLightingAccumulator > sm.LightingAccumulatorThreshold)
{
var lightningProto = sm.LightningPrototypeIDs[(int)Math.Clamp(sm.AVLightingAccumulator, 0, 3)];
_lightning.ShootRandomLightnings(uid, 3, (int)sm.AVLightingAccumulator, lightningProto);
sm.AVLightingAccumulator = 0;
}

Comp<RadiationSourceComponent>(uid).Intensity = 1 + sm.AVRadiationAccumulator;
sm.AVRadiationAccumulator /= 2;
sm.InternalEnergy /= 2;

var mix = _atmos.GetContainingMixture((uid, Transform(uid)), true, true) ?? new();
mix.Temperature += sm.AVHeatAccumulator * 4;
sm.AVHeatAccumulator /= sm.ThermalСonductivity;
}
/// <summary>
/// React to damage dealt by all doodads.
Expand All @@ -196,19 +207,16 @@ private void ProcessDamage(EntityUid uid, SupermatterComponent sm)

sm.TempLimit = Math.Max(tempLimitBase + tempLimitGas + tempLimitMoles, Atmospherics.TCMB);

var damageExternal = sm.ExternalDamage * Math.Clamp((sm.DamageEmergencyPoint - sm.Damage) / sm.DamageEmergencyPoint, 0, 1);
sm.ExternalDamage = 0f;

var damageHeat = Math.Clamp((sm.AbsorbedGasMix.Temperature - sm.TempLimit) / 24000, 0, .15f);
var damagePower = Math.Clamp((sm.InternalEnergy - SupermatterComponent.PowerPenaltyThreshold) / 40000, 0, .1f);
var damagePower = Math.Clamp((sm.InternalEnergy - SupermatterComponent.PowerPenaltyThreshold), 0, .1f);
var damageMoles = Math.Clamp((sm.AbsorbedGasMix.TotalMoles - SupermatterComponent.MolePenaltyThreshold) / 3200, 0, .1f);

var damageHealHeat = 0f;

if (sm.AbsorbedGasMix.TotalMoles > 0)
damageHealHeat = Math.Clamp((sm.AbsorbedGasMix.TotalMoles - sm.TempLimit) / 6000, -.1f, 0);

var totalDamage = damageExternal + damageHeat + damagePower + damageMoles + damageHealHeat;
var totalDamage = damageHeat + damagePower + damageMoles + damageHealHeat;

sm.Damage += Math.Max(totalDamage, 0);

Expand All @@ -235,7 +243,7 @@ private void ProcessWaste(EntityUid uid, SupermatterComponent sm)
mergeMix.Temperature = Math.Clamp(mergeMix.Temperature, Atmospherics.TCMB, 2500 * sm.WasteMultiplier);

mergeMix.AdjustMoles(Gas.Plasma, Math.Max(.65f * sm.InternalEnergy * sm.WasteMultiplier * SupermatterComponent.PlasmaReleaseModifier, 0));
mergeMix.AdjustMoles(Gas.Oxygen, Math.Max((.65f + mergeMix.Temperature * sm.WasteMultiplier - Atmospherics.T0C) * SupermatterComponent.OxygenReleaseModifier, 0));
mergeMix.AdjustMoles(Gas.Oxygen, Math.Max(.65f * sm.InternalEnergy * sm.WasteMultiplier * SupermatterComponent.OxygenReleaseModifier, 0));

_atmos.Merge(mix, mergeMix);
}
Expand Down Expand Up @@ -282,7 +290,7 @@ private void GenerateAnomaly(EntityUid uid, float amount = 1)

for (var i = 0; i < amount; i++)
{
_anomaly.SpawnOnRandomGridLocation((EntityUid) grid, "RandomAnomalySpawner");
_anomaly.SpawnOnRandomGridLocation((EntityUid)grid, "RandomAnomalySpawner");
_adminLogger.Add(LogType.Anomaly, LogImpact.Medium, $"An anomaly has been spawned by the supermatter crystal.");
}
}
Expand All @@ -295,21 +303,27 @@ private void Vaporize(EntityUid uid, EntityUid smUid)
if (EntityManager.IsQueuedForDeletion(uid))
return;

if (_tagSystem.HasTag(uid, "EmitterBolt")
|| HasComp<SingularityComponent>(uid))
return;

if (TryComp<SupermatterComponent>(smUid, out var sm))
sm.AVExternalDamage += 1f;

_sound.PlayPvs(SupermatterComponent.VaporizeSound, smUid);
EntityManager.QueueDeleteEntity(uid);

// getting discombobulated by the SM is the same as permanent round removal so why not log that
_adminLogger.Add(LogType.Action, LogImpact.High, $"{EntityManager.ToPrettyString(uid):player} has been vaporized by the supermatter.");
}


/// <summary>
/// Handle supermatter delamination and the end of the station.
/// </summary>
private void Delaminate(EntityUid uid, SupermatterComponent sm)
{
sm.PreferredDelamType = sm.PreferredDelamType ?? (int) ChooseDelam(sm);
Delaminate(uid, sm, (DelamType) sm.PreferredDelamType);
sm.PreferredDelamType = sm.PreferredDelamType ?? (int)ChooseDelam(sm);
Delaminate(uid, sm, (DelamType)sm.PreferredDelamType);
}

/// <summary>
Expand Down Expand Up @@ -413,8 +427,6 @@ private void DelamCountdown(EntityUid uid, SupermatterComponent sm)
sm.DelamCountdownAccumulator++;
}



private void OnCollide(EntityUid uid, SupermatterComponent sm, StartCollideEvent args)
{
if (!sm.Activated)
Expand Down Expand Up @@ -446,7 +458,7 @@ private void OnClick(EntityUid uid, SupermatterComponent sm, InteractUsingEvent
private void OnGetSliver(EntityUid uid, SupermatterComponent sm, SupermatterDoAfterEvent args)
{
sm.Damage += 10; // your criminal actions will not go unnoticed
SupermatterAlert(uid, Loc.GetString("supermatter-announcement-tamper", ("integrity", (int) (100 - sm.Damage))));
SupermatterAlert(uid, Loc.GetString("supermatter-announcement-tamper", ("integrity", (int)(100 - sm.Damage))));

Spawn(sm.SliverPrototype, _transform.GetMapCoordinates(args.User));
_popup.PopupClient(Loc.GetString("supermatter-tamper-end"), args.User);
Expand All @@ -457,17 +469,14 @@ private void OnGetHit(EntityUid uid, SupermatterComponent sm, DamageChangedEvent
if (!sm.Activated)
sm.Activated = true;

sm.ExternalDamage += args.DamageDelta?.GetTotal().Value / 1000 ?? 0;

Cycle(uid, sm);
ProcessPower(uid, sm);
sm.AVExternalDamage += args.DamageDelta?.GetTotal().Value / 100 ?? 0;
}

private void OnExamine(EntityUid uid, SupermatterComponent sm, ExaminedEvent args)
{
if (args.IsInDetailsRange) // get all close to it
{
args.PushMarkup(Loc.GetString("supermatter-examine-integrity", ("integrity", (int) (100 - sm.Damage))));
args.PushMarkup(Loc.GetString("supermatter-examine-integrity", ("integrity", (int)(100 - sm.Damage))));
}
}
}
20 changes: 10 additions & 10 deletions Content.Shared/Actions/ActionContainerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@ public bool AddAction(EntityUid uid, EntityUid actionId, BaseActionComponent? ac
DebugTools.AssertOwner(uid, comp);
comp ??= EnsureComp<ActionsContainerComponent>(uid);

///if (!TryComp<MetaDataComponent>(actionId, out var actionData))
/// return false;
///if (!TryPrototype(actionId, out var actionProto, actionData))
/// return false;

///if (HasAction(uid, actionProto.ID))
///{
/// Log.Debug($"Tried to insert action {ToPrettyString(actionId)} into {ToPrettyString(uid)}. Failed due to duplicate actions.");
/// return false;
///}
if (!TryComp<MetaDataComponent>(actionId, out var actionData))
return false;
if (!TryPrototype(actionId, out var actionProto, actionData))
return false;

if (HasAction(uid, actionProto.ID, comp))
{
Log.Debug($"Tried to insert action {ToPrettyString(actionId)} into {ToPrettyString(uid)}. Failed due to duplicate actions.");
return false;
}

if (!_container.Insert(actionId, comp.Container))
{
Expand Down
Loading
Loading