Skip to content

Commit

Permalink
Revert "Implement some field-level deltas (space-wizards#28242)"
Browse files Browse the repository at this point in the history
This reverts commit ea0359e.
  • Loading branch information
sleepyyapril committed Dec 21, 2024
1 parent c1b272a commit db0cd2c
Show file tree
Hide file tree
Showing 129 changed files with 1,942 additions and 2,245 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Server.Body.Components;
using Content.Server.Body.Events;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.EntityEffects.Effects;
using Content.Server.Chemistry.ReactionEffects;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Forensics;
using Content.Server.Popups;
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Body/Systems/MetabolizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Database;
using Content.Shared.EntityEffects;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
Expand Down Expand Up @@ -197,7 +196,8 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
var ev = new TryMetabolizeReagent(reagent, proto, quantity);
RaiseLocalEvent(actualEntity, ref ev);

var args = new EntityEffectReagentArgs(actualEntity, EntityManager, ent, solution, mostToRemove, proto, null, scale);
var args = new ReagentEffectArgs(actualEntity, ent, solution, proto, mostToRemove,
EntityManager, null, scale * ev.Scale, ev.QuantityMultiplier);

// do all effects, if conditions apply
foreach (var effect in entry.Effects)
Expand Down
7 changes: 3 additions & 4 deletions Content.Server/Body/Systems/RespiratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Content.Server.Body.Components;
using Content.Server.Chat.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.EntityEffects.EffectConditions;
using Content.Server.EntityEffects.Effects;
using Content.Server.Chemistry.ReagentEffectConditions;
using Content.Server.Chemistry.ReagentEffects;
using Content.Server.Popups;
using Content.Shared.Alert;
using Content.Shared.Atmos;
Expand All @@ -15,7 +15,6 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.EntityEffects;
using Content.Shared.Mobs.Systems;
using Content.Shared.Mood;
using JetBrains.Annotations;
Expand Down Expand Up @@ -269,7 +268,7 @@ private float GetSaturation(Solution solution, Entity<MetabolizerComponent?> lun
// TODO generalize condition checks
// this is pretty janky, but I just want to bodge a method that checks if an entity can breathe a gas mixture
// Applying actual reaction effects require a full ReagentEffectArgs struct.
bool CanMetabolize(EntityEffect effect)
bool CanMetabolize(ReagentEffect effect)
{
if (effect.Conditions == null)
return true;
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Botany/SeedPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Server.Botany.Components;
using Content.Server.Botany.Systems;
using Content.Shared.Atmos;
using Content.Shared.EntityEffects;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Expand Down Expand Up @@ -80,7 +80,7 @@ public partial struct SeedChemQuantity

// TODO reduce the number of friends to a reasonable level. Requires ECS-ing things like plant holder component.
[Virtual, DataDefinition]
[Access(typeof(BotanySystem), typeof(PlantHolderSystem), typeof(SeedExtractorSystem), typeof(PlantHolderComponent), typeof(EntityEffect), typeof(MutationSystem))]
[Access(typeof(BotanySystem), typeof(PlantHolderSystem), typeof(SeedExtractorSystem), typeof(PlantHolderComponent), typeof(ReagentEffect), typeof(MutationSystem))]
public partial class SeedData
{
#region Tracking
Expand Down
83 changes: 83 additions & 0 deletions Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Audio;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Maps;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Chemistry.ReactionEffects
{
/// <summary>
/// Basically smoke and foam reactions.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public sealed partial class AreaReactionEffect : ReagentEffect
{
/// <summary>
/// How many seconds will the effect stay, counting after fully spreading.
/// </summary>
[DataField("duration")] private float _duration = 10;

/// <summary>
/// How many units of reaction for 1 smoke entity.
/// </summary>
[DataField] public FixedPoint2 OverflowThreshold = FixedPoint2.New(2.5);

/// <summary>
/// The entity prototype that will be spawned as the effect.
/// </summary>
[DataField("prototypeId", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string _prototypeId = default!;

/// <summary>
/// Sound that will get played when this reaction effect occurs.
/// </summary>
[DataField("sound", required: true)] private SoundSpecifier _sound = default!;

public override bool ShouldLog => true;

protected override string ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-missing");

public override LogImpact LogImpact => LogImpact.High;

public override void Effect(ReagentEffectArgs args)
{
if (args.Source == null)
return;

var spreadAmount = (int) Math.Max(0, Math.Ceiling((args.Quantity / OverflowThreshold).Float()));
var splitSolution = args.Source.SplitSolution(args.Source.Volume);
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
var mapManager = IoCManager.Resolve<IMapManager>();
var mapSys = args.EntityManager.System<MapSystem>();
var sys = args.EntityManager.System<TransformSystem>();
var mapCoords = sys.GetMapCoordinates(args.SolutionEntity, xform: transform);

if (!mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) ||
!mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace())
{
return;
}

var coords = mapSys.MapToGrid(gridUid, mapCoords);
var ent = args.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid());

var smoke = args.EntityManager.System<SmokeSystem>();
smoke.StartSmoke(ent, splitSolution, _duration, spreadAmount);

var audio = args.EntityManager.System<SharedAudioSystem>();
audio.PlayPvs(_sound, args.SolutionEntity, AudioHelpers.WithVariation(0.125f));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Content.Shared.EntityEffects;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.EntityEffects.Effects;
namespace Content.Server.Chemistry.ReactionEffects;

[DataDefinition]
public sealed partial class CreateEntityReactionEffect : EntityEffect
public sealed partial class CreateEntityReactionEffect : ReagentEffect
{
/// <summary>
/// What entity to create.
Expand All @@ -25,17 +26,15 @@ public sealed partial class CreateEntityReactionEffect : EntityEffect
("entname", IoCManager.Resolve<IPrototypeManager>().Index<EntityPrototype>(Entity).Name),
("amount", Number));

public override void Effect(EntityEffectBaseArgs args)
public override void Effect(ReagentEffectArgs args)
{
var transform = args.EntityManager.GetComponent<TransformComponent>(args.TargetEntity);
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
var transformSystem = args.EntityManager.System<SharedTransformSystem>();
var quantity = (int)Number;
if (args is EntityEffectReagentArgs reagentArgs)
quantity *= reagentArgs.Quantity.Int();
var quantity = Number * args.Quantity.Int();

for (var i = 0; i < quantity; i++)
{
var uid = args.EntityManager.SpawnEntity(Entity, transformSystem.GetMapCoordinates(args.TargetEntity, xform: transform));
var uid = args.EntityManager.SpawnEntity(Entity, transformSystem.GetMapCoordinates(args.SolutionEntity, xform: transform));
transformSystem.AttachToGridOrMap(uid);

// TODO figure out how to properly spawn inside of containers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using Content.Server.Emp;
using Content.Shared.EntityEffects;
using Content.Shared.Chemistry.Reagent;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.Server.EntityEffects.Effects;
namespace Content.Server.Chemistry.ReactionEffects;


[DataDefinition]
public sealed partial class EmpReactionEffect : EntityEffect
public sealed partial class EmpReactionEffect : ReagentEffect
{
/// <summary>
/// Impulse range per unit of quantity
/// Impulse range per unit of reagent
/// </summary>
[DataField("rangePerUnit")]
public float EmpRangePerUnit = 0.5f;
Expand All @@ -37,20 +36,14 @@ public sealed partial class EmpReactionEffect : EntityEffect
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-emp-reaction-effect", ("chance", Probability));

public override void Effect(EntityEffectBaseArgs args)
public override void Effect(ReagentEffectArgs args)
{
var tSys = args.EntityManager.System<TransformSystem>();
var transform = args.EntityManager.GetComponent<TransformComponent>(args.TargetEntity);

var range = EmpRangePerUnit;

if (args is EntityEffectReagentArgs reagentArgs)
{
range = MathF.Min((float) (reagentArgs.Quantity * EmpRangePerUnit), EmpMaxRange);
}
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
var range = MathF.Min((float) (args.Quantity*EmpRangePerUnit), EmpMaxRange);

args.EntityManager.System<EmpSystem>()
.EmpPulse(tSys.GetMapCoordinates(args.TargetEntity, xform: transform),
.EmpPulse(tSys.GetMapCoordinates(args.SolutionEntity, xform: transform),
range,
EnergyConsumption,
DisableDuration);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Database;
using Content.Shared.Explosion;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using System.Text.Json.Serialization;

namespace Content.Server.Chemistry.ReactionEffects
{
[DataDefinition]
public sealed partial class ExplosionReactionEffect : ReagentEffect
{
/// <summary>
/// The type of explosion. Determines damage types and tile break chance scaling.
/// </summary>
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<ExplosionPrototype>))]
[JsonIgnore]
public string ExplosionType = default!;

/// <summary>
/// The max intensity the explosion can have at a given tile. Places an upper limit of damage and tile break
/// chance.
/// </summary>
[DataField]
[JsonIgnore]
public float MaxIntensity = 5;

/// <summary>
/// How quickly intensity drops off as you move away from the epicenter
/// </summary>
[DataField]
[JsonIgnore]
public float IntensitySlope = 1;

/// <summary>
/// The maximum total intensity that this chemical reaction can achieve. Basically here to prevent people
/// from creating a nuke by collecting enough potassium and water.
/// </summary>
/// <remarks>
/// A slope of 1 and MaxTotalIntensity of 100 corresponds to a radius of around 4.5 tiles.
/// </remarks>
[DataField]
[JsonIgnore]
public float MaxTotalIntensity = 100;

/// <summary>
/// The intensity of the explosion per unit reaction.
/// </summary>
[DataField]
[JsonIgnore]
public float IntensityPerUnit = 1;

public override bool ShouldLog => true;

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-explosion-reaction-effect", ("chance", Probability));
public override LogImpact LogImpact => LogImpact.High;

public override void Effect(ReagentEffectArgs args)
{
var intensity = MathF.Min((float) args.Quantity * IntensityPerUnit, MaxTotalIntensity);

EntitySystem.Get<ExplosionSystem>().QueueExplosion(
args.SolutionEntity,
ExplosionType,
intensity,
IntensitySlope,
MaxIntensity);
}
}
}
Loading

0 comments on commit db0cd2c

Please sign in to comment.