Files
OldThink/Content.Client/Atmos/Overlays/GasTileOverlay.cs

292 lines
12 KiB
C#
Raw Normal View History

using System.Numerics;
2023-06-28 21:22:03 +10:00
using Content.Client.Atmos.Components;
Atmos pipe rework (#3833) * Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
2021-06-19 13:25:05 +02:00
using Content.Client.Atmos.EntitySystems;
2022-07-25 14:10:18 +12:00
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
2022-07-25 14:10:18 +12:00
using Content.Shared.Atmos.Prototypes;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
2022-07-25 14:10:18 +12:00
using Robust.Client.ResourceManagement;
Atmos pipe rework (#3833) * Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
2021-06-19 13:25:05 +02:00
using Robust.Shared.Enums;
2023-09-11 19:18:06 +10:00
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Map;
2023-06-28 21:22:03 +10:00
using Robust.Shared.Map.Components;
2022-07-25 14:10:18 +12:00
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
Atmos pipe rework (#3833) * Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
2021-06-19 13:25:05 +02:00
namespace Content.Client.Atmos.Overlays
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
{
public sealed class GasTileOverlay : Overlay
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
{
private readonly IEntityManager _entManager;
2022-07-25 14:10:18 +12:00
private readonly IMapManager _mapManager;
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities | OverlaySpace.WorldSpaceBelowWorld;
2022-07-25 14:10:18 +12:00
private readonly ShaderInstance _shader;
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
2022-07-25 14:10:18 +12:00
// Gas overlays
private readonly float[] _timer;
private readonly float[][] _frameDelays;
private readonly int[] _frameCounter;
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
2022-07-25 14:10:18 +12:00
// TODO combine textures into a single texture atlas.
private readonly Texture[][] _frames;
// Fire overlays
private const int FireStates = 3;
private const string FireRsiPath = "/Textures/Effects/fire.rsi";
private readonly float[] _fireTimer = new float[FireStates];
private readonly float[][] _fireFrameDelays = new float[FireStates][];
private readonly int[] _fireFrameCounter = new int[FireStates];
private readonly Texture[][] _fireFrames = new Texture[FireStates][];
private int _gasCount;
public const int GasOverlayZIndex = (int) Shared.DrawDepth.DrawDepth.Effects; // Under ghosts, above mostly everything else
2022-07-25 14:10:18 +12:00
public GasTileOverlay(GasTileOverlaySystem system, IEntityManager entManager, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys)
2022-07-25 14:10:18 +12:00
{
_entManager = entManager;
2022-07-25 14:10:18 +12:00
_mapManager = IoCManager.Resolve<IMapManager>();
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
ZIndex = GasOverlayZIndex;
_gasCount = system.VisibleGasId.Length;
2022-07-25 14:10:18 +12:00
_timer = new float[_gasCount];
_frameDelays = new float[_gasCount][];
_frameCounter = new int[_gasCount];
_frames = new Texture[_gasCount][];
for (var i = 0; i < _gasCount; i++)
{
var gasPrototype = protoMan.Index<GasPrototype>(system.VisibleGasId[i].ToString());
2022-07-25 14:10:18 +12:00
SpriteSpecifier overlay;
if (!string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayState))
overlay = new SpriteSpecifier.Rsi(new (gasPrototype.GasOverlaySprite), gasPrototype.GasOverlayState);
2022-07-25 14:10:18 +12:00
else if (!string.IsNullOrEmpty(gasPrototype.GasOverlayTexture))
overlay = new SpriteSpecifier.Texture(new (gasPrototype.GasOverlayTexture));
2022-07-25 14:10:18 +12:00
else
continue;
switch (overlay)
{
case SpriteSpecifier.Rsi animated:
var rsi = resourceCache.GetResource<RSIResource>(animated.RsiPath).RSI;
var stateId = animated.RsiState;
if (!rsi.TryGetState(stateId, out var state))
continue;
2022-07-25 14:10:18 +12:00
2023-09-11 19:18:06 +10:00
_frames[i] = state.GetFrames(RsiDirection.South);
2022-07-25 14:10:18 +12:00
_frameDelays[i] = state.GetDelays();
_frameCounter[i] = 0;
break;
case SpriteSpecifier.Texture texture:
_frames[i] = new[] { spriteSys.Frame0(texture) };
_frameDelays[i] = Array.Empty<float>();
break;
}
}
var fire = resourceCache.GetResource<RSIResource>(FireRsiPath).RSI;
for (var i = 0; i < FireStates; i++)
{
if (!fire.TryGetState((i + 1).ToString(), out var state))
throw new ArgumentOutOfRangeException($"Fire RSI doesn't have state \"{i}\"!");
2023-09-11 19:18:06 +10:00
_fireFrames[i] = state.GetFrames(RsiDirection.South);
2022-07-25 14:10:18 +12:00
_fireFrameDelays[i] = state.GetDelays();
_fireFrameCounter[i] = 0;
}
}
protected override void FrameUpdate(FrameEventArgs args)
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
{
2022-07-25 14:10:18 +12:00
base.FrameUpdate(args);
for (var i = 0; i < _gasCount; i++)
{
var delays = _frameDelays[i];
if (delays.Length == 0)
continue;
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
2022-07-25 14:10:18 +12:00
var frameCount = _frameCounter[i];
_timer[i] += args.DeltaSeconds;
var time = delays[frameCount];
if (_timer[i] < time)
continue;
_timer[i] -= time;
_frameCounter[i] = (frameCount + 1) % _frames[i].Length;
}
for (var i = 0; i < FireStates; i++)
{
var delays = _fireFrameDelays[i];
if (delays.Length == 0)
continue;
2022-07-25 14:10:18 +12:00
var frameCount = _fireFrameCounter[i];
_fireTimer[i] += args.DeltaSeconds;
var time = delays[frameCount];
if (_fireTimer[i] < time) continue;
_fireTimer[i] -= time;
_fireFrameCounter[i] = (frameCount + 1) % _fireFrames[i].Length;
}
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
}
2021-04-19 09:52:40 +02:00
protected override void Draw(in OverlayDrawArgs args)
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
{
2023-06-28 21:22:03 +10:00
if (args.MapId == MapId.Nullspace)
return;
2021-04-19 09:52:40 +02:00
var drawHandle = args.WorldHandle;
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
var overlayQuery = _entManager.GetEntityQuery<GasTileOverlayComponent>();
2023-06-28 21:22:03 +10:00
var gridState = (args.WorldBounds,
args.WorldHandle,
_gasCount,
_frames,
_frameCounter,
_fireFrames,
_fireFrameCounter,
_shader,
overlayQuery,
xformQuery);
2023-06-28 21:22:03 +10:00
var mapUid = _mapManager.GetMapEntityId(args.MapId);
if (_entManager.TryGetComponent<MapAtmosphereComponent>(mapUid, out var atmos))
DrawMapOverlay(drawHandle, args, mapUid, atmos);
2023-06-28 21:22:03 +10:00
if (args.Space != OverlaySpace.WorldSpaceEntities)
return;
2022-07-25 14:10:18 +12:00
2023-06-28 21:22:03 +10:00
// TODO: WorldBounds callback.
_mapManager.FindGridsIntersecting(args.MapId, args.WorldAABB, ref gridState,
static (EntityUid uid, MapGridComponent grid,
2023-06-28 21:22:03 +10:00
ref (Box2Rotated WorldBounds,
DrawingHandleWorld drawHandle,
int gasCount,
Texture[][] frames,
int[] frameCounter,
Texture[][] fireFrames,
int[] fireFrameCounter,
ShaderInstance shader,
EntityQuery<GasTileOverlayComponent> overlayQuery,
EntityQuery<TransformComponent> xformQuery) state) =>
2022-07-25 14:10:18 +12:00
{
2023-06-28 21:22:03 +10:00
if (!state.overlayQuery.TryGetComponent(uid, out var comp) ||
!state.xformQuery.TryGetComponent(uid, out var gridXform))
{
return true;
}
2022-07-25 14:10:18 +12:00
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
2023-06-28 21:22:03 +10:00
state.drawHandle.SetTransform(worldMatrix);
var floatBounds = invMatrix.TransformBox(in state.WorldBounds).Enlarged(grid.TileSize);
var localBounds = new Box2i(
(int) MathF.Floor(floatBounds.Left),
(int) MathF.Floor(floatBounds.Bottom),
(int) MathF.Ceiling(floatBounds.Right),
(int) MathF.Ceiling(floatBounds.Top));
// Currently it would be faster to group drawing by gas rather than by chunk, but if the textures are
// ever moved to a single atlas, that should no longer be the case. So this is just grouping draw calls
// by chunk, even though its currently slower.
state.drawHandle.UseShader(null);
foreach (var chunk in comp.Chunks.Values)
2022-07-25 14:10:18 +12:00
{
2023-06-28 21:22:03 +10:00
var enumerator = new GasChunkEnumerator(chunk);
2022-07-25 14:10:18 +12:00
2023-06-28 21:22:03 +10:00
while (enumerator.MoveNext(out var gas))
{
if (gas.Opacity == null!)
continue;
var tilePosition = chunk.Origin + (enumerator.X, enumerator.Y);
if (!localBounds.Contains(tilePosition))
continue;
for (var i = 0; i < state.gasCount; i++)
{
var opacity = gas.Opacity[i];
if (opacity > 0)
state.drawHandle.DrawTexture(state.frames[i][state.frameCounter[i]], tilePosition, Color.White.WithAlpha(opacity));
}
}
}
// And again for fire, with the unshaded shader
state.drawHandle.UseShader(state.shader);
foreach (var chunk in comp.Chunks.Values)
{
var enumerator = new GasChunkEnumerator(chunk);
while (enumerator.MoveNext(out var gas))
{
if (gas.FireState == 0)
continue;
2022-07-25 14:10:18 +12:00
2023-06-28 21:22:03 +10:00
var index = chunk.Origin + (enumerator.X, enumerator.Y);
if (!localBounds.Contains(index))
continue;
var fireState = gas.FireState - 1;
var texture = state.fireFrames[fireState][state.fireFrameCounter[fireState]];
state.drawHandle.DrawTexture(texture, index);
}
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
}
2023-06-28 21:22:03 +10:00
return true;
});
2022-07-25 14:10:18 +12:00
drawHandle.UseShader(null);
drawHandle.SetTransform(Matrix3.Identity);
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
}
private void DrawMapOverlay(
DrawingHandleWorld handle,
OverlayDrawArgs args,
EntityUid map,
MapAtmosphereComponent atmos)
{
var mapGrid = _entManager.HasComponent<MapGridComponent>(map);
// map-grid atmospheres get drawn above grids
if (mapGrid && args.Space != OverlaySpace.WorldSpaceEntities)
return;
// Normal map atmospheres get drawn below grids
if (!mapGrid && args.Space != OverlaySpace.WorldSpaceBelowWorld)
return;
var bottomLeft = args.WorldAABB.BottomLeft.Floored();
var topRight = args.WorldAABB.TopRight.Ceiled();
for (var x = bottomLeft.X; x <= topRight.X; x++)
{
for (var y = bottomLeft.Y; y <= topRight.Y; y++)
{
var tilePosition = new Vector2(x, y);
for (var i = 0; i < atmos.OverlayData.Opacity.Length; i++)
{
var opacity = atmos.OverlayData.Opacity[i];
if (opacity > 0)
handle.DrawTexture(_frames[i][_frameCounter[i]], tilePosition, Color.White.WithAlpha(opacity));
}
}
}
}
Adds atmos (#1389) * Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday :relieved: * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-08-02 20:08:20 +02:00
}
}