Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Morb0 committed Jan 21, 2024
2 parents adbbfe9 + 8f1d670 commit b12f127
Show file tree
Hide file tree
Showing 41 changed files with 415 additions and 78 deletions.
5 changes: 0 additions & 5 deletions Content.Server/Anomaly/Effects/TileAnomalySystem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System.Linq;
using System.Numerics;
using Content.Server.Maps;
using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects.Components;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Random;

namespace Content.Server.Anomaly.Effects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Power.Generator;
Expand All @@ -13,11 +14,10 @@ namespace Content.Server.Power.Generator;
public sealed partial class ChemicalFuelGeneratorAdapterComponent : Component
{
/// <summary>
/// The reagent to accept as fuel.
/// A dictionary relating a reagent to accept as fuel to a value to multiply reagent amount by to get fuel amount.
/// </summary>
[DataField("reagent", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
[ViewVariables(VVAccess.ReadWrite)]
public string Reagent = "WeldingFuel";
[DataField]
public Dictionary<ProtoId<ReagentPrototype>, float> Reagents = new();

/// <summary>
/// The name of <see cref="Solution"/>.
Expand All @@ -32,16 +32,10 @@ public sealed partial class ChemicalFuelGeneratorAdapterComponent : Component
[DataField("solutionRef")]
public Entity<SolutionComponent>? Solution = null;

/// <summary>
/// Value to multiply reagent amount by to get fuel amount.
/// </summary>
[DataField("multiplier"), ViewVariables(VVAccess.ReadWrite)]
public float Multiplier = 1f;

/// <summary>
/// How much reagent (can be fractional) is left in the generator.
/// Stored in units of <see cref="FixedPoint2.Epsilon"/>.
/// </summary>
[DataField("fractionalReagent"), ViewVariables(VVAccess.ReadWrite)]
public float FractionalReagent;
[DataField]
public Dictionary<ProtoId<ReagentPrototype>, float> FractionalReagents = new();
}
44 changes: 31 additions & 13 deletions Content.Server/Power/Generator/GeneratorSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Audio;
using System.Linq;
using Content.Server.Audio;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Materials;
Expand Down Expand Up @@ -81,7 +82,7 @@ private void ChemicalGetClogged(Entity<ChemicalFuelGeneratorAdapterComponent> en

foreach (var reagentQuantity in solution)
{
if (reagentQuantity.Reagent.Prototype != entity.Comp.Reagent)
if (!entity.Comp.Reagents.ContainsKey(reagentQuantity.Reagent.Prototype))
{
args.Clogged = true;
return;
Expand All @@ -94,24 +95,41 @@ private void ChemicalUseFuel(Entity<ChemicalFuelGeneratorAdapterComponent> entit
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;

var availableReagent = solution.GetTotalPrototypeQuantity(entity.Comp.Reagent).Value;
var toRemove = RemoveFractionalFuel(
ref entity.Comp.FractionalReagent,
args.FuelUsed,
entity.Comp.Multiplier * FixedPoint2.Epsilon.Float(),
availableReagent);

_solutionContainer.RemoveReagent(entity.Comp.Solution.Value, entity.Comp.Reagent, FixedPoint2.FromCents(toRemove));
var totalAvailableReagents = solution.GetTotalPrototypeQuantity(entity.Comp.Reagents.Keys.Select(p => p.Id).ToArray()).Value;
foreach (var (reagentId, multiplier) in entity.Comp.Reagents)
{
var availableReagent = solution.GetTotalPrototypeQuantity(reagentId).Value;
var removalPercentage = availableReagent / totalAvailableReagents;
var fractionalReagent = entity.Comp.FractionalReagents.GetValueOrDefault(reagentId);
var toRemove = RemoveFractionalFuel(
ref fractionalReagent,
args.FuelUsed * removalPercentage,
multiplier * FixedPoint2.Epsilon.Float(),
availableReagent);

entity.Comp.FractionalReagents[reagentId] = fractionalReagent;
_solutionContainer.RemoveReagent(entity.Comp.Solution.Value, reagentId, FixedPoint2.FromCents(toRemove));
}
}

private void ChemicalGetFuel(Entity<ChemicalFuelGeneratorAdapterComponent> entity, ref GeneratorGetFuelEvent args)
{
if (!_solutionContainer.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution, out var solution))
return;

var availableReagent = solution.GetTotalPrototypeQuantity(entity.Comp.Reagent).Float();
var reagent = entity.Comp.FractionalReagent * FixedPoint2.Epsilon.Float() + availableReagent;
args.Fuel = reagent * entity.Comp.Multiplier;
var totalAvailableReagents = solution.GetTotalPrototypeQuantity(entity.Comp.Reagents.Keys.Select(p => p.Id).ToArray());
var fuel = 0f;
foreach (var (reagentId, multiplier) in entity.Comp.Reagents)
{
var availableReagent = solution.GetTotalPrototypeQuantity(reagentId);
var percentage = availableReagent / totalAvailableReagents;
var fractionalReagent = (availableReagent * percentage).Float();

var reagent = entity.Comp.FractionalReagents.GetValueOrDefault(reagentId) * FixedPoint2.Epsilon.Float() + fractionalReagent;
fuel += reagent * multiplier;
}

args.Fuel = fuel;
}

private void SolidUseFuel(EntityUid uid, SolidFuelGeneratorAdapterComponent component, GeneratorUseFuel args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

namespace Content.Server.Spawners.Components
{
Expand All @@ -8,15 +7,15 @@ namespace Content.Server.Spawners.Components
public partial class ConditionalSpawnerComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("prototypes", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> Prototypes { get; set; } = new();
[DataField]
public List<EntProtoId> Prototypes { get; set; } = new();

[ViewVariables(VVAccess.ReadWrite)]
[DataField("gameRules", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> GameRules = new();
[DataField]
public List<EntProtoId> GameRules = new();

[ViewVariables(VVAccess.ReadWrite)]
[DataField("chance")]
[DataField]
public float Chance { get; set; } = 1.0f;
}
}
12 changes: 7 additions & 5 deletions Content.Server/Spawners/Components/RandomSpawnerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

namespace Content.Server.Spawners.Components
{
[RegisterComponent]
public sealed partial class RandomSpawnerComponent : ConditionalSpawnerComponent
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("rarePrototypes", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> RarePrototypes { get; set; } = new();
[DataField]
public List<EntProtoId> RarePrototypes { get; set; } = new();

[ViewVariables(VVAccess.ReadWrite)]
[DataField("rareChance")]
[DataField]
public float RareChance { get; set; } = 0.05f;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("offset")]
[DataField]
public float Offset { get; set; } = 0.2f;

[DataField]
public bool DeleteSpawnerAfterSpawn = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ private void OnCondSpawnMapInit(EntityUid uid, ConditionalSpawnerComponent compo
private void OnRandSpawnMapInit(EntityUid uid, RandomSpawnerComponent component, MapInitEvent args)
{
Spawn(uid, component);
QueueDel(uid);
if (component.DeleteSpawnerAfterSpawn)
QueueDel(uid);
}

private void OnRuleStarted(ref GameRuleStartedEvent args)
Expand Down
15 changes: 10 additions & 5 deletions Content.Server/Spreader/KudzuComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,33 @@ public sealed partial class KudzuComponent : Component
/// <summary>
/// Chance to spread whenever an edge spread is possible.
/// </summary>
[DataField("spreadChance")]
[DataField]
public float SpreadChance = 1f;

/// <summary>
/// How much damage is required to reduce growth level
/// </summary>
[DataField("growthHealth")]
[DataField]
public float GrowthHealth = 10.0f;

/// <summary>
/// How much damage is required to prevent growth
/// </summary>
[DataField("growthBlock")]
[DataField]
public float GrowthBlock = 20.0f;

/// <summary>
/// How much the kudzu heals each tick
/// </summary>
[DataField("damageRecovery")]
[DataField]
public DamageSpecifier? DamageRecovery = null;

[DataField("growthTickChance")]
[DataField]
public float GrowthTickChance = 1f;

/// <summary>
/// number of sprite variations for kudzu
/// </summary>
[DataField]
public int SpriteVariants = 3;
}
2 changes: 1 addition & 1 deletion Content.Server/Spreader/KudzuSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void SetupKudzu(EntityUid uid, KudzuComponent component, ComponentStartu
return;
}

_appearance.SetData(uid, KudzuVisuals.Variant, _robustRandom.Next(1, 3), appearance);
_appearance.SetData(uid, KudzuVisuals.Variant, _robustRandom.Next(1, component.SpriteVariants), appearance);
_appearance.SetData(uid, KudzuVisuals.GrowthLevel, 1, appearance);
}

Expand Down
8 changes: 3 additions & 5 deletions Content.Shared/Anomaly/Effects/Components/TileSpawnAnomaly.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Content.Shared.Maps;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

namespace Content.Shared.Anomaly.Effects.Components;

Expand All @@ -11,7 +9,7 @@ public sealed partial class TileSpawnAnomalyComponent : Component
/// <summary>
/// The maximum radius of tiles scales with stability
/// </summary>
[DataField("spawnRange"), ViewVariables(VVAccess.ReadWrite)]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float SpawnRange = 5f;

/// <summary>
Expand All @@ -23,6 +21,6 @@ public sealed partial class TileSpawnAnomalyComponent : Component
/// <summary>
/// The tile that is spawned by the anomaly's effect
/// </summary>
[DataField("floorTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
public string FloorTileId = "FloorFlesh";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<ContentTileDefinition> FloorTileId = "FloorFlesh";
}
18 changes: 7 additions & 11 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
Entries:
- author: Bhijn and Myr
changes:
- message: Speech bubbles now display the name of whatever or whoever spoke them!
The options menu has a setting to disable this outright, or add a background
to the name for the sake of accessibility, for anyone who would like those options.
type: Add
- message: The bubbles associated with emotes and LOOC now display exactly what
the associated message prints in your chatbox.
type: Tweak
id: 5259
time: '2023-12-04T23:10:49.0000000+00:00'
- author: brainfood1183
changes:
- message: Clowns can now craft the Banana Clown outfit.
Expand Down Expand Up @@ -3791,3 +3780,10 @@
id: 5759
time: '2024-01-20T23:38:27.0000000+00:00'
url: https://api.github.com/repos/space-wizards/space-station-14/pulls/24328
- author: TheShuEd
changes:
- message: Added new Floral anomaly!
type: Add
id: 5760
time: '2024-01-21T01:31:12.0000000+00:00'
url: https://api.github.com/repos/space-wizards/space-station-14/pulls/24351
Loading

0 comments on commit b12f127

Please sign in to comment.