mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
* More Tajaran Markings (#1834) <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Description. Adds separate eye colors to Tajaran and makes most of the markings from "Fashion Update: Earrings & Makeup" available to Tajarans --- <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>   </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Tonk - add: Tajarans now have separate eye, wrist, tattoo, and makeup markings --------- Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit e45008ddf8a529c2126907ecac8ffff2a74058de) * Automatic Changelog Update (#1834) (cherry picked from commit 0091c1ebdc4bc768c0906049fa9d417d962d1839) * Cybernetics Trait Changes (#1828) # Description Changes/buffs to Cybernetic Traits. Some lesser used traits get some love, while some other stuff gets some logical re-balancing. Feel free to point out if some shitcode is broken or need explaining. --- # TODO - [ ] I got ideas cooking that I don't know how to code --- # Changelog 🆑 tweak: Striking Calluses no longer require you to be one of 3 jobs and Human. Also increased the +1 damage to +2. tweak: Bionic Spinarette SHOULD no longer have a hunger penalty and costs less. tweak: Platelet Factories heal rate buffed from 0.07 to 0.35, airloss from 0.7 to 0.25 and healing cap increased from 200 to 400. tweak: Decreased the cost of Thermal Vision to be in line with Night Vision. tweak: IPC Platelet Factories healing cap increased from 200 to 250 tweak: Cyber-Eyes Omnihud now pickable by Command too. fix: Fixed name and description of Cyber-Eyes Modules for Night Vision and Thermal Vision. remove: Mind over Machine from Cyber-Eyes Modules. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - "Striking Calluses" now delivers increased unarmed strike damage, enhancing combat performance. - **Documentation** - Trait names and descriptions have been updated for greater clarity and consistency, including changes to "Cyber-Eyes" terminology. - **Chores** - Redundant trait options were removed from the selection pool to streamline gameplay. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Raikyr0 <Kurohana@hotmail.com.au> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit a480c6605ebdfdd32d87a9001f2aef8303433a8d) * Automatic Changelog Update (#1828) (cherry picked from commit 365dd4353a06854120e0a38ff05f193bad48bbc7) * Shadowkin Age Fixes & Plus Plushies (#1684) # Description Shadowkin middle-aged increased to 80, old age lowered to 175, max age lowered to 250. Shadowkin can now collect their goofy little plushie from a variety of sources --- # TODO - [x] Adjust Shadowkin age brackets - [x] Add Shadowkin plushie to crates and stuff --- # Changelog 🆑 ShirouAjisai - add: Added Shadowkin plushie to crates and stuff - tweak: Tweaked Shadowkin age brackets <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new "shadowkin plushie" loadout item, enhancing customization options. - Expanded the collectible pool by adding a new plushie available in multiple game areas, including reward systems and random spawners. - Enhanced the variety of items available for the `PresentRandom` entity with the addition of the "shadowkin plushie." - **Adjustments** - Refined life-stage parameters for the Shadowkin species, adjusting age thresholds to better define maturity. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: SixplyDev <einlichen@gmail.com> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: ShirouAjisai <zaneromeave319@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit fb3d00036f6a21d7fa3c4b41341cd61b1e41e0d0) * Automatic Changelog Update (#1684) (cherry picked from commit caf8572352d38f51b15d21f0e1f92434f869dd14) * Trait Add Tag (#1846) # Description Added TraitAddTag Function, which for example can be used to add Spidercraft to the Spinerette trait. # Changelog 🆑 - add: TraitAddTag Function <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Entities now receive automatic tag assignments at spawn, enhancing the system's trait interaction and overall categorization capabilities. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Raikyr0 <Kurohana@hotmail.com.au> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit b1acdc4017dc1181b7f557351e82ef1df93635c2) * Automatic Changelog Update (#1846) (cherry picked from commit 9622d443d5308eda14231c3b3bb3130884465272) * Arachne SpiderCrafting (#1847) # Description Added SpiderCraft Tag to Arachne # Changelog 🆑 - add: Added SpiderCraft to Arachne <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new "SpiderCraft" classification for the Urist McArachne entity, expanding its behavior and interactions related to spider-specific mechanisms. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Raikyr0 <Kurohana@hotmail.com.au> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit ff4146f879d397993eee22a2a4807e986e404641) * Automatic Changelog Update (#1847) (cherry picked from commit 91d40483c2c49f86d7b2609a5ac9cd7b30d16c00) * Add Centcom Disabler (#1845) <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> it self recharges a bit. It's also green. It's also a steal target, because it's green. I noticed the Nanotrasen Representative has a disabler in his locker by default, but does not get to pick one in a loadout. I figured I'd remedy this, by giving him a shiny green Disabler that slightly recharges on its own. It deals the same stamina damage as the normal Disabler. The only differences are: - Green - Steal Target - Slightly higher rate of fire - Slightly recharges itself (half as slow as the antique pistol) - Admits Centcom doesn't trust you with lethals in its description --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>   https://github.com/user-attachments/assets/f7eaff3d-b8b9-4954-9688-fb9ef0d04588  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Added CentCom disabler as loadout option for the Nanotrasen Representative. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Expanded loadout options for the Nanotrasen Representative role with a dedicated weapon configuration. - Introduced the "CentCom disabler," a new self-defense weapon option with advanced features. - Updated localization entries to reflect the new representative weapon grouping. - Added a new steal target group for the Nanotrasen representative's weapon. - Enhanced visual assets with updated animations and states for the new weapon. - Introduced new objectives related to the Nanotrasen Representative role, enhancing gameplay experiences. - Added the "Nanotrasen Representative" job title to localization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> (cherry picked from commit 143d24951a200ab94f3e4e88d3a3a90eeb8856ca) * Automatic Changelog Update (#1845) (cherry picked from commit 7ca0757334ee9a1d87c9cbf1f9cc02a860ecc136) * Plant Analyzer Port (#1849) <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Ported directly from https://github.com/Goob-Station/Goob-Station/pull/1685 I tweaked the sprite, and changed its usage of a Papersystem. I can't speak for the code quality, since I didn't write it, but I'm willing to fix things so long as I have the capability to do so. --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>    https://github.com/user-attachments/assets/0189567a-57ca-4e9d-ba0d-74e622e1d30d https://github.com/user-attachments/assets/25ea6100-1458-4804-98e4-5f70b6bfcd45 </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Port Plant Analyzer from botanySupremacist, who took it from ian321 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a comprehensive plant analyzer interface that displays detailed plant health, tray data, and environmental conditions. - Added an in-game report printing feature for easy access to analysis results. - **Enhancements** - Refined yield calculations and plant metabolism behaviors. - Integrated the analyzer item into crafting recipes, vending machines, and locker inventories. - Expanded localization for clearer, user-friendly plant analysis information. - Added new localization strings for printer status feedback. - Introduced new classes and messages for improved data handling and user interaction within the plant analyzer system. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Timfa <timfalken@hotmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit 47a55408ad92af463159dea3325edd0c9c9611ce) * Automatic Changelog Update (#1849) (cherry picked from commit 4da1efdfd293d5df1c8bd889c621eea94ed5fed8) * Mind Role Entities (#31318) * Mind Role Entities wip * headrev count fix * silicon stuff, cleanup * exclusive antag config, cleanup * jobroleadd overwerite * logging stuff * MindHasRole cleanup, admin log stuff * last second cleanup * ocd * minor cleanup * remove createdTime datafield * now actually using the event replacement I made for role time tracking * weh (cherry picked from commit 24fae223e698b09cf9928c4a0f2f1dc774f266ab) * Fix error (cherry picked from commit d33bf89a62ae2f5d51f3af01b4ae2ef54341b5c5) * Update SharedContentIoC.cs (cherry picked from commit a50fed2fee56b57d0507a58ebf7bc13de82ad9d2) * dragon antag refactor (#28217) * remove dragon system usage of GenericAntag * add AntagRandomSpawn for making antags spawn at a random tile * add AntagSpawner to make an antag spawner just spawn an entity * add antag prototype for dragon since it never had one * make dragon spawner a GhostRoleAntagSpawner, remove GenericAntag * make dragon rule use AntagSelection and stuff * remove dragon GenericAntag rule * add back to spawn menu --------- Co-authored-by: deltanedas <@deltanedas:kde.org> (cherry picked from commit c0a56377bc5b9563de973d04f92d7d6923ca9145) * Cultist Mind Roles (cherry picked from commit 585e26103a67cc2bd185faaa468ddc5840a8e9c3) * Update midround.yml (cherry picked from commit b78d24ce6bb7f8cb4a85a89f6f974fbce1d83055) * Update ghost_roles.yml (cherry picked from commit 22df7509b5c5113afc8f1ba168223b0756de5d47) * Solarian Alliance Content (#1851) # Description This PR acts as a proper introduction to players for the Sol Aliance faction, a major antagonist group from my old home server's lore. To do so, I've ported a large number of assets from Aurora.3 to this repo, as well as created a new Midround Antagonist called "Deserters", which shows off this group to players. <details><summary><h1>Media</h1></summary> <p>    </p> </details> # Changelog 🆑 - add: A new Midround Antagonist has been added to the game. The "Solarian Deserters" are a group of highly trained soldiers who haven't been paid for far too long, whom have come to the station to loot it for everything valuable. - add: Lore guidebook entry for the Solarian Alliance, a majorly antagonistic faction. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the "Solarian Navy Deserter" role with detailed localization, objectives, and traits. - Launched a dynamic shuttle event featuring interactive elements like secure doors, turret defenses, and specialized equipment. - Expanded gameplay with new storage options, tactical helmets, uniforms, identification cards, and door access tailored for the Sol Alliance. - Added a new NPC faction and game events enhancing combat and role-play dynamics. - Introduced various clothing items and uniforms associated with the Sol Alliance, including tactical gear and dress uniforms. - Added new metadata and structured entries for various clothing and equipment assets. - **Documentation** - Enriched lore and guidebook entries with expanded nation details, emphasizing the Solarian Alliance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit 6d919038f3845bb4008a17e1d068196779162f4a) * Automatic Changelog Update (#1851) (cherry picked from commit ffaf99ca4b01e63f6bb98731e630f066fad25909) * Supermatter Atmos Mapping Assets (#1859) # Description This adds "High Flow" variants of all existing atmos devices, which are useful for supermatter engines. I also added the ability for FixAtmosMarkers to optionally accept a gas mixture directly, as opposed to the stupid hardcoded gas mixes that they were limited to using previously. # Changelog 🆑 - add: Added high pressure variants of atmos devices intended for supermatter engines. - add: Added engineering locked high security doors, also for use in supermatter engines. - add: Fix Atmos markers can now accept a gas mixture directly for modifying their tile. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced atmospheric commands now dynamically use specific gas mixtures for more flexible performance. - Introduced a new supermatter coolant entity, offering an alternative liquid nitrogen-like option. - Added several high-pressure and high-flow gas components, including pumps, filters, mixers, vents, and injectors. - Updated map elements by refining door access prototypes and labels for improved in-game clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai --> (cherry picked from commit b9c3c8b366c15b5f09cfd641c90b09254f06de94) * Automatic Changelog Update (#1859) (cherry picked from commit 468a263863f17772e6233032e5099d6c83764616) * Rerotate Arena (#1853) <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Rerotates Arena. Adds an AI satellite, and maps a few station maps, cameras, and psionic registry computers. Adds myself as the maintainer for it. Do note that I am still learning how to map. Please state any changes that is wished to be seen before it is ready to merge. It is 3AM, I need sleep. --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [x] Space cleanup - [x] Psionic Registry Computers - [x] AI Satellite & Related Stuff --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Arena is back <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - The Arena map is now reactivated with updated configurations and active maintenance. - Enhanced gameplay details and role assignments have been enabled for a more engaging experience. - The configuration for the Arena map has been fully activated, including various roles and attributes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> (cherry picked from commit 534a058eb489ceb4abaadac7e4943ed2baaa8c67) * Automatic Changelog Update (#1853) (cherry picked from commit 3b30c0a1fe8dc5e10c3cb0536e26d101893663a2) * Port Grab Intent From Goob (#1856) # Description After months, Grab intent is finally ported to EE, as a result of a 4 hour Adderall induced code binge. ## This PR is more shit than code. Required for CQC, an attempt to port that will come later. @Erisfiregamer1 requires this for [Changelings](https://github.com/Simple-Station/Einstein-Engines/pull/1855). Thanks to Gus for the Goobstation pr, and to Spatison for the original port on WWDP Tests on my local repo worked. # TODO * [ ] Await review * [ ] pain # Media  # Changelog 🆑 Eagle * add: Ported Grab Intent from Goobstation <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced pulling and grabbing interactions now feature multiple stages that impact how actions and collisions feel. - Virtual item handling during throws and drops has been refined for more dynamic in-game outcomes. - Alert visuals have been updated to provide nuanced feedback depending on the intensity of pulls and grabs. - Player movement and breathing mechanics have been fine-tuned for more realistic behavior. - New localization strings deliver clearer, context-sensitive notifications for grab-related actions. - Introduced a new component and system for managing entities thrown while grabbed, including damage handling and visual effects. - New event classes enhance interaction handling for virtual items during grabbing actions. - **Bug Fixes** - Improved logic for stopping pull actions to ignore grab states when necessary. - **Chores** - Added metadata for new textures related to alerts in the user interface. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 18722e86f3190632026127af111dcc0d10d4af49) * Automatic Changelog Update (#1856) (cherry picked from commit 309ab74013fed2be64d9fb0457631210d860644b) * Port Role Types (#1860) Ports https://github.com/space-wizards/space-station-14/pull/33420 This is the last requirement before we can start mass-porting new antags. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced role displays in player and character interfaces with a new "Role Type" column. - Updated admin overlay options, including a classic antagonist label. - Expanded ghost role behaviors for various entities, offering more dynamic gameplay. - New localization entries for role types and UI settings for sounds and layout customization. - Added new mind roles and role types, improving role management and gameplay interactions. - Introduced new events for player spawning processes to enhance gameplay scenarios. - **Refactor** - Streamlined role management and update processes for improved reliability and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com> (cherry picked from commit e10c51cdb39845ed1f2bb9b08f0b226cefbd402e) * Rock And Stone <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Ports Lavaland and required systems from Goobstation. --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [X] Port over _Lavaland - [x] Port over required codepatches - [-] Test locally (Should be fine) - [X] Pass tests --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Lavaland has been ported! <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a dynamic mining voucher interface allowing players to redeem various mining kits. - Enhanced shuttle docking systems with an updated console interface for smoother FTL transitions. - Added immersive boss music management for enhanced in-game boss encounters. - Expanded Lavaland gameplay with new procedural map generation, weather events, and storm scheduling. - Integrated new interactive commands and UI improvements for advanced weapon upgrades, Hierophant boss actions, and research features. - Added new components and systems for managing various gameplay elements, including damage squares, tendrils, and block charges. - Implemented new localization entries for improved player experience across various game features. - Introduced new components for managing mining vendors and vouchers, enhancing the interaction with mining kits. - Added a new system for managing the deployment of shelter capsules in the Lavaland environment. - **Tests** - Added integration tests to validate Lavaland planet generation and map initialization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit f2f5d4610db795a124b37780230eec5d5ca0264a) * Automatic Changelog Update (#1844) (cherry picked from commit 990878b9ed60b4e22388038b63714ec2dc693bbf) * fixs * fix * fuck --------- Co-authored-by: Tonk-GCR <190437025+Tonk-GCR@users.noreply.github.com> Co-authored-by: SimpleStation Changelogs <SimpleStation14@users.noreply.github.com> Co-authored-by: Raikyr0 <kurohana@hotmail.com.au> Co-authored-by: SixplyDev <einlichen@gmail.com> Co-authored-by: Timfa <timfalken@hotmail.com> Co-authored-by: Errant <35878406+errant-4@users.noreply.github.com> Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: astriloqua <129308840+astriloqua@users.noreply.github.com> Co-authored-by: Eagle-0 <114363363+Eagle-0@users.noreply.github.com> Co-authored-by: Eris <eris@erisws.com>
894 lines
33 KiB
C#
894 lines
33 KiB
C#
using System.Numerics;
|
|
using Content.Server.Atmos.EntitySystems;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Explosion;
|
|
using Content.Shared.Explosion.Components;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Physics;
|
|
using Content.Shared.Projectiles;
|
|
using Content.Shared.Tag;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
|
|
using Content.Server.Atmos.Components;
|
|
using Content.Server.Atmos.EntitySystems;
|
|
|
|
namespace Content.Server.Explosion.EntitySystems;
|
|
|
|
public sealed partial class ExplosionSystem
|
|
{
|
|
[Dependency] private readonly FlammableSystem _flammableSystem = default!;
|
|
|
|
/// <summary>
|
|
/// Used to limit explosion processing time. See <see cref="MaxProcessingTime"/>.
|
|
/// </summary>
|
|
internal readonly Stopwatch Stopwatch = new();
|
|
|
|
/// <summary>
|
|
/// How many tiles to explode before checking the stopwatch timer
|
|
/// </summary>
|
|
internal static int TileCheckIteration = 1;
|
|
|
|
/// <summary>
|
|
/// Queue for delayed processing of explosions. If there is an explosion that covers more than <see
|
|
/// cref="TilesPerTick"/> tiles, other explosions will actually be delayed slightly. Unless it's a station
|
|
/// nuke, this delay should never really be noticeable.
|
|
/// This is also used to combine explosion intensities of the same kind.
|
|
/// </summary>
|
|
private Queue<QueuedExplosion> _explosionQueue = new();
|
|
|
|
/// <summary>
|
|
/// All queued explosions that will be processed in <see cref="_explosionQueue"/>.
|
|
/// These always have the same contents.
|
|
/// </summary>
|
|
private HashSet<QueuedExplosion> _queuedExplosions = new();
|
|
|
|
/// <summary>
|
|
/// The explosion currently being processed.
|
|
/// </summary>
|
|
private Explosion? _activeExplosion;
|
|
|
|
/// <summary>
|
|
/// This list is used when raising <see cref="BeforeExplodeEvent"/> to avoid allocating a new list per event.
|
|
/// </summary>
|
|
private readonly List<EntityUid> _containedEntities = new();
|
|
|
|
private readonly List<(EntityUid, DamageSpecifier)> _toDamage = new();
|
|
|
|
private List<EntityUid> _anchored = new();
|
|
|
|
private void OnMapChanged(MapChangedEvent ev)
|
|
{
|
|
// If a map was deleted, check the explosion currently being processed belongs to that map.
|
|
if (ev.Created)
|
|
return;
|
|
|
|
if (_activeExplosion?.Epicenter.MapId != ev.Map)
|
|
return;
|
|
|
|
QueueDel(_activeExplosion.VisualEnt);
|
|
_activeExplosion = null;
|
|
_nodeGroupSystem.PauseUpdating = false;
|
|
_pathfindingSystem.PauseUpdating = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process the explosion queue.
|
|
/// </summary>
|
|
public override void Update(float frameTime)
|
|
{
|
|
if (_activeExplosion == null && _explosionQueue.Count == 0)
|
|
// nothing to do
|
|
return;
|
|
|
|
Stopwatch.Restart();
|
|
var x = Stopwatch.Elapsed.TotalMilliseconds;
|
|
|
|
var tilesRemaining = TilesPerTick;
|
|
while (tilesRemaining > 0 && MaxProcessingTime > Stopwatch.Elapsed.TotalMilliseconds)
|
|
{
|
|
// if there is no active explosion, get a new one to process
|
|
if (_activeExplosion == null)
|
|
{
|
|
// EXPLOSION TODO allow explosion spawning to be interrupted by time limit. In the meantime, ensure that
|
|
// there is at-least 1ms of time left before creating a new explosion
|
|
if (MathF.Max(MaxProcessingTime - 1, 0.1f) < Stopwatch.Elapsed.TotalMilliseconds)
|
|
break;
|
|
|
|
if (!_explosionQueue.TryDequeue(out var queued))
|
|
break;
|
|
|
|
_queuedExplosions.Remove(queued);
|
|
_activeExplosion = SpawnExplosion(queued);
|
|
|
|
// explosion spawning can be null if something somewhere went wrong. (e.g., negative explosion
|
|
// intensity).
|
|
if (_activeExplosion == null)
|
|
continue;
|
|
|
|
// just a lil nap
|
|
if (SleepNodeSys)
|
|
{
|
|
_nodeGroupSystem.PauseUpdating = true;
|
|
_pathfindingSystem.PauseUpdating = true;
|
|
// snooze grid-chunk regeneration?
|
|
// snooze power network (recipients look for new suppliers as wires get destroyed).
|
|
}
|
|
|
|
if (_activeExplosion.Area > SingleTickAreaLimit)
|
|
break; // start processing next turn.
|
|
}
|
|
|
|
// TODO EXPLOSION check if active explosion is on a paused map. If it is... I guess support swapping out &
|
|
// storing the "currently active" explosion?
|
|
|
|
#if EXCEPTION_TOLERANCE
|
|
try
|
|
{
|
|
#endif
|
|
var processed = _activeExplosion.Process(tilesRemaining);
|
|
tilesRemaining -= processed;
|
|
|
|
// has the explosion finished processing?
|
|
if (_activeExplosion.FinishedProcessing)
|
|
{
|
|
var comp = EnsureComp<TimedDespawnComponent>(_activeExplosion.VisualEnt);
|
|
comp.Lifetime = _cfg.GetCVar(CCVars.ExplosionPersistence);
|
|
_appearance.SetData(_activeExplosion.VisualEnt, ExplosionAppearanceData.Progress, int.MaxValue);
|
|
_activeExplosion = null;
|
|
}
|
|
#if EXCEPTION_TOLERANCE
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Ensure the system does not get stuck in an error-loop.
|
|
if (_activeExplosion != null)
|
|
QueueDel(_activeExplosion.VisualEnt);
|
|
_activeExplosion = null;
|
|
_nodeGroupSystem.PauseUpdating = false;
|
|
_pathfindingSystem.PauseUpdating = false;
|
|
throw;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
Log.Info($"Processed {TilesPerTick - tilesRemaining} tiles in {Stopwatch.Elapsed.TotalMilliseconds}ms");
|
|
|
|
// we have finished processing our tiles. Is there still an ongoing explosion?
|
|
if (_activeExplosion != null)
|
|
{
|
|
_appearance.SetData(_activeExplosion.VisualEnt, ExplosionAppearanceData.Progress, _activeExplosion.CurrentIteration + 1);
|
|
return;
|
|
}
|
|
|
|
if (_explosionQueue.Count > 0)
|
|
return;
|
|
|
|
//wakey wakey
|
|
_nodeGroupSystem.PauseUpdating = false;
|
|
_pathfindingSystem.PauseUpdating = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether an entity is blocking a tile or not. (whether it can prevent the tile from being uprooted
|
|
/// by an explosion).
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Used for a variation of <see cref="TurfHelpers.IsBlockedTurf()"/> that makes use of the fact that we have
|
|
/// already done an entity lookup on a tile, and don't need to do so again.
|
|
/// </remarks>
|
|
public bool IsBlockingTurf(EntityUid uid)
|
|
{
|
|
if (EntityManager.IsQueuedForDeletion(uid))
|
|
return false;
|
|
|
|
if (!_physicsQuery.TryGetComponent(uid, out var physics))
|
|
return false;
|
|
|
|
return physics.CanCollide && physics.Hard && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Find entities on a grid tile using the EntityLookupComponent and apply explosion effects.
|
|
/// </summary>
|
|
/// <returns>True if the underlying tile can be uprooted, false if the tile is blocked by a dense entity</returns>
|
|
internal bool ExplodeTile(BroadphaseComponent lookup,
|
|
Entity<MapGridComponent> grid,
|
|
Vector2i tile,
|
|
float throwForce,
|
|
DamageSpecifier damage,
|
|
MapCoordinates epicenter,
|
|
HashSet<EntityUid> processed,
|
|
string id,
|
|
float? fireStacks)
|
|
{
|
|
var size = grid.Comp.TileSize;
|
|
var gridBox = new Box2(tile * size, (tile + 1) * size);
|
|
|
|
// get the entities on a tile. Note that we cannot process them directly, or we get
|
|
// enumerator-changed-while-enumerating errors.
|
|
List<(EntityUid, TransformComponent)> list = new();
|
|
var state = (list, processed, _transformQuery);
|
|
|
|
// get entities:
|
|
lookup.DynamicTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
lookup.StaticTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
lookup.SundriesTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
lookup.StaticSundriesTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
|
|
// process those entities
|
|
foreach (var (uid, xform) in list)
|
|
{
|
|
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
|
|
}
|
|
|
|
// process anchored entities
|
|
var tileBlocked = false;
|
|
_anchored.Clear();
|
|
_map.GetAnchoredEntities(grid, tile, _anchored);
|
|
foreach (var entity in _anchored)
|
|
{
|
|
processed.Add(entity);
|
|
ProcessEntity(entity, epicenter, damage, throwForce, id, null, fireStacks);
|
|
}
|
|
|
|
// Walls and reinforced walls will break into girders. These girders will also be considered turf-blocking for
|
|
// the purposes of destroying floors. Again, ideally the process of damaging an entity should somehow return
|
|
// information about the entities that were spawned as a result, but without that information we just have to
|
|
// re-check for new anchored entities. Compared to entity spawning & deleting, this should still be relatively minor.
|
|
if (_anchored.Count > 0)
|
|
{
|
|
_anchored.Clear();
|
|
_map.GetAnchoredEntities(grid, tile, _anchored);
|
|
foreach (var entity in _anchored)
|
|
{
|
|
tileBlocked |= IsBlockingTurf(entity);
|
|
}
|
|
}
|
|
|
|
// Next, we get the intersecting entities AGAIN, but purely for throwing. This way, glass shards spawned from
|
|
// windows will be flung outwards, and not stay where they spawned. This is however somewhat unnecessary, and a
|
|
// prime candidate for computational cost-cutting. Alternatively, it would be nice if there was just some sort
|
|
// of spawned-on-destruction event that could be used to automatically assemble a list of new entities that need
|
|
// to be thrown.
|
|
//
|
|
// All things considered, until entity spawning & destruction is sped up, this isn't all that time consuming.
|
|
// And throwing is disabled for nukes anyways.
|
|
if (throwForce <= 0)
|
|
return !tileBlocked;
|
|
|
|
list.Clear();
|
|
lookup.DynamicTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
lookup.SundriesTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
|
|
|
|
foreach (var (uid, xform) in list)
|
|
{
|
|
// Here we only throw, no dealing damage. Containers n such might drop their entities after being destroyed, but
|
|
// they should handle their own damage pass-through, with their own damage reduction calculation.
|
|
ProcessEntity(uid, epicenter, null, throwForce, id, xform, null);
|
|
}
|
|
|
|
return !tileBlocked;
|
|
}
|
|
|
|
private static bool GridQueryCallback(
|
|
ref (List<(EntityUid, TransformComponent)> List, HashSet<EntityUid> Processed, EntityQuery<TransformComponent> XformQuery) state,
|
|
in EntityUid uid)
|
|
{
|
|
if (state.Processed.Add(uid) && state.XformQuery.TryGetComponent(uid, out var xform))
|
|
state.List.Add((uid, xform));
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool GridQueryCallback(
|
|
ref (List<(EntityUid, TransformComponent)> List, HashSet<EntityUid> Processed, EntityQuery<TransformComponent> XformQuery) state,
|
|
in FixtureProxy proxy)
|
|
{
|
|
var owner = proxy.Entity;
|
|
return GridQueryCallback(ref state, in owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Same as <see cref="ExplodeTile"/>, but for SPAAAAAAACE.
|
|
/// </summary>
|
|
internal void ExplodeSpace(BroadphaseComponent lookup,
|
|
Matrix3x2 spaceMatrix,
|
|
Matrix3x2 invSpaceMatrix,
|
|
Vector2i tile,
|
|
float throwForce,
|
|
DamageSpecifier damage,
|
|
MapCoordinates epicenter,
|
|
HashSet<EntityUid> processed,
|
|
string id,
|
|
float? fireStacks)
|
|
{
|
|
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, new Vector2(DefaultTileSize, DefaultTileSize));
|
|
var worldBox = spaceMatrix.TransformBox(gridBox);
|
|
var list = new List<(EntityUid, TransformComponent)>();
|
|
var state = (list, processed, invSpaceMatrix, lookup.Owner, _transformQuery, gridBox, _transformSystem);
|
|
|
|
// get entities:
|
|
lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
lookup.StaticTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
lookup.StaticSundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
|
|
foreach (var (uid, xform) in state.Item1)
|
|
{
|
|
processed.Add(uid);
|
|
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
|
|
}
|
|
|
|
if (throwForce <= 0)
|
|
return;
|
|
|
|
// Also, throw any entities that were spawned as shrapnel. Compared to entity spawning & destruction, this extra
|
|
// lookup is relatively minor computational cost, and throwing is disabled for nukes anyways.
|
|
list.Clear();
|
|
lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
|
|
|
foreach (var (uid, xform) in list)
|
|
{
|
|
ProcessEntity(uid, epicenter, null, throwForce, id, xform, fireStacks);
|
|
}
|
|
}
|
|
|
|
private static bool SpaceQueryCallback(
|
|
ref (List<(EntityUid, TransformComponent)> List, HashSet<EntityUid> Processed, Matrix3x2 InvSpaceMatrix, EntityUid LookupOwner, EntityQuery<TransformComponent> XformQuery, Box2 GridBox, SharedTransformSystem System) state,
|
|
in EntityUid uid)
|
|
{
|
|
if (state.Processed.Contains(uid))
|
|
return true;
|
|
|
|
var xform = state.XformQuery.GetComponent(uid);
|
|
|
|
if (xform.ParentUid == state.LookupOwner)
|
|
{
|
|
// parented directly to the map, use local position
|
|
if (state.GridBox.Contains(Vector2.Transform(xform.LocalPosition, state.InvSpaceMatrix)))
|
|
state.List.Add((uid, xform));
|
|
|
|
return true;
|
|
}
|
|
|
|
// finally check if it intersects our tile
|
|
var wpos = state.System.GetWorldPosition(xform);
|
|
if (state.GridBox.Contains(Vector2.Transform(wpos, state.InvSpaceMatrix)))
|
|
state.List.Add((uid, xform));
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool SpaceQueryCallback(
|
|
ref (List<(EntityUid, TransformComponent)> List, HashSet<EntityUid> Processed, Matrix3x2 InvSpaceMatrix, EntityUid LookupOwner, EntityQuery<TransformComponent> XformQuery, Box2 GridBox, SharedTransformSystem System) state,
|
|
in FixtureProxy proxy)
|
|
{
|
|
var uid = proxy.Entity;
|
|
return SpaceQueryCallback(ref state, in uid);
|
|
}
|
|
|
|
private DamageSpecifier GetDamage(EntityUid uid,
|
|
string id, DamageSpecifier damage)
|
|
{
|
|
// TODO Explosion Performance
|
|
// Cache this? I.e., instead of raising an event, check for a component?
|
|
var resistanceEv = new GetExplosionResistanceEvent(id);
|
|
RaiseLocalEvent(uid, ref resistanceEv);
|
|
resistanceEv.DamageCoefficient = Math.Max(0, resistanceEv.DamageCoefficient);
|
|
|
|
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
|
if (resistanceEv.DamageCoefficient != 1)
|
|
damage *= resistanceEv.DamageCoefficient;
|
|
|
|
return damage;
|
|
}
|
|
|
|
private void GetEntitiesToDamage(EntityUid uid, DamageSpecifier originalDamage, string prototype)
|
|
{
|
|
_toDamage.Clear();
|
|
|
|
// don't raise BeforeExplodeEvent if the entity is completely immune to explosions
|
|
var thisDamage = GetDamage(uid, prototype, originalDamage);
|
|
if (thisDamage.Empty)
|
|
return;
|
|
|
|
_toDamage.Add((uid, thisDamage));
|
|
|
|
for (var i = 0; i < _toDamage.Count; i++)
|
|
{
|
|
var (ent, damage) = _toDamage[i];
|
|
_containedEntities.Clear();
|
|
var ev = new BeforeExplodeEvent(damage, prototype, _containedEntities);
|
|
RaiseLocalEvent(ent, ref ev);
|
|
|
|
if (_containedEntities.Count == 0)
|
|
continue;
|
|
|
|
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
|
if (ev.DamageCoefficient != 1)
|
|
damage *= ev.DamageCoefficient;
|
|
|
|
_toDamage.EnsureCapacity(_toDamage.Count + _containedEntities.Count);
|
|
foreach (var contained in _containedEntities)
|
|
{
|
|
var newDamage = GetDamage(contained, prototype, damage);
|
|
_toDamage.Add((contained, newDamage));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// This function actually applies the explosion affects to an entity.
|
|
/// </summary>
|
|
private void ProcessEntity(
|
|
EntityUid uid,
|
|
MapCoordinates epicenter,
|
|
DamageSpecifier? originalDamage,
|
|
float throwForce,
|
|
string id,
|
|
TransformComponent? xform,
|
|
float? fireStacksOnIgnite)
|
|
{
|
|
if (originalDamage != null)
|
|
{
|
|
GetEntitiesToDamage(uid, originalDamage, id);
|
|
foreach (var (entity, damage) in _toDamage)
|
|
{
|
|
// TODO EXPLOSIONS turn explosions into entities, and pass the the entity in as the damage origin.
|
|
_damageableSystem.TryChangeDamage(entity, damage, ignoreResistances: true, partMultiplier: 0.3f); // Shitmed: Temp change, nerf explosion delimbing
|
|
|
|
}
|
|
}
|
|
|
|
// ignite
|
|
if (fireStacksOnIgnite != null)
|
|
{
|
|
if (_flammableQuery.TryGetComponent(uid, out var flammable))
|
|
{
|
|
flammable.FireStacks += fireStacksOnIgnite.Value;
|
|
_flammableSystem.Ignite(uid, uid, flammable);
|
|
}
|
|
}
|
|
|
|
// throw
|
|
if (xform != null // null implies anchored or in a container
|
|
&& !xform.Anchored
|
|
&& throwForce > 0
|
|
&& !EntityManager.IsQueuedForDeletion(uid)
|
|
&& _physicsQuery.TryGetComponent(uid, out var physics)
|
|
&& physics.BodyType == BodyType.Dynamic)
|
|
{
|
|
var pos = _transformSystem.GetWorldPosition(xform);
|
|
_throwingSystem.TryThrow(
|
|
uid,
|
|
pos - epicenter.Position,
|
|
physics,
|
|
xform,
|
|
_projectileQuery,
|
|
throwForce);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to damage floor tiles. Not to be confused with the function that damages entities intersecting the
|
|
/// grid tile.
|
|
/// </summary>
|
|
public void DamageFloorTile(TileRef tileRef,
|
|
float effectiveIntensity,
|
|
int maxTileBreak,
|
|
bool canCreateVacuum,
|
|
List<(Vector2i GridIndices, Tile Tile)> damagedTiles,
|
|
ExplosionPrototype type)
|
|
{
|
|
if (_tileDefinitionManager[tileRef.Tile.TypeId] is not ContentTileDefinition tileDef)
|
|
return;
|
|
|
|
if (!CanCreateVacuum)
|
|
canCreateVacuum = false;
|
|
else if (tileDef.MapAtmosphere)
|
|
canCreateVacuum = true; // is already a vacuum.
|
|
|
|
int tileBreakages = 0;
|
|
while (maxTileBreak > tileBreakages && _robustRandom.Prob(type.TileBreakChance(effectiveIntensity)))
|
|
{
|
|
tileBreakages++;
|
|
effectiveIntensity -= type.TileBreakRerollReduction;
|
|
|
|
// does this have a base-turf that we can break it down to?
|
|
if (string.IsNullOrEmpty(tileDef.BaseTurf))
|
|
break;
|
|
|
|
if (_tileDefinitionManager[tileDef.BaseTurf] is not ContentTileDefinition newDef)
|
|
break;
|
|
|
|
if (newDef.MapAtmosphere && !canCreateVacuum)
|
|
break;
|
|
|
|
tileDef = newDef;
|
|
}
|
|
|
|
if (tileDef.TileId == tileRef.Tile.TypeId)
|
|
return;
|
|
|
|
damagedTiles.Add((tileRef.GridIndices, new Tile(tileDef.TileId)));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// This is a data class that stores information about the area affected by an explosion, for processing by <see
|
|
/// cref="ExplosionSystem"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is basically the output of <see cref="ExplosionSystem.GetExplosionTiles()"/>, but with some utility functions for
|
|
/// iterating over the tiles, along with the ability to keep track of what entities have already been damaged by
|
|
/// this explosion.
|
|
/// </remarks>
|
|
sealed class Explosion
|
|
{
|
|
/// <summary>
|
|
/// For every grid (+ space) that the explosion reached, this data struct stores information about the tiles and
|
|
/// caches the entity-lookup component so that it doesn't have to be re-fetched for every tile.
|
|
/// </summary>
|
|
struct ExplosionData
|
|
{
|
|
/// <summary>
|
|
/// The tiles that the explosion damaged, grouped by the iteration (can be thought of as the distance from the epicenter)
|
|
/// </summary>
|
|
public Dictionary<int, List<Vector2i>> TileLists;
|
|
|
|
/// <summary>
|
|
/// Lookup component for this grid (or space/map).
|
|
/// </summary>
|
|
public BroadphaseComponent Lookup;
|
|
|
|
/// <summary>
|
|
/// The actual grid that this corresponds to. If null, this implies space.
|
|
/// </summary>
|
|
public MapGridComponent? MapGrid;
|
|
}
|
|
|
|
private readonly List<ExplosionData> _explosionData = new();
|
|
|
|
/// <summary>
|
|
/// The explosion intensity associated with each tile iteration.
|
|
/// </summary>
|
|
private readonly List<float> _tileSetIntensity;
|
|
|
|
/// <summary>
|
|
/// Used to avoid applying explosion effects repeatedly to the same entity. Particularly important if the
|
|
/// explosion throws this entity, as then it will be moving while the explosion is happening.
|
|
/// </summary>
|
|
public readonly HashSet<EntityUid> ProcessedEntities = new();
|
|
|
|
/// <summary>
|
|
/// This integer tracks how much of this explosion has been processed.
|
|
/// </summary>
|
|
public int CurrentIteration { get; private set; } = 0;
|
|
|
|
/// <summary>
|
|
/// The prototype for this explosion. Determines tile break chance, damage, etc.
|
|
/// </summary>
|
|
public readonly ExplosionPrototype ExplosionType;
|
|
|
|
/// <summary>
|
|
/// The center of the explosion. Used for physics throwing. Also used to identify the map on which the explosion is happening.
|
|
/// </summary>
|
|
public readonly MapCoordinates Epicenter;
|
|
|
|
/// <summary>
|
|
/// The matrix that defines the reference frame for the explosion in space.
|
|
/// </summary>
|
|
private readonly Matrix3x2 _spaceMatrix;
|
|
|
|
/// <summary>
|
|
/// Inverse of <see cref="_spaceMatrix"/>
|
|
/// </summary>
|
|
private readonly Matrix3x2 _invSpaceMatrix;
|
|
|
|
/// <summary>
|
|
/// Have all the tiles on all the grids been processed?
|
|
/// </summary>
|
|
public bool FinishedProcessing;
|
|
|
|
// Variables used for enumerating over tiles, grids, etc
|
|
private DamageSpecifier _currentDamage = default!;
|
|
#if DEBUG
|
|
private DamageSpecifier? _expectedDamage;
|
|
#endif
|
|
private BroadphaseComponent _currentLookup = default!;
|
|
private MapGridComponent? _currentGrid;
|
|
private float _currentIntensity;
|
|
private float _currentThrowForce;
|
|
private List<Vector2i>.Enumerator _currentEnumerator;
|
|
private int _currentDataIndex;
|
|
|
|
/// <summary>
|
|
/// The set of tiles that need to be updated when the explosion has finished processing. Used to avoid having
|
|
/// the explosion trigger chunk regeneration & shuttle-system processing every tick.
|
|
/// </summary>
|
|
private readonly Dictionary<MapGridComponent, List<(Vector2i, Tile)>> _tileUpdateDict = new();
|
|
|
|
// Entity Queries
|
|
private readonly EntityQuery<TransformComponent> _xformQuery;
|
|
private readonly EntityQuery<PhysicsComponent> _physicsQuery;
|
|
private readonly EntityQuery<DamageableComponent> _damageQuery;
|
|
private readonly EntityQuery<ProjectileComponent> _projectileQuery;
|
|
private readonly EntityQuery<TagComponent> _tagQuery;
|
|
|
|
/// <summary>
|
|
/// Total area that the explosion covers.
|
|
/// </summary>
|
|
public readonly int Area;
|
|
|
|
/// <summary>
|
|
/// factor used to scale the tile break chances.
|
|
/// </summary>
|
|
private readonly float _tileBreakScale;
|
|
|
|
/// <summary>
|
|
/// Maximum number of times that an explosion will break a single tile.
|
|
/// </summary>
|
|
private readonly int _maxTileBreak;
|
|
|
|
/// <summary>
|
|
/// Whether this explosion can turn non-vacuum tiles into vacuum-tiles.
|
|
/// </summary>
|
|
private readonly bool _canCreateVacuum;
|
|
|
|
private readonly IEntityManager _entMan;
|
|
private readonly ExplosionSystem _system;
|
|
|
|
public readonly EntityUid VisualEnt;
|
|
|
|
/// <summary>
|
|
/// Initialize a new instance for processing
|
|
/// </summary>
|
|
public Explosion(ExplosionSystem system,
|
|
ExplosionPrototype explosionType,
|
|
ExplosionSpaceTileFlood? spaceData,
|
|
List<ExplosionGridTileFlood> gridData,
|
|
List<float> tileSetIntensity,
|
|
MapCoordinates epicenter,
|
|
Matrix3x2 spaceMatrix,
|
|
int area,
|
|
float tileBreakScale,
|
|
int maxTileBreak,
|
|
bool canCreateVacuum,
|
|
IEntityManager entMan,
|
|
IMapManager mapMan,
|
|
EntityUid visualEnt)
|
|
{
|
|
VisualEnt = visualEnt;
|
|
_system = system;
|
|
ExplosionType = explosionType;
|
|
_tileSetIntensity = tileSetIntensity;
|
|
Epicenter = epicenter;
|
|
Area = area;
|
|
|
|
_tileBreakScale = tileBreakScale;
|
|
_maxTileBreak = maxTileBreak;
|
|
_canCreateVacuum = canCreateVacuum;
|
|
_entMan = entMan;
|
|
|
|
_xformQuery = entMan.GetEntityQuery<TransformComponent>();
|
|
_physicsQuery = entMan.GetEntityQuery<PhysicsComponent>();
|
|
_damageQuery = entMan.GetEntityQuery<DamageableComponent>();
|
|
_tagQuery = entMan.GetEntityQuery<TagComponent>();
|
|
_projectileQuery = entMan.GetEntityQuery<ProjectileComponent>();
|
|
|
|
if (spaceData != null)
|
|
{
|
|
var mapUid = mapMan.GetMapEntityId(epicenter.MapId);
|
|
|
|
_explosionData.Add(new()
|
|
{
|
|
TileLists = spaceData.TileLists,
|
|
Lookup = entMan.GetComponent<BroadphaseComponent>(mapUid),
|
|
MapGrid = null
|
|
});
|
|
|
|
_spaceMatrix = spaceMatrix;
|
|
Matrix3x2.Invert(spaceMatrix, out _invSpaceMatrix);
|
|
}
|
|
|
|
foreach (var grid in gridData)
|
|
{
|
|
_explosionData.Add(new ExplosionData
|
|
{
|
|
TileLists = grid.TileLists,
|
|
Lookup = entMan.GetComponent<BroadphaseComponent>(grid.Grid.Owner),
|
|
MapGrid = grid.Grid,
|
|
});
|
|
}
|
|
|
|
if (TryGetNextTileEnumerator())
|
|
MoveNext();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Find the next tile-enumerator. This either means retrieving a set of tiles on the next grid, or incrementing
|
|
/// the tile iteration by one and moving back to the first grid. This will also update the current damage, current entity-lookup, etc.
|
|
/// </summary>
|
|
private bool TryGetNextTileEnumerator()
|
|
{
|
|
while (CurrentIteration < _tileSetIntensity.Count)
|
|
{
|
|
_currentIntensity = _tileSetIntensity[CurrentIteration];
|
|
|
|
#if DEBUG
|
|
if (_expectedDamage != null)
|
|
{
|
|
// Check that explosion processing hasn't somehow accidentally mutated the damage set.
|
|
DebugTools.Assert(_expectedDamage.Equals(_currentDamage));
|
|
_expectedDamage = ExplosionType.DamagePerIntensity * _currentIntensity;
|
|
}
|
|
#endif
|
|
|
|
_currentDamage = ExplosionType.DamagePerIntensity * _currentIntensity;
|
|
|
|
// only throw if either the explosion is small, or if this is the outer ring of a large explosion.
|
|
var doThrow = Area < _system.ThrowLimit || CurrentIteration > _tileSetIntensity.Count - 6;
|
|
_currentThrowForce = doThrow ? 10 * MathF.Sqrt(_currentIntensity) : 0;
|
|
|
|
// for each grid/space tile set
|
|
while (_currentDataIndex < _explosionData.Count)
|
|
{
|
|
// try get any tile hash-set corresponding to this intensity
|
|
var tileSets = _explosionData[_currentDataIndex].TileLists;
|
|
if (!tileSets.TryGetValue(CurrentIteration, out var tileList))
|
|
{
|
|
_currentDataIndex++;
|
|
continue;
|
|
}
|
|
|
|
_currentEnumerator = tileList.GetEnumerator();
|
|
_currentLookup = _explosionData[_currentDataIndex].Lookup;
|
|
_currentGrid = _explosionData[_currentDataIndex].MapGrid;
|
|
_currentDataIndex++;
|
|
|
|
// sanity checks, in case something changed while the explosion was being processed over several ticks.
|
|
if (_currentLookup.Deleted || _currentGrid != null && !_entMan.EntityExists(_currentGrid.Owner))
|
|
continue;
|
|
|
|
return true;
|
|
}
|
|
|
|
// All the tiles belonging to this explosion iteration have been processed. Move onto the next iteration and
|
|
// reset the grid counter.
|
|
CurrentIteration++;
|
|
_currentDataIndex = 0;
|
|
}
|
|
|
|
// No more explosion tiles to process
|
|
FinishedProcessing = true;
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the next tile that needs processing
|
|
/// </summary>
|
|
private bool MoveNext()
|
|
{
|
|
if (FinishedProcessing)
|
|
return false;
|
|
|
|
while (!FinishedProcessing)
|
|
{
|
|
if (_currentEnumerator.MoveNext())
|
|
return true;
|
|
else
|
|
TryGetNextTileEnumerator();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempt to process (i.e., damage entities) some number of grid tiles.
|
|
/// </summary>
|
|
public int Process(int processingTarget)
|
|
{
|
|
// In case the explosion terminated early last tick due to exceeding the allocated processing time, use this
|
|
// time to update the tiles.
|
|
SetTiles();
|
|
|
|
int processed;
|
|
for (processed = 0; processed < processingTarget; processed++)
|
|
{
|
|
if (processed % ExplosionSystem.TileCheckIteration == 0 &&
|
|
_system.Stopwatch.Elapsed.TotalMilliseconds > _system.MaxProcessingTime)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// Is the current tile on a grid (instead of in space)?
|
|
if (_currentGrid != null &&
|
|
_currentGrid.TryGetTileRef(_currentEnumerator.Current, out var tileRef) &&
|
|
!tileRef.Tile.IsEmpty)
|
|
{
|
|
if (!_tileUpdateDict.TryGetValue(_currentGrid, out var tileUpdateList))
|
|
{
|
|
tileUpdateList = new();
|
|
_tileUpdateDict[_currentGrid] = tileUpdateList;
|
|
}
|
|
|
|
// damage entities on the tile. Also figures out whether there are any solid entities blocking the floor
|
|
// from being destroyed.
|
|
var canDamageFloor = _system.ExplodeTile(_currentLookup,
|
|
(_currentGrid.Owner, _currentGrid),
|
|
_currentEnumerator.Current,
|
|
_currentThrowForce,
|
|
_currentDamage,
|
|
Epicenter,
|
|
ProcessedEntities,
|
|
ExplosionType.ID,
|
|
ExplosionType.FireStacks);
|
|
|
|
// If the floor is not blocked by some dense object, damage the floor tiles.
|
|
if (canDamageFloor)
|
|
_system.DamageFloorTile(tileRef, _currentIntensity * _tileBreakScale, _maxTileBreak, _canCreateVacuum, tileUpdateList, ExplosionType);
|
|
}
|
|
else
|
|
{
|
|
// The current "tile" is in space. Damage any entities in that region
|
|
_system.ExplodeSpace(_currentLookup,
|
|
_spaceMatrix,
|
|
_invSpaceMatrix,
|
|
_currentEnumerator.Current,
|
|
_currentThrowForce,
|
|
_currentDamage,
|
|
Epicenter,
|
|
ProcessedEntities,
|
|
ExplosionType.ID,
|
|
ExplosionType.FireStacks);
|
|
}
|
|
|
|
if (!MoveNext())
|
|
break;
|
|
}
|
|
|
|
// Update damaged/broken tiles on the grid.
|
|
SetTiles();
|
|
return processed;
|
|
}
|
|
|
|
private void SetTiles()
|
|
{
|
|
// Updating the grid can result in chunk collision regeneration & slow processing by the shuttle system.
|
|
// Therefore, tile breaking may be configure to only happen at the end of an explosion, rather than during every
|
|
// tick.
|
|
if (!_system.IncrementalTileBreaking && !FinishedProcessing)
|
|
return;
|
|
|
|
foreach (var (grid, list) in _tileUpdateDict)
|
|
{
|
|
if (list.Count > 0 && _entMan.EntityExists(grid.Owner))
|
|
{
|
|
grid.SetTiles(list);
|
|
}
|
|
}
|
|
_tileUpdateDict.Clear();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Data needed to spawn an explosion with <see cref="ExplosionSystem.SpawnExplosion"/>.
|
|
/// </summary>
|
|
public sealed class QueuedExplosion
|
|
{
|
|
public MapCoordinates Epicenter;
|
|
public ExplosionPrototype Proto = new();
|
|
public float TotalIntensity, Slope, MaxTileIntensity, TileBreakScale;
|
|
public int MaxTileBreak;
|
|
public bool CanCreateVacuum;
|
|
}
|