Commit Graph
51 Commits
Author SHA1 Message Date
83c2a1be11 [Dependency] source generator part 2 (#6550)
* [Dependency] source generator

No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn

* Apply dependencies generator changes to all code

* Release notes

* Preprocessor got hands

* Handle nullable dependencies

These are bad but gotta deal with it.

* Apply suggestions from code review

Co-authored-by: Moony <moony@hellomouse.net>

* Fine, let's not use collection expressions

---------

Co-authored-by: Moony <moony@hellomouse.net>
2026-05-08 12:38:33 +02:00
Pieter-Jan Briers 3a55118143 Replace CVar OnValueChanged in systems with Subs.CVar 2024-02-11 13:29:27 +01:00
metalgearslothandGitHub 89a1d32e1d Remove some redundant physics calls (#3425) 2022-11-03 12:33:41 +11:00
Leon FriedrichandGitHub 2b594f6356 Cache broadphases and container rejig (#3407) 2022-10-31 10:06:08 +11:00
metalgearslothandGitHub de01b9d8cb Raise collision events by-ref (#3201) 2022-09-14 17:23:35 +10:00
metalgearslothandGitHub db3f3e5b32 Allow maps to be saved (#3055)
* Allow maps to be saved

* I hate myself

* fix?

* Fix maybe?
2022-07-25 15:30:20 +10:00
AcruidandGitHub 31764d3c2d Mark C# events on MapManager as Obsolete (#2586)
* Obsoleted C# grid events from MapManager.GridCollection. Use the ECS EventBus events instead.

* Obsoleted C# events from MapManager.MapCollection. Use the ECS EventBus events instead.
2022-03-07 15:51:00 -08:00
de4d255841 Analyzer to enforce classes to be either [Virtual], abstract, or sealed. (#2469)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-02-05 19:31:58 +01:00
metalgearsloth 66435e6022 optimise the shit out of rendertrees 2021-12-07 23:47:12 +11:00
20kdc e9ec2ee1d3 Susser Todd: Robust.Server, Error Pass 2 2021-12-03 21:33:10 +00:00
Vera Aguilera Puerto 4f92301d25 More manual fixes. 2021-12-03 17:35:20 +01:00
Vera Aguilera Puerto 19f50d60c9 Inline AddComponent 2021-12-03 11:33:40 +01:00
metalgearslothandGitHub 80a9a82278 Fix client-side physics bodies getting stuck awake (#1946)
* Fix client-side physics bodies getting stuck awake

Wasn't a huge perf hit but it could leak a bit. Also there's a bunch of E/C stuff in here and I'll deal with it later.

* Fix broadphase leak

* Fix robust server sim
2021-08-23 15:01:08 +10:00
metalgearslothandGitHub f780f04784 Deprecate PhysShapeGrid (#1862)
* Grid fixtures

* termp

* Fixes

* Test reversion reversion?

* Tests

* Fix Equals

* Slight box2i cleanup

* Better initializer

* Also add static grid assert
2021-07-14 18:47:17 +10:00
metalgearslothandGitHub 6cf5fdc5d6 Grid-trees for rendering (#1666) 2021-04-02 20:25:16 +11:00
d8612aff64 Re-implement inertia (#1652)
* Implement inertia

* actual SPEEN

* Sync mass

* bitcoin miner

* I am le dumb

* also dis

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-30 21:42:05 +11:00
Paul fd8c90dcbb reverting cringe (moved controller metrics cvar get to server) 2021-03-16 12:05:56 +01:00
c17c8d7a11 Physics (#1605)
* Physics worlds

* Paul's a good boy

* Build working

* Ingame and not lagging to hell

* Why didn't you commit ahhhhh

* Hard collisions working

* Solver parity

* Decent broadphase work done

* BroadPhase outline done

* BroadPhase working

* waiting for pvs

* Fix static PVS AABB

* Stop static bodies from awakening

* Optimise a bunch of stuff

* Even more broadphase stuff

* I'm fucking stupid

* Optimise fixture updates

* Collision solver start

* Building

* A is for Argumentative

* Fix contact caching island flags

* Circle shapes actually workeded

* Damping

* DS2 consumables only

* Slightly more stable

* Even slightlier more stablier

* VV your heart out

* Initial joint support

* 90% of joints I just wanted to push as I'd scream if I lost progress

* JOINT PURGATORY

* Joints barely functional lmao

* Okay these joints slightly more functional

* Remove station FrictionJoint

* Also that

* Some Box2D ports

* Cleanup mass

* Edge shape

* Active contacts

* Fix active contacts

* Optimise active contacts even more

* Boxes be stacking

* I would die for smug oh my fucking god

* In which everything is fixed

* Distance joints working LETS GO

* Remove frequency on distancejoint

* Fix some stuff and break joints

* Crashing fixed mehbeh

* ICollideSpecial and more resilience

* auto-clear

* showbb vera

* Slap that TODO in there

* Fix restartround crash

* Random fixes

* Fix fixture networking

* Add intersection method for broadphase

* Fix contacts

* Licenses done

* Optimisations

* Fix wall clips

* Config caching for island

* allocations optimisations

* Optimise casts

* Optimise events queue for physics

* Contact manager optimisations

* Optimise controllers

* Sloth joint or something idk

* Controller graph

* Remove content cvar

* Random cleanup

* Finally remove VirtualController

* Manifold structs again

* Optimise this absolute retardation

* Optimise

* fix license

* Cleanup physics interface

* AHHHHHHHHHHHHH

* Fix collisions again

* snivybus

* Fix potential nasty manifold bug

* Tests go snivy

* Disable prediction for now

* Spans

* Fix ShapeTypes

* fixes

* ch ch changeesss

* Kinematic idea

* Prevent static bodies from waking

* Pass WorldAABB to MoveEvent

* Fix collisions

* manifold structs fucking WOOORRKKKINNGGG

* Better pushing

* Fix merge ickies

* Optimise MoveEvents

* Use event for collisions performance

* Fix content tests

* Do not research tests

* Fix most conflicts

* Paul's trying to kill me

* Maybe collisions work idk

* Make us whole again

* Smug is also trying to kill me

* nani

* shitty collisions

* Settling

* Do not research collisions

* SHIP IT

* Fix joints

* PVS moment

* Fix other assert

* Fix locker collisions

* serializable sleeptime

* Aether2D contacts

* Physics is no longer crashing (and burning)

* Add to the TODO list

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-08 03:19:01 +11:00
AcruidandGitHub 2183cd7ca1 Massive Namespace Cleanup (#1544)
* Removed the Interfaces folder.
* All objects inside the GameObjects subfolders are now in the GameObjects namespace.
* Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces.
* Simplified Robust.client.Graphics namespace.
* Automated remove redundant using statements.
2021-02-10 23:27:19 -08:00
00fbefa4e5 Physics caching go brrt (#1307)
* Physics caching go brrt

* Minor optimisation

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-10-09 11:40:02 +02:00
VinceandGitHub 6a546dadf1 Fixes most warnings (#1233) 2020-08-16 14:04:15 +02:00
Acruid c7f5521d2e Removed IsEntityPaused from the server component query, it was bugged and only about 1/5 of the entities on the map were actually processed in the collision system. This change causes a noticeable perf impact when starting the server and lasting until everything on the map goes to sleep.
BodyType is now serializable, fixes bug with VV.
Moved both velocity properties from ICollidableComponent to IPhysBody, added default methods to IPhysBody to get the word transform.
Added DebugTools.Break() method, calling it breaks execution in the attacked debugger.
Added VV attributes to various CollidableComponent properties.
2020-08-13 21:52:53 -07:00
Acruid 876d528578 Had to optimize the physics so that the client runs on my laptop. 2020-07-29 00:47:47 -07:00
Acruid 4ed044ddb4 Added an interface for PhysicsComponent.
Converted everything to use collision and physics component interfaces.
2020-07-19 00:32:06 -07:00
AcruidandGitHub 99933499b7 Merged Client and Server PhysicsComponent (#1163) 2020-07-02 09:34:16 +02:00
Pieter-Jan Briers 2af0d9df55 Optimizations to physics system.
Nothing major, just picking low hanging fruit and improving code quality around the place.
2020-06-30 15:13:51 +02:00
Pieter-Jan BriersandGitHub 31fb65bcb9 Movement prediction work. (#1144)
* Fix client-side input system not sending sequence numbers for input messages.

This caused message ordering issues and keys getting stuck down.

* Make sure EyeUpdateSystem runs after physics.

* IGameTiming.TickFraction helper.

* Subtick data for input commands.

* Literally a unit test to verify that I wasn't going insane while debugging input message ordering issues.

* More prediction logs behind net.predict.

* Move physics to shared and run it on the client.

* Synchronize grid gravity.

* Fix ResetPredictedEntities crash when entities get deleted server-side.

* Fix CollidableComponent setters not calling Dirty()

* Fix going into space while predicting.

* Watch window uses history line edit.

* Fix unpredicted objects stuck-jittering.

* VV tags for interp vars on transform.

* Fix 0 mass objects on client.

* Fix friction calculations being TPS dependent.

* Reset predict flag on handelComponentState
2020-06-24 20:47:20 +02:00
Tyler YoungandGitHub c997d7e3b6 Dynamically Manage Collision Solver Iterations (#1139)
modulate solver iterations dynamically depending on tps
2020-06-22 12:33:08 +02:00
Pieter-Jan BriersandGitHub 0d3cd41382 Enable NRTs on Robust.Server (#1118) 2020-06-09 14:18:29 +02:00
Jackson LewisandGitHub 80536daadf Fix problem with colliding objects getting 'squashed' (#1077) 2020-05-25 20:11:03 +02:00
Jackson LewisandGitHub f03860a16a Fix ICollideBehavior.OnCollide being called multiple times (#1074)
* Fix ICollideBehavior dispatching

* Move collision behavior code to execute after impulse resolution.
2020-05-25 15:41:54 +02:00
Jackson LewisandGitHub f675aa95d5 Optimize collision code in physics engine (#1071) 2020-05-25 01:20:08 +02:00
Pieter-Jan Briers fb82568d59 Fix exception in physics system. 2020-05-23 02:38:13 +02:00
Jackson LewisandGitHub 274334c926 Rewrite the physics engine (#1037) 2020-05-23 01:21:02 +02:00
Jackson LewisandGitHub db8d9bd228 Gravity (#1031) 2020-04-23 16:49:19 +02:00
PrPleGooandGitHub 8cee7ba685 Reworked how friction impacts velocity. (#1015)
* Rework friction to work as a sum instead of indiviually

* Removed comments

* Changed how friction works from reducing movement to increased the effect of mass.
2020-03-15 07:28:32 +01:00
Pieter-Jan Briers eae2a9283d Fix compiler warnings 2020-02-17 13:57:18 +01:00
Tyler YoungandGitHub 5d37780f4e Have PhysicsManager use DynamicTree (#955)
* have PhysicsManager use DynamicTree

* remove BroadPhaseNative

add BroadPhase wrapping DynamicTree

replace IBroadPhase with regards to DynamicTree

* add collision enumeration capability for proper BroadPhase

* fix slow app exit due to MapId being unavailable at various stages of shutdown

reduce code footprint of alternate query in AnyEntitiesIntersecting by using existing query (only used rarely)
2020-02-07 15:15:33 -08:00
Tyler YoungandGitHub 3cc10f7eb7 Fix crash from destruction of containers containing containers (#956) 2020-02-07 17:53:22 +01:00
QuantomicusandGitHub 3d34265c6f Fixes #923 (#950) 2020-02-04 19:14:44 +01:00
Acruid 78a33076f9 Merged client and server CollidableComponent into a shared version. Now shared code can add collidable components to entities. 2020-01-11 14:10:25 -08:00
Acruid 7a77fa59e2 Switched physics collision broadphase from spatial partition to Naive.
Grid->Grid collision works.
2020-01-10 15:39:34 -08:00
Pieter-Jan Briers a69738a7a4 Terrible fix for physics crashes. 2020-01-05 00:48:45 +01:00
Pieter-Jan Briers 259f6c8ea4 Fix bullets crashing the server.
This is not a proper fix. A proper fix would be a better physics engine.

But as it stands I really wanna get a progress report out and having to refactor physics to do it would just suck.
2019-12-29 01:06:57 +01:00
AcruidandPieter-Jan Briers f5c0dba194 Map & Grid Entities (#916)
* Adds Map components to the ECS system.

* Grid entities are now created along with map grids.
Grid components are now properly reused from map deserialization when a grid is created through the MapManager.

* Make MapGridComponent shared.
Don't send Nullspace default grid to client, they have their own.
Properly link the new grid with the entity sent from the server.

* Fixes nullRefException when ToString() is called on an Entity with no Prototype.

* Adds logging debug info about binding a map/grid to an entity.
Nightly Commit.

* Client map networking now properly pivots a grid from the client entity to the shared entity.
Added IMapGridComponent.ClearGridId() to properly dissociate the component from a grid before deleting it.
WorldPosition of a default grid is always 0,0 regardless of the entity transform (if any).
Nullspace map and default grid are not bound to an entity.
Nullspace map and default grid cannot be deleted.

* Map Entities are now created along with new maps.

* Client & Server load with new scene hierarchy.

* Fix rebase damage.

* Added ContainerHelpers helper class.

* Fix Container checks.

* Fixed clothes.

* Fixing unit tests.

* Removed disabled code.

* Actually initialize and startup the Map and Grid entities.
2019-12-21 22:11:17 +01:00
Pieter-Jan Briers 9b15070126 Remove allocations from PhysicsSystem HandleMovement.
LINQ is bad alright.
This removes approx 20% of allocations on the server.
2019-12-04 13:48:45 +01:00
Pieter-Jan BriersandGitHub bb4a1eda8e Project file refactor (#819)
* Project file refactor

Move all the .csproj files to the new .NET Core style.
This doesn't make any difference for compiling for Framework,
but it does reduce a ton of useless boilerplate.

As an extension of this, killed a bunch of uncompiled & unmaintained .cs files.

Compiling for release (to profile) works now.
Removed AnyCPU targets from the solution file.

* Fix compiler warnings.
2019-05-28 00:16:01 +02:00
AcruidandPieter-Jan Briers 1b3cc8aba6 Grid Bounds (#800)
* Added centered unit box static field to Box2.

* MapGrid is more testable.

* Added some unit tests for MapGrid.
Fixed bug in MapChunk.GridTileToLocal().
MapGrid.UpdateAABB() actually expands properly now.

* Moved IMapChunk to Robust.Shared.Map.
Moved Chunk class out of MapManager class.

* Added unit tests for MapChunk.

* Bounds reduce by 1, so almost working.

* Now bound shrinking works :D

* Moved MapGrid out of MapManager.
Moved IMapGrid into the Shared/Map folder.
Replaced all calls to IMapGrid.ParentMap.Index with IMapGrid.ParentMapId.

* Added more MapGrid unit tests.
Fixed a bug in TryGetTileRef.
2019-04-29 12:43:20 +02:00
AcruidandPieter-Jan Briers 7053fb15f8 Map System Code Refactor (#796)
* Removed unused method TileRef.GetStep().
Removed unused property TileRef.TileSize.
Removed unused property TileRef.Tile, made the field public with the same name.
Made the TileRef struct readonly.
Removed property TileRef.TileDef.
Removed property TileRef.LocalPos.
Renamed GridTile to GridIndices.
Implemented IEquatable on TileRef.
Implemented Equality operators on TileRef.
Added PublicAPI attribute to TileRef.
Added doc comments to TileRef.

* Modified Tile:
Added the PublicApi annotation.
Made struct readonly.
Filled out doc comments.
Changed auto properties to readonly fields.
Renamed TileId to TypeId.
Added a static Empty tile to the struct.
Implemented IEquatable.

* Modified MapCoordinates:
Added PublicApi attribute.
Implemented IEquatable.
Filled out doc comments.
Removed Map property.

* Modified ScreenCoordinates:
Filled out doc comments.
Added the PublicApi attribute.
Implemented IEquatable.

* Modified GridCoordinates:
Removed method IsValidLocation.

* Removed property GridCoordinates.Grid.

* Removed GridCoordinates.Map.

* Removed GridCoordinates.MapId.

* Removed property GridCoordinates.IsWorld.
Removed constructors taking a MapId.

* Removed static IoCManager calls from GridCoordinates.

* Modified GridCoordinates:
Added attribute PublicApi.
Filled out doc comments.

* Filled out doc comments for MapGrid.
Filled out doc comments for MapIndices.
Misc refactors for both.

* added command to teleport grids.

* Added method Box2.Intersect.
Added method Box2.Union.
Placement manager now spawns new grids to place tiles not connected to an existing grid.
2019-04-20 20:37:37 +02:00
AcruidandPieter-Jan Briers a5a3a539dc Tick Logic Timing and Bandwidth Improvements (#795)
Code was changed so that time starts at tick zero, and all entities are initialized in the space between tick 0 to 1. This was a solution to the fact fromSequence was including entities with lastStateUpdate tick one less than the actual sequence number. This is purely an issue about when exactly the game does its logic relative to the tick signals, ie positive or negative edge of the tick. Right now the game is set up to run the game logic on the positive edge of a Tick (enforced by GameLoop).

The second big part is that an empty collection takes 5ish bytes more than a null collection in the NetSerializer, even though they are conceptually the same thing in a game state. This PR puts null checks around everything and allows GameStates to have whole sections of itself null. This reduced the payload size of an empty game state from 49B to 15B.

This PR also fixes the bug where the physics system marks every movable entity as dirty every tick.
2019-04-20 18:08:43 +02:00