Puddle refactor 2: Spillastic boogaloo (#4784)

* Refactor PuddleComponent

* Move puddle effects into separate RSIs

Basically egg/tomato/powder puddle will be moved into separate
/Textures/Fluids RSIs

* Fix YAML for puddles

* Fix issues sloth pointed out.

* Ensure Puddle Component are properly added when spawned

* Remove unnecessary method init puddle with starting maxVolume

* Addressed ElectroSr comments

* Add Resolves

* Try fix error in ensureSolution

* Puddle unanchoring

* Address some issues with puddles

* Fix continue -> return
This commit is contained in:
Ygg01
2021-10-27 09:24:18 +01:00
committed by GitHub
parent 03b1fed47d
commit 14b401f9b3
30 changed files with 753 additions and 564 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Coordinates.Helpers;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
@@ -138,13 +139,15 @@ namespace Content.Server.Fluids.Components
}
}
var puddleSystem = EntitySystem.Get<PuddleSystem>();
foreach (var spillEntity in spillEntities)
{
if (!spillEntity.TryGetComponent(out PuddleComponent? puddleComponent)) continue;
if (!overflow && puddleComponent.WouldOverflow(solution)) return null;
if (!overflow && puddleSystem.WouldOverflow(puddleComponent.Owner.Uid, solution, puddleComponent)) return null;
if (!puddleComponent.TryAddSolution(solution, sound)) continue;
if (!puddleSystem.TryAddSolution(puddleComponent.Owner.Uid, solution, sound)) continue;
puddle = puddleComponent;
spilt = true;
@@ -157,7 +160,7 @@ namespace Content.Server.Fluids.Components
var puddleEnt = serverEntityManager.SpawnEntity(prototype, spillGridCoords);
var newPuddleComponent = puddleEnt.GetComponent<PuddleComponent>();
newPuddleComponent.TryAddSolution(solution, sound);
puddleSystem.TryAddSolution(newPuddleComponent.Owner.Uid, solution, sound);
return newPuddleComponent;
}