mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
+44









deltanedas
Ubaser
YourUsername
pa.pecherskij
PraxisMapper
EmoGarbage404
Ekkosangen
Chief-Engineer
Winkarst
Ilya246
PJBot
Errant
godisdeadLOL
lzk
Boaz1111
Mervill
slarticodefast
DrSmugleaf
Nemanja
deltanedas
poeMota
Mota
Moomoobeef
Cojoke
Pieter-Jan Briers
themias
Emisse
Арт
ScarKy0
IProduceWidgets
metalgearsloth
Fildrance
Lye
DieselMohawk
Hreno
eoineoineoin
Eoin Mcloughlin
qwerltaz
Ty Ashley
Token
Alzore
chromiumboy
Psychpsyo
drakewill-CRL
Nim
Perry Fraser
Ekkosangen
Ed
Chubbicous
Ps3Moira
FungiFellow
Futuristic-OK
Ian
TsjipTsjip
c93551dad7
* Remove always false checks (#31708) * Remove calls to FormattedMessage obsolete methods (#31706) * Remove FormattedMessage obsolete methods * Oops * remove misinformation from tip 26 (#31705) tip 26 * Automatic changelog update * Replace obsolete code in AnomalySystem.Generator.cs (#31718) * replace obsolete * weh * Added cursor indicator for space dragon fire breath ability (#31725) space dragon breath cursor indicator Co-authored-by: YourUsername <you@example.com> * Automatic changelog update * small yml cleanup (#31720) * Updates descriptions of station specific jobs. (#31713) done * Remove unused IoC dependency references. (#31704) Remove unused IoC dependencies * cleanup filing cabinets yml (#31211) * partmedia ahh kommit * ahh * everything should be fine now * f * now should be good * Update Resources/Prototypes/Entities/Structures/Storage/filing_cabinets.yml Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * fix suffix --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Move IgnitionEvent to shared (#30985) * Cleanup railings yml (#31618) * Cleanup railings * fix line * real fix * Roundstart Grappling Gun (#31737) Roundstart grappling hook * Automatic changelog update * Added in-hand sprite for Smile the Slime (#31731) added smile the slime in-hand texture Co-authored-by: YourUsername <you@example.com> * Lite Magnet Rebalancing (#31726) magnet rebalancing ish * unnerf fishops * Devmap crew monitor fix (#31677) * Automatic changelog update * Add ERT time stats (#31629) * add jobs for ghost roles * add job to ToggleableGhostRole * typo --------- Co-authored-by: Mota <belochuc@gmail.com> * Automatic changelog update * Fix CS0642 - Possible mistaken empty statement (#31740) * Throw the book at em! The space law book now does 1 blunt projectile damage (#31387) * you can now throw the space law book for 1 blunt damage * made book damage a feature of all books * Replace instances of SolutionContainerSystem with SharedSolutionContainerSystem (#30084) * Replace instances of SolutionContainerSystem with SharedSolutionContainerSystem * guap * More fixes * Wait you can do that? --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> * Add Donk Co. microwave board to Combat Bakery Kit (#31239) * Add special microwave board to Combat Bakery Kit * use event instead of trycomp * make the board sus * add instructions note * embarrassing typo * Add functionality to Donk Co. microwave instead * update note * Automatic changelog update * Actions bar dynamic resizing (#31759) * action bar dynamic resizing * action bar dynamic resizing for separated style * decreased indent for separated style --------- Co-authored-by: YourUsername <you@example.com> * Automatic changelog update * Fix warnings related to non-exhaustive pattern matching. (#31763) old man shakes fist at modern syntax * ats update (#31766) * ats update * fix pipenet * Ninja throwing star ability fix (#31684) fixed ninja star not spawning Co-authored-by: YourUsername <you@example.com> * Automatic changelog update * Remove duplicate using from FoodSystem (#31769) * vox voices revamp (#31679) vox voices v2 * fixed broken pipe sprites (#31773) * Return Long2 and Long3 hairstyles (#30963) * Sprites * Prototype_&_Locale * sorted_in_alphabetical_order * Automatic changelog update * Added many old ion lawsets for borgs and AI. (#31664) * Added the Commandments, Paladin, LetLive, Station Efficiency, Robocop, Overlord, Dungeon Master, Artist, Antimov and Nutimov lawsets/ * Wording * Anti-Antimov * Fixed fun * Add Snails (#30765) * add snails * scuffix * migrate * mo-grate * oopsied the ftls * Revert "oopsied the ftls" This reverts commit 0d3c6c17f31ec904679d6a48799cea71e77c1f99. * the curse of staging the wrong file, resolved. * Snoth * fix my dumbs * reviews 1 * anti space technology * salt hurty * spelling * Its a slotherhouse out here * sequencing * cooked snail * volfix * speed reversal * Automatic changelog update * Remove testbed command (#31793) * feat: now when research is unlocked in console, approver of reasearch is radio-ed too (#31170) * feat: now when research is unlocked in console, approver of reasearch is radio-ed too * refactor: now most of events that require actor name to be radio-ed or logged use TryGetIdentityShortInfoEvent which is subscibed by id-card system and borg system (to work for both carbon and synthetic life-forms) * refactor: moved TryGetIdentityShortInfoEvent on id card system to shared, fixed cargo cent-com-originated orders * remove unused check * refactor: decoupled systems from IdCardSystem (those that are not dependent on it anymore) * refactor: removed unuseed usings * feat: emagged cargo/research consoles wont radio messages on buy/research confirm anymore --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> * Automatic changelog update * New chemical based artifact nodes (#30873) * Initial pH nodes, and description changes to indicate pH * Psychoactive and stimulant nodes, Medical foundation, bioreactive hint * Added medical reagents to medical node. Added norepinephric acid to acidic and made up a pH * Added pyrotechnic chem node, and corresponding hint * spelled psychedelic correctly * Fixed capitalisation skill issue * fixed indentation skill issue * fixed a further indentation skill issue * Removed extraneous whitespace * Replaced bioreactive with theraputic and psychoactive. Also fixed typo skill issue. * removed unnecessary comment * Replaced heartbreaker with THC for psychadelic * removed artifexium from acidic * added tran acid to acidic * added more medical chems * removed pH values * removed all but medical * Automatic changelog update * Add Red Neck Gaiter To Secdrobe (#30106) * Red Neck Gaiter Added to SecDrobe * Removes Gaiter From TheaterDrobe * Automatic changelog update * Fixed typos (#31811) * Automatic changelog update * Station AI has their name displayed in announcements now. (#31802) * Station AI has their name displayed in announcements now. * I'm so sorry * Corrections * part 2 * part 3 :| * part 4 * Whitespace * Fixing whitespace part 1 * No more whitespace * PLEASE NO MORE WHITESPACE * Automatic changelog update * Add disabled station anchors version (#31794) * Add disabled station anchors versions * remove this * add structural damage taken to a lot of prototypes (#30790) * fix * add structural damage taken to a lot of other things * do requested changes * how did this happen * Automatic changelog update * No Mr.Snail, I expect you to die! (fix sprite) (#31834) * No Mr.Snail, I expect you to die! * emoting * Allow some mobs to walk slowly (#31360) * Allow mice to walk slowly * add more * Automatic changelog update * Delete nonsense solar assembly construction through the Construction window (#31425) * Delete construction for solar assembly, it's the way to do it * Fix description of solar tracker electronics * Improvements to hand labeler UI (#31833) Give line edit focus when window is opened No longer require pressing enter to set the text Give feedback when user hits the maximum label length Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es> * make tesla brighter (#31357) * make tesla brighter * radius to 10 * Automatic changelog update * CorrectContraband levels on each type of magboots (#30960) * Added a ClothingShoesBootsMagBase, to allow the other versions of the magboots to have their own contraband settings * Changed Science Boots to not be contraband * Made ClothingShoesBootsMagBase abstract * Removed Engineering Contraband from base magboots. Now only the CE's Advanced Magboots are contraband (Grand Theft Contraband). Blood Reds are Syndie Contraband. * Automatic changelog update * Morgue system refactor remove unused VVs and into Entity (#31835) * Remove unused VVs params and usings from entityUid, MorgueComponent into Entity<MorgueComponent> ent * remove unnecesary VVs cuz datafields add em * Make midround zombie outbreaks much rarer (#30266) * Remove midround zombies * super rare, like, 1/651 chance every few minutes. * weight to 1 --------- Co-authored-by: Ubaser <134914314+UbaserB@users.noreply.github.com> * Automatic changelog update * Teleporting while pulling crash fix (#31787) teleporting while pulling crash fix Co-authored-by: YourUsername <you@example.com> * Automatic changelog update * quietify stealthbox (#30741) * Automatic changelog update * Atmospheric alerts computer (#25938) * Atmospheric alerts computer * Moved components, restricted access to them * Minor tweaks * The screen will now turn off when the computer is not powered * Bug fix * Adjusted label * Updated to latest master version * Automatic changelog update * Day 0 bug fix for atmos alerts computer (#31858) Initial commit * Basically every electronic device can now be used by the AI. (#31730) * Basically every electronic device can now be used by the AI. * Removed stuff that didnt make sense * oops * Removed access from mailing and disposal units. * Added AI wires to a couple machines. * cool epic stuff * Automatic changelog update * Fix a typo in the 10 commandments (#31856) * feat: #26107 uplink discounts for traitors (no nukies for now) (#26297) * feat: #26107 uplink discounts for traitors and nukies * refactor: #26107 extracted discount label from price of StoreListingControl * refactor: minor renaming * refactor: parametrized adding discounts to uplink store * fix: #26107 prevent exception on empty discountOptions * feat: uplink now have 'Discounted' category which contains all discounted items on this session. * after merge fixups * rename discount categories according to common sense * refactor: DiscountOptions is now optional (nullable) on ListingData * add nullability check ignore for already checked listingData.DiscountOptions * fix after merge store menu ui * remove unused using * final fix after merge conflicts * [refactor]: #26107 fix variables naming in UplinkSystem * fix: #26107 fix after merge * refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount * feat: #26107 support multiple currency discount in store on side of discount message label * refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now * refactor: #26107 move more code from storesystem to StoreDiscountComponent * refactor: #26107 separated StoreSystem and StoreDiscountSystem using events * fix: #26107 placed not-nullable variable initialization in ListingData for tests * refactor: #26107 minor renaming, xml-docs * fix: #26107 changed most of discounts to be down to half price for balance purposes * ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified * decoupled storesystem and store discount system * xml-docs * refactor: #26107 xml-doc for StoreDiscountSystem * is now a thing (tmp) * fix: compilation errors + StoreDiscountData.DiscountCategoryId * refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog * refactor: removed unused code, more StoreDiscountSystem docs, simplify code * refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected * refactor: rename back (its not prototype) * refactor: move ListingItemsInitializingEvent to file with handling logic * refactor: comments for StoreBuyFinishedEvent handling, more logging * refactor: moved StoreInitializedEvent, xml-doc * refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc * refactor: restore old listing data cost field name * refactor: fix linter in uplink_catalog.yml * refactor: xml-doc for ListingDataWithCostModifiers * refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers * refactor: purged linq, removed custom datafield names, minor cleanup * refactor: removed double-allocation on getting available listings * refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code) * fix: minor discount categories on uplink items changes following design overview * refactor: StoreBuyListingMessage now uses protoId and not whole object * refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> * Automatic changelog update * Fixed AI Actions (#31823) * Updated sprites for AI HUD * Epic test fail * Merged AGhost actions and AI actions together again. * Seperate comms and bugfix. Fixed broadcast. * Automatic changelog update * add wireless net to evac shuttles * Automatic changelog update * A kit to help new botanists discover chemistry (#31738) * Add a kit for botanists to do some limited chemistry to the NutriMax. Intended to help new botanists learn in-game about chemistry. * remove exclamation marks from names * naming fix * Rejected trademark application for 'Farmers Helper'. --------- Co-authored-by: PraxisMapper <praxismapper@gmail.com> * Automatic changelog update * Board for the AI upload console (#31867) board * Automatic changelog update * Fix typo in agri-chem manual (#31869) * Fix typo in agri-chem manual * Unremove my added newline * Cleanup books.yml (#31838) * Cleanup books.yml * yeah * shame * Vox sign/N2 locker update (#31845) * Vox sign/N2 locker update The "vox area" sign and N2 locker sprite were both taken from /vg/station. These sprites have bad racist connotations as discussed in https://github.com/space-wizards/space-station-14/issues/31840, and do not fit our server culture. The new N2 locker is not a taped on piece of trash. It now also has a blue stripe to mimic the regular O2 locker and make it more distinct from fire safety closets. The new "vox area" sign sprite follows the same style as other "area indicator" signs used throughout the blue and isn't an explicit warning sign anymore. It still has "No O2" on it to fill that role though. * emogarbage adjustments --------- Co-authored-by: EmoGarbage404 <retron404@gmail.com> * Automatic changelog update * Pizza boxes now have a chance to contain cotton pizza (#31883) Pizza box now contains cotton pizza Co-authored-by: Ekkosangen <9094006+XyyxShard@users.noreply.github.com> * Automatic changelog update * Tech Anomaly (#31764) * A * B * C * D * Update TechAnomalySystem.cs * idle anim * Update meta.json * new animation * Automatic changelog update * Fixed throngler name inconsistencies (#31889) changed throngler names * I have spent more time today cleaning up garbage than coding new shit, and I am mad (#31246) * Fix logging of GetWebhook errors Yeah let's just not log the error only stack trace. * I have spent more time today cleaning up garbage than coding new shit, and I am mad Cleans up the custom vote Discord webhook code because I *happened* to lay my eyes on how completely terrible it was and immediately found an obvious bug with it. Also did basic QA because jesus christ: it more clearly reports pending votes, properly indicates cancelled votes, improves footer formatting, better error logging, all the usual shit. Requires https://github.com/space-wizards/RobustToolbox/pull/5375 to avoid test failures * Mineral Scanner (#31390) * Mineral Scanner * doink * review * sunday funday * review and fix bugs i think? * Update MiningOverlay.cs * Automatic changelog update * Fix ai upload console itemslot whitelist (#31900) * Fix ai upload console itemslot whitelist * aw man * Automatic changelog update * improved vox laugh (#31798) vox laugh not underwater * fix pump shotgun wielded sprite (#31885) * fix shotgun sprite * fix take 2 * fix: Snail event wasnt tabled (#31884) pest events reorganized and snails spawn * Automatic changelog update * Force stop pulling when fall asleep (#31893) * break pull at sleep * TryStopPull without user --------- Co-authored-by: YourUsername <you@example.com> * Automatic changelog update * Energy Shotgun Change 2 - Narrow Nerf + instances from NoSpawn --> categories: [ HideSpawnMenu ] + self recharge removed + 1 more shot + normal recharge speed (#31235) * narrow nerf * last instance of nospawn gone * removes self recharge * 8 shots, less recharge time * Automatic changelog update * Add justice helm (#31905) * Add justice helm * backslash moment * spinny light * remove power cell from recipe * Automatic changelog update * Quiver Crafting Recipe (#27198) * Update quiver.yml * Create quiver.yml * Update clothing.yml * Update pneumatic_cannon.yml * Update pneumatic_cannon.yml * Update pneumatic_cannon.yml * Update pneumatic_cannon.yml * Delete RDs binary encryption key (#31909) Deleting binary key Silicon supremacy! * undelete rd key * Automatic changelog update * split temperature protection into heating and cooling (#30662) * split temperature protection into heating and cooling * fugg * weh * update TemperatureProtection for stuff * Automatic changelog update * makes the maple wing marking have a primary and a secondary color (#31691) bogos binted * Automatic changelog update * Remake bottles and syringes names to use labels (#29956) * Remake bottles and syringes names to use labels * vial * fix and add stuff * Automatic changelog update * guide on agrichem and botanicals guidebook update (#31896) * Automatic changelog update * Automatic changelog update * Lost evac pod thing tiny fan (#31915) * disaster evacpod tinyfan * real * :trollface: * untroll * Ghostrole rule updates (#29249) * First batch of ghostrole rule updates * Second pass * Re-word free agent * Apply review comments Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * You heard it here first folks God rules are weird to write. Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * Honkbot -> Free Agent Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * Mimebot -> Free Agent Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * Jonkbot -> Free Agent Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * Softer blue --------- Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * :trollface: * :trollface: * :trollface: * pro --------- Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com> Co-authored-by: Ilya246 <57039557+Ilya246@users.noreply.github.com> Co-authored-by: PJBot <pieterjan.briers+bot@gmail.com> Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com> Co-authored-by: godisdeadLOL <169250097+godisdeadLOL@users.noreply.github.com> Co-authored-by: YourUsername <you@example.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com> Co-authored-by: Mervill <mervills.email@gmail.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: poeMota <142114334+poeMota@users.noreply.github.com> Co-authored-by: Mota <belochuc@gmail.com> Co-authored-by: Moomoobeef <62638182+Moomoobeef@users.noreply.github.com> Co-authored-by: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: themias <89101928+themias@users.noreply.github.com> Co-authored-by: Emisse <99158783+Emisse@users.noreply.github.com> Co-authored-by: Арт <123451459+JustArt1m@users.noreply.github.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: Lye <128915833+Lyroth001@users.noreply.github.com> Co-authored-by: DieselMohawk <gavin.drinka@gmail.com> Co-authored-by: Hreno <hrenor@gmail.com> Co-authored-by: eoineoineoin <github@eoinrul.es> Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es> Co-authored-by: qwerltaz <69696513+qwerltaz@users.noreply.github.com> Co-authored-by: Ty Ashley <42426760+TyAshley@users.noreply.github.com> Co-authored-by: Token <esil.bektay@yandex.com> Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com> Co-authored-by: Ubaser <134914314+UbaserB@users.noreply.github.com> Co-authored-by: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Co-authored-by: Psychpsyo <60073468+Psychpsyo@users.noreply.github.com> Co-authored-by: drakewill-CRL <46307022+drakewill-CRL@users.noreply.github.com> Co-authored-by: PraxisMapper <praxismapper@gmail.com> Co-authored-by: Nim <128169402+Nimfar11@users.noreply.github.com> Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: Ekkosangen <9094006+Ekkosangen@users.noreply.github.com> Co-authored-by: Ekkosangen <9094006+XyyxShard@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Chubbicous <100180479+Chubbicous@users.noreply.github.com> Co-authored-by: Ps3Moira <113228053+ps3moira@users.noreply.github.com> Co-authored-by: FungiFellow <151778459+FungiFellow@users.noreply.github.com> Co-authored-by: Futuristic-OK <141568243+Futuristic-OK@users.noreply.github.com> Co-authored-by: Ian <ignaz.k@live.de> Co-authored-by: TsjipTsjip <19798667+TsjipTsjip@users.noreply.github.com> Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
746 lines
28 KiB
C#
746 lines
28 KiB
C#
using Content.Server.Administration.Logs;
|
|
using Content.Server.DoAfter;
|
|
using Content.Server.Fluids.Components;
|
|
using Content.Server.Spreader;
|
|
using Content.Shared.Chemistry;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Chemistry.Reaction;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Effects;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Fluids;
|
|
using Content.Shared.Fluids.Components;
|
|
using Content.Shared.Friction;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Movement.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Slippery;
|
|
using Content.Shared.StepTrigger.Components;
|
|
using Content.Shared.StepTrigger.Systems;
|
|
using Robust.Server.Audio;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Fluids.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// Handles solutions on floors. Also handles the spreader logic for where the solution overflows a specified volume.
|
|
/// </summary>
|
|
public sealed partial class PuddleSystem : SharedPuddleSystem
|
|
{
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly SharedMapSystem _map = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
|
|
[Dependency] private readonly AudioSystem _audio = default!;
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
|
[Dependency] private readonly ReactiveSystem _reactive = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popups = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
|
[Dependency] private readonly StepTriggerSystem _stepTrigger = default!;
|
|
[Dependency] private readonly SpeedModifierContactsSystem _speedModContacts = default!;
|
|
[Dependency] private readonly TileFrictionController _tile = default!;
|
|
|
|
[ValidatePrototypeId<ReagentPrototype>]
|
|
private const string Blood = "Blood";
|
|
|
|
[ValidatePrototypeId<ReagentPrototype>]
|
|
private const string Slime = "Slime";
|
|
|
|
[ValidatePrototypeId<ReagentPrototype>]
|
|
private const string CopperBlood = "CopperBlood";
|
|
|
|
private static string[] _standoutReagents = [Blood, Slime, CopperBlood];
|
|
|
|
public static readonly float PuddleVolume = 1000;
|
|
|
|
// Using local deletion queue instead of the standard queue so that we can easily "undelete" if a puddle
|
|
// loses & then gains reagents in a single tick.
|
|
private HashSet<EntityUid> _deletionQueue = [];
|
|
|
|
private EntityQuery<PuddleComponent> _puddleQuery;
|
|
|
|
/*
|
|
* TODO: Need some sort of way to do blood slash / vomit solution spill on its own
|
|
* This would then evaporate into the puddle tile below
|
|
*/
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_puddleQuery = GetEntityQuery<PuddleComponent>();
|
|
|
|
// Shouldn't need re-anchoring.
|
|
SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
|
SubscribeLocalEvent<PuddleComponent, SolutionContainerChangedEvent>(OnSolutionUpdate);
|
|
SubscribeLocalEvent<PuddleComponent, ComponentInit>(OnPuddleInit);
|
|
SubscribeLocalEvent<PuddleComponent, SpreadNeighborsEvent>(OnPuddleSpread);
|
|
SubscribeLocalEvent<PuddleComponent, SlipEvent>(OnPuddleSlip);
|
|
|
|
SubscribeLocalEvent<EvaporationComponent, MapInitEvent>(OnEvaporationMapInit);
|
|
|
|
InitializeTransfers();
|
|
}
|
|
|
|
private void OnPuddleSpread(Entity<PuddleComponent> entity, ref SpreadNeighborsEvent args)
|
|
{
|
|
// Overflow is the source of the overflowing liquid. This contains the excess fluid above overflow limit (20u)
|
|
var overflow = GetOverflowSolution(entity.Owner, entity.Comp);
|
|
|
|
if (overflow.Volume == FixedPoint2.Zero)
|
|
{
|
|
RemCompDeferred<ActiveEdgeSpreaderComponent>(entity);
|
|
return;
|
|
}
|
|
|
|
// For overflows, we never go to a fully evaporative tile just to avoid continuously having to mop it.
|
|
|
|
// First we go to free tiles.
|
|
// Need to go even if we have a little remainder to avoid solution sploshing around internally
|
|
// for ages.
|
|
if (args.NeighborFreeTiles.Count > 0 && args.Updates > 0)
|
|
{
|
|
_random.Shuffle(args.NeighborFreeTiles);
|
|
var spillAmount = overflow.Volume / args.NeighborFreeTiles.Count;
|
|
|
|
foreach (var neighbor in args.NeighborFreeTiles)
|
|
{
|
|
var split = overflow.SplitSolution(spillAmount);
|
|
TrySpillAt(_map.GridTileToLocal(neighbor.Tile.GridUid, neighbor.Grid, neighbor.Tile.GridIndices), split, out _, false);
|
|
args.Updates--;
|
|
|
|
if (args.Updates <= 0)
|
|
break;
|
|
}
|
|
|
|
RemCompDeferred<ActiveEdgeSpreaderComponent>(entity);
|
|
return;
|
|
}
|
|
|
|
// Then we overflow to neighbors with overflow capacity
|
|
if (args.Neighbors.Count > 0)
|
|
{
|
|
var resolvedNeighbourSolutions = new ValueList<(Solution neighborSolution, PuddleComponent puddle, EntityUid neighbor)>();
|
|
|
|
// Resolve all our neighbours first, so we can use their properties to decide who to operate on first.
|
|
foreach (var neighbor in args.Neighbors)
|
|
{
|
|
if (!_puddleQuery.TryGetComponent(neighbor, out var puddle) ||
|
|
!_solutionContainerSystem.ResolveSolution(neighbor, puddle.SolutionName, ref puddle.Solution,
|
|
out var neighborSolution) ||
|
|
CanFullyEvaporate(neighborSolution))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
resolvedNeighbourSolutions.Add(
|
|
(neighborSolution, puddle, neighbor)
|
|
);
|
|
}
|
|
|
|
// We want to deal with our neighbours by lowest current volume to highest, as this allows us to fill up our low points quickly.
|
|
resolvedNeighbourSolutions.Sort(
|
|
(x, y) =>
|
|
x.neighborSolution.Volume.CompareTo(y.neighborSolution.Volume));
|
|
|
|
// Overflow to neighbors with remaining space.
|
|
foreach (var (neighborSolution, puddle, neighbor) in resolvedNeighbourSolutions)
|
|
{
|
|
// Water doesn't flow uphill
|
|
if (neighborSolution.Volume >= (overflow.Volume + puddle.OverflowVolume))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Work out how much we could send into this neighbour without overflowing it, and send up to that much
|
|
var remaining = puddle.OverflowVolume - neighborSolution.Volume;
|
|
|
|
// If we can't send anything, then skip this neighbour
|
|
if (remaining <= FixedPoint2.Zero)
|
|
continue;
|
|
|
|
// We don't want to spill over to make high points either.
|
|
if (neighborSolution.Volume + remaining >= (overflow.Volume + puddle.OverflowVolume))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var split = overflow.SplitSolution(remaining);
|
|
|
|
if (puddle.Solution != null && !_solutionContainerSystem.TryAddSolution(puddle.Solution.Value, split))
|
|
continue;
|
|
|
|
args.Updates--;
|
|
EnsureComp<ActiveEdgeSpreaderComponent>(neighbor);
|
|
|
|
if (args.Updates <= 0)
|
|
break;
|
|
}
|
|
|
|
// If there is nothing left to overflow from our tile, then we'll stop this tile being a active spreader
|
|
if (overflow.Volume == FixedPoint2.Zero)
|
|
{
|
|
RemCompDeferred<ActiveEdgeSpreaderComponent>(entity);
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Then we go to anything else.
|
|
if (overflow.Volume > FixedPoint2.Zero && args.Neighbors.Count > 0 && args.Updates > 0)
|
|
{
|
|
var resolvedNeighbourSolutions =
|
|
new ValueList<(Solution neighborSolution, PuddleComponent puddle, EntityUid neighbor)>();
|
|
|
|
// Keep track of the total volume in the area
|
|
FixedPoint2 totalVolume = 0;
|
|
|
|
// Resolve all our neighbours so that we can use their properties to decide who to act on first
|
|
foreach (var neighbor in args.Neighbors)
|
|
{
|
|
if (!_puddleQuery.TryGetComponent(neighbor, out var puddle) ||
|
|
!_solutionContainerSystem.ResolveSolution(neighbor, puddle.SolutionName, ref puddle.Solution,
|
|
out var neighborSolution) ||
|
|
CanFullyEvaporate(neighborSolution))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
resolvedNeighbourSolutions.Add((neighborSolution, puddle, neighbor));
|
|
totalVolume += neighborSolution.Volume;
|
|
}
|
|
|
|
// We should act on neighbours by their total volume.
|
|
resolvedNeighbourSolutions.Sort(
|
|
(x, y) =>
|
|
x.neighborSolution.Volume.CompareTo(y.neighborSolution.Volume)
|
|
);
|
|
|
|
// Overflow to neighbors with remaining total allowed space (1000u) above the overflow volume (20u).
|
|
foreach (var (neighborSolution, puddle, neighbor) in resolvedNeighbourSolutions)
|
|
{
|
|
// What the source tiles current volume is.
|
|
var sourceCurrentVolume = overflow.Volume + puddle.OverflowVolume;
|
|
|
|
// Water doesn't flow uphill
|
|
if (neighborSolution.Volume >= sourceCurrentVolume)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// We're in the low point in this area, let the neighbour tiles have a chance to spread to us first.
|
|
var idealAverageVolume =
|
|
(totalVolume + overflow.Volume + puddle.OverflowVolume) / (args.Neighbors.Count + 1);
|
|
|
|
if (idealAverageVolume > sourceCurrentVolume)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Work our how far off the ideal average this neighbour is.
|
|
var spillThisNeighbor = idealAverageVolume - neighborSolution.Volume;
|
|
|
|
// Skip if we want to spill negative amounts of fluid to this neighbour
|
|
if (spillThisNeighbor < FixedPoint2.Zero)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Try to send them as much towards the average ideal as we can
|
|
var split = overflow.SplitSolution(spillThisNeighbor);
|
|
|
|
// If we can't do it, move on.
|
|
if (puddle.Solution != null && !_solutionContainerSystem.TryAddSolution(puddle.Solution.Value, split))
|
|
continue;
|
|
|
|
// If we succeed, then ensure that this neighbour is also able to spread it's overflow onwards
|
|
EnsureComp<ActiveEdgeSpreaderComponent>(neighbor);
|
|
args.Updates--;
|
|
|
|
if (args.Updates <= 0)
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Add the remainder back
|
|
if (_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution))
|
|
{
|
|
_solutionContainerSystem.TryAddSolution(entity.Comp.Solution.Value, overflow);
|
|
}
|
|
}
|
|
|
|
private void OnPuddleSlip(Entity<PuddleComponent> entity, ref SlipEvent args)
|
|
{
|
|
// Reactive entities have a chance to get a touch reaction from slipping on a puddle
|
|
// (i.e. it is implied they fell face first onto it or something)
|
|
if (!HasComp<ReactiveComponent>(args.Slipped) || HasComp<SlidingComponent>(args.Slipped))
|
|
return;
|
|
|
|
// Eventually probably have some system of 'body coverage' to tweak the probability but for now just 0.5
|
|
// (implying that spacemen have a 50% chance to either land on their ass or their face)
|
|
if (!_random.Prob(0.5f))
|
|
return;
|
|
|
|
if (!_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution,
|
|
out var solution))
|
|
return;
|
|
|
|
_popups.PopupEntity(Loc.GetString("puddle-component-slipped-touch-reaction", ("puddle", entity.Owner)),
|
|
args.Slipped, args.Slipped, PopupType.SmallCaution);
|
|
|
|
// Take 15% of the puddle solution
|
|
var splitSol = _solutionContainerSystem.SplitSolution(entity.Comp.Solution.Value, solution.Volume * 0.15f);
|
|
_reactive.DoEntityReaction(args.Slipped, splitSol, ReactionMethod.Touch);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
foreach (var ent in _deletionQueue)
|
|
{
|
|
Del(ent);
|
|
}
|
|
|
|
_deletionQueue.Clear();
|
|
|
|
TickEvaporation();
|
|
}
|
|
|
|
private void OnPuddleInit(Entity<PuddleComponent> entity, ref ComponentInit args)
|
|
{
|
|
_solutionContainerSystem.EnsureSolution(entity.Owner, entity.Comp.SolutionName, out _, FixedPoint2.New(PuddleVolume));
|
|
}
|
|
|
|
private void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
|
|
{
|
|
if (args.SolutionId != entity.Comp.SolutionName)
|
|
return;
|
|
|
|
if (args.Solution.Volume <= 0)
|
|
{
|
|
_deletionQueue.Add(entity);
|
|
return;
|
|
}
|
|
|
|
_deletionQueue.Remove(entity);
|
|
UpdateSlip(entity, entity.Comp, args.Solution);
|
|
UpdateSlow(entity, args.Solution);
|
|
UpdateEvaporation(entity, args.Solution);
|
|
UpdateAppearance(entity, entity.Comp);
|
|
}
|
|
|
|
private void UpdateAppearance(EntityUid uid, PuddleComponent? puddleComponent = null,
|
|
AppearanceComponent? appearance = null)
|
|
{
|
|
if (!Resolve(uid, ref puddleComponent, ref appearance, false))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var volume = FixedPoint2.Zero;
|
|
Color color = Color.White;
|
|
|
|
if (_solutionContainerSystem.ResolveSolution(uid, puddleComponent.SolutionName, ref puddleComponent.Solution,
|
|
out var solution))
|
|
{
|
|
volume = solution.Volume / puddleComponent.OverflowVolume;
|
|
|
|
// Make blood stand out more
|
|
// Kinda EH
|
|
// Could potentially do alpha per-solution but future problem.
|
|
|
|
color = solution.GetColorWithout(_prototypeManager, _standoutReagents);
|
|
color = color.WithAlpha(0.7f);
|
|
|
|
foreach (var standout in _standoutReagents)
|
|
{
|
|
var quantity = solution.GetTotalPrototypeQuantity(standout);
|
|
if (quantity <= FixedPoint2.Zero)
|
|
continue;
|
|
|
|
var interpolateValue = quantity.Float() / solution.Volume.Float();
|
|
color = Color.InterpolateBetween(color,
|
|
_prototypeManager.Index<ReagentPrototype>(standout).SubstanceColor, interpolateValue);
|
|
}
|
|
}
|
|
|
|
_appearance.SetData(uid, PuddleVisuals.CurrentVolume, volume.Float(), appearance);
|
|
_appearance.SetData(uid, PuddleVisuals.SolutionColor, color, appearance);
|
|
}
|
|
|
|
private void UpdateSlip(EntityUid entityUid, PuddleComponent component, Solution solution)
|
|
{
|
|
var isSlippery = false;
|
|
// The base sprite is currently at 0.3 so we require at least 2nd tier to be slippery or else it's too hard to see.
|
|
var amountRequired = FixedPoint2.New(component.OverflowVolume.Float() * LowThreshold);
|
|
var slipperyAmount = FixedPoint2.Zero;
|
|
|
|
foreach (var (reagent, quantity) in solution.Contents)
|
|
{
|
|
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
|
|
|
if (reagentProto.Slippery)
|
|
{
|
|
slipperyAmount += quantity;
|
|
|
|
if (slipperyAmount > amountRequired)
|
|
{
|
|
isSlippery = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isSlippery)
|
|
{
|
|
var comp = EnsureComp<StepTriggerComponent>(entityUid);
|
|
_stepTrigger.SetActive(entityUid, true, comp);
|
|
var friction = EnsureComp<TileFrictionModifierComponent>(entityUid);
|
|
_tile.SetModifier(entityUid, TileFrictionController.DefaultFriction * 0.5f, friction);
|
|
}
|
|
else if (TryComp<StepTriggerComponent>(entityUid, out var comp))
|
|
{
|
|
_stepTrigger.SetActive(entityUid, false, comp);
|
|
RemCompDeferred<TileFrictionModifierComponent>(entityUid);
|
|
}
|
|
}
|
|
|
|
private void UpdateSlow(EntityUid uid, Solution solution)
|
|
{
|
|
var maxViscosity = 0f;
|
|
foreach (var (reagent, _) in solution.Contents)
|
|
{
|
|
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
|
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
|
|
}
|
|
|
|
if (maxViscosity > 0)
|
|
{
|
|
var comp = EnsureComp<SpeedModifierContactsComponent>(uid);
|
|
var speed = 1 - maxViscosity;
|
|
_speedModContacts.ChangeModifiers(uid, speed, comp);
|
|
}
|
|
else
|
|
{
|
|
RemComp<SpeedModifierContactsComponent>(uid);
|
|
}
|
|
}
|
|
|
|
private void OnAnchorChanged(Entity<PuddleComponent> entity, ref AnchorStateChangedEvent args)
|
|
{
|
|
if (!args.Anchored)
|
|
QueueDel(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the current volume of the given puddle, which may not necessarily be PuddleVolume.
|
|
/// </summary>
|
|
public FixedPoint2 CurrentVolume(EntityUid uid, PuddleComponent? puddleComponent = null)
|
|
{
|
|
if (!Resolve(uid, ref puddleComponent))
|
|
return FixedPoint2.Zero;
|
|
|
|
return _solutionContainerSystem.ResolveSolution(uid, puddleComponent.SolutionName, ref puddleComponent.Solution,
|
|
out var solution)
|
|
? solution.Volume
|
|
: FixedPoint2.Zero;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Try to add solution to <paramref name="puddleUid"/>.
|
|
/// </summary>
|
|
/// <param name="puddleUid">Puddle to which we add</param>
|
|
/// <param name="addedSolution">Solution that is added to puddleComponent</param>
|
|
/// <param name="sound">Play sound on overflow</param>
|
|
/// <param name="checkForOverflow">Overflow on encountered values</param>
|
|
/// <param name="puddleComponent">Optional resolved PuddleComponent</param>
|
|
/// <returns></returns>
|
|
public bool TryAddSolution(EntityUid puddleUid,
|
|
Solution addedSolution,
|
|
bool sound = true,
|
|
bool checkForOverflow = true,
|
|
PuddleComponent? puddleComponent = null,
|
|
SolutionContainerManagerComponent? sol = null)
|
|
{
|
|
if (!Resolve(puddleUid, ref puddleComponent, ref sol))
|
|
return false;
|
|
|
|
_solutionContainerSystem.EnsureAllSolutions((puddleUid, sol));
|
|
|
|
if (addedSolution.Volume == 0 ||
|
|
!_solutionContainerSystem.ResolveSolution(puddleUid, puddleComponent.SolutionName,
|
|
ref puddleComponent.Solution))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_solutionContainerSystem.AddSolution(puddleComponent.Solution.Value, addedSolution);
|
|
|
|
if (checkForOverflow && IsOverflowing(puddleUid, puddleComponent))
|
|
{
|
|
EnsureComp<ActiveEdgeSpreaderComponent>(puddleUid);
|
|
}
|
|
|
|
if (!sound)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
_audio.PlayPvs(puddleComponent.SpillSound, puddleUid);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Whether adding this solution to this puddle would overflow.
|
|
/// </summary>
|
|
public bool WouldOverflow(EntityUid uid, Solution solution, PuddleComponent? puddle = null)
|
|
{
|
|
if (!Resolve(uid, ref puddle))
|
|
return false;
|
|
|
|
return CurrentVolume(uid, puddle) + solution.Volume > puddle.OverflowVolume;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Whether adding this solution to this puddle would overflow.
|
|
/// </summary>
|
|
private bool IsOverflowing(EntityUid uid, PuddleComponent? puddle = null)
|
|
{
|
|
if (!Resolve(uid, ref puddle))
|
|
return false;
|
|
|
|
return CurrentVolume(uid, puddle) > puddle.OverflowVolume;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the solution amount above the overflow threshold for the puddle.
|
|
/// </summary>
|
|
public Solution GetOverflowSolution(EntityUid uid, PuddleComponent? puddle = null)
|
|
{
|
|
if (!Resolve(uid, ref puddle) ||
|
|
!_solutionContainerSystem.ResolveSolution(uid, puddle.SolutionName, ref puddle.Solution))
|
|
{
|
|
return new Solution(0);
|
|
}
|
|
|
|
// TODO: This is going to fail with struct solutions.
|
|
var remaining = puddle.OverflowVolume;
|
|
var split = _solutionContainerSystem.SplitSolution(puddle.Solution.Value,
|
|
CurrentVolume(uid, puddle) - remaining);
|
|
return split;
|
|
}
|
|
|
|
#region Spill
|
|
|
|
/// <inheritdoc/>
|
|
public override bool TrySplashSpillAt(EntityUid uid,
|
|
EntityCoordinates coordinates,
|
|
Solution solution,
|
|
out EntityUid puddleUid,
|
|
bool sound = true,
|
|
EntityUid? user = null)
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
|
|
if (solution.Volume == 0)
|
|
return false;
|
|
|
|
var targets = new List<EntityUid>();
|
|
var reactive = new HashSet<Entity<ReactiveComponent>>();
|
|
_lookup.GetEntitiesInRange(coordinates, 1.0f, reactive);
|
|
|
|
// Get reactive entities nearby--if there are some, it'll spill a bit on them instead.
|
|
foreach (var ent in reactive)
|
|
{
|
|
// sorry! no overload for returning uid, so .owner must be used
|
|
var owner = ent.Owner;
|
|
|
|
// between 5 and 30%
|
|
var splitAmount = solution.Volume * _random.NextFloat(0.05f, 0.30f);
|
|
var splitSolution = solution.SplitSolution(splitAmount);
|
|
|
|
if (user != null)
|
|
{
|
|
_adminLogger.Add(LogType.Landed,
|
|
$"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity} which splashed a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} onto {ToPrettyString(owner):target}");
|
|
}
|
|
|
|
targets.Add(owner);
|
|
_reactive.DoEntityReaction(owner, splitSolution, ReactionMethod.Touch);
|
|
_popups.PopupEntity(
|
|
Loc.GetString("spill-land-spilled-on-other", ("spillable", uid),
|
|
("target", Identity.Entity(owner, EntityManager))), owner, PopupType.SmallCaution);
|
|
}
|
|
|
|
_color.RaiseEffect(solution.GetColor(_prototypeManager), targets,
|
|
Filter.Pvs(uid, entityManager: EntityManager));
|
|
|
|
return TrySpillAt(coordinates, solution, out puddleUid, sound);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool TrySpillAt(EntityCoordinates coordinates, Solution solution, out EntityUid puddleUid, bool sound = true)
|
|
{
|
|
if (solution.Volume == 0)
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
var gridUid = coordinates.GetGridUid(EntityManager);
|
|
if (!TryComp<MapGridComponent>(gridUid, out var mapGrid))
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
return TrySpillAt(_map.GetTileRef(gridUid.Value, mapGrid, coordinates), solution, out puddleUid, sound);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool TrySpillAt(EntityUid uid, Solution solution, out EntityUid puddleUid, bool sound = true,
|
|
TransformComponent? transformComponent = null)
|
|
{
|
|
if (!Resolve(uid, ref transformComponent, false))
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
return TrySpillAt(transformComponent.Coordinates, solution, out puddleUid, sound: sound);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool TrySpillAt(TileRef tileRef, Solution solution, out EntityUid puddleUid, bool sound = true,
|
|
bool tileReact = true)
|
|
{
|
|
if (solution.Volume <= 0)
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
// If space return early, let that spill go out into the void
|
|
if (tileRef.Tile.IsEmpty || tileRef.IsSpace(_tileDefMan))
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
// Let's not spill to invalid grids.
|
|
var gridId = tileRef.GridUid;
|
|
if (!TryComp<MapGridComponent>(gridId, out var mapGrid))
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
if (tileReact)
|
|
{
|
|
// First, do all tile reactions
|
|
DoTileReactions(tileRef, solution);
|
|
}
|
|
|
|
// Tile reactions used up everything.
|
|
if (solution.Volume == FixedPoint2.Zero)
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
return false;
|
|
}
|
|
|
|
// Get normalized co-ordinate for spill location and spill it in the centre
|
|
// TODO: Does SnapGrid or something else already do this?
|
|
var anchored = _map.GetAnchoredEntitiesEnumerator(gridId, mapGrid, tileRef.GridIndices);
|
|
var puddleQuery = GetEntityQuery<PuddleComponent>();
|
|
var sparklesQuery = GetEntityQuery<EvaporationSparkleComponent>();
|
|
|
|
while (anchored.MoveNext(out var ent))
|
|
{
|
|
// If there's existing sparkles then delete it
|
|
if (sparklesQuery.TryGetComponent(ent, out var sparkles))
|
|
{
|
|
QueueDel(ent.Value);
|
|
continue;
|
|
}
|
|
|
|
if (!puddleQuery.TryGetComponent(ent, out var puddle))
|
|
continue;
|
|
|
|
if (TryAddSolution(ent.Value, solution, sound, puddleComponent: puddle))
|
|
{
|
|
EnsureComp<ActiveEdgeSpreaderComponent>(ent.Value);
|
|
}
|
|
|
|
puddleUid = ent.Value;
|
|
return true;
|
|
}
|
|
|
|
var coords = _map.GridTileToLocal(gridId, mapGrid, tileRef.GridIndices);
|
|
puddleUid = EntityManager.SpawnEntity("Puddle", coords);
|
|
EnsureComp<PuddleComponent>(puddleUid);
|
|
if (TryAddSolution(puddleUid, solution, sound))
|
|
{
|
|
EnsureComp<ActiveEdgeSpreaderComponent>(puddleUid);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void DoTileReactions(TileRef tileRef, Solution solution)
|
|
{
|
|
for (var i = solution.Contents.Count - 1; i >= 0; i--)
|
|
{
|
|
var (reagent, quantity) = solution.Contents[i];
|
|
var proto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
|
var removed = proto.ReactionTile(tileRef, quantity, EntityManager, reagent.Data);
|
|
if (removed <= FixedPoint2.Zero)
|
|
continue;
|
|
|
|
solution.RemoveReagent(reagent, removed);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to get the relevant puddle entity for a tile.
|
|
/// </summary>
|
|
public bool TryGetPuddle(TileRef tile, out EntityUid puddleUid)
|
|
{
|
|
puddleUid = EntityUid.Invalid;
|
|
|
|
if (!TryComp<MapGridComponent>(tile.GridUid, out var grid))
|
|
return false;
|
|
|
|
var anc = _map.GetAnchoredEntitiesEnumerator(tile.GridUid, grid, tile.GridIndices);
|
|
var puddleQuery = GetEntityQuery<PuddleComponent>();
|
|
|
|
while (anc.MoveNext(out var ent))
|
|
{
|
|
if (!puddleQuery.HasComponent(ent.Value))
|
|
continue;
|
|
|
|
puddleUid = ent.Value;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|