Compare commits

...

485 Commits

Author SHA1 Message Date
metalgearsloth
09e648d086 Version: 0.8.43 2022-02-04 12:43:43 +11:00
metalgearsloth
933724e4ee Nuke CompGetStateAttempt allocs (#2497) 2022-02-04 12:35:57 +11:00
metalgearsloth
c076be95a6 Version: 0.8.42 2022-02-03 13:26:13 +11:00
metalgearsloth
7b732dd68a Remove unnecessary resolves from MapLoader (#2462) 2022-02-03 13:25:22 +11:00
metalgearsloth
3e34b1414e The end of IMapInit (#2479) 2022-02-03 13:15:17 +11:00
Acruid
8456cd90d1 Move MapGrid data from MapManager to MapGridComponent (#2430) 2022-02-03 13:15:06 +11:00
Pieter-Jan Briers
d716e1ff62 Fix EstPixelSize for Rg32f.
This function literally isn't used but that won't stop me from making this commit.
2022-02-02 21:46:42 +01:00
metalgearsloth
8e9acc9191 Reduce broadphase allocs a l'il bit (#2493) 2022-02-03 00:52:04 +11:00
metalgearsloth
b37bfff155 Remove string allocs from client prediction (#2494) 2022-02-02 21:59:40 +11:00
Leon Friedrich
a14cce222b Misc physics/shutdown related optimizations (#2496) 2022-02-02 18:12:53 +11:00
Leon Friedrich
c077e09436 Add explicit transform matrices (#2483) 2022-02-02 10:03:45 +11:00
Leon Friedrich
213955566b remove GetBus() (#2491) 2022-02-02 10:03:03 +11:00
metalgearsloth
fcbb97ec55 Fix edge collisions (#2482) 2022-02-01 15:28:12 +11:00
Pieter-Jan Briers
c1ac7aebdb Version: 0.8.41 2022-01-31 17:37:35 +01:00
Pieter-Jan Briers
e4b0d1a03c Hotfix servers not working due to auto pause. 2022-01-31 17:37:19 +01:00
Leon Friedrich
f13f9dc5cd Make OffsetRsiDir() and GetDir() public (#2434) 2022-01-31 19:22:56 +11:00
metalgearsloth
53c7ec8ddc Version: 0.8.40 2022-01-31 17:55:53 +11:00
Leon Friedrich
c1df7dcca7 Move some static helpers to container system (#2470) 2022-01-31 17:21:09 +11:00
Pieter-Jan Briers
f141a0033e Automatically pause server if no players connected. (#2465) 2022-01-31 17:20:26 +11:00
metalgearsloth
227d047584 Version: 0.8.39 2022-01-31 16:25:52 +11:00
metalgearsloth
73b73cd9da Fix InvWorldMatrix helper (#2478) 2022-01-31 16:20:21 +11:00
Pieter-Jan Briers
66be082bdb Fix display.angle_force_es2 defaulting to true. 2022-01-30 20:21:35 +01:00
Pieter-Jan Briers
ac43cf0de1 Fix GLES2 support. 2022-01-30 20:20:23 +01:00
Pieter-Jan Briers
fb41601d9f CVar to force a GLES2 context with GLContextAngle. 2022-01-30 18:06:59 +01:00
metalgearsloth
f35dda3fb3 Version: 0.8.38 2022-01-31 02:09:20 +11:00
metalgearsloth
7ee14f6f4f Remove some unnecessary writer resolves (#2475) 2022-01-31 00:54:30 +11:00
metalgearsloth
97920b42ee Fix FindGridContacts (#2474) 2022-01-30 18:32:13 +11:00
metalgearsloth
8ace0ec254 Fix entity map change crash (#2461) 2022-01-30 17:44:07 +11:00
metalgearsloth
a3606f1098 Fix grid fixture deserialization (#2472) 2022-01-30 17:09:22 +11:00
metalgearsloth
616d379902 Version: 0.8.37 2022-01-29 16:18:05 +11:00
metalgearsloth
a27f475715 Proxy method for entitymanager.dirty(comp) (#2467) 2022-01-29 16:16:32 +11:00
Leon Friedrich
6ee76e8f46 Fix point light add/remove (#2466) 2022-01-29 16:05:23 +11:00
metalgearsloth
891c30c9be Fix maplinearvelocity? (#2317) 2022-01-27 18:01:20 +11:00
metalgearsloth
9757a4c3b6 Fix broadphase for rotation events (#2463) 2022-01-27 17:36:17 +11:00
Pieter-Jan Briers
5be2f610cd Fix thread pool queue histogram having buckets divided by 1000. 2022-01-27 01:55:33 +01:00
metalgearsloth
35324e0853 Version: 0.8.36 2022-01-26 17:56:54 +11:00
metalgearsloth
ac753cdb93 Revert "Reduce component / resolve calls in transformcomp (#2450)" (#2459) 2022-01-26 17:56:30 +11:00
metalgearsloth
3edd39f0eb Version: 0.8.35 2022-01-26 16:10:45 +11:00
metalgearsloth
8f790c28be Deprecate component.Paused (#2449) 2022-01-26 16:10:25 +11:00
metalgearsloth
c253afaf8e Version: 0.8.34 2022-01-26 15:15:19 +11:00
metalgearsloth
a6ac1dced0 Fix more physics ordering bugs (#2458) 2022-01-26 14:59:31 +11:00
wrexbe
d1e0f2cd94 Automatic Component Names (Alternate ending) (#2389) 2022-01-25 14:10:08 +01:00
metalgearsloth
af861d289a Remove some unnecessary resolves (#2452) 2022-01-25 14:01:44 +01:00
metalgearsloth
753f3f8c0f Add dirty method to entmanager for components (#2453) 2022-01-25 14:00:03 +01:00
Leon Friedrich
5c2a5741ee Prevent CreateAudioSource() from erroring/crashing in debug when hitting source limit (#2448) 2022-01-25 13:35:01 +01:00
metalgearsloth
26941a2013 Reduce component / resolve calls in transformcomp (#2450) 2022-01-25 13:32:28 +01:00
Moony
fad4c20da2 VV for entity systems. (#2447) 2022-01-25 13:29:17 +01:00
Pieter-Jan Briers
2b79ef301d Add prometheus-net.DotNetRuntime for more detailed runtime metrics like GC pause times. (#2457) 2022-01-25 13:23:55 +01:00
metalgearsloth
014491e674 Fix joints crash (#2454) 2022-01-25 12:39:31 +11:00
metalgearsloth
2e70cd4f2e Add HasComp to EntityQuery struct (#2451) 2022-01-24 18:48:45 +11:00
metalgearsloth
689e1baa12 Version: 0.8.33 2022-01-24 11:58:16 +11:00
metalgearsloth
c34e84378a Fix grid deletion (#2445) 2022-01-24 11:55:37 +11:00
Kara D
9a44becc73 Version: 0.8.32 2022-01-21 20:08:35 -07:00
mirrorcult
d324d9fcf3 Merge pull request #2429 from metalgearsloth/2022-01-17_grid-iter 2022-01-21 20:04:35 -07:00
Pieter-Jan Briers
74cd48401c Engine changes for launcher ContentDB/delta updates. 2022-01-21 17:24:07 +01:00
metalgearsloth
43081c57e7 Add acruid's funny entity query (#2440) 2022-01-21 10:45:10 +11:00
Leon Friedrich
b80a51d03f Raise an attempt-event when receiving client BUI messages. (#2414) 2022-01-20 02:42:48 +11:00
mirrorcult
e90d5e4977 Merge pull request #2433 from wrexbe/warningfixes 2022-01-18 15:24:14 -07:00
mirrorcult
979034906a Merge pull request #2417 from weaversam8/shutdown-pre-mainloop 2022-01-18 15:23:46 -07:00
Pieter-Jan Briers
9e4fd2905b Release DXGI Factory in VramCommand 2022-01-18 18:16:02 +01:00
Leon Friedrich
914c269411 return -> continue (#2437) 2022-01-18 23:41:55 +11:00
metalgearsloth
2cacc4cd49 Version: 0.8.31 2022-01-18 19:02:43 +11:00
Leon Friedrich
3024094584 Add IsQueuedForDeletion (#2421)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-01-18 19:02:10 +11:00
Leon Friedrich
4c66451324 Stop updating entity tree on pre-delete un-anchor event (#2422) 2022-01-18 17:49:31 +11:00
Leon Friedrich
7e7d808c90 Sprite offset rendering fix (#2432) 2022-01-18 17:45:49 +11:00
wrexbe
0538e89948 Fixes warnings 2022-01-17 19:13:54 -08:00
Sam Weaver
6376f7c35d Add System.Text.Json.JsonPropertyNameAttribute to sandbox allowlist (#2435) 2022-01-18 03:14:10 +01:00
metalgearsloth
37721f2327 Align rotation 2022-01-17 15:26:39 +11:00
metalgearsloth
b0d2404644 sussy init 2022-01-17 15:09:33 +11:00
metalgearsloth
5f76cb4819 Tests working let's go 2022-01-17 15:05:36 +11:00
metalgearsloth
427a54fc67 Fix tests I guess 2022-01-17 14:53:51 +11:00
metalgearsloth
1cd1fb905d Comment 2022-01-17 14:40:12 +11:00
metalgearsloth
33333f87d2 Nuke broadphase caches
Scales really poorly at high grid counts and better to just lazy load.
2022-01-17 14:26:15 +11:00
metalgearsloth
4e5b8ec1e2 Fix early move / rotate crash 2022-01-17 13:40:54 +11:00
metalgearsloth
007feb76b7 Optimise broadphase movebuffer 2022-01-17 13:27:16 +11:00
metalgearsloth
d34dcb81fb ! 2022-01-17 12:47:16 +11:00
metalgearsloth
8abb366903 aaaaaaaaaaaAAAAAAAAAAAAAAA 2022-01-17 12:43:31 +11:00
metalgearsloth
3e7ba7ca28 Just work please 2022-01-17 11:55:19 +11:00
Pieter-Jan Briers
14d52a9da9 Update ManagedHttpListener. This gives it IPv6 support 2022-01-16 16:32:46 +01:00
Pieter-Jan Briers
847f8d1fee Document most engine CVars.c 2022-01-16 15:08:10 +01:00
Pieter-Jan Briers
0c8d7adf37 Fix wrong comment in cvars 2022-01-16 14:12:23 +01:00
Leon Friedrich
d68d803709 Prevent disembowelling on tile removal. (#2418) 2022-01-16 18:51:04 +11:00
metalgearsloth
13ef514d3e Version: 0.8.30 2022-01-16 18:47:43 +11:00
Vera Aguilera Puerto
e20cd248a0 Makes VirtualController an abstract class inheriting EntitySystem (#2424) 2022-01-16 18:46:48 +11:00
mirrorcult
b8a3bda31d Don't dirty entities when NetSyncEnabled is false (#2426) 2022-01-15 19:31:05 +01:00
ElectroJr
001493d984 Version: 0.8.29 2022-01-15 15:21:54 +13:00
Paul Ritter
013a3e3e8c removes componentdependencies (#2423) 2022-01-15 13:06:29 +11:00
Vera Aguilera Puerto
4c2d984835 Fix singleplayer clients being in "prediction" always, breaking physics. 2022-01-14 19:07:16 +01:00
Paul Ritter
21bb0f15e0 i fudged it 2022-01-12 23:03:54 +01:00
Paul Ritter
8d5162ef8d forgot some 2022-01-12 22:49:10 +01:00
Paul Ritter
257913ac0e add myself to codeowners 2022-01-12 22:43:11 +01:00
metalgearsloth
c90dfccbf4 Version: 0.8.28 2022-01-12 23:15:37 +11:00
metalgearsloth
9c7dc8876f Deduplicate most of loadbp and loadmap (#2409) 2022-01-12 23:14:19 +11:00
metalgearsloth
fc8cbdf01f Entity lookup fixes (#2407) 2022-01-12 14:45:01 +11:00
Sam Weaver
5af4bfa912 Merge branch 'space-wizards:master' into shutdown-pre-mainloop 2022-01-11 22:16:33 -05:00
Sam Weaver
0c5a47ff9d Allow the server to shutdown before the main loop has started 2022-01-11 19:34:41 -05:00
metalgearsloth
b4b4a3864f Version: 0.8.27 2022-01-12 00:43:33 +11:00
metalgearsloth
dca8561881 Remove some unnecessary physics resolves and events (#2404) 2022-01-12 00:35:32 +11:00
metalgearsloth
ee58b5299d Joint serialization (#2410) 2022-01-12 00:31:39 +11:00
Leon Friedrich
7868b12279 Remove unused grid-tile-lookup related code (#2416) 2022-01-11 18:56:09 +11:00
Leon Friedrich
42e91e8c4d Deparent entities on grid tile delete (#2415) 2022-01-11 18:55:23 +11:00
Leon Friedrich
28c9326305 Move popup above modal in RootControl (#2412) 2022-01-10 16:35:04 +01:00
metalgearsloth
40b8772980 Prettify contact deletions (#2413) 2022-01-10 16:34:50 +01:00
Pieter-Jan Briers
b6a548629a More async stuff for StatusHost. 2022-01-10 16:34:16 +01:00
Vera Aguilera Puerto
291a37924d Add a method to unregister "manual" commands from IConsoleHost. (#2403) 2022-01-10 12:51:13 +01:00
Vera Aguilera Puerto
0b5eccd60a Expose ConsoleHost.RegisteredCommand and its callback. (#2394) 2022-01-10 12:50:55 +01:00
Vera Aguilera Puerto
866a324922 ServerConsoleHost logs errors as errors, not warnings. 2022-01-10 12:50:23 +01:00
Pieter-Jan Briers
baf48a8dc1 Update ManagedHttpListener submodule 2022-01-10 11:55:08 +01:00
Pieter-Jan Briers
a85b2dd43c Version: 0.8.26 2022-01-10 01:36:12 +01:00
Pieter-Jan Briers
43059b3985 Remove usages of Newtonsoft.Json from StatusHost (#2405) 2022-01-10 01:36:00 +01:00
Vera Aguilera Puerto
4d6183d6af Add new entries to CODEOWNERS for myself. 2022-01-09 19:26:22 +01:00
metalgearsloth
79f87f03ce Version: 0.8.25 2022-01-09 23:46:35 +11:00
metalgearsloth
01ede29fc4 Nuke gridtilelookup (#2399) 2022-01-09 23:45:48 +11:00
Pieter-Jan Briers
fb54d0df1c Remove usages of Newtonsoft.Json outside StatusHost 2022-01-09 11:53:06 +01:00
E F R
5b65495fbc Controls/SplitContainer: Allow Content to change the SplitState (#2392) 2022-01-09 10:26:24 +01:00
Pieter-Jan Briers
cec3a8c1c2 Remove unnecessary warning mute from Clyde. 2022-01-09 10:21:00 +01:00
Leon Friedrich
8bd0b459b9 Make entity manager proxy methods protected (#2402) 2022-01-07 11:21:28 +01:00
Leon Friedrich
7da50516f9 Fix ghost-pointing visibility (#2401) 2022-01-07 17:08:19 +11:00
Kara D
6cbb2135b8 Version: 0.8.24 2022-01-04 17:51:39 -07:00
mirrorcult
66dbc05022 Merge pull request #2390 from wrexbe/tilesid 2022-01-04 17:48:50 -07:00
Paul
18cc385c70 version bump & changes to itemlist 2022-01-04 21:11:47 +01:00
Matz05
384f672eec Engine changes for more server-pushed lighting variables (#2367)
* Engine changes for more server-pushed lighting variables, but apparently this is a deprecated way of doing things anyway

* Removed two unecessary uses of virtual
2022-01-05 02:57:49 +11:00
Paul
f49a29cfb3 smol itemlist change & version bump 2022-01-03 04:12:04 +01:00
Wrexbe
e8b70877cf Tiles Name->Id DisplayName->Name 2022-01-01 20:52:59 -08:00
Paul Ritter
9b084ea6a9 bandaid fix pvs grid crash for or14 2022-01-01 23:29:14 +01:00
ShadowCommander
51f2fc4259 TeleportTo upgrades (#2384)
* Clean up TeleportTo

* Change TeleportTo to allow teleporting to EntitiyUid

* Rename TeleportToPlayerCommand to TeleportToCommand

* Move duplicate parsing code to TryGetTransformFromUidOrUsername
2022-01-01 17:14:17 +01:00
Pieter-Jan Briers
bb27482e9f Fix release/debug serializer mismatch. 2021-12-31 10:06:32 +01:00
Pieter-Jan Briers
75912896c9 Version: 0.8.21 2021-12-31 09:37:30 +01:00
Pieter-Jan Briers
6e0632ae1b Explicitly block P/Invoke methods in AssemblyTypeChecker 2021-12-31 09:35:34 +01:00
Pieter-Jan Briers
7c90da0402 Correctly load mismatching versions from Robust modules. 2021-12-31 09:35:34 +01:00
Pieter-Jan Briers
313a3eb7f2 Minor GLContextEgl cleanup:
* Compile it in by default but leave display.egl=false by default.
* Minor code cleanup/TerraFX usage.
2021-12-31 09:35:34 +01:00
metalgearsloth
cb054f0761 Avoid touching physicscomp when removed from container (#2379) 2021-12-31 08:36:08 +01:00
Paul Ritter
579b21716d version 0.8.20 2021-12-30 22:55:06 +01:00
Paul Ritter
3ffdc8cc2d changes needed for inventory refactor (#2350)
* get that crap outta here

* reenables tests

* helper

* removes serverside itemcomp & misc fixes

* oopsie

* fixes tests

* motivation low

* container stuff

* resolves optional

* fix some tests

* fixes

Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2021-12-30 22:54:00 +01:00
Pieter-Jan Briers
e68af15b40 Don't skip viewer entity in PVS for streaming
This causes problems on the client.
2021-12-30 21:00:52 +01:00
Pieter-Jan Briers
8e5fafaf05 Version: 0.8.19 2021-12-30 18:20:38 +01:00
Pieter-Jan Briers
95f9418e56 Remove some garbage from .gitignore
A different time
2021-12-30 18:12:35 +01:00
Pieter-Jan Briers
23af814ebc Remove Resources/.gitignore
:salute:
2021-12-30 18:10:13 +01:00
Pieter-Jan Briers
ae7dda9dab Update NetSerializer 2021-12-30 18:04:59 +01:00
Pieter-Jan Briers
c5899944a2 Uncomment stuff in manifest so it's not empty and won't break the launcher.
Whoops.
2021-12-30 17:48:22 +01:00
Pieter-Jan Briers
c0e0f65ebe Unhardcode Lidgren App Identifier.
Default value is now RobustToolbox, not SS14_NetTag
2021-12-30 17:32:49 +01:00
Pieter-Jan Briers
3bdce98964 Change X11 instance/class names to RobustToolbox 2021-12-30 17:24:25 +01:00
Pieter-Jan Briers
478ab3bec4 Remove Space Station 14 reference from a MessageBox 2021-12-30 17:23:29 +01:00
Pieter-Jan Briers
ae77ee3df4 Remove SS14 logo/icon/splash/window title branding. Make it all configurable with manifest.yml 2021-12-30 17:22:21 +01:00
Pieter-Jan Briers
86e4a558c5 F3 menu moves out of the way when console opens 2021-12-30 16:49:36 +01:00
metalgearsloth
15c1e8f7bf Run appearancevisualizers on dummy entities again (#2380) 2021-12-30 20:41:55 +11:00
metalgearsloth
f38770dbb5 Poly-edge collision optimisations (#2366) 2021-12-30 20:17:55 +11:00
Pieter-Jan Briers
75d37f8309 Version: 0.8.18 2021-12-30 03:10:50 +01:00
Pieter-Jan Briers
ed641c8cc8 Properly dispose debug console history writer so it flushes properly. 2021-12-30 03:10:01 +01:00
Pieter-Jan Briers
069ebbc8d0 Make disabled prediction work again.
Simulation input and Update() does not happen when prediction is disabled. Both of these can be re-opted in on a per-handler/system basis with a bool flag. Stuff like physics opts out of this now.
2021-12-30 03:03:39 +01:00
Pieter-Jan Briers
720f33a12a Updated webview packaging script 2021-12-29 20:27:50 +01:00
Leon Friedrich
08f1cfbc79 add CanInsertIfEmpty() (#2382)
* add CanInsertIfEmpty

* make CanInsert call CanInsertIfEmpty
2021-12-29 20:27:01 +01:00
Pieter-Jan Briers
9896697919 Viewports have configurable clear color, default to black. 2021-12-29 20:11:08 +01:00
metalgearsloth
057d50b60b BQL optimisations (#2315) 2021-12-29 14:04:19 +11:00
Pieter-Jan Briers
e3dc446e9e Version: 0.8.17 2021-12-28 22:27:33 +01:00
Pieter-Jan Briers
c529f756af Make default visibility mask if no EyeComponent 1 in PVS.
This fixes OpenDream.

@metalgearsloth
2021-12-28 22:27:20 +01:00
metalgearsloth
c07eaecacb Version: 0.8.16 2021-12-29 05:12:05 +11:00
metalgearsloth
ddc03a1d62 Cache vismask on each entity (#2312) 2021-12-29 05:11:53 +11:00
Pieter-Jan Briers
ca59cff07f WiP launcher CEF loading. (#2376) 2021-12-28 17:37:54 +01:00
Pieter-Jan Briers
df4ddfdf25 Unhardcode ACZ stuff to be more flexible (and work on master SS14). 2021-12-28 16:17:21 +01:00
Pieter-Jan Briers
c667a326a3 Fix ACZ creating invalid zip paths on Windows.
Zip files always use / path separators.
2021-12-28 16:17:21 +01:00
Vera Aguilera Puerto
0099442852 Version 0.8.15 2021-12-27 18:48:46 +01:00
Vera Aguilera Puerto
eecb104cc5 Adds help method to C# scripting. (#2368) 2021-12-27 18:47:16 +01:00
Vera Aguilera Puerto
a54283e637 ByRefEvent attribute for events. (#2375) 2021-12-27 17:59:32 +01:00
Vera Aguilera Puerto
ed06107a9f Proxy method AddComp actually returns the added component now. 2021-12-27 16:43:54 +01:00
Vera Aguilera Puerto
2d833daa57 Fix EntitySpawnWindow Erase Mode not being toggled off correctly.
It would always get toggled back on after Clear cleared the erase mode status...
2021-12-27 16:40:52 +01:00
metalgearsloth
67dd0a9433 Make gridfixture_test use fixturescomp (#2370) 2021-12-25 19:05:16 +01:00
Vera Aguilera Puerto
fcc16d67f7 Remove Eye Lerping from engine. (#2371) 2021-12-25 19:05:07 +01:00
metalgearsloth
394f51f70d Version: 0.8.14 2021-12-25 21:42:26 +11:00
metalgearsloth
538627328e Don't wake destroyed contact bodies if they can't collide (#2369)
e.g. if they're getting yeeted to nullspace or inserted into a container.
2021-12-25 11:26:47 +01:00
Vera Aguilera Puerto
b5a21ccc4d Version 0.8.13 2021-12-23 13:06:39 +01:00
metalgearsloth
2d331ff786 Broadphase fix take 2 (#2327)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-12-23 12:20:59 +01:00
metalgearsloth
9d9ad15274 Entity deletion stuff (#2365) 2021-12-23 12:20:44 +01:00
Pieter-Jan Briers
114ec2e493 This is literally me when you need to google just to delete a submodule 2021-12-23 12:10:51 +01:00
Pieter-Jan Briers
2fb45da0d7 Switch to NuGet packages for Linguini 2021-12-23 10:42:19 +01:00
metalgearsloth
54a693dfa7 Fix attached effects 2021-12-23 15:50:19 +11:00
Pieter-Jan Briers
4be572ba58 whoops 2021-12-23 01:25:42 +01:00
Pieter-Jan Briers
e22d6ea65c Use float.IsFinite in some appropriate places previously using IsNan || IsInfinity 2021-12-23 01:21:57 +01:00
Pieter-Jan Briers
baf86b5b83 Get rid of ComponentTypeCache stuff.
It didn't really work.
2021-12-23 01:15:25 +01:00
Pieter-Jan Briers
e56c77319c Fix tests breaking due to component index stuff. 2021-12-23 01:12:56 +01:00
Pieter-Jan Briers
a170dbd716 Use BitOperations for MathHelper.NextPowerOfTwo instead. 2021-12-23 01:12:02 +01:00
Pieter-Jan Briers
b821833437 Fix compiler warning in GLContextAngle.cs 2021-12-22 20:50:53 +01:00
Pieter-Jan Briers
1bb9b8cae3 Fix launchauth command 2021-12-22 20:46:57 +01:00
metalgearsloth
1e32eb135d Version: 0.8.12 2021-12-22 10:30:23 +11:00
Pieter-Jan Briers
b695ce581e Replace Win32 interop sigs with TerraFX.
We include TerraFX in builds now so this shouldn't be a problem.
2021-12-21 17:29:06 +01:00
Pieter-Jan Briers
8138fc5fa2 Remove component get caching from PVS.
This was literally slower than simply doing it directly.
2021-12-21 17:16:58 +01:00
Pieter-Jan Briers
0b2693cb98 Optimize TryGetComponent & friends with array type -> dict lookups. 2021-12-21 17:16:08 +01:00
Vera Aguilera Puerto
3d959c98ed Version 0.8.11 2021-12-20 17:17:03 +01:00
Vera Aguilera Puerto
0ccee0b496 Fix engine status host not reporting hostname correctly.
The hostname wasn't being cached at server start.
2021-12-20 17:16:13 +01:00
Paul
b7b2a0ab5e quickly put that back 2021-12-20 15:33:50 +01:00
metalgearsloth
375402c455 Optimise DetachParentToNull for grid deletion (#2362) 2021-12-20 13:59:50 +01:00
Paul
03505da382 fixes a bunch of warnings 2021-12-20 13:59:01 +01:00
metalgearsloth
f56219746b Allow tight grid fits (#2309) 2021-12-20 13:58:33 +01:00
metalgearsloth
116c3e491c Use velocities and positions by ref in constraints solver (#2360) 2021-12-20 13:57:32 +01:00
Vera Aguilera Puerto
e94c2f039c Some fixes for map init. (#2355) 2021-12-20 13:57:26 +01:00
Pieter-Jan Briers
2fd52ef3eb Add automatic hub advertisement. 2021-12-20 13:56:17 +01:00
Paul
29659536aa version 0.8.10 2021-12-20 12:39:19 +01:00
Paul Ritter
338a2831ee Revert Rich Text (#2363) 2021-12-20 12:38:35 +01:00
metalgearsloth
c64c1aca5b Fix effect rotation (#2357) 2021-12-19 17:44:26 +11:00
Vera Aguilera Puerto
0dd72f4434 Extra MIDI sanity checks.
Makes sure the tracking entity is valid before setting source velocity based on global linear velocity.
2021-12-18 00:31:23 +01:00
Vera Aguilera Puerto
891d1da208 Version 0.8.9 2021-12-17 23:41:02 +01:00
E F R
f8e903c422 Rich Text Fixes The 3rd (#2351) 2021-12-17 23:39:46 +01:00
Vera Aguilera Puerto
b373824cf5 Various MIDI improvements and fixes.
- Fix bug where MIDI renderers in other maps than the current map in IEyeManager would be silenced forever.
- Tracking an entity now sets the TrackingCoordinates to the entity's coordinates.
- MIDI renderers not in your same IEyeManager.CurrentMap or that have invalid coordinates will have their occlusion set to the max value, essentially becoming silenced. I feel like this is a much better solution than changing the volume, as things should be able to call Source.SetVolume without it being changed by positional audio shenanigans.
2021-12-17 23:38:14 +01:00
Paul
6c3c51e816 fix FloatSerializer.cs 2021-12-16 17:52:14 +01:00
Paul
9abc3fbee2 remove allocations with this one simple trick. doctors hate em! 2021-12-16 14:25:26 +01:00
Vera Aguilera Puerto
9f20c325ab Cache transform comp in CreateEntityUninitialized.
Instead of getting it 5 times in a row.
2021-12-16 12:58:12 +01:00
Vera Aguilera Puerto
e7308efdd7 Botch VV to allow viewing remote entities that don't exist locally. (#2346) 2021-12-16 11:32:54 +01:00
Vera Aguilera Puerto
c2113b5719 Remove AggressiveOptimization flag from EntitySystem proxy methods.
Also fixes xmldoc inheritance for some methods.
2021-12-15 11:45:34 +01:00
Leon Friedrich
c43f7ea861 Add nullable overrides for the the Deleted() & Exists() proxy methods. (#2348) 2021-12-15 11:38:45 +01:00
E F R
5fac3f4adb UserInterface/RichTextEntry: Rich Text Fixes (Round 2) (#2340)
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-12-15 10:25:33 +01:00
metalgearsloth
7a31525c3c EntityQuery funnies (#2347) 2021-12-15 18:02:02 +11:00
Vera Aguilera Puerto
1613f5e982 Expose IContentRoot to content. (#2338) 2021-12-14 13:49:07 +01:00
Leon Friedrich
b6907e999d Make ContainerSystem.ContainsEntity() not log missing components (#2345) 2021-12-14 10:14:09 +01:00
Vera Aguilera Puerto
c73077014b EntityUid now shows a "View" button in VV. (#2342) 2021-12-14 09:57:46 +01:00
metalgearsloth
ce9bf26204 Minor render tree updates optimisation (#2337) 2021-12-14 09:51:27 +01:00
Paul Ritter
85f716ef03 pvs optimizations (#2341) 2021-12-14 09:50:34 +01:00
metalgearsloth
fba696ad6d Optimise client 5% with this one trick (#2334) 2021-12-14 09:50:03 +01:00
metalgearsloth
ed4267df50 Minor xform optimisations (#2335) 2021-12-14 09:49:30 +01:00
Insineer
1afeac4b95 fix(server): specify default culture for float.Parse (#2307)
Co-authored-by: Acruid <shatter66@gmail.com>
2021-12-13 11:27:16 +01:00
ShadowCommander
1c761737b6 Version: 0.8.8 2021-12-12 23:19:42 -08:00
ShadowCommander
a159db74f6 Version: 0.2.26 2021-12-12 23:19:07 -08:00
ShadowCommander
ac781e51ec Clean up unused variables in OutputPanel 2021-12-12 23:17:38 -08:00
E F R
e050af31af Controls/OutputPanel: Conslidate logic in _invalidateEntries, and get rid of some rogue LineHeight calculations (#2332) 2021-12-12 23:10:24 -08:00
Acruid
9ca1b8dae0 Version: 0.8.7 2021-12-12 18:20:47 -08:00
wrexbe
a59ab44199 Add IWritableDirProvider helper (#2321) 2021-12-12 16:19:51 -08:00
ShadowCommander
45d4a67ff4 Fix replicated cvars not copying overrides from cmd line (#2329) 2021-12-12 16:17:19 -08:00
Acruid
97f5131ce0 Fixed bug where _pendingResolves was not getting cleared. (#2328)
Added an option to defer field DI for RegisteredInstances until BuildGraph is called. This lets you register instances that contain dependency fields that are not instantiated yet.
2021-12-12 16:12:52 -08:00
localcc
2d4ddd8bd1 Texture GetPixel implemented (#2320) 2021-12-12 16:09:02 -08:00
wrexbe
c94e49ed08 Cache Component Types (#2325) 2021-12-12 16:06:51 -08:00
metalgearsloth
30a72b1227 Optimise some physics stuff (#2303)
* Optimise some physics stuff

* Fix build
2021-12-12 15:45:29 -08:00
metalgearsloth
b5ac7752d4 Make client console check perms locally (#2188) 2021-12-13 00:43:33 +01:00
E F R
04ed7e14e2 Console/SystemConsoleManager: Short-circuit console input handling when not interactive (#2311)
* Console/SystemConsoleManager: Short-circuit console input handling when not interactive

* Console/SystemConsoleManager: Use a `Task` for reading input

Now with 100% less blocking (on the main thread, at least)

* Console/SystemConsoleManager: move command execution off the worker thread
2021-12-12 15:28:02 -08:00
E F R
d168926f98 Graphics/Clyde: add option to submit GLSL #defines for shaders (#2306) 2021-12-12 15:05:50 -08:00
E F R
2a8887d0b4 Rich text redux (#2213)
* Shared/Utility: Define new FormattedMessage core types

* Shared/Utility: Move MarkupParser to a new namespace, update to new FormattedText

* Shared/Serialization: Temporary fix for FormattedMessageSerializer

* Scripting/ScriptInstanceShared: Move to new FormattedMessage.Builder

* Shared/Utility: Add a FormattedMessage loader to the .Builder

* Server/Scripting: Port SciptHost to FormattedMessage.Builder

* UserInterface/RichTextEntry: NOP out almost everything

not gonna bother fixing it until more groundwork is laid

* Shared/Utility: Expand Utility.Extensions a bit

strictly for pesonal reasons

* Client/UserInterface: Add the base TextLayout engine

* Client/Graphics: Add a Font Library manager

* Graphics/TextLayout: Finish up implementing the TextLayout engine

* Utility/FormattedMessage: Add yet another hack to keep the serializer in service

* Commands/Debug: Use FormattedMessage.Builder

* Console/Completions: Use FormattedMessage.Builder

* Utility/FormattedMessage: Add `AddMessage` methods

* Console/ScriptConsole: Use FormattedMessage.Builder

* Client/Log: Use FormattedMessage.Builder

* CustomControls/DebugConsole: Use FormattedMessage.Builder

* Controls/OutputPanel: Use FormattedMessage.Builder, NOP `Draw` pending rewrite

* Controls/RichTextLabel: Use FormattedMessage.Builder, NOP `Draw` pending rewrite

* UnitTesting: Update FormattedMessage/Markup Tests

They will NOT pass yet, but I don't care; it compiles.

* Utility/FormattedMessage: Fix some off-by-one Builder bugs

* Utility/FormattedMessage: Continue cleanup, test compliance

* Utility/FormattedMessage: Work around https://github.com/dotnet/roslyn/issues/57870

* Utility/FormattedMessage: Move ISectionable from TextLayout, implement it for FormattedMessage

* UserInterface/TextLayout: Add a `postcreate` function to set up new `TIn`s

Apparently Roslyn isn't big-brained enough to understand that a
closure of type `Func<T>` means that `var n = new(); return n;` requires
`new()` to return a `T`.

Ironically, it's significantly less cbt to add this than to convert
that big tuple in `Layout` in to a class or struct of some sort
(to initialize the `List<>`s).

* UserInterface/TextLayout: Throw if `Meta` isn't recognized

TODO warning go brrr

* Graphics/FontLibrary: Add a `DummyVariant`

* UserInterface/UITheme: Move to FontLibraries

* UserInterface/TextLayout: Move to an un-nested `ImmutableArray`

* UserInterface/RichTextEntry: Go ahead. Draw.

* Markup/Basic: Add extension & helpers for FormattedMessage.Builder

* Markup/Basic: Add `EscapeText` back in

A forgotten casualty of the great Markup separation of 2021

* Graphics/FontLibrary: Clean up bit magic, ensure that at least one font is picked

* Graphics/FontLibrary: Add diagnostics to the "no fonts" exception

* UserInterface/TextLayout: Scrap `Word`, return to `Offset`

* UserInterface/TextLayout: A whole bunch of hard-fought bugfixes

* Utility/FormattedMessage: Add a static, empty FormattedMessage

* Utility/FormattedMessage: Fix. Bugs.

* UserInterface/RichTextEntry: Bug fixin'

* UserInterface: CSS teim

* Markup/Basic: Add an optional "default" style to use

* Utility/FormattedMessage: I'm surprised I only made this mistake once.

* Log/DebugConsoleLogHandler: work around lack of a default style
2021-12-12 14:35:26 -08:00
E F R
f7f6b74fd3 Graphics/Clyde: make Clearing RenderTargets optional (#2302) 2021-12-11 16:48:34 -08:00
Leon Friedrich
7609a49c17 Make AudioSystem no longer automatically add players in range. (#2299)
* make adding entities in range optional

* Revert "make adding entities in range optional"

This reverts commit bd707b9f4e.

* remove AudioSystem filter modifications
2021-12-11 16:32:17 -08:00
Vera Aguilera Puerto
213db08566 Version 0.8.6 2021-12-11 21:09:40 +01:00
Vera Aguilera Puerto
ba2fbd99a8 Revert "Fix broadphase RemoveBody issue (#2318)"
Caused severe issues, such as firelocks not having collision and some funny exceptions.
This reverts commit fd1a1d326c.
2021-12-11 20:59:44 +01:00
Vera Aguilera Puerto
8ed681d82e EntityStringRepresentation implements IFormattable 2021-12-11 16:00:26 +01:00
Vera Aguilera Puerto
1032f10d85 Version 0.8.5 2021-12-11 15:32:31 +01:00
Vera Aguilera Puerto
4fc46ac814 Transform DetachParentToNull sets map to nullspace before raising the event. 2021-12-11 15:32:10 +01:00
Vera Aguilera Puerto
1611fb00d8 Version 0.8.4 2021-12-11 14:19:40 +01:00
Vera Aguilera Puerto
57a1f2743e Some minor PVS optimizations (#2324) 2021-12-11 14:17:38 +01:00
metalgearsloth
fd1a1d326c Fix broadphase RemoveBody issue (#2318) 2021-12-11 14:08:57 +01:00
metalgearsloth
ca7fdacfeb Make RunDeferred use worldpos+rot method (#2314) 2021-12-11 14:02:43 +01:00
Vera Aguilera Puerto
80f05d7467 Fix botched delete inline in EntityLookup 2021-12-11 12:38:32 +01:00
Paul Ritter
e84604f7e3 Fixes pvs culling & make budgets more granular (#2322) 2021-12-11 12:11:16 +01:00
Vera Aguilera Puerto
66c3013e39 VV EntityUid Name/Description setter.
For all your adminbus needs!
2021-12-10 11:53:00 +01:00
Vera Aguilera Puerto
717802fe54 Fix wrong grid placement direction when grid is rotated
Something to note is that grid placement is still very scuffed. On certain rotations, it begins acting weird.
2021-12-10 11:24:39 +01:00
Paul
977a840253 version bump 2021-12-10 10:17:25 +01:00
Paul
6051d4d358 removes statecache 2021-12-10 10:16:22 +01:00
Vera Aguilera Puerto
0a00a8a109 Fix build 2021-12-09 21:30:50 +01:00
wrexbe
9d1aff3a75 Fix NextMultipleOf for int/long (#2289) 2021-12-09 12:27:08 -08:00
E F R
3332279e75 SharedPhysicsSystem: convert parents' angular velocity to linear when leaving (#2208)
* SharedPhysicsSystem: convert parents' angular velocity to linear when leaving

Co-authored-by: ElectroJr <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Tomeno <Tomeno@users.noreply.github.com>

* SharedPhysicsSystem: Use Center of Mass now that it supposedly works

* SharedPhysicsSystem: Use REAL MATH™ to handle rotation when reparenting

* SharedPhysicsSystem: Cache some reused matrices

Addresses:
https://github.com/space-wizards/RobustToolbox/pull/2208#discussion_r762503056
https://github.com/space-wizards/RobustToolbox/pull/2208#discussion_r762502704

* SharedPhysicsSystem: More caching, I guess

* SharedPhysicsSystem: save ONE WHOLE ACCESS

What's next, shortening variable names to make it load faster?

Co-authored-by: ElectroJr <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Tomeno <Tomeno@users.noreply.github.com>
2021-12-09 12:18:37 -08:00
Vera Aguilera Puerto
d8059cacf4 Version 0.8.2
I hate myself sometimes
2021-12-09 14:55:15 +01:00
Vera Aguilera Puerto
374e80aad3 Version 0.8.1
Fixes bug regarding actors and player sessions on RELEASE.
2021-12-09 14:53:05 +01:00
Vera Aguilera Puerto
2fd15b0375 Version 0.8.0 2021-12-09 14:27:12 +01:00
Vera Aguilera Puerto
9293421f41 Merge branch '2021-12-03-remove-IEntity-komm-süsser-todd' 2021-12-09 14:25:49 +01:00
Vera Aguilera Puerto
4f358b3a5e proper VV for EntityUid 2021-12-09 13:24:19 +01:00
Vera Aguilera Puerto
76a804d427 TempQualifier moment 2021-12-09 12:54:49 +01:00
Vera Aguilera Puerto
f8bf877b61 Fix weird lifestage autorefactors. 2021-12-09 12:39:42 +01:00
Vera Aguilera Puerto
1f99f43755 Resolve IEntityManager as needed in MetaDataComponent 2021-12-09 11:22:56 +01:00
Vera Aguilera Puerto
457abf323b Merge branch 'master' into 2021-12-03-remove-IEntity-komm-süsser-todd
# Conflicts:
#	Robust.Shared/GameObjects/EntitySystem.Resolve.cs
2021-12-09 10:39:00 +01:00
Vera Aguilera Puerto
35d81974a8 Resolve no longer debug-asserts that the entity exists. 2021-12-09 01:59:02 +01:00
Paul
c6a9113144 version bump 2021-12-08 19:56:32 +01:00
Paul
c76d1d8c5c Merge branch 'master' of https://github.com/space-wizards/RobustToolbox 2021-12-08 19:55:42 +01:00
Paul
0e289873f5 pvs fixes 2021-12-08 19:55:24 +01:00
Paul
7e59febb47 nukes more resolves 2021-12-08 19:38:59 +01:00
Vera Aguilera Puerto
fb7a231b78 Fix VV crash 2021-12-08 13:33:21 +01:00
Vera Aguilera Puerto
85ded7a5a5 Fix build 2021-12-08 12:23:33 +01:00
Vera Aguilera Puerto
db996b9fb3 A bunch more resolves removed wooo 2021-12-08 11:37:11 +01:00
Vera Aguilera Puerto
52b09cef71 Fix build on RELEASE
EXCEPTION TOLERANCEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaAAaAAaaAAaAAaaAaaAAaaAaaAAAAAAaaaaaaaAAAAaaAAAAAaaaAAAAaaaaAAAAAaaaaaAAAAaaaaaaaAAAAAAAaaaaAAAAAaaaaaaaaAAAAAAAAAAAAAaaaaaaAAAAAAAAAAAaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAa
2021-12-08 11:11:13 +01:00
Vera Aguilera Puerto
26dcef4a11 Fix more useless resolves, makes entity system proxy "Deleted" not throw. 2021-12-08 11:10:11 +01:00
Vera Aguilera Puerto
9133879bd3 Remove more IoCManager IEntityManager resolves
Also adds convenience "Deleted" method to IEntityManager
2021-12-08 10:53:24 +01:00
Paul
76b2909116 removes resolves 2021-12-08 00:09:41 +01:00
Paul
9dab8e77a7 oh nein, kringe 2021-12-07 23:50:05 +01:00
Paul
0464b89cfe nonsense 2021-12-07 23:37:05 +01:00
Vera Aguilera Puerto
877e64f6be Merge pull request #12 from wrexbe/fork123 2021-12-07 18:52:59 +01:00
Wrexbe
4df03f859b Fix release building 2021-12-07 09:50:07 -08:00
metalgearsloth
66435e6022 optimise the shit out of rendertrees 2021-12-07 23:47:12 +11:00
Vera Aguilera Puerto
dc4f3b8f6f Merge pull request #10 from metalgearsloth/2021-12-03-remove-IEntity-komm-süsser-todd 2021-12-07 13:43:42 +01:00
metalgearsloth
8377acb672 more cast memes 2021-12-07 22:14:44 +11:00
metalgearsloth
84c14a4657 Remove redundant IComponent casts 2021-12-07 21:53:44 +11:00
Vera Aguilera Puerto
1d5476e01b More crash fixes 2021-12-06 15:56:14 +01:00
Vera Aguilera Puerto
73d21da0dd entity spawn panel fix 2021-12-06 15:41:38 +01:00
Vera Aguilera Puerto
81672fbe29 Goes in-game now 2021-12-06 15:34:46 +01:00
DrSmugleaf
5655dea1c7 Fix more errors, client and server now build 2021-12-06 14:00:38 +01:00
DrSmugleaf
2616f3cedd Merge branch 'master' of https://github.com/space-wizards/RobustToolbox into 2021-12-03-remove-IEntity-komm-süsser-todd 2021-12-06 12:44:57 +01:00
DrSmugleaf
511f272e96 Merge branch '2021-12-03-remove-IEntity-komm-süsser-todd' of https://github.com/Zumorica/RobustToolbox into 2021-12-03-remove-IEntity-komm-süsser-todd 2021-12-06 12:44:52 +01:00
DrSmugleaf
3c7f87b8c3 Add GetComponentOrNull extension for nullable EUid 2021-12-06 12:44:11 +01:00
DrSmugleaf
7f89aabbb0 Merge branch 'master' of https://github.com/space-wizards/RobustToolbox into 2021-12-03-remove-IEntity-komm-süsser-todd 2021-12-06 12:41:36 +01:00
DrSmugleaf
d6c9420a74 Add an overload for nullable EUid CompOrNull 2021-12-06 12:38:04 +01:00
Vera Aguilera Puerto
43e67c0db9 Add new EntitySystem proxy methods. (#2310) 2021-12-06 12:33:04 +01:00
metalgearsloth
2e1aa16d38 Merge pull request #9 from wrexbe/fixingitagain 2021-12-06 15:48:51 +11:00
metalgearsloth
849bcaeb74 Merge branch '2021-12-03-remove-IEntity-komm-süsser-todd' into fixingitagain 2021-12-06 15:48:44 +11:00
metalgearsloth
dce320d0f5 AttachedEntity stuff 2021-12-06 15:07:12 +11:00
metalgearsloth
d40804b41e testing push perms 2021-12-06 14:27:59 +11:00
Wrexbe
90596c8979 Fixed It 2021-12-05 18:12:56 -08:00
DrSmugleaf
36f582a712 Fix errors 2021-12-05 21:02:03 +01:00
DrSmugleaf
163deff564 Fix 3000 errors 2021-12-05 18:13:33 +01:00
metalgearsloth
ca68041199 Optimise showchunkbb a lot (#2308) 2021-12-05 13:38:40 +11:00
Vera Aguilera Puerto
850d7ba032 More error fixes. 2021-12-04 12:47:09 +01:00
Vera Aguilera Puerto
4c5fefc3b2 Merge pull request #8 from wrexbe/fork3 2021-12-04 11:50:26 +01:00
Wrexbe
84ee039f62 Fix the tests 2021-12-03 18:48:29 -08:00
Vera Aguilera Puerto
a84b481143 Merge pull request #6 from wrexbe/fork2 2021-12-03 23:27:28 +01:00
Wrexbe
69fa2eed64 Building Tests 2021-12-03 14:22:53 -08:00
Vera Aguilera Puerto
71f8275ae2 Merge pull request #4 from 20kdc/susser-todd 2021-12-03 22:46:57 +01:00
20kdc
b89bf5739c Move porting convenience properties 2021-12-03 21:44:14 +00:00
20kdc
e9ec2ee1d3 Susser Todd: Robust.Server, Error Pass 2 2021-12-03 21:33:10 +00:00
Vera Aguilera Puerto
a44a25fb96 Merge pull request #3 from wrexbe/fork1 2021-12-03 22:09:32 +01:00
Wrexbe
5356523305 Client builds 2021-12-03 12:58:37 -08:00
Vera Aguilera Puerto
2004ee9040 Merge pull request #2 from 20kdc/susser-todd 2021-12-03 21:00:09 +01:00
20kdc
7b6d9bd719 Susser Todd: Robust.Client/Robust.Server: Error Pass 1 2021-12-03 19:57:19 +00:00
Vera Aguilera Puerto
287e57f717 Merge pull request #1 from 20kdc/susser-todd 2021-12-03 20:44:39 +01:00
20kdc
add06753e9 Susser Todd: Robust.Shared.Scripting, Error Pass 2021-12-03 19:38:13 +00:00
20kdc
8aa6fb478b Susser Todd: Robust.Shared, Error Pass 2 "It Now Compiles" 2021-12-03 19:36:16 +00:00
20kdc
5e7d617736 Susser Todd: Robust.Shared, Error Pass 1 2021-12-03 18:40:55 +00:00
Vera Aguilera Puerto
fa6c37778e Minor EntityLookup fixes. 2021-12-03 17:50:37 +01:00
Vera Aguilera Puerto
4f92301d25 More manual fixes. 2021-12-03 17:35:20 +01:00
Vera Aguilera Puerto
bd6be35b4d ForAll, Spawn, etc 2021-12-03 17:11:29 +01:00
Vera Aguilera Puerto
c39f6d09eb Lots of manual fixing. More to come. 2021-12-03 17:01:46 +01:00
Vera Aguilera Puerto
5eda1b326d Inline OwnerUid 2021-12-03 16:30:34 +01:00
Vera Aguilera Puerto
5c3b058e81 Literally fucking remove IEntity 2021-12-03 16:08:41 +01:00
Vera Aguilera Puerto
7a06db60cf Inline UID 2021-12-03 15:53:10 +01:00
Vera Aguilera Puerto
aafb15aff5 Perform a slight amount of trolling 2021-12-03 15:35:18 +01:00
Vera Aguilera Puerto
c437fadd25 Inline GetComponentOrNull 2021-12-03 15:32:05 +01:00
Vera Aguilera Puerto
bab37587c5 Inline Name 2021-12-03 15:25:51 +01:00
Vera Aguilera Puerto
c4cd1fb6ee Some manual GetComponentOrNull inlines 2021-12-03 15:09:45 +01:00
Vera Aguilera Puerto
94e6886a85 Inline Transform 2021-12-03 14:20:35 +01:00
Vera Aguilera Puerto
e93ae73e50 Inline TryGetComponent completely, for real 2021-12-03 14:17:01 +01:00
Vera Aguilera Puerto
9739eaa34a Inline TryGetComponent completely 2021-12-03 14:05:36 +01:00
Vera Aguilera Puerto
2aa5e8c07f Version 0.7.21 2021-12-03 13:07:22 +01:00
Vera Aguilera Puerto
f8b2412855 holy fucking shit, fuck exception tolerance only being in RELEASE 2021-12-03 13:07:22 +01:00
metalgearsloth
04782b83ab Add overload to draw rotated position (#2304) 2021-12-03 12:41:58 +01:00
metalgearsloth
e2f2b3a26d Get rid of unused dependency on EffectOverlay 2021-12-03 22:24:23 +11:00
Vera Aguilera Puerto
b44a1cde88 Inline HasComponent entirely 2021-12-03 12:23:18 +01:00
Vera Aguilera Puerto
af964b52ed Inline one TryGetComponent overload 2021-12-03 12:18:25 +01:00
Vera Aguilera Puerto
ebca38b57a Inline one HasComponent overload 2021-12-03 12:18:21 +01:00
Vera Aguilera Puerto
86d05dfa1e Inline GetComponent 2021-12-03 11:55:25 +01:00
Vera Aguilera Puerto
e10bd576ff Inline SendNetworkMessage 2021-12-03 11:47:46 +01:00
Vera Aguilera Puerto
20ff1e86c0 Inline SendMessage 2021-12-03 11:47:24 +01:00
Vera Aguilera Puerto
9d2a2ef4ba Inline ToString 2021-12-03 11:46:53 +01:00
Vera Aguilera Puerto
70d2457514 Inline QueueDelete 2021-12-03 11:43:22 +01:00
Vera Aguilera Puerto
ba8deea700 Inline Delete 2021-12-03 11:43:03 +01:00
Vera Aguilera Puerto
f44d797057 Inline GetAllComponents 2021-12-03 11:42:24 +01:00
Vera Aguilera Puerto
e72d29a677 Remove Debug asserts 2021-12-03 11:39:36 +01:00
Vera Aguilera Puerto
5730465c36 Inline RemoveComponent 2021-12-03 11:34:00 +01:00
Vera Aguilera Puerto
19f50d60c9 Inline AddComponent 2021-12-03 11:33:40 +01:00
Vera Aguilera Puerto
bbf5e92f32 Inline IsValid 2021-12-03 11:32:53 +01:00
Vera Aguilera Puerto
419f4f36ab Inline Paused 2021-12-03 11:30:39 +01:00
Vera Aguilera Puerto
7769252109 Inline Deleted 2021-12-03 11:30:03 +01:00
Vera Aguilera Puerto
3785777983 Remove Initializing 2021-12-03 11:29:13 +01:00
Vera Aguilera Puerto
61aa73ffe3 Fix Prototype inline errors 2021-12-03 11:28:14 +01:00
Vera Aguilera Puerto
ce11bf4564 Inline Initialized 2021-12-03 11:24:56 +01:00
Vera Aguilera Puerto
0cf97780f0 Inline LastModifiedTick 2021-12-03 11:15:40 +01:00
Vera Aguilera Puerto
fc2f6d4910 Inline Description 2021-12-03 11:15:12 +01:00
Vera Aguilera Puerto
69158de99b Inline Prototype 2021-12-03 11:13:58 +01:00
Vera Aguilera Puerto
7bec76d8d1 Inline LifeStage 2021-12-03 11:13:18 +01:00
Vera Aguilera Puerto
6e86f98406 Inline MetaData 2021-12-03 11:12:35 +01:00
Vera Aguilera Puerto
f782e76671 Inline EntityManager 2021-12-03 11:11:52 +01:00
metalgearsloth
5a8464b518 Get rid of grid log spam 2021-12-03 21:08:01 +11:00
Vera Aguilera Puerto
5f1feb9bb1 Version 0.7.20 2021-12-03 11:02:48 +01:00
Vera Aguilera Puerto
196e2bb427 The End of Entity (Komm, Süsser Todd: Part 1.0) (#2295)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-12-03 11:01:59 +01:00
Acruid
f8bebee904 Remove Entity Transform/MetaData Component Cache (#2296)
Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
2021-12-03 10:33:06 +01:00
Vera Aguilera Puerto
6515b08b41 Better ToPrettyString with EntityStringRepresentation (#2301) 2021-12-03 10:09:49 +01:00
Vera Aguilera Puerto
6e2f18d0d8 Add joints to RobustServerSimulation. 2021-12-02 12:33:40 +01:00
metalgearsloth
a2ecd63e9d Version: 0.7.19 2021-12-01 18:31:44 +11:00
metalgearsloth
6da9176410 Fixture 2 electric boogaloo (#2297) 2021-12-01 18:31:13 +11:00
metalgearsloth
ae9b771c8c Version: 0.7.18 2021-12-01 13:57:48 +11:00
metalgearsloth
d1e206864c Revert "Quick hotfix for fixtures"
This reverts commit 7316d9e950.
2021-12-01 13:56:32 +11:00
metalgearsloth
f812eb1e27 Revert "Move physics fixtures to its own component (#2220)"
This reverts commit ebc0fc9c60.
2021-12-01 13:54:32 +11:00
metalgearsloth
1dec0dd980 Version: 0.7.17 2021-12-01 13:07:10 +11:00
metalgearsloth
7316d9e950 Quick hotfix for fixtures 2021-12-01 13:06:54 +11:00
metalgearsloth
f7c2305bce Version: 0.7.16 2021-12-01 13:02:55 +11:00
metalgearsloth
ebc0fc9c60 Move physics fixtures to its own component (#2220) 2021-12-01 12:59:42 +11:00
metalgearsloth
d157aab786 Hotfix effect rotation (#2291) 2021-12-01 12:59:28 +11:00
Pieter-Jan Briers
70a5d1bad6 Return of ExpandPvsEvent
Paul has been declared irrational and is extremely coping rn.
2021-11-30 18:35:50 +01:00
Paul
2471bf8b4b we do a little trolling 2021-11-30 18:13:36 +01:00
Paul
e7c5706b04 comments out tests until i fix inventorycode 2021-11-30 18:09:19 +01:00
Paul
7b6d8a1465 fixes at least one test 2021-11-30 18:04:43 +01:00
Paul
31b750bd5b fixes that goddamn AngleSerializerTest 2021-11-30 17:50:52 +01:00
Paul
6ebd0eb4ae fuck mapmanager 2021-11-30 16:59:44 +01:00
Paul
37eac8c73f version 0.7.14 2021-11-30 15:19:13 +01:00
Paul Ritter
44649eea1c pvs refactor (#2247)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2021-11-30 15:07:08 +01:00
Pieter-Jan Briers
caa0212282 Swap ANGLE-related CVars around.
ANGLE is now off by default, angle_custom_swap_chain on if you set ANGLE.
2021-11-29 18:36:14 +01:00
Pieter-Jan Briers
7f9d08c8f9 Fix duplicate GL init on ANGLE GL context. 2021-11-29 18:35:24 +01:00
Pieter-Jan Briers
1c128e6b74 Return of the VRAM command. 2021-11-29 13:23:58 +01:00
Pieter-Jan Briers
099e7c5c48 IDXGIFactory6::EnumAdapterByGpuPreference for GLContextAngle. 2021-11-29 13:14:59 +01:00
Pieter-Jan Briers
2f76908efb Remove PlatformTarget from WebView project.
Fixes a compiler warning.
2021-11-29 08:35:39 +01:00
Pieter-Jan Briers
5adde7d588 Version: 0.7.13 2021-11-29 00:20:45 +01:00
Pieter-Jan Briers
7b1bb7df47 Expand PVS event (#2287) 2021-11-28 23:43:05 +01:00
Pieter-Jan Briers
8e5eb6ebbb Version: 0.7.12 2021-11-28 23:14:42 +01:00
Pieter-Jan Briers
87ef010348 Remove another NativeLibrary.Load -> exception catch.
This time with Optimus stuff.
2021-11-28 23:13:50 +01:00
wrexbe
229d1c248b Make benchmark debuggable (#2285) 2021-11-28 23:11:58 +01:00
wrexbe
8db606c4e4 Remove duplicate PluralRules.Generator in RobustToolbox.sln (#2286) 2021-11-28 23:03:46 +01:00
Pieter-Jan Briers
6b5181269b Do some trimming for client publishes.
Almost completely removes TerraFX and OpenToolkit.Graphics from client publishes size wise. This cuts publish size in half.
2021-11-28 22:26:05 +01:00
Pieter-Jan Briers
17b84c3520 Update to latest TerraFX, compile custom swapchain ANGLE in. 2021-11-28 22:12:17 +01:00
Pieter-Jan Briers
42875fc101 Remove RobustTaskScheduler entirely.
No longer necessary thanks to #2263.
2021-11-28 15:09:01 +01:00
wrexbe
72a7bc2ae7 Unwrap ParsedMain (#2263) 2021-11-28 15:07:25 +01:00
Leon Friedrich
bef4f75419 Fix AudioParams DataDefinition (#2283) 2021-11-28 15:00:23 +01:00
metalgearsloth
216509f89d Fix multi-subscriber crash for PVS (#2282) 2021-11-28 13:22:13 +01:00
20kdc
b7991204f1 Cleanup NativeLibrary.Load usages by replacing them with TryLoad (#2259)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-11-28 00:41:53 +01:00
metalgearsloth
02987ac703 Update some hotpaths to use new transform method (#2281) 2021-11-28 00:41:08 +01:00
ike709
5cf8cb262f Updates cefglue (#2258)
Co-authored-by: ike709 <ike709@github.com>
2021-11-28 00:40:10 +01:00
metalgearsloth
49dfca169c Add scale command (#2256) 2021-11-28 00:38:41 +01:00
Acruid
33008a2bce Cannot use 'System.Runtime.CompilerServices.DefaultInterpolatedStringHandler' as a type argument 2021-11-26 19:24:31 -08:00
Acruid
c2e90132c0 Makes the scene command actually check for scene types instead of trying to instantiate random classes like ecs event args. 2021-11-26 08:30:18 -08:00
Vera Aguilera Puerto
9859b5b090 IConsoleCommands get dependencies injected by default now. (#2264)
As the DI gods intended.
2021-11-26 02:28:07 -08:00
metalgearsloth
20aec0a8f9 Add method to get worldpos and worldrot at the same time (#2226)
* Add method to get worldpos and worldrot at the same time

Somewhat of a gain because it halves the number of GetComponent<TransformComponent> + _parent.IsValid() calls

* Remove redundant methods

* Also inverse

* Test

* Import

* Add benchmark

* Delete benchmark
2021-11-26 01:47:51 -08:00
Vera Aguilera Puerto
a9ee78e40d MIDI player looping fix.
SetLoop sets the amount of times to loop a song. If you set it to 1, it'll loop once, if you set it to -1, it'll loop infinitely. This should have been 0 from the start, so it doesn't loop when disabled.
2021-11-25 15:06:55 +01:00
Vera Aguilera Puerto
69f36aac6f Add ToPrettyString method to EntityManager (#2257) 2021-11-24 12:04:18 +01:00
Pieter-Jan Briers
173b41ab9e Send level as log label again in loki. 2021-11-24 08:36:01 +01:00
Vera Aguilera Puerto
7796d7f065 IEntityManager.Clear() actually drops entity system as its xmldoc says. 2021-11-23 11:07:16 +01:00
metalgearsloth
175c111be9 Version: 0.7.11 2021-11-23 18:21:23 +11:00
Acruid
279cc0f83f AppearanceComponent Cleanup (#2253) 2021-11-23 18:16:37 +11:00
DrSmugleaf
b334d927a5 Version: 0.7.10 2021-11-22 19:02:28 +01:00
Vera Aguilera Puerto
bdb9b9af2b Remove PlayerHelpers static class. 2021-11-21 17:58:54 +01:00
Pieter-Jan Briers
5aa634b5eb Don't enable Lidgren UPnP support unless requested.
It wasn't being *used* but discovery was still happening, so...
2021-11-21 17:15:08 +01:00
Javier Guardia Fernández
60d7430fe7 Whitelist CallerArgumentExpressionAttribute, InterpolatedStringHandlerAttribute and IsByRefLikeAttribute (#2251) 2021-11-21 16:04:00 +01:00
Pieter-Jan Briers
a9aeff9b78 Version: 0.7.9 2021-11-21 15:20:41 +01:00
20kdc
e7a0409645 Status host uses net.port by default, add UPnP port forwarding option (#2237)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2021-11-21 15:19:39 +01:00
ShadowCommander
3e718575ff Change Button Pressed to work with non-focus keybinds (#1978) 2021-11-21 14:52:41 +01:00
Acruid
746ec9eab7 Marked PlayerSession find methods on PlayerManager Obsolete (#2244) 2021-11-21 14:51:17 +01:00
Pieter-Jan Briers
60e6ecb0cc Fix loading of command binds from keybinds file. 2021-11-21 14:48:17 +01:00
metalgearsloth
3a00e0d497 Expose physics contacts as an enumerable (#2250) 2021-11-21 18:41:12 +11:00
Leon Friedrich
24a5020b42 fix rotated box contains (#2248) 2021-11-19 22:59:49 -08:00
20kdc
bbb9e94ce9 Arbitrary occluder rotation (#2218)
* All forms of rotated occluders now work

* Utility getters for vector CW/CCW rotations
2021-11-19 15:09:45 -08:00
pointer-to-null
2bea9576f0 Public FpsCounter class. (#2246) 2021-11-19 15:00:14 -08:00
Tomeno
6e0be2b8c9 Clear placementManager when searching/clearing/closing window (#2245)
Co-authored-by: Tomeno <tomeno@lulzsec.co.uk>
2021-11-19 17:46:40 +01:00
Vera Aguilera Puerto
0a348dd1be Version 0.7.8 2021-11-18 19:34:43 +01:00
metalgearsloth
a95283913b Optimise broadphase a LOT for grids moving (#2243)
Previously it went through the entire movebuffer. Now it just uses the localbounds.
2021-11-18 15:40:28 +01:00
metalgearsloth
ebc73a71c2 Optimise GetBroadphases (#2242)
* Optimise GetBroadphases

Only used in public APIs. Should be significantly faster as it doesn't iterate every fixture on a grid.

* Fix the staged stuff
2021-11-18 15:24:18 +01:00
metalgearsloth
05321f0381 Miscellaneous fixes for thrusters (#2239) 2021-11-17 22:42:00 +01:00
Javier Guardia Fernández
6554144c42 Add CollectionsMarshal.AsSpan<T>(List<T>) to the sandbox whitelist (#2241) 2021-11-17 22:37:57 +01:00
20kdc
28e6cdc92f Clyde audio cleanup & fallback if audio device is not available (#2240) 2021-11-17 14:18:04 +01:00
metalgearsloth
2ec715b70e Remove fixture removal error
Client can predict these removals so it just spams the log.
2021-11-17 22:25:36 +11:00
Acruid
424e0768c8 Fixed some code that I forgot to change to help IoC instantiate protected constructors. 2021-11-17 03:10:12 -08:00
Acruid
e1b9327ec0 Misc Engine Tweaks (#2238) 2021-11-17 09:39:18 +01:00
Flipp Syder
80308a799f Adds collapsible widgets (#2199)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2021-11-16 19:09:59 +01:00
20kdc
e30f8f3e69 Async status host handlers to reduce ACZ stalling (#2235) 2021-11-16 13:27:29 +01:00
20kdc
302b910cf3 ACZ: Work around exception handling issues in ManagedHttpListener (#2236) 2021-11-16 13:26:10 +01:00
Pieter-Jan Briers
5a6a16e7dc Upgrade Loki sink to 4.0.0-beta3.
This fixes many bugs with it.
2021-11-15 13:42:19 +01:00
Pieter-Jan Briers
8d84c56a72 Remove testing profile opt stuff. 2021-11-15 11:32:51 +01:00
Pieter-Jan Briers
13f821be5f Grid entity deletion, attempt two.
Previous attempt broke an integration test.
2021-11-15 11:06:30 +01:00
Pieter-Jan Briers
d647ab1c61 Fix some warnings. 2021-11-15 10:53:39 +01:00
Pieter-Jan Briers
b902ef290a Fix directly deleting grid entities.
A bad return statement meant that the associated grid was not being properly deleted.

This fix means the game won't effectively crash PVS if a grid entity is directly deleted.
2021-11-15 10:49:05 +01:00
Pieter-Jan Briers
058d897529 Version: 0.7.7 2021-11-15 02:43:49 +01:00
Javier Guardia Fernández
8e173a7a18 Fix FormattedMessage serialization and add tests (#2233) 2021-11-15 02:42:47 +01:00
20kdc
5443f77526 Automatic Client Zipping (#2225) 2021-11-15 02:42:20 +01:00
20kdc
b406526592 Version update and tag script (#2234) 2021-11-15 02:18:20 +01:00
Pieter-Jan Briers
48697da450 Add version to Robust.Engine.props 2021-11-14 22:46:13 +01:00
Javier Guardia Fernández
06f20ea722 Add a method to get a FormattedMessage with markup tags included (#2223) 2021-11-14 19:42:36 +01:00
metalgearsloth
427378f94d Optimise physics broadphase cache (#2224) 2021-11-14 19:42:02 +01:00
Vera Aguilera Puerto
6cf5021efa Add Resolves to IoCManager and EntitySystemManager (#2231) 2021-11-14 19:41:34 +01:00
Tomeno
ad9bda2efe Adds setters on SS14Window for styling header & title (#2232)
Co-authored-by: T <tomeno@lulzsec.co.uk>
2021-11-14 19:19:12 +01:00
Pieter-Jan Briers
f0bf251acf Improve IUserInterfaceManager.RootControl comment 2021-11-14 19:08:14 +01:00
Pieter-Jan Briers
21f5fed32f Fix IsVisibleInTree calculation with secondary window roots 2021-11-14 19:08:14 +01:00
metalgearsloth
cc67a47c32 Pass around filter dependencies (#2228) 2021-11-14 02:08:09 +01:00
Javier Guardia Fernández
e78e7bacfe Add bool Contains(string, System.StringComparison) to the whitelist (#2230) 2021-11-14 01:37:33 +01:00
Vera Aguilera Puerto
6301008ac3 Revert "adds required check to the yamllinter (#2216)"
This reverts commit 772076826a.
2021-11-12 11:27:53 +01:00
Pieter-Jan Briers
dfd572a0aa Change Microsoft.Data.Sqlite reference to SQLitePCLRaw.bundle_e_sqlite, use version to fix .NET 6 build thing. 2021-11-11 18:23:16 +01:00
Pieter-Jan Briers
97fab99971 You can now bind console commands to keybinds. 2021-11-11 18:05:08 +01:00
Pieter-Jan Briers
25d6bd908b Remove BGRA32 uploads from Clyde.
BGRA uploads are not supported on GLES. Use a shader to swizzle WebViewControl contents instead.
2021-11-11 18:05:04 +01:00
Pieter-Jan Briers
fd5a8bf207 Fix GLContextAngle unbinding GL context when resizing secondary windows. 2021-11-11 18:05:03 +01:00
Paul Ritter
772076826a adds required check to the yamllinter (#2216)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2021-11-11 17:39:41 +01:00
Vera Aguilera Puerto
52d669e032 Fixes exceptions on shutdown. (#2219) 2021-11-11 17:39:25 +01:00
metalgearsloth
75fc9089c3 Add weld joints and other misc changes for docking (#2197) 2021-11-11 19:54:08 +11:00
Kara D
0972601a43 Revert "entity creation crash fixes"
This reverts commit 603c252c48.
2021-11-10 12:09:31 -07:00
Paul
603c252c48 entity creation crash fixes 2021-11-10 18:57:47 +01:00
Paul
d5b1c044b7 fixes the crash for realsies 2021-11-10 18:34:21 +01:00
metalgearsloth
4600f0531d Fix centre of mass (#2212) 2021-11-10 17:25:38 +01:00
Leon Friedrich
c88498eca9 Add function to directly perform lookups using an EntityLookupComponent (#2200) 2021-11-11 01:12:49 +11:00
Paul Ritter
f15f1eb345 adds gridremovalevent (#2201)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2021-11-10 23:27:11 +11:00
Pieter-Jan Briers
5be3ced05a UI scaling for WebViewControl. 2021-11-10 11:57:58 +01:00
Pieter-Jan Briers
7f03e88e97 OSWindow not adjusts SetSize when window is resized. 2021-11-10 11:57:12 +01:00
Pieter-Jan Briers
8e3fa3e52d Pass + as command line arg to client/server to execute commands after init. 2021-11-10 02:01:31 +01:00
metalgearsloth
f9ae3e1fc2 Significantly optimise server when PVS disabled (#2196) 2021-11-10 01:38:37 +01:00
mirrorcult
bf9e95fa8a Update README.md 2021-11-09 17:21:37 -07:00
ZorenZal
030a7d265b Added set English language checkbox (#2136) 2021-11-10 01:12:36 +01:00
Pieter-Jan Briers
df70e94743 ununupdated comment 2021-11-10 01:09:06 +01:00
metalgearsloth
d68cd4d7eb Add overlay for physics COM (#2210) 2021-11-10 01:05:08 +01:00
Pieter-Jan Briers
d098881bff Make BVH tree expansion exponential.
Fixes #2215
2021-11-10 00:59:53 +01:00
ike709
b8fbe32c27 Bump Robust.Client.WebView TargetFramework to .NET 6 (#2214) 2021-11-09 20:17:37 +01:00
Pieter-Jan Briers
02d2bd31e7 Update Lidgren submodule; re-enable encryption. 2021-11-09 19:34:55 +01:00
Pieter-Jan Briers
bd0dba0df0 Disable network encryption to bandaid it for .NET 6. 2021-11-09 18:07:59 +01:00
546 changed files with 17654 additions and 11901 deletions

19
.github/CODEOWNERS vendored
View File

@@ -1,7 +1,20 @@
# Last match in file takes precedence.
# Ping for all PRs
* @Acruid @PJB3005 @Silvertorch5
/Robust.*/Audio/Midi/ @Zumorica
/Robust.Client.NameGenerator @PaulRitter
/Robust.Client.Injectors @PaulRitter
/Robust.Generators @PaulRitter
/Robust.Analyzers @PaulRitter
/Robust.*/GameStates @PaulRitter
/Robust.Shared/Analyzers @PaulRitter
/Robust.*/Serialization @PaulRitter
/Robust.*/Prototypes @PaulRitter
/Robust.Shared/GameObjects/ComponentDependencies @PaulRitter
/Robust.*/Containers @PaulRitter
# Be they Fluent translations or Freemarker templates, I know them both!
*.ftl @RemieRichards
# Ping for all PRs
* @Acruid @PJB3005 @Silvertorch5

22
.gitignore vendored
View File

@@ -41,18 +41,6 @@ _ReSharper*/
# Resources
*.resources
/Resources/textures/Animations/*.*
/Resources/ResourcePack.zip
/Resources/textures/*_Animations.png
/Resources/textures/*_Decals.png
/Resources/textures/*_Effects.png
/Resources/textures/*_Items.png
/Resources/textures/*_Objects.png
/Resources/textures/*_Tiles.png
/Resources/textures/*_UserInterface.png
/Resources/textures/*.TAI
/Resources/SpriteRenderer/Ogre.log
/Resources/Spriterenderer/output
/Media
/setenv.bat
@@ -78,16 +66,6 @@ project.lock.json
# Created by NUnit.
TestResult.xml
NetSerializerDebug.dll
# We're not gonna ship Mac extlibs with the repo due to size. (11 MB)
Third-Party/extlibs/Mac/
# Or the automatically-fetched Windows natives, for that matter.
Third-Party/extlibs/Windows/
# Actually I'll make this folder because SS14.Shared.Bsdiff isn't third-party is it?
Dependencies/
# Python stuff
__pycache__
.mypy_cache

3
.gitmodules vendored
View File

@@ -13,9 +13,6 @@
[submodule "ManagedHttpListener"]
path = ManagedHttpListener
url = https://github.com/space-wizards/ManagedHttpListener.git
[submodule "Linguini"]
path = Linguini
url = https://github.com/space-wizards/Linguini
[submodule "cefglue"]
path = cefglue
url = https://github.com/space-wizards/cefglue.git

Submodule Linguini deleted from b3c05c2f31

View File

@@ -0,0 +1,4 @@
<Project>
<!-- This file automatically reset by Tools/version.py -->
<PropertyGroup><Version>0.8.43</Version></PropertyGroup>
</Project>

View File

@@ -6,4 +6,5 @@
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>
<Import Project="Robust.Engine.Version.props" />
</Project>

View File

@@ -0,0 +1,122 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<!--
Stuff for using ILLink trimming without self-contained deployments.
This is not something officially supported by the .NET SDK currently, but we can simply run ILLink ourselves.
-->
<!--
A lot of stuff taken from Microsoft.NET.ILLink.targets in the SDK files.
-->
<ItemDefinitionGroup>
<RobustLinkRoots>
<Visible>false</Visible>
</RobustLinkRoots>
<RobustLinkAssemblies>
<Visible>false</Visible>
</RobustLinkAssemblies>
</ItemDefinitionGroup>
<Target Name="RobustILLink"
BeforeTargets="ILLink"
Condition="'$(PublishTrimmed)' != 'true' And
'$(RobustILLink)' == 'true'"
DependsOnTargets="_ComputeAssembliesToPostprocessOnPublish">
<ComputeManagedAssemblies Assemblies="@(ResolvedFileToPublish)">
<Output TaskParameter="ManagedAssemblies" ItemName="_ResolvedFileToPublishFiltered" />
</ComputeManagedAssemblies>
<JoinItems Left="@(_ResolvedFileToPublishFiltered)" LeftKey="FileName" LeftMetadata="*"
Right="@(RobustLinkRoots)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_RobustLinkRootsJoined" />
</JoinItems>
<JoinItems Left="@(_ResolvedFileToPublishFiltered)" LeftKey="FileName" LeftMetadata="*"
Right="@(RobustLinkAssemblies)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_RobustLinkAssembliesJoined" />
</JoinItems>
<PropertyGroup>
<TrimMode Condition=" '$(TrimMode)' == '' ">link</TrimMode>
<TrimmerDefaultAction Condition=" '$(TrimmerDefaultAction)' == '' ">copy</TrimmerDefaultAction>
<_ExtraTrimmerArgs>--skip-unresolved true $(_ExtraTrimmerArgs)</_ExtraTrimmerArgs>
<ILLinkTreatWarningsAsErrors Condition=" '$(ILLinkTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</ILLinkTreatWarningsAsErrors>
<TrimmerSingleWarn Condition=" '$(TrimmerSingleWarn)' == '' ">true</TrimmerSingleWarn>
</PropertyGroup>
<ItemGroup>
<RobustAssemblyToLink Include="@(_RobustLinkRootsJoined)">
<TrimMode>Copy</TrimMode>
</RobustAssemblyToLink>
<RobustAssemblyToLink Include="@(_RobustLinkAssembliesJoined)">
<TrimMode>Link</TrimMode>
</RobustAssemblyToLink>
</ItemGroup>
<ItemGroup>
<!-- The linker implicitly picks up PDBs next to input assemblies. We will filter these out of the publish set. -->
<__PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(RobustAssemblyToLink->'%(RelativeDir)%(Filename).pdb')" />
<_PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(__PDBToLink)" />
</ItemGroup>
<ItemGroup>
<_LinkedResolvedFileToPublishCandidate Include="@(RobustAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />
<_LinkedResolvedFileToPublishCandidate Include="@(_PDBToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />
</ItemGroup>
<!--<Message Text="@(ResolvedFileToPublish)" Importance="high" />-->
<ItemGroup>
<_TrimmerFeatureSettings Include="@(RuntimeHostConfigurationOption)"
Condition="'%(RuntimeHostConfigurationOption.Trim)' == 'true'" />
</ItemGroup>
<Delete Files="@(_LinkedResolvedFileToPublishCandidate)" />
<ILLink AssemblyPaths="@(RobustAssemblyToLink)"
ReferenceAssemblyPaths="@(ReferencePath)"
RootAssemblyNames="@(RobustLinkRoots)"
TrimMode="Skip"
DefaultAction="$(TrimmerDefaultAction)"
RemoveSymbols="false"
FeatureSettings="@(_TrimmerFeatureSettings)"
CustomData="@(_TrimmerCustomData)"
BeforeFieldInit="$(_TrimmerBeforeFieldInit)"
OverrideRemoval="$(_TrimmerOverrideRemoval)"
UnreachableBodies="$(_TrimmerUnreachableBodies)"
UnusedInterfaces="$(_TrimmerUnusedInterfaces)"
IPConstProp="$(_TrimmerIPConstProp)"
Sealer="$(_TrimmerSealer)"
Warn="$(ILLinkWarningLevel)"
NoWarn="$(NoWarn)"
TreatWarningsAsErrors="$(ILLinkTreatWarningsAsErrors)"
WarningsAsErrors="$(WarningsAsErrors)"
WarningsNotAsErrors="$(WarningsNotAsErrors)"
SingleWarn="$(TrimmerSingleWarn)"
CustomSteps="@(_TrimmerCustomSteps)"
RootDescriptorFiles="@(TrimmerRootDescriptor)"
OutputDirectory="$(IntermediateLinkDir)"
DumpDependencies="$(_TrimmerDumpDependencies)"
ExtraArgs="$(_ExtraTrimmerArgs)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)"
ContinueOnError="ErrorAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_ILLinkExitCode" />
</ILLink>
<Touch Files="$(_LinkSemaphore)" AlwaysCreate="true" Condition=" '$(_ILLinkExitCode)' == '0' " />
<ItemGroup>
<_LinkedResolvedFileToPublish Include="@(_LinkedResolvedFileToPublishCandidate)" Condition="Exists('%(Identity)')" />
<ResolvedFileToPublish Remove="@(RobustAssemblyToLink)" />
<ResolvedFileToPublish Remove="@(_PDBToLink)" />
<ResolvedFileToPublish Include="@(_LinkedResolvedFileToPublish)" />
</ItemGroup>
</Target>
</Project>

View File

@@ -18,20 +18,18 @@ namespace OpenToolkit.GraphicsLibraryFramework
NativeLibrary.SetDllImportResolver(typeof(GLFWNative).Assembly, (name, assembly, path) =>
{
// Please keep in sync with what Robust.Shared/DllMapHelper.cs does.
if (name != "glfw3.dll")
{
return IntPtr.Zero;
}
if (OperatingSystem.IsLinux())
{
return NativeLibrary.Load("libglfw.so.3", assembly, path);
}
string rName = null;
if (OperatingSystem.IsLinux()) rName = "libglfw.so.3";
else if (OperatingSystem.IsMacOS()) rName = "libglfw.3.dylib";
if (OperatingSystem.IsMacOS())
{
return NativeLibrary.Load("libglfw.3.dylib", assembly, path);
}
if ((rName != null) && NativeLibrary.TryLoad(rName, assembly, path, out var handle))
return handle;
return IntPtr.Zero;
});

View File

@@ -10,7 +10,7 @@ Use the [content repo](https://github.com/space-wizards/space-station-14) for ac
## Documentation/Wiki
The [HackMD Wiki](https://hackmd.io/@ss14/docs/wiki) has documentation on SS14s content, engine, game design and more. We also have lots of resources for new contributors to the project.
The [wiki](https://docs.spacestation14.io/) has documentation on SS14s content, engine, game design and more. We also have lots of resources for new contributors to the project.
## Contributing

View File

@@ -1,8 +0,0 @@
# .import files are made by Godot because the assets are exposed if using symlinks.
# IF you need to persist a .import file because of something used Godot-side (GUI-side),
# you can do a negation with !.
*.import
# Negation would be like this:
#!/Textures/UserInterface/1pxwhite.png.import
!/Scenes/SS14Window/closewindow.png.import
/I_MADE_THE_SYMLINK

View File

@@ -0,0 +1 @@
defaultwindow-placeholder-title = Exemplary Window Title Here

View File

@@ -1 +0,0 @@
ss14window-placeholder-title = Exemplary Window Title Here

View File

@@ -7,3 +7,8 @@
- type: shader
id: shaded
kind: canvas
- type: shader
id: bgra
kind: source
path: "/Shaders/Internal/bgra.swsl"

View File

@@ -0,0 +1,6 @@
// Swaps B and R channel so you can render BGRA stuff without swizzling at upload time.
// Currently used by CEF.
void fragment() {
COLOR = zTexture(UV).bgra;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,2 +0,0 @@
sample:
filter: true

View File

@@ -1,152 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="113.67364mm"
height="56.37999mm"
viewBox="0 0 113.67364 56.37999"
version="1.1"
id="svg3223"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="logo.svg"
inkscape:export-filename="/home/pj/Projects/space-station-14/RobustToolbox/Resources/Textures/Logo/logo.png"
inkscape:export-xdpi="67.034012"
inkscape:export-ydpi="67.034012">
<defs
id="defs3217" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="159.25688"
inkscape:cy="149.8376"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:pagecheckerboard="true"
inkscape:window-width="1920"
inkscape:window-height="1043"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata3220">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-56.556041,-109.30405)">
<g
transform="translate(-3.7799155,-23.482217)"
id="g2559">
<path
inkscape:connector-curvature="0"
id="path148"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 143.44393,145.03077 0.1484,-0.70241 5.14257,-0.35974 -6.23062,29.75753 -0.69199,0.0483 6.08255,-29.05476 z m 1.18682,31.16724 7.31835,-35.07438 -10.43302,0.72923 -1.28514,6.12249 4.45021,-0.31125 -6.03235,28.95253 z" />
<path
sodipodi:nodetypes="cccccccccccccccccccccc"
inkscape:connector-curvature="0"
id="path152"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 169.25392,142.53363 -3.53672,16.8925 4.79124,-0.32874 -0.15681,0.75402 -4.79234,0.32881 -2.53549,12.11072 -0.75405,0.052 2.53724,-12.11108 -11.37332,0.78724 z m -18.98495,21.327 11.37324,-0.78724 -2.5247,12.11146 5.98312,-0.41839 2.52513,-12.10406 4.82658,-0.33116 1.26721,-6.07903 -4.82564,0.33109 3.52398,-16.89101 -4.56014,0.33565 -16.70168,19.60839 z" />
<path
inkscape:connector-curvature="0"
id="path156"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 88.591903,151.83158 -2.595368,0.18103 0.741705,-3.62685 2.595079,-0.182 z m -4.581719,-6.72375 -3.99857,19.05572 3.468889,-0.24195 1.774487,-8.38766 6.064403,-0.42299 2.224789,-10.66981 z" />
<path
inkscape:connector-curvature="0"
id="path160"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 100.85029,147.82177 2.83371,-0.19837 -0.74166,3.60045 -2.83371,0.19836 z m -6.726869,15.77696 3.469312,-0.24198 1.774487,-8.38695 2.8337,-0.19837 -1.77453,8.38695 3.46938,-0.24296 3.99895,-19.05608 -9.771974,0.68329 z" />
<path
inkscape:connector-curvature="0"
id="path164"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 108.80467,162.68768 9.74554,-0.68118 1.377,-6.50502 -3.4693,0.24296 -0.63527,2.9832 -2.80718,0.19654 2.51548,-12.01379 2.80731,-0.19754 -0.50239,2.4195 3.46902,-0.24294 1.24513,-5.93998 -9.74589,0.68119 z" />
<path
inkscape:connector-curvature="0"
id="path168"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 135.66767,145.61788 0.7409,-3.5211 -8.95132,0.6259 -3.99824,19.0564 8.95097,-0.62626 0.74082,-3.52077 -5.4816,0.383 1.03272,-4.89224 3.78675,-0.26474 0.74189,-3.52113 -3.78675,0.26474 0.74081,-3.6011 z" />
<path
inkscape:connector-curvature="0"
id="path172"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 71.070134,172.95255 -4.734664,0.33077 0.57447,-2.73456 2.139294,-0.14973 -0.376241,1.80924 2.595442,-0.18103 0.930868,-4.44332 -7.330114,0.5118 -1.66358,8.00131 4.734672,-0.33077 -0.773014,3.62025 -2.119829,0.1484 0.475696,-2.23174 -2.614982,0.18237 -1.030327,4.86616 7.330104,-0.5118 z" />
<path
inkscape:connector-curvature="0"
id="path176"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 74.794828,169.99754 2.496095,-0.17422 -2.436556,11.62085 2.595151,-0.182 2.436903,-11.62086 2.496023,-0.17421 0.554678,-2.63441 -7.587516,0.53064 z" />
<path
inkscape:connector-curvature="0"
id="path180"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 87.573322,171.75893 0.554606,-2.69318 2.119754,-0.1484 -0.554978,2.69354 z m 2.832629,8.59803 2.991888,-14.25529 -7.310379,0.51154 -2.99153,14.25493 2.595227,-0.18201 1.327293,-6.27378 2.11968,-0.14839 -1.327288,6.27414 z" />
<path
inkscape:connector-curvature="0"
id="path184"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 98.977684,179.78056 2.436926,-11.62086 2.49608,-0.1752 0.55493,-2.63374 -7.587518,0.53065 -0.554634,2.63373 2.495947,-0.17421 -2.436599,11.6212 z" />
<path
inkscape:connector-curvature="0"
id="path188"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 104.62426,179.38562 2.5951,-0.18101 2.9915,-14.25528 -2.59522,0.182 z" />
<path
inkscape:connector-curvature="0"
id="path192"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 115.73198,167.18138 2.11975,-0.14839 -1.88236,8.98749 -2.11949,0.14838 z m -5.03203,11.80203 7.31001,-0.51042 2.99153,-14.25494 -7.31028,0.51044 z" />
<path
inkscape:connector-curvature="0"
id="path196"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 124.08538,178.07141 1.36653,-6.47511 1.18856,6.29603 2.25853,-0.15792 2.99192,-14.25493 -2.59522,0.18201 -1.36734,6.57353 -1.18854,-6.39514 -2.25854,0.15791 -2.99084,14.25493 z" />
<path
inkscape:connector-curvature="0"
id="path200"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 66.677649,158.65784 -1.377018,6.50538 9.798398,-0.68471 2.489415,-11.87958 -6.329111,0.44214 0.767747,-3.65465 2.860076,-0.20018 -0.503204,2.41917 3.469299,-0.24297 1.244526,-5.93996 -4.328229,0.30289 -8.728772,0.56991 2.909827,1.489 -1.87565,9.01912 6.329037,-0.44213 -1.032406,4.83973 -2.833645,0.19738 0.635302,-2.98354 z" />
<path
inkscape:connector-curvature="0"
id="path204"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 70.519326,139.92277 -0.277457,1.36553 103.473271,-7.11317 0.29445,-1.38886 z" />
<path
inkscape:connector-curvature="0"
id="path208"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 60.335956,189.16626 103.473274,-7.11356 0.29444,-1.38885 -103.489968,7.13649 z" />
<path
sodipodi:nodetypes="cccccccc"
inkscape:connector-curvature="0"
id="path1772"
d="m 167.92741,145.26275 -12.87687,14.89523 9.91366,-0.68019 z m -3.743,7.27758 -1.02896,4.93612 -3.51544,0.2412 z"
style="fill:#e23229;fill-opacity:1;stroke:none;stroke-width:0.2626844px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 8.4 KiB

View File

@@ -1,4 +1,6 @@
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
using System;
namespace Robust.Benchmarks
{
@@ -8,7 +10,14 @@ namespace Robust.Benchmarks
// --anyCategories=ctg1,ctg2
public static void Main(string[] args)
{
#if DEBUG
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nWARNING: YOU ARE RUNNING A DEBUG BUILD, USE A RELEASE BUILD FOR AN ACCURATE BENCHMARK");
Console.WriteLine("THE DEBUG BUILD IS ONLY GOOD FOR FIXING A CRASHING BENCHMARK\n");
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new DebugInProcessConfig());
#else
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
#endif
}
}
}

View File

@@ -301,7 +301,7 @@ namespace {nameSpace}
foreach (var candidateClass in receiver.CandidateClasses)
{
var model = compilation.GetSemanticModel(candidateClass.SyntaxTree);
var typeSymbol = (INamedTypeSymbol) model.GetDeclaredSymbol(candidateClass);
var typeSymbol = model.GetDeclaredSymbol(candidateClass);
var relevantAttribute = typeSymbol.GetAttributes().FirstOrDefault(attr =>
attr.AttributeClass != null &&
attr.AttributeClass.Equals(attributeSymbol, SymbolEqualityComparer.Default));

View File

@@ -9,14 +9,16 @@ namespace Robust.Client.WebView.Cef
{
internal sealed class ImageBuffer
{
public Image<Bgra32> Buffer { get; private set; } = new(1, 1);
public Image<Rgba32> Buffer { get; private set; } = new(1, 1);
public unsafe void UpdateBuffer(int width, int height, IntPtr buffer, CefRectangle dirtyRect)
{
if (width != Buffer.Width || height != Buffer.Height)
UpdateSize(width, height);
var span = new ReadOnlySpan<Bgra32>((void*) buffer, width * height);
// NOTE: Image data from CEF is actually BGRA32, not RGBA32.
// OpenGL ES does not allow uploading BGRA data, so we pretend it's RGBA32 and use a shader to swizzle it.
var span = new ReadOnlySpan<Rgba32>((void*) buffer, width * height);
ImageSharpExt.Blit(
span,
@@ -28,7 +30,7 @@ namespace Robust.Client.WebView.Cef
private void UpdateSize(int width, int height)
{
Buffer = new Image<Bgra32>(width, height);
Buffer = new Image<Rgba32>(width, height);
}
}
}

View File

@@ -18,7 +18,9 @@ namespace Robust.Client.WebView.Cef
{
public IWebViewControlImpl MakeControlImpl(WebViewControl owner)
{
var impl = new ControlImpl(owner);
var shader = _prototypeManager.Index<ShaderPrototype>("bgra");
var shaderInstance = shader.Instance();
var impl = new ControlImpl(owner, shaderInstance);
_dependencyCollection.InjectDependencies(impl);
return impl;
}
@@ -131,10 +133,12 @@ namespace Robust.Client.WebView.Cef
[Dependency] private readonly IInputManager _inputMgr = default!;
public readonly WebViewControl Owner;
private readonly ShaderInstance _shaderInstance;
public ControlImpl(WebViewControl owner)
public ControlImpl(WebViewControl owner, ShaderInstance shaderInstance)
{
Owner = owner;
_shaderInstance = shaderInstance;
}
private const int ScrollSpeed = 50;
@@ -183,7 +187,7 @@ namespace Robust.Client.WebView.Cef
// Create the web browser! And by default, we go to about:blank.
var browser = CefBrowserHost.CreateBrowserSync(info, client, settings, _startUrl);
var texture = _clyde.CreateBlankTexture<Bgra32>(Vector2i.One);
var texture = _clyde.CreateBlankTexture<Rgba32>(Vector2i.One);
_data = new LiveData(texture, client, browser, renderer);
}
@@ -386,7 +390,7 @@ namespace Robust.Client.WebView.Cef
_data.Browser.GetHost().NotifyMoveOrResizeStarted();
_data.Browser.GetHost().WasResized();
_data.Texture.Dispose();
_data.Texture = _clyde.CreateBlankTexture<Bgra32>((Owner.PixelWidth, Owner.PixelHeight));
_data.Texture = _clyde.CreateBlankTexture<Rgba32>((Owner.PixelWidth, Owner.PixelHeight));
}
public void Draw(DrawingHandleScreen handle)
@@ -404,6 +408,7 @@ namespace Robust.Client.WebView.Cef
Math.Min(Owner.PixelWidth, bufImg.Width),
Math.Min(Owner.PixelHeight, bufImg.Height)));
handle.UseShader(_shaderInstance);
handle.DrawTexture(_data.Texture, Vector2.Zero);
}
@@ -533,8 +538,7 @@ namespace Robust.Client.WebView.Cef
if (_control.Owner.Disposed)
return false;
// TODO CEF: Get actual scale factor?
screenInfo.DeviceScaleFactor = 1.0f;
screenInfo.DeviceScaleFactor = _control.Owner.UIScale;
return true;
}

View File

@@ -1,17 +1,22 @@
using System;
using System.IO;
using System.Reflection;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
{
internal partial class WebViewManagerCef : IWebViewManagerImpl
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location!)!;
private CefApp _app = default!;
[Dependency] private readonly IDependencyCollection _dependencyCollection = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public void Initialize()
{
@@ -25,7 +30,7 @@ namespace Robust.Client.WebView.Cef
else
throw new NotSupportedException("Unsupported platform for CEF!");
var subProcessPath = PathHelpers.ExecutableRelativeFile(subProcessName);
var subProcessPath = Path.Combine(BasePath, subProcessName);
var cefResourcesPath = LocateCefResources();
// System.Console.WriteLine(AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES"));
@@ -58,7 +63,7 @@ namespace Robust.Client.WebView.Cef
private static string? LocateCefResources()
{
if (ProbeDir(PathHelpers.GetExecutableDirectory(), out var path))
if (ProbeDir(BasePath, out var path))
return path;

View File

@@ -3,8 +3,7 @@
<Import Project="..\MSBuild\Robust.Engine.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>WinExe</OutputType>
</PropertyGroup>
@@ -15,7 +14,6 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.3.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="Robust.Natives.Cef" Version="95.7.14" />
</ItemGroup>

View File

@@ -2,6 +2,7 @@ using System;
using JetBrains.Annotations;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Client.Animations
{
@@ -18,8 +19,8 @@ namespace Robust.Client.Animations
throw new InvalidOperationException("Must set parameters to non-null values.");
}
var entity = (IEntity) context;
var component = entity.GetComponent(ComponentType);
var entity = (EntityUid) context;
var component = IoCManager.Resolve<IEntityManager>().GetComponent(entity, ComponentType);
if (component is IAnimationProperties properties)
{

View File

@@ -25,7 +25,7 @@ namespace Robust.Client.Animations
public override (int KeyFrameIndex, float FramePlayingTime)
AdvancePlayback(object context, int prevKeyFrameIndex, float prevPlayingTime, float frameTime)
{
var entity = (IEntity) context;
var entity = (EntityUid) context;
var playingTime = prevPlayingTime + frameTime;
var keyFrameIndex = prevKeyFrameIndex;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Robust.Client.Animations
@@ -38,8 +39,8 @@ namespace Robust.Client.Animations
{
DebugTools.AssertNotNull(LayerKey);
var entity = (IEntity) context;
var sprite = entity.GetComponent<ISpriteComponent>();
var entity = (EntityUid) context;
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
var playingTime = prevPlayingTime + frameTime;
var keyFrameIndex = prevKeyFrameIndex;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
@@ -293,60 +293,50 @@ namespace Robust.Client.Audio.Midi
}
MapCoordinates? mapPos = null;
var trackingEntity = renderer.TrackingEntity != null && !_entityManager.Deleted(renderer.TrackingEntity);
if (trackingEntity)
{
renderer.TrackingCoordinates = _entityManager.GetComponent<TransformComponent>(renderer.TrackingEntity!.Value).Coordinates;
}
if (renderer.TrackingCoordinates != null)
{
mapPos = renderer.TrackingCoordinates.Value.ToMap(_entityManager);
}
else if (renderer.TrackingEntity != null)
{
mapPos = renderer.TrackingEntity.Transform.MapPosition;
}
if (mapPos != null)
if (mapPos != null && mapPos.Value.MapId == _eyeManager.CurrentMap)
{
var pos = mapPos.Value;
if (pos.MapId != _eyeManager.CurrentMap)
{
renderer.Source.SetVolume(-10000000);
}
else
{
var sourceRelative = _eyeManager.CurrentEye.Position.Position - pos.Position;
var occlusion = 0f;
if (sourceRelative.Length > 0)
{
occlusion = _broadPhaseSystem.IntersectRayPenetration(
pos.MapId,
new CollisionRay(
pos.Position,
sourceRelative.Normalized,
OcclusionCollisionMask),
sourceRelative.Length,
renderer.TrackingEntity);
}
renderer.Source.SetOcclusion(occlusion);
var sourceRelative = _eyeManager.CurrentEye.Position.Position - pos.Position;
var occlusion = 0f;
if (sourceRelative.Length > 0)
{
occlusion = _broadPhaseSystem.IntersectRayPenetration(
pos.MapId,
new CollisionRay(
pos.Position,
sourceRelative.Normalized,
OcclusionCollisionMask),
sourceRelative.Length,
renderer.TrackingEntity);
}
if (renderer.Source.SetPosition(pos.Position))
renderer.Source.SetOcclusion(occlusion);
if (!renderer.Source.SetPosition(pos.Position))
{
continue;
return;
}
if (renderer.TrackingEntity != null)
if (trackingEntity)
{
renderer.Source.SetVelocity(renderer.TrackingEntity.GlobalLinearVelocity());
renderer.Source.SetVelocity(renderer.TrackingEntity!.Value.GlobalLinearVelocity());
}
if (float.IsNaN(pos.Position.X) || float.IsNaN(pos.Position.Y))
{
// just duck out instead of move to NaN
renderer.Source.SetOcclusion(float.MaxValue);
continue;
}
_midiSawmill?.Warning("Interrupting positional audio, can't set position.");
renderer.Source.StopPlaying();
}
else
{
renderer.Source.SetOcclusion(float.MaxValue);
}
}

View File

@@ -150,7 +150,7 @@ namespace Robust.Client.Audio.Midi
/// The entity whose position will be used for positional audio.
/// This is only used if <see cref="Mono"/> is set to True.
/// </summary>
IEntity? TrackingEntity { get; set; }
EntityUid? TrackingEntity { get; set; }
/// <summary>
/// The position that will be used for positional audio.
@@ -297,7 +297,7 @@ namespace Robust.Client.Audio.Midi
set
{
lock (_playerStateLock)
_player?.SetLoop(value ? -1 : 1);
_player?.SetLoop(value ? -1 : 0);
_loopMidi = value;
}
}
@@ -306,7 +306,7 @@ namespace Robust.Client.Audio.Midi
public bool VolumeBoost { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public IEntity? TrackingEntity { get; set; } = null;
public EntityUid? TrackingEntity { get; set; } = null;
[ViewVariables(VVAccess.ReadWrite)]
public EntityCoordinates? TrackingCoordinates { get; set; } = null;

View File

@@ -5,6 +5,7 @@ using Robust.Client.Debugging;
using Robust.Client.GameObjects;
using Robust.Client.GameStates;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Audio;
using Robust.Client.Graphics.Clyde;
using Robust.Client.Input;
using Robust.Client.Map;
@@ -42,9 +43,9 @@ namespace Robust.Client
IoCManager.Register<IGameTiming, ClientGameTiming>();
IoCManager.Register<IClientGameTiming, ClientGameTiming>();
IoCManager.Register<IPrototypeManager, ClientPrototypeManager>();
IoCManager.Register<IMapManager, ClientMapManager>();
IoCManager.Register<IMapManagerInternal, ClientMapManager>();
IoCManager.Register<IClientMapManager, ClientMapManager>();
IoCManager.Register<IMapManager, NetworkedMapManager>();
IoCManager.Register<IMapManagerInternal, NetworkedMapManager>();
IoCManager.Register<INetworkedMapManager, NetworkedMapManager>();
IoCManager.Register<IEntityManager, ClientEntityManager>();
IoCManager.Register<IEntityLookup, EntityLookup>();
IoCManager.Register<IReflectionManager, ClientReflectionManager>();
@@ -82,8 +83,9 @@ namespace Robust.Client
case GameController.DisplayMode.Headless:
IoCManager.Register<IClyde, ClydeHeadless>();
IoCManager.Register<IClipboardManager, ClydeHeadless>();
IoCManager.Register<IClydeAudio, ClydeHeadless>();
IoCManager.Register<IClydeInternal, ClydeHeadless>();
IoCManager.Register<IClydeAudio, ClydeAudioHeadless>();
IoCManager.Register<IClydeAudioInternal, ClydeAudioHeadless>();
IoCManager.Register<IInputManager, InputManager>();
IoCManager.Register<IFileDialogManager, DummyFileDialogManager>();
IoCManager.Register<IUriOpener, UriOpenerDummy>();
@@ -91,8 +93,9 @@ namespace Robust.Client
case GameController.DisplayMode.Clyde:
IoCManager.Register<IClyde, Clyde>();
IoCManager.Register<IClipboardManager, Clyde>();
IoCManager.Register<IClydeAudio, Clyde>();
IoCManager.Register<IClydeInternal, Clyde>();
IoCManager.Register<IClydeAudio, FallbackProxyClydeAudio>();
IoCManager.Register<IClydeAudioInternal, FallbackProxyClydeAudio>();
IoCManager.Register<IInputManager, ClydeInputManager>();
IoCManager.Register<IFileDialogManager, FileDialogManager>();
IoCManager.Register<IUriOpener, UriOpener>();

View File

@@ -4,177 +4,186 @@ using Robust.Shared;
using Robust.Shared.Utility;
using C = System.Console;
namespace Robust.Client
namespace Robust.Client;
internal sealed class CommandLineArgs
{
internal sealed class CommandLineArgs
public MountOptions MountOptions { get; }
public bool Headless { get; }
public bool SelfContained { get; }
public bool Connect { get; }
public string ConnectAddress { get; }
public string? Ss14Address { get; }
public bool Launcher { get; }
public string? Username { get; }
public IReadOnlyCollection<(string key, string value)> CVars { get; }
public IReadOnlyCollection<(string key, string value)> LogLevels { get; }
public IReadOnlyList<string> ExecCommands { get; set; }
// Manual parser because C# has no good command line parsing libraries. Also dependencies bad.
// Also I don't like spending 100ms parsing command line args. Do you?
public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArgs? parsed)
{
public MountOptions MountOptions { get; }
public bool Headless { get; }
public bool SelfContained { get; }
public bool Connect { get; }
public string ConnectAddress { get; }
public string? Ss14Address { get; }
public bool Launcher { get; }
public string? Username { get; }
public IReadOnlyCollection<(string key, string value)> CVars { get; }
public IReadOnlyCollection<(string key, string value)> LogLevels { get; }
parsed = null;
var headless = false;
var selfContained = false;
var connect = false;
var connectAddress = "localhost";
string? ss14Address = null;
var launcher = false;
string? username = null;
var cvars = new List<(string, string)>();
var logLevels = new List<(string, string)>();
var mountOptions = new MountOptions();
var execCommands = new List<string>();
// Manual parser because C# has no good command line parsing libraries. Also dependencies bad.
// Also I don't like spending 100ms parsing command line args. Do you?
public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArgs? parsed)
using var enumerator = args.GetEnumerator();
while (enumerator.MoveNext())
{
parsed = null;
var headless = false;
var selfContained = false;
var connect = false;
var connectAddress = "localhost";
string? ss14Address = null;
var launcher = false;
string? username = null;
var cvars = new List<(string, string)>();
var logLevels = new List<(string, string)>();
var mountOptions = new MountOptions();
using var enumerator = args.GetEnumerator();
while (enumerator.MoveNext())
var arg = enumerator.Current;
if (arg == "--connect")
{
var arg = enumerator.Current;
if (arg == "--connect")
connect = true;
}
else if (arg == "--connect-address")
{
if (!enumerator.MoveNext())
{
connect = true;
}
else if (arg == "--connect-address")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing connection address.");
return false;
}
connectAddress = enumerator.Current;
}
else if (arg == "--ss14-address")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing SS14 address.");
return false;
}
ss14Address = enumerator.Current;
}
else if (arg == "--self-contained")
{
selfContained = true;
}
else if (arg == "--launcher")
{
launcher = true;
}
else if (arg == "--headless")
{
headless = true;
}
else if (arg == "--username")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing username.");
return false;
}
username = enumerator.Current;
}
else if (arg == "--cvar")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing cvar value.");
return false;
}
var cvar = enumerator.Current;
DebugTools.AssertNotNull(cvar);
var pos = cvar.IndexOf('=');
if (pos == -1)
{
C.WriteLine("Expected = in cvar.");
return false;
}
cvars.Add((cvar[..pos], cvar[(pos + 1)..]));
}
else if (arg == "--mount-zip")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing mount path");
return false;
}
mountOptions.ZipMounts.Add(enumerator.Current);
}
else if (arg == "--mount-dir")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing mount path");
return false;
}
mountOptions.DirMounts.Add(enumerator.Current);
}
else if (arg == "--loglevel")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing loglevel sawmill.");
return false;
}
var loglevel = enumerator.Current;
DebugTools.AssertNotNull(loglevel);
var pos = loglevel.IndexOf('=');
if (pos == -1)
{
C.WriteLine("Expected = in loglevel.");
return false;
}
logLevels.Add((loglevel[..pos], loglevel[(pos + 1)..]));
}
else if (arg == "--help")
{
PrintHelp();
C.WriteLine("Missing connection address.");
return false;
}
else
{
C.WriteLine("Unknown argument: {0}", arg);
}
connectAddress = enumerator.Current;
}
else if (arg == "--ss14-address")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing SS14 address.");
return false;
}
parsed = new CommandLineArgs(
headless,
selfContained,
connect,
launcher,
username,
cvars,
logLevels,
connectAddress,
ss14Address,
mountOptions);
ss14Address = enumerator.Current;
}
else if (arg == "--self-contained")
{
selfContained = true;
}
else if (arg == "--launcher")
{
launcher = true;
}
else if (arg == "--headless")
{
headless = true;
}
else if (arg == "--username")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing username.");
return false;
}
return true;
username = enumerator.Current;
}
else if (arg == "--cvar")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing cvar value.");
return false;
}
var cvar = enumerator.Current;
DebugTools.AssertNotNull(cvar);
var pos = cvar.IndexOf('=');
if (pos == -1)
{
C.WriteLine("Expected = in cvar.");
return false;
}
cvars.Add((cvar[..pos], cvar[(pos + 1)..]));
}
else if (arg == "--mount-zip")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing mount path");
return false;
}
mountOptions.ZipMounts.Add(enumerator.Current);
}
else if (arg == "--mount-dir")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing mount path");
return false;
}
mountOptions.DirMounts.Add(enumerator.Current);
}
else if (arg == "--loglevel")
{
if (!enumerator.MoveNext())
{
C.WriteLine("Missing loglevel sawmill.");
return false;
}
var loglevel = enumerator.Current;
DebugTools.AssertNotNull(loglevel);
var pos = loglevel.IndexOf('=');
if (pos == -1)
{
C.WriteLine("Expected = in loglevel.");
return false;
}
logLevels.Add((loglevel[..pos], loglevel[(pos + 1)..]));
}
else if (arg == "--help")
{
PrintHelp();
return false;
}
else if (arg.StartsWith("+"))
{
execCommands.Add(arg[1..]);
}
else
{
C.WriteLine("Unknown argument: {0}", arg);
}
}
private static void PrintHelp()
{
C.WriteLine(@"
parsed = new CommandLineArgs(
headless,
selfContained,
connect,
launcher,
username,
cvars,
logLevels,
connectAddress,
ss14Address,
mountOptions,
execCommands);
return true;
}
private static void PrintHelp()
{
C.WriteLine(@"
Usage: Robust.Client [options] [+command [+command]]
Options:
--headless Run without graphics/audio/input.
--self-contained Store data relative to executable instead of user-global locations.
@@ -189,30 +198,34 @@ Options:
--mount-dir Resource directory to mount.
--mount-zip Resource zip to mount.
--help Display this help text and exit.
");
}
private CommandLineArgs(
bool headless,
bool selfContained,
bool connect,
bool launcher,
string? username,
IReadOnlyCollection<(string key, string value)> cVars,
IReadOnlyCollection<(string key, string value)> logLevels,
string connectAddress, string? ss14Address,
MountOptions mountOptions)
{
Headless = headless;
SelfContained = selfContained;
Connect = connect;
Launcher = launcher;
Username = username;
CVars = cVars;
LogLevels = logLevels;
ConnectAddress = connectAddress;
Ss14Address = ss14Address;
MountOptions = mountOptions;
}
+command: You can pass a set of commands, prefixed by +,
to be executed in the console in order after the game has finished initializing.
");
}
private CommandLineArgs(
bool headless,
bool selfContained,
bool connect,
bool launcher,
string? username,
IReadOnlyCollection<(string key, string value)> cVars,
IReadOnlyCollection<(string key, string value)> logLevels,
string connectAddress, string? ss14Address,
MountOptions mountOptions,
IReadOnlyList<string> execCommands)
{
Headless = headless;
SelfContained = selfContained;
Connect = connect;
Launcher = launcher;
Username = username;
CVars = cVars;
LogLevels = logLevels;
ConnectAddress = connectAddress;
Ss14Address = ss14Address;
MountOptions = mountOptions;
ExecCommands = execCommands;
}
}

View File

@@ -23,7 +23,7 @@ namespace Robust.Client.Console
public bool CanCommand(string cmdName)
{
return _implementation?.CanCommand(cmdName) ?? false;
return _implementation?.CanCommand(cmdName) ?? true;
}
public bool CanViewVar()

View File

@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using Robust.Client.Log;
using Robust.Client.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
@@ -40,6 +43,8 @@ namespace Robust.Client.Console
/// <inheritdoc cref="IClientConsoleHost" />
internal class ClientConsoleHost : ConsoleHost, IClientConsoleHost
{
[Dependency] private readonly IClientConGroupController _conGroup = default!;
private bool _requestedCommands;
/// <inheritdoc />
@@ -103,6 +108,14 @@ namespace Robust.Client.Console
if (AvailableCommands.ContainsKey(commandName))
{
var playerManager = IoCManager.Resolve<IPlayerManager>();
if (!_conGroup.CanCommand(commandName) && playerManager.LocalPlayer?.Session.Status > SessionStatus.Connecting)
{
WriteError(null, $"Insufficient perms for command: {commandName}");
return;
}
var command1 = AvailableCommands[commandName];
args.RemoveAt(0);
var shell = new ConsoleShell(this, null);

View File

@@ -21,13 +21,12 @@ namespace Robust.Client.Console.Commands
return;
}
var entityUid = EntityUid.Parse(args[0]);
var entity = EntityUid.Parse(args[0]);
var componentName = args[1];
var compFactory = IoCManager.Resolve<IComponentFactory>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var entity = entityManager.GetEntity(entityUid);
var component = (Component) compFactory.GetComponent(componentName);
component.Owner = entity;

View File

@@ -15,15 +15,15 @@ namespace Robust.Client.Console.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
if (player?.ControlledEntity == null)
var controlled = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity ?? EntityUid.Invalid;
if (controlled == EntityUid.Invalid)
{
shell.WriteLine("You don't have an attached entity.");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
entityManager.SpawnEntity(args[0], player.ControlledEntity.Transform.Coordinates);
entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(controlled).Coordinates);
}
}
}

View File

@@ -4,13 +4,12 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime;
using System.Text;
using System.Text.RegularExpressions;
using Robust.Client.Input;
using Robust.Client.Debugging;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -41,9 +40,9 @@ namespace Robust.Client.Console.Commands
{
var entityManager = IoCManager.Resolve<IEntityManager>();
foreach (var e in entityManager.GetEntities().OrderBy(e => e.Uid))
foreach (var e in entityManager.GetEntities().OrderBy(e => e))
{
shell.WriteLine($"entity {e.Uid}, {e.Prototype?.ID}, {e.Transform.Coordinates}.");
shell.WriteLine($"entity {e}, {entityManager.GetComponent<MetaDataComponent>(e).EntityPrototype?.ID}, {entityManager.GetComponent<TransformComponent>(e).Coordinates}.");
}
}
}
@@ -238,15 +237,15 @@ namespace Robust.Client.Console.Commands
var uid = EntityUid.Parse(args[0]);
var entmgr = IoCManager.Resolve<IEntityManager>();
if (!entmgr.TryGetEntity(uid, out var entity))
if (!entmgr.EntityExists(uid))
{
shell.WriteError("That entity does not exist. Sorry lad.");
return;
}
shell.WriteLine($"{entity.Uid}: {entity.Prototype?.ID}/{entity.Name}");
shell.WriteLine($"init/del/lmt: {entity.Initialized}/{entity.Deleted}/{entity.LastModifiedTick}");
foreach (var component in entity.GetAllComponents())
var meta = entmgr.GetComponent<MetaDataComponent>(uid);
shell.WriteLine($"{uid}: {meta.EntityPrototype?.ID}/{meta.EntityName}");
shell.WriteLine($"init/del/lmt: {meta.EntityInitialized}/{meta.EntityDeleted}/{meta.EntityLastModifiedTick}");
foreach (var component in entmgr.GetComponents(uid))
{
shell.WriteLine(component.ToString() ?? "");
if (component is IComponentDebug debug)
@@ -450,15 +449,13 @@ namespace Robust.Client.Console.Commands
var uiMgr = IoCManager.Resolve<IUserInterfaceManager>();
var res = IoCManager.Resolve<IResourceManager>();
using (var stream = res.UserData.Create(new ResourcePath("/guidump.txt")))
using (var writer = new StreamWriter(stream, EncodingHelpers.UTF8))
using var writer = res.UserData.OpenWriteText(new ResourcePath("/guidump.txt"));
foreach (var root in uiMgr.AllRoots)
{
foreach (var root in uiMgr.AllRoots)
{
writer.WriteLine($"ROOT: {root}");
_writeNode(root, 0, writer);
writer.WriteLine("---------------");
}
writer.WriteLine($"ROOT: {root}");
_writeNode(root, 0, writer);
writer.WriteLine("---------------");
}
shell.WriteLine("Saved guidump");
@@ -523,7 +520,7 @@ namespace Robust.Client.Console.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var window = new SS14Window { MinSize = (500, 400)};
var window = new DefaultWindow { MinSize = (500, 400)};
var tabContainer = new TabContainer();
window.Contents.AddChild(tabContainer);
var scroll = new ScrollContainer();

View File

@@ -1,9 +1,7 @@
#if !FULL_RELEASE
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Data.Sqlite;
using Robust.Client.Utility;
using Robust.Shared.Console;
using Robust.Shared.IoC;
@@ -22,44 +20,38 @@ namespace Robust.Client.Console.Commands
var wantName = args.Length > 0 ? args[0] : null;
var basePath = Path.GetDirectoryName(UserDataDir.GetUserDataDir())!;
var cfgPath = Path.Combine(basePath, "launcher", "launcher_config.json");
var dbPath = Path.Combine(basePath, "launcher", "settings.db");
var data = JsonSerializer.Deserialize<LauncherConfig>(File.ReadAllText(cfgPath))!;
using var con = new SqliteConnection($"Data Source={dbPath};Mode=ReadOnly");
con.Open();
using var cmd = con.CreateCommand();
cmd.CommandText = "SELECT UserId, UserName, Token FROM Login WHERE Expires > datetime('NOW')";
var login = wantName != null
? data.Logins.FirstOrDefault(p => p.Username == wantName)
: data.Logins.FirstOrDefault();
if (wantName != null)
{
cmd.CommandText += " AND UserName = @userName";
cmd.Parameters.AddWithValue("@userName", wantName);
}
if (login == null)
cmd.CommandText += " LIMIT 1;";
using var reader = cmd.ExecuteReader();
if (!reader.Read())
{
shell.WriteLine("Unable to find a matching login");
return;
}
var token = login.Token.Token;
var userId = login.UserId;
var userId = Guid.Parse(reader.GetString(0));
var userName = reader.GetString(1);
var token = reader.GetString(2);
var cfg = IoCManager.Resolve<IAuthManager>();
cfg.Token = token;
cfg.UserId = new NetUserId(Guid.Parse(userId));
}
cfg.UserId = new NetUserId(userId);
private sealed class LauncherConfig
{
[JsonInclude] [JsonPropertyName("logins")]
public LauncherLogin[] Logins = default!;
}
private sealed class LauncherLogin
{
[JsonInclude] public string Username = default!;
[JsonInclude] public string UserId = default!;
[JsonInclude] public LauncherToken Token = default!;
}
private sealed class LauncherToken
{
[JsonInclude] public string Token = default!;
shell.WriteLine($"Logged into account {userName}");
}
}
}

View File

@@ -24,6 +24,9 @@ namespace Robust.Client.Console.Commands
case "aabbs":
system.Flags ^= PhysicsDebugFlags.AABBs;
break;
case "com":
system.Flags ^= PhysicsDebugFlags.COM;
break;
case "contactnormals":
system.Flags ^= PhysicsDebugFlags.ContactNormals;
break;

View File

@@ -11,7 +11,7 @@ using static Robust.Shared.Network.Messages.MsgScriptCompletionResponse;
namespace Robust.Client.Console
{
public class Completions : SS14Window
public class Completions : DefaultWindow
{
private HistoryLineEdit _textBar;
private ScrollContainer _suggestPanel = new()

View File

@@ -210,6 +210,23 @@ namespace Robust.Client.Console
vvm.OpenVV(a);
}
protected override void WriteSyntax(object toString)
{
var code = toString.ToString();
if (code == null)
return;
var options = ScriptInstanceShared.GetScriptOptions(_owner._reflectionManager).AddReferences(typeof(Image).Assembly);
var script = CSharpScript.Create(code, options, typeof(ScriptGlobals));
script.Compile();
var syntax = new FormattedMessage();
ScriptInstanceShared.AddWithSyntaxHighlighting(script, syntax, code, _owner._highlightWorkspace);
_owner.OutputPanel.AddMessage(syntax);
}
public override void write(object toString)
{
_owner.OutputPanel.AddText(toString?.ToString() ?? "");

View File

@@ -15,7 +15,7 @@ using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Robust.Client.Console
{
public class WatchWindow : SS14Window
public class WatchWindow : DefaultWindow
{
private readonly IReflectionManager _reflectionManager;
@@ -155,6 +155,11 @@ namespace Robust.Client.Console
IoCManager.InjectDependencies(this);
}
protected override void WriteSyntax(object toString)
{
// No-op: nothing to write to.
}
public override void write(object toString)
{
// No-op: nothing to write to.

View File

@@ -79,13 +79,13 @@ namespace Robust.Client.Debugging
foreach (var ent in grid.GetAnchoredEntities(spot))
{
if (!EntityManager.TryGetEntity(ent, out var entity))
if (EntityManager.TryGetComponent<MetaDataComponent>(ent, out var meta))
{
text.AppendLine($"uid: {ent}, invalid");
text.AppendLine($"uid: {ent}, {meta.EntityName}");
}
else
{
text.AppendLine($"uid: {ent}, {entity.Name}");
text.AppendLine($"uid: {ent}, invalid");
}
}

View File

@@ -12,6 +12,7 @@ namespace Robust.Client.Debugging
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IEntityLookup _lookup = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private bool _debugPositions;
@@ -30,7 +31,7 @@ namespace Robust.Client.Debugging
if (value && !_overlayManager.HasOverlay<EntityPositionOverlay>())
{
_overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, _eyeManager));
_overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, _eyeManager, _entityManager));
}
else
{
@@ -43,13 +44,15 @@ namespace Robust.Client.Debugging
{
private readonly IEntityLookup _lookup;
private readonly IEyeManager _eyeManager;
private readonly IEntityManager _entityManager;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public EntityPositionOverlay(IEntityLookup lookup, IEyeManager eyeManager)
public EntityPositionOverlay(IEntityLookup lookup, IEyeManager eyeManager, IEntityManager entityManager)
{
_lookup = lookup;
_eyeManager = eyeManager;
_entityManager = entityManager;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -61,7 +64,7 @@ namespace Robust.Client.Debugging
foreach (var entity in _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, viewport))
{
var transform = entity.Transform;
var transform = _entityManager.GetComponent<TransformComponent>(entity);
var center = transform.WorldPosition;
var worldRotation = transform.WorldRotation;

View File

@@ -162,6 +162,7 @@ namespace Robust.Client.Debugging
ShapeInfo = 1 << 3,
Joints = 1 << 4,
AABBs = 1 << 5,
COM = 1 << 6,
}
internal sealed class PhysicsDebugOverlay : Overlay
@@ -190,23 +191,23 @@ namespace Robust.Client.Debugging
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
private void DrawWorld(DrawingHandleWorld worldHandle)
private void DrawWorld(DrawingHandleWorld worldHandle, OverlayDrawArgs args)
{
var viewport = _eyeManager.GetWorldViewport();
var viewBounds = _eyeManager.GetWorldViewbounds();
var viewBounds = args.WorldBounds;
var viewAABB = args.WorldAABB;
var mapId = _eyeManager.CurrentMap;
if ((_debugPhysicsSystem.Flags & PhysicsDebugFlags.Shapes) != 0 && !viewport.IsEmpty())
if ((_debugPhysicsSystem.Flags & PhysicsDebugFlags.Shapes) != 0)
{
foreach (var physBody in _physicsSystem.GetCollidingEntities(mapId, viewBounds))
{
if (physBody.Owner.HasComponent<MapGridComponent>()) continue;
if (_entityManager.HasComponent<MapGridComponent>(physBody.Owner)) continue;
var xform = physBody.GetTransform();
const float AlphaModifier = 0.2f;
foreach (var fixture in physBody.Fixtures)
foreach (var fixture in _entityManager.GetComponent<FixturesComponent>(physBody.Owner).Fixtures.Values)
{
// Invalid shape - Box2D doesn't check for IsSensor
if (physBody.BodyType == BodyType.Dynamic && fixture.Mass == 0f)
@@ -237,18 +238,43 @@ namespace Robust.Client.Debugging
}
}
if ((_debugPhysicsSystem.Flags & PhysicsDebugFlags.AABBs) != 0 && !viewport.IsEmpty())
if ((_debugPhysicsSystem.Flags & PhysicsDebugFlags.COM) != 0)
{
foreach (var physBody in _physicsSystem.GetCollidingEntities(mapId, viewBounds))
{
if (physBody.Owner.HasComponent<MapGridComponent>()) continue;
Color color;
const float Alpha = 0.25f;
float size;
if (_entityManager.HasComponent<MapGridComponent>(physBody.Owner))
{
color = Color.Orange.WithAlpha(Alpha);
size = 1f;
}
else
{
color = Color.Purple.WithAlpha(Alpha);
size = 0.2f;
}
var transform = physBody.GetTransform();
worldHandle.DrawCircle(Transform.Mul(transform, physBody.LocalCenter), size, color);
}
}
if ((_debugPhysicsSystem.Flags & PhysicsDebugFlags.AABBs) != 0)
{
foreach (var physBody in _physicsSystem.GetCollidingEntities(mapId, viewBounds))
{
if (_entityManager.HasComponent<MapGridComponent>(physBody.Owner)) continue;
var xform = physBody.GetTransform();
const float AlphaModifier = 0.2f;
Box2? aabb = null;
foreach (var fixture in physBody.Fixtures)
foreach (var fixture in _entityManager.GetComponent<FixturesComponent>(physBody.Owner).Fixtures.Values)
{
for (var i = 0; i < fixture.Shape.ChildCount; i++)
{
@@ -270,8 +296,8 @@ namespace Robust.Client.Debugging
foreach (var jointComponent in _entityManager.EntityQuery<JointComponent>(true))
{
if (jointComponent.JointCount == 0 ||
!_entityManager.TryGetComponent(jointComponent.Owner.Uid, out TransformComponent? xf1) ||
!viewport.Contains(xf1.WorldPosition)) continue;
!_entityManager.TryGetComponent(jointComponent.Owner, out TransformComponent? xf1) ||
!viewAABB.Contains(xf1.WorldPosition)) continue;
foreach (var (_, joint) in jointComponent.Joints)
{
@@ -312,7 +338,7 @@ namespace Robust.Client.Debugging
}
}
private void DrawScreen(DrawingHandleScreen screenHandle)
private void DrawScreen(DrawingHandleScreen screenHandle, OverlayDrawArgs args)
{
var mapId = _eyeManager.CurrentMap;
var mousePos = _inputManager.MouseScreenPosition;
@@ -324,7 +350,7 @@ namespace Robust.Client.Debugging
foreach (var physBody in _physicsSystem.GetCollidingEntities(mapId, bounds))
{
if (physBody.Owner.HasComponent<MapGridComponent>()) continue;
if (_entityManager.HasComponent<MapGridComponent>(physBody.Owner)) continue;
hoverBodies.Add(physBody);
}
@@ -359,10 +385,10 @@ namespace Robust.Client.Debugging
switch (args.Space)
{
case OverlaySpace.ScreenSpace:
DrawScreen((DrawingHandleScreen) args.DrawingHandle);
DrawScreen((DrawingHandleScreen) args.DrawingHandle, args);
break;
case OverlaySpace.WorldSpace:
DrawWorld((DrawingHandleWorld) args.DrawingHandle);
DrawWorld((DrawingHandleWorld) args.DrawingHandle, args);
break;
}
}
@@ -382,8 +408,8 @@ namespace Robust.Client.Debugging
if (edge.OneSided)
{
worldHandle.DrawCircle(v1, 0.5f, color);
worldHandle.DrawCircle(v2, 0.5f, color);
worldHandle.DrawCircle(v1, 0.1f, color);
worldHandle.DrawCircle(v2, 0.1f, color);
}
break;
@@ -416,11 +442,45 @@ namespace Robust.Client.Debugging
var p1 = matrix1.Transform(joint.LocalAnchorA);
var p2 = matrix2.Transform(joint.LocalAnchorB);
var xfa = new Transform(xf1, xform1.WorldRotation);
var xfb = new Transform(xf2, xform2.WorldRotation);
switch (joint)
{
case DistanceJoint:
worldHandle.DrawLine(xf1, xf2, JointColor);
break;
case PrismaticJoint prisma:
var pA = Transform.Mul(xfa, joint.LocalAnchorA);
var pB = Transform.Mul(xfb, joint.LocalAnchorB);
var axis = Transform.Mul(xfa.Quaternion2D, prisma._localXAxisA);
Color c1 = new(0.7f, 0.7f, 0.7f);
Color c2 = new(0.3f, 0.9f, 0.3f);
Color c3 = new(0.9f, 0.3f, 0.3f);
Color c4 = new(0.3f, 0.3f, 0.9f);
Color c5 = new(0.4f, 0.4f, 0.4f);
worldHandle.DrawLine(pA, pB, c5);
if (prisma.EnableLimit)
{
var lower = pA + axis * prisma.LowerTranslation;
var upper = pA + axis * prisma.UpperTranslation;
var perp = Transform.Mul(xfa.Quaternion2D, prisma._localYAxisA);
worldHandle.DrawLine(lower, upper, c1);
worldHandle.DrawLine(lower - perp * 0.5f, lower + perp * 0.5f, c2);
worldHandle.DrawLine(upper - perp * 0.5f, upper + perp * 0.5f, c3);
}
else
{
worldHandle.DrawLine(pA - axis * 1.0f, pA + axis * 1.0f, c1);
}
worldHandle.DrawCircle(pA, 0.5f, c1);
worldHandle.DrawCircle(pB, 0.5f, c4);
break;
default:
worldHandle.DrawLine(xf1, p1, JointColor);
worldHandle.DrawLine(p1, p2, JointColor);

View File

@@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using Robust.Client.WebViewHook;
using Robust.Shared.Log;
using Robust.Shared.Utility;
@@ -8,12 +10,8 @@ namespace Robust.Client
{
internal sealed partial class GameController
{
private void LoadOptionalRobustModules(GameController.DisplayMode mode)
private void LoadOptionalRobustModules(DisplayMode mode, ResourceManifestData manifest)
{
// In the future, this manifest should be loaded somewhere else and used for more parts of init.
// For now, this is fine.
var manifest = LoadResourceManifest();
foreach (var module in manifest.Modules)
{
switch (module)
@@ -32,7 +30,8 @@ namespace Robust.Client
{
Logger.Debug("Loading Robust.Client.WebView");
var assembly = LoadRobustModuleAssembly("Robust.Client.WebView");
var alc = CreateModuleLoadContext("Robust.Client.WebView");
var assembly = alc.LoadFromAssemblyName(new AssemblyName("Robust.Client.WebView"));
var attribute = assembly.GetCustomAttribute<WebViewManagerImplAttribute>()!;
DebugTools.AssertNotNull(attribute);
@@ -43,10 +42,52 @@ namespace Robust.Client
Logger.Debug("Done initializing Robust.Client.WebView");
}
private Assembly LoadRobustModuleAssembly(string assemblyName)
/// <summary>
/// Creates an <see cref="AssemblyLoadContext"/> that loads from an engine module directory.
/// </summary>
private AssemblyLoadContext CreateModuleLoadContext(string moduleName)
{
// TODO: Launcher distribution and all that stuff.
return Assembly.Load(assemblyName);
var sawmill = _logManager.GetSawmill("robust.mod");
var alc = new AssemblyLoadContext(moduleName);
var envVarName = $"ROBUST_MODULE_{moduleName.ToUpperInvariant().Replace('.', '_')}";
var envVar = Environment.GetEnvironmentVariable(envVarName);
if (string.IsNullOrEmpty(envVar))
{
sawmill.Debug("Module {ModuleName} has no path override specified", moduleName);
return alc;
}
sawmill.Debug("Path for module {ModuleName} is {ModulePath}", moduleName, envVar);
alc.Resolving += (_, name) =>
{
sawmill.Debug("Loading {AssemblyName} from module {ModuleName}", name.ToString(), moduleName);
var assemblyPath = Path.Combine(envVar, $"{name.Name}.dll");
if (!File.Exists(assemblyPath))
return null;
return alc.LoadFromAssemblyPath(assemblyPath);
};
_modLoader.ExtraModuleLoaders += name =>
{
foreach (var assembly in alc.Assemblies)
{
var assemblyName = assembly.GetName();
if (assemblyName.Name == name.Name)
{
sawmill.Debug("Resolved {ResolvingAssembly} as assembly {ResolvedAssembly} from {ModuleName}", name.ToString(), assemblyName.ToString(), moduleName);
return assembly;
}
}
return null;
};
_modLoader.AddEngineModuleDirectory(envVar);
return alc;
}
}
}

View File

@@ -59,6 +59,7 @@ namespace Robust.Client
[Dependency] private readonly IViewVariablesManagerInternal _viewVariablesManager = default!;
[Dependency] private readonly IDiscordRichPresence _discord = default!;
[Dependency] private readonly IClydeInternal _clyde = default!;
[Dependency] private readonly IClydeAudioInternal _clydeAudio = default!;
[Dependency] private readonly IFontManagerInternal _fontManager = default!;
[Dependency] private readonly IModLoaderInternal _modLoader = default!;
[Dependency] private readonly IScriptClient _scriptClient = default!;
@@ -78,6 +79,8 @@ namespace Robust.Client
public GameControllerOptions Options { get; private set; } = new();
public InitialLaunchState LaunchState { get; private set; } = default!;
private ResourceManifestData? _resourceManifest;
public void SetCommandLineArgs(CommandLineArgs args)
{
_commandLineArgs = args;
@@ -85,18 +88,25 @@ namespace Robust.Client
internal bool StartupContinue(DisplayMode displayMode)
{
DebugTools.AssertNotNull(_resourceManifest);
_clyde.InitializePostWindowing();
_clyde.SetWindowTitle(Options.DefaultWindowTitle);
_clydeAudio.InitializePostWindowing();
_clyde.SetWindowTitle(Options.DefaultWindowTitle ?? _resourceManifest!.DefaultWindowTitle ?? "RobustToolbox");
_taskManager.Initialize();
_fontManager.SetFontDpi((uint)_configurationManager.GetCVar(CVars.DisplayFontDpi));
// Load optional Robust modules.
LoadOptionalRobustModules(displayMode, _resourceManifest!);
// Disable load context usage on content start.
// This prevents Content.Client being loaded twice and things like csi blowing up because of it.
_modLoader.SetUseLoadContext(!ContentStart);
_modLoader.SetEnableSandboxing(Options.Sandboxing);
if (!_modLoader.TryLoadModulesFrom(Options.AssemblyDirectory, Options.ContentModulePrefix))
var assemblyPrefix = Options.ContentModulePrefix ?? _resourceManifest!.AssemblyPrefix ?? "Content.";
if (!_modLoader.TryLoadModulesFrom(Options.AssemblyDirectory, assemblyPrefix))
{
Logger.Fatal("Errors while loading content assemblies.");
return false;
@@ -109,9 +119,6 @@ namespace Robust.Client
IoCManager.Resolve<ISerializationManager>().Initialize();
// Load optional Robust modules.
LoadOptionalRobustModules(displayMode);
// Call Init in game assemblies.
_modLoader.BroadcastRunLevel(ModRunLevel.PreInit);
_modLoader.BroadcastRunLevel(ModRunLevel.Init);
@@ -127,8 +134,8 @@ namespace Robust.Client
_prototypeManager.Initialize();
_prototypeManager.LoadDirectory(Options.PrototypeDirectory);
_prototypeManager.Resync();
_mapManager.Initialize();
_entityManager.Initialize();
_mapManager.Initialize();
_gameStateManager.Initialize();
_placementManager.Initialize();
_viewVariablesManager.Initialize();
@@ -198,6 +205,8 @@ namespace Robust.Client
_client.ConnectToServer(LaunchState.ConnectEndpoint);
}
ProgramShared.RunExecCommands(_console, _commandLineArgs?.ExecCommands);
return true;
}
@@ -205,7 +214,7 @@ namespace Robust.Client
{
// Parses /manifest.yml for game-specific settings that cannot be exclusively set up by content code.
if (!_resourceCache.TryContentFileRead("/manifest.yml", out var stream))
return new ResourceManifestData(Array.Empty<string>());
return new ResourceManifestData(Array.Empty<string>(), null, null, null, null);
var yamlStream = new YamlStream();
using (stream)
@@ -214,6 +223,9 @@ namespace Robust.Client
yamlStream.Load(streamReader);
}
if (yamlStream.Documents.Count == 0)
return new ResourceManifestData(Array.Empty<string>(), null, null, null, null);
if (yamlStream.Documents.Count != 1 || yamlStream.Documents[0].RootNode is not YamlMappingNode mapping)
{
throw new InvalidOperationException(
@@ -231,7 +243,23 @@ namespace Robust.Client
}
}
return new ResourceManifestData(modules);
string? assemblyPrefix = null;
if (mapping.TryGetNode("assemblyPrefix", out var prefixNode))
assemblyPrefix = prefixNode.AsString();
string? defaultWindowTitle = null;
if (mapping.TryGetNode("defaultWindowTitle", out var winTitleNode))
defaultWindowTitle = winTitleNode.AsString();
string? windowIconSet = null;
if (mapping.TryGetNode("windowIconSet", out var iconSetNode))
windowIconSet = iconSetNode.AsString();
string? splashLogo = null;
if (mapping.TryGetNode("splashLogo", out var splashNode))
splashLogo = splashNode.AsString();
return new ResourceManifestData(modules, assemblyPrefix, defaultWindowTitle, windowIconSet, splashLogo);
}
internal bool StartupSystemSplash(GameControllerOptions options, Func<ILogHandler>? logHandlerFactory)
@@ -297,15 +325,6 @@ namespace Robust.Client
_configurationManager.OverrideConVars(_commandLineArgs.CVars);
}
{
// Handle GameControllerOptions implicit CVar overrides.
_configurationManager.OverrideConVars(new[]
{
(CVars.DisplayWindowIconSet.Name, options.WindowIconSet.ToString()),
(CVars.DisplaySplashLogo.Name, options.SplashLogo.ToString())
});
}
ProfileOptSetup.Setup(_configurationManager);
_resourceCache.Initialize(Options.LoadConfigAndUserData ? userDataDir : null);
@@ -320,11 +339,32 @@ namespace Robust.Client
if (_loaderArgs != null)
{
if (_loaderArgs.ApiMounts is { } mounts)
{
foreach (var (api, prefix) in mounts)
{
_resourceCache.MountLoaderApi(api, "", new ResourcePath(prefix));
}
}
_stringSerializer.EnableCaching = false;
_resourceCache.MountLoaderApi(_loaderArgs.FileApi, "Resources/");
_modLoader.VerifierExtraLoadHandler = VerifierExtraLoadHandler;
}
_resourceManifest = LoadResourceManifest();
{
// Handle GameControllerOptions implicit CVar overrides.
_configurationManager.OverrideConVars(new[]
{
(CVars.DisplayWindowIconSet.Name,
options.WindowIconSet?.ToString() ?? _resourceManifest.WindowIconSet ?? ""),
(CVars.DisplaySplashLogo.Name,
options.SplashLogo?.ToString() ?? _resourceManifest.SplashLogo ?? "")
});
}
_clyde.TextEntered += TextEntered;
_clyde.MouseMove += MouseMove;
_clyde.KeyUp += KeyUp;
@@ -427,7 +467,9 @@ namespace Robust.Client
// In singleplayer, however, we're in full control instead.
else if (_client.RunLevel == ClientRunLevel.SinglePlayerGame)
{
_entityManager.TickUpdate(frameEventArgs.DeltaSeconds);
// The last real tick is the current tick! This way we won't be in "prediction" mode.
_gameTiming.LastRealTick = _gameTiming.CurTick;
_entityManager.TickUpdate(frameEventArgs.DeltaSeconds, noPredictions: false);
_lookup.Update();
}
@@ -437,6 +479,7 @@ namespace Robust.Client
private void Update(FrameEventArgs frameEventArgs)
{
_webViewHook?.Update();
_clydeAudio.FrameProcess(frameEventArgs);
_clyde.FrameProcess(frameEventArgs);
_modLoader.BroadcastUpdate(ModUpdateLevel.FramePreEngine, frameEventArgs);
_stateManager.FrameUpdate(frameEventArgs);
@@ -535,8 +578,15 @@ namespace Robust.Client
IoCManager.Resolve<IEntityLookup>().Shutdown();
_entityManager.Shutdown();
_clyde.Shutdown();
_clydeAudio.Shutdown();
}
private sealed record ResourceManifestData(string[] Modules);
private sealed record ResourceManifestData(
string[] Modules,
string? AssemblyPrefix,
string? DefaultWindowTitle,
string? WindowIconSet,
string? SplashLogo
);
}
}

View File

@@ -30,12 +30,18 @@ namespace Robust.Client
/// <summary>
/// Default window title.
/// </summary>
public string DefaultWindowTitle { get; init; } = "Space Station 14";
/// <remarks>
/// Defaults to <c>RobustToolbox</c> if unset.
/// </remarks>
public string? DefaultWindowTitle { get; init; }
/// <summary>
/// Assemblies with this prefix will be loaded.
/// </summary>
public string ContentModulePrefix { get; init; } = "Content.";
/// <remarks>
/// Defaults to <c>Content.</c> if unset.
/// </remarks>
public string? ContentModulePrefix { get; init; }
/// <summary>
/// Name of the content build directory, for game pack mounting purposes.
@@ -55,12 +61,12 @@ namespace Robust.Client
/// <summary>
/// Directory resource path containing window icons to load.
/// </summary>
public ResourcePath WindowIconSet { get; init; } = new("/Textures/Logo/icon");
public ResourcePath? WindowIconSet { get; init; }
/// <summary>
/// Resource path for splash image to show when the game starts up.
/// </summary>
public ResourcePath SplashLogo { get; init; } = new("/Textures/Logo/logo.png");
public ResourcePath? SplashLogo { get; init; }
/// <summary>
/// Whether to disable mounting the "Resources/" folder on FULL_RELEASE.

View File

@@ -27,16 +27,11 @@ namespace Robust.Client.GameObjects
RegisterClass<ClientOccluderComponent>();
RegisterClass<OccluderTreeComponent>();
RegisterClass<EyeComponent>();
RegisterClass<AppearanceComponent>();
RegisterClass<AnimationPlayerComponent>();
RegisterClass<TimerComponent>();
#if DEBUG
RegisterClass<DebugExceptionOnAddComponent>();
RegisterClass<DebugExceptionInitializeComponent>();
RegisterClass<DebugExceptionStartupComponent>();
#endif
}
}
}

View File

@@ -33,19 +33,19 @@ namespace Robust.Client.GameObjects
base.Initialize();
}
IEntity IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid? uid)
EntityUid IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid uid)
{
return base.CreateEntity(prototypeName, uid);
}
void IClientEntityManagerInternal.InitializeEntity(IEntity entity)
void IClientEntityManagerInternal.InitializeEntity(EntityUid entity)
{
base.InitializeEntity((Entity)entity);
base.InitializeEntity(entity);
}
void IClientEntityManagerInternal.StartEntity(IEntity entity)
void IClientEntityManagerInternal.StartEntity(EntityUid entity)
{
base.StartEntity((Entity)entity);
base.StartEntity(entity);
}
#region IEntityNetworkManager impl
@@ -67,7 +67,7 @@ namespace Robust.Client.GameObjects
_networkManager.RegisterNetMessage<MsgEntity>(HandleEntityNetworkMessage);
}
public override void TickUpdate(float frameTime, Histogram? histogram)
public override void TickUpdate(float frameTime, bool noPredictions, Histogram? histogram)
{
using (histogram?.WithLabels("EntityNet").NewTimer())
{
@@ -79,7 +79,7 @@ namespace Robust.Client.GameObjects
}
}
base.TickUpdate(frameTime, histogram);
base.TickUpdate(frameTime, noPredictions, histogram);
}
/// <inheritdoc />
@@ -107,16 +107,17 @@ namespace Robust.Client.GameObjects
/// <inheritdoc />
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
public void SendComponentNetworkMessage(INetChannel? channel, IEntity entity, IComponent component, ComponentMessage message)
public void SendComponentNetworkMessage(INetChannel? channel, EntityUid entity, IComponent component, ComponentMessage message)
{
var netId = ComponentFactory.GetRegistration(component.GetType()).NetID;
var componentType = component.GetType();
var netId = ComponentFactory.GetRegistration(componentType).NetID;
if (!netId.HasValue)
throw new ArgumentException($"Component {component.Name} does not have a NetID.", nameof(component));
throw new ArgumentException($"Component {componentType} does not have a NetID.", nameof(component));
var msg = _networkManager.CreateNetMessage<MsgEntity>();
msg.Type = EntityMessageType.ComponentMessage;
msg.EntityUid = entity.Uid;
msg.EntityUid = entity;
msg.NetId = netId.Value;
msg.ComponentMessage = message;
msg.SourceTick = _gameTiming.CurTick;

View File

@@ -13,8 +13,6 @@ namespace Robust.Client.GameObjects
{
// TODO: Give this component a friend someday. Way too much content shit to change atm ._.
public override string Name => "AnimationPlayer";
public int PlayingAnimationCount => PlayingAnimations.Count;
internal readonly Dictionary<string, AnimationPlayback> PlayingAnimations

View File

@@ -1,161 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Robust.Client.GameObjects
{
[ComponentReference(typeof(SharedAppearanceComponent))]
public sealed class AppearanceComponent : SharedAppearanceComponent
{
[ViewVariables]
private Dictionary<object, object> data = new();
[ViewVariables]
[DataField("visuals")]
internal List<AppearanceVisualizer> Visualizers = new();
[ViewVariables]
private bool _appearanceDirty;
public override void SetData(string key, object value)
{
SetData(key, value);
}
public override void SetData(Enum key, object value)
{
SetData(key, value);
}
public override T GetData<T>(string key)
{
return (T) data[key];
}
public override T GetData<T>(Enum key)
{
return (T) data[key];
}
internal T GetData<T>(object key)
{
return (T) data[key];
}
public override bool TryGetData<T>(Enum key, [NotNullWhen(true)] out T data)
{
return TryGetData(key, out data);
}
public override bool TryGetData<T>(string key, [NotNullWhen(true)] out T data)
{
return TryGetData(key, out data);
}
internal bool TryGetData<T>(object key, [NotNullWhen(true)] out T data)
{
if (this.data.TryGetValue(key, out var dat))
{
data = (T) dat;
return true;
}
data = default!;
return false;
}
private void SetData(object key, object value)
{
if (data.TryGetValue(key, out var existing) && existing.Equals(value)) return;
data[key] = value;
MarkDirty();
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (curState is not AppearanceComponentState actualState)
return;
var stateDiff = data.Count != actualState.Data.Count;
if (!stateDiff)
{
foreach (var (key, value) in data)
{
if (!actualState.Data.TryGetValue(key, out var stateValue) ||
!value.Equals(stateValue))
{
stateDiff = true;
break;
}
}
}
if (!stateDiff) return;
data = actualState.Data;
MarkDirty();
}
internal void MarkDirty()
{
if (_appearanceDirty)
{
return;
}
EntitySystem.Get<AppearanceSystem>().EnqueueUpdate(this);
_appearanceDirty = true;
}
internal void UnmarkDirty()
{
_appearanceDirty = false;
}
protected override void Initialize()
{
base.Initialize();
foreach (var visual in Visualizers)
{
visual.InitializeEntity(Owner);
}
MarkDirty();
}
}
/// <summary>
/// Handles the visualization of data inside of an appearance component.
/// Implementations of this class are NOT bound to a specific entity, they are flyweighted across multiple.
/// </summary>
[ImplicitDataDefinitionForInheritors]
public abstract class AppearanceVisualizer
{
/// <summary>
/// Initializes an entity to be managed by this appearance controller.
/// DO NOT assume this is your only entity. Visualizers are shared.
/// </summary>
public virtual void InitializeEntity(IEntity entity)
{
}
/// <summary>
/// Called whenever appearance data for an entity changes.
/// Update its visuals here.
/// </summary>
/// <param name="component">The appearance component of the entity that might need updating.</param>
public virtual void OnChangeData(AppearanceComponent component)
{
}
}
}

View File

@@ -0,0 +1,29 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Robust.Client.GameObjects;
/// <summary>
/// Handles the visualization of data inside of an appearance component.
/// Implementations of this class are NOT bound to a specific entity, they are flyweighted across multiple.
/// </summary>
[ImplicitDataDefinitionForInheritors]
public abstract class AppearanceVisualizer
{
/// <summary>
/// Initializes an entity to be managed by this appearance controller.
/// DO NOT assume this is your only entity. Visualizers are shared.
/// </summary>
public virtual void InitializeEntity(EntityUid entity)
{
}
/// <summary>
/// Called whenever appearance data for an entity changes.
/// Update its visuals here.
/// </summary>
/// <param name="component">The appearance component of the entity that might need updating.</param>
public virtual void OnChangeData(AppearanceComponent component)
{
}
}

View File

@@ -0,0 +1,47 @@
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Robust.Client.GameObjects;
/// <summary>
/// This is the client instance of <see cref="AppearanceComponent"/>.
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(AppearanceComponent))]
public sealed class ClientAppearanceComponent : AppearanceComponent
{
[ViewVariables]
private bool _appearanceDirty;
[ViewVariables]
[DataField("visuals")]
internal List<AppearanceVisualizer> Visualizers = new();
protected override void MarkDirty()
{
if (_appearanceDirty)
return;
EntitySystem.Get<AppearanceSystem>().EnqueueUpdate(this);
_appearanceDirty = true;
}
protected override void Initialize()
{
base.Initialize();
foreach (var visual in Visualizers)
{
visual.InitializeEntity(Owner);
}
MarkDirty();
}
internal void UnmarkDirty()
{
_appearanceDirty = false;
}
}

View File

@@ -3,8 +3,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -14,9 +12,7 @@ namespace Robust.Client.GameObjects
public class EyeComponent : SharedEyeComponent
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
/// <inheritdoc />
public override string Name => "Eye";
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private Eye? _eye = default!;
@@ -118,7 +114,7 @@ namespace Robust.Client.GameObjects
_eye = new Eye
{
Position = Owner.Transform.MapPosition,
Position = _entityManager.GetComponent<TransformComponent>(Owner).MapPosition,
Zoom = _setZoomOnInitialize,
DrawFov = _setDrawFovOnInitialize
};
@@ -166,7 +162,7 @@ namespace Robust.Client.GameObjects
public void UpdateEyePosition()
{
if (_eye == null) return;
var mapPos = Owner.Transform.MapPosition;
var mapPos = _entityManager.GetComponent<TransformComponent>(Owner).MapPosition;
_eye.Position = new MapCoordinates(mapPos.Position, mapPos.MapId);
}
}

View File

@@ -1,4 +1,4 @@
using Robust.Client.Graphics;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.Utility;
using Robust.Shared.GameObjects;
@@ -14,7 +14,6 @@ namespace Robust.Client.GameObjects
[RegisterComponent]
public class IconComponent : Component, ISerializationHooks
{
public override string Name => "Icon";
public IDirectionalTextureProvider? Icon { get; private set; }
[DataField("sprite")]

View File

@@ -1,4 +1,4 @@
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -10,9 +10,6 @@ namespace Robust.Client.GameObjects
/// </summary>
public class InputComponent : Component
{
/// <inheritdoc />
public override string Name => "Input";
/// <summary>
/// The context that will be made active for a client that attaches to this entity.
/// </summary>

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
@@ -12,6 +11,7 @@ namespace Robust.Client.GameObjects
internal sealed class ClientOccluderComponent : OccluderComponent
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables] private (GridId, Vector2i) _lastPosition;
[ViewVariables] internal OccluderDir Occluding { get; private set; }
@@ -32,7 +32,7 @@ namespace Robust.Client.GameObjects
{
base.Startup();
if (Owner.Transform.Anchored)
if (_entityManager.GetComponent<TransformComponent>(Owner).Anchored)
{
AnchorStateChanged();
}
@@ -42,11 +42,11 @@ namespace Robust.Client.GameObjects
{
SendDirty();
if(!Owner.Transform.Anchored)
if(!_entityManager.GetComponent<TransformComponent>(Owner).Anchored)
return;
var grid = _mapManager.GetGrid(Owner.Transform.GridID);
_lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates));
var grid = _mapManager.GetGrid(_entityManager.GetComponent<TransformComponent>(Owner).GridID);
_lastPosition = (_entityManager.GetComponent<TransformComponent>(Owner).GridID, grid.TileIndicesFor(_entityManager.GetComponent<TransformComponent>(Owner).Coordinates));
}
protected override void Shutdown()
@@ -58,9 +58,9 @@ namespace Robust.Client.GameObjects
private void SendDirty()
{
if (Owner.Transform.Anchored)
if (_entityManager.GetComponent<TransformComponent>(Owner).Anchored)
{
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local,
_entityManager.EventBus.RaiseEvent(EventSource.Local,
new OccluderDirtyEvent(Owner, _lastPosition));
}
}
@@ -69,18 +69,18 @@ namespace Robust.Client.GameObjects
{
Occluding = OccluderDir.None;
if (Deleted || !Owner.Transform.Anchored)
if (Deleted || !_entityManager.GetComponent<TransformComponent>(Owner).Anchored)
{
return;
}
var grid = _mapManager.GetGrid(_entityManager.GetComponent<TransformComponent>(Owner).GridID);
var position = _entityManager.GetComponent<TransformComponent>(Owner).Coordinates;
void CheckDir(Direction dir, OccluderDir oclDir)
{
var grid = _mapManager.GetGrid(Owner.Transform.GridID);
var position = Owner.Transform.Coordinates;
foreach (var neighbor in grid.GetInDir(position, dir))
{
if (Owner.EntityManager.TryGetComponent(neighbor, out ClientOccluderComponent? comp) && comp.Enabled)
if (_entityManager.TryGetComponent(neighbor, out ClientOccluderComponent? comp) && comp.Enabled)
{
Occluding |= oclDir;
break;
@@ -88,10 +88,20 @@ namespace Robust.Client.GameObjects
}
}
CheckDir(Direction.North, OccluderDir.North);
CheckDir(Direction.East, OccluderDir.East);
CheckDir(Direction.South, OccluderDir.South);
CheckDir(Direction.West, OccluderDir.West);
var angle = _entityManager.GetComponent<TransformComponent>(Owner).LocalRotation;
var dirRolling = angle.GetCardinalDir();
// dirRolling starts at effective south
CheckDir(dirRolling, OccluderDir.South);
dirRolling = dirRolling.GetClockwise90Degrees();
CheckDir(dirRolling, OccluderDir.West);
dirRolling = dirRolling.GetClockwise90Degrees();
CheckDir(dirRolling, OccluderDir.North);
dirRolling = dirRolling.GetClockwise90Degrees();
CheckDir(dirRolling, OccluderDir.East);
}
[Flags]

View File

@@ -1,6 +1,7 @@
using Robust.Client.Graphics;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -12,6 +13,8 @@ namespace Robust.Client.GameObjects
[ComponentReference(typeof(SharedPointLightComponent))]
public class PointLightComponent : SharedPointLightComponent, ISerializationHooks
{
[Dependency] private readonly IEntityManager _entityManager = default!;
internal bool TreeUpdateQueued { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
@@ -31,7 +34,7 @@ namespace Robust.Client.GameObjects
{
if (_enabled == value) return;
base.Enabled = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PointLightUpdateEvent());
_entityManager.EventBus.RaiseLocalEvent(Owner, new PointLightUpdateEvent());
}
}
@@ -44,7 +47,7 @@ namespace Robust.Client.GameObjects
if (_containerOccluded == value) return;
_containerOccluded = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PointLightUpdateEvent());
_entityManager.EventBus.RaiseLocalEvent(Owner, new PointLightUpdateEvent());
}
}
@@ -93,26 +96,6 @@ namespace Robust.Client.GameObjects
[ViewVariables(VVAccess.ReadWrite)]
public Texture? Mask { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
[Animatable]
public float Energy
{
get => _energy;
set => _energy = value;
}
/// <summary>
/// Soft shadow strength multiplier.
/// Has no effect if soft shadows are not enabled.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[Animatable]
public float Softness
{
get => _softness;
set => _softness = value;
}
[ViewVariables(VVAccess.ReadWrite)]
public bool VisibleNested
{
@@ -131,10 +114,7 @@ namespace Robust.Client.GameObjects
[DataField("autoRot")]
private bool _maskAutoRotate;
private Angle _rotation;
[DataField("energy")]
private float _energy = 1f;
[DataField("softness")]
private float _softness = 1f;
[DataField("mask")]
internal string? _maskPath;
@@ -151,7 +131,7 @@ namespace Robust.Client.GameObjects
if (MathHelper.CloseToPercent(value, _radius)) return;
base.Radius = value;
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new PointLightRadiusChangedEvent(this));
_entityManager.EventBus.RaiseEvent(EventSource.Local, new PointLightRadiusChangedEvent(this));
}
}

View File

@@ -23,6 +23,11 @@ namespace Robust.Client.GameObjects
public sealed class SpriteBoundsSystem : EntitySystem
{
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly RenderingTreeSystem _renderingTree = default!;
private SpriteBoundsOverlay? _overlay;
public bool Enabled
@@ -37,15 +42,13 @@ namespace Robust.Client.GameObjects
if (_enabled)
{
DebugTools.AssertNull(_overlay);
var overlayManager = IoCManager.Resolve<IOverlayManager>();
_overlay = new SpriteBoundsOverlay(EntitySystem.Get<RenderingTreeSystem>(), IoCManager.Resolve<IEyeManager>());
overlayManager.AddOverlay(_overlay);
_overlay = new SpriteBoundsOverlay(_renderingTree, _eye, _entityManager);
_overlayManager.AddOverlay(_overlay);
}
else
{
if (_overlay == null) return;
var overlayManager = IoCManager.Resolve<IOverlayManager>();
overlayManager.RemoveOverlay(_overlay);
_overlayManager.RemoveOverlay(_overlay);
_overlay = null;
}
}
@@ -58,13 +61,15 @@ namespace Robust.Client.GameObjects
{
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly IEyeManager _eyeManager = default!;
private readonly IEyeManager _eyeManager;
private readonly IEntityManager _entityManager;
private RenderingTreeSystem _renderTree;
public SpriteBoundsOverlay(RenderingTreeSystem renderTree, IEyeManager eyeManager)
public SpriteBoundsOverlay(RenderingTreeSystem renderTree, IEyeManager eyeManager, IEntityManager entityManager)
{
_renderTree = renderTree;
_eyeManager = eyeManager;
_entityManager = entityManager;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -75,11 +80,11 @@ namespace Robust.Client.GameObjects
foreach (var comp in _renderTree.GetRenderTrees(currentMap, viewport))
{
var localAABB = comp.Owner.Transform.InvWorldMatrix.TransformBox(viewport);
var localAABB = _entityManager.GetComponent<TransformComponent>(comp.Owner).InvWorldMatrix.TransformBox(viewport);
foreach (var sprite in comp.SpriteTree.QueryAabb(localAABB))
{
var worldPos = sprite.Owner.Transform.WorldPosition;
var worldPos = _entityManager.GetComponent<TransformComponent>(sprite.Owner).WorldPosition;
var bounds = sprite.CalculateBoundingBox(worldPos);
handle.DrawRect(bounds, Color.Red.WithAlpha(0.2f));
handle.DrawRect(bounds.Scale(0.2f).Translated(-new Vector2(0f, bounds.Extents.Y)), Color.Blue.WithAlpha(0.5f));

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Text;
@@ -13,14 +12,11 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
@@ -34,6 +30,7 @@ namespace Robust.Client.GameObjects
{
[Dependency] private readonly IResourceCache resourceCache = default!;
[Dependency] private readonly IPrototypeManager prototypes = default!;
[Dependency] private readonly IEntityManager entities = default!;
[DataField("visible")]
private bool _visible = true;
@@ -47,7 +44,7 @@ namespace Robust.Client.GameObjects
if (_visible == value) return;
_visible = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
entities.EventBus.RaiseLocalEvent(Owner, new SpriteUpdateEvent());
}
}
@@ -213,6 +210,7 @@ namespace Robust.Client.GameObjects
layer.Color = layerDatum.Color;
layer.Rotation = layerDatum.Rotation;
layer._offset = layerDatum.Offset;
// If neither state: nor texture: were provided we assume that they want a blank invisible layer.
layer.Visible = anyTextureAttempted && layerDatum.Visible;
layer.Scale = layerDatum.Scale;
@@ -302,7 +300,7 @@ namespace Robust.Client.GameObjects
{
if (_containerOccluded == value) return;
_containerOccluded = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
entities.EventBus.RaiseLocalEvent(Owner, new SpriteUpdateEvent());
}
}
@@ -1259,7 +1257,10 @@ namespace Robust.Client.GameObjects
if (worldRotation.Theta < 0)
worldRotation = new Angle(worldRotation.Theta + Math.Tau);
var localMatrix = GetLocalMatrix();
// sprite matrix, WITHOUT offset.
// offset is applied after sprite numDirs snapping/rotation correction
// --> apply at same time as layer offset
var spriteMatrix = Matrix3.CreateTransform(Vector2.Zero, rotation, scale);
foreach (var layer in Layers)
{
@@ -1270,9 +1271,10 @@ namespace Robust.Client.GameObjects
var numDirs = GetLayerDirectionCount(layer);
var layerRotation = worldRotation + layer.Rotation;
var layerPosition = worldPosition + layerRotation.RotateVec(layer._offset + offset);
CalcModelMatrix(numDirs, eyeRotation, layerRotation, worldPosition, out var modelMatrix);
Matrix3.Multiply(ref localMatrix, ref modelMatrix, out var transformMatrix);
CalcModelMatrix(numDirs, eyeRotation, layerRotation, layerPosition, out var modelMatrix);
Matrix3.Multiply(ref spriteMatrix, ref modelMatrix, out var transformMatrix);
drawingHandle.SetTransform(in transformMatrix);
RenderLayer(drawingHandle, layer, eyeRotation, layerRotation, overrideDirection);
@@ -1290,7 +1292,7 @@ namespace Robust.Client.GameObjects
var layerColor = color * layer.Color;
var position = -(Vector2)texture.Size / (2f * EyeManager.PixelsPerMeter) + layer.Offset;
var position = -(Vector2)texture.Size / (2f * EyeManager.PixelsPerMeter);
var textureSize = texture.Size / (float)EyeManager.PixelsPerMeter;
var quad = Box2.FromDimensions(position, textureSize);
@@ -1475,35 +1477,11 @@ namespace Robust.Client.GameObjects
}
}
private RSI.State.Direction GetDir(RSI.State.DirectionType rsiDirectionType, Angle worldRotation)
{
var dir = rsiDirectionType switch
{
RSI.State.DirectionType.Dir1 => Direction.South,
RSI.State.DirectionType.Dir4 => worldRotation.GetCardinalDir(),
RSI.State.DirectionType.Dir8 => worldRotation.GetDir(),
_ => throw new ArgumentException($"Unknown RSI DirectionType: {rsiDirectionType}.", nameof(rsiDirectionType))
};
return dir switch
{
Direction.North => RSI.State.Direction.North,
Direction.South => RSI.State.Direction.South,
Direction.East => RSI.State.Direction.East,
Direction.West => RSI.State.Direction.West,
Direction.SouthEast => RSI.State.Direction.SouthEast,
Direction.SouthWest => RSI.State.Direction.SouthWest,
Direction.NorthEast => RSI.State.Direction.NorthEast,
Direction.NorthWest => RSI.State.Direction.NorthWest,
_ => throw new ArgumentOutOfRangeException(nameof(dir), dir, null)
};
}
private void QueueUpdateIsInert()
{
// Look this was an easy way to get bounds checks for layer updates.
// If you really want it optimal you'll need to comb through all 2k lines of spritecomponent.
if (Owner?.EntityManager?.EventBus != null)
if ((Owner != default ? entities : null)?.EventBus != null)
UpdateBounds();
if (_inertUpdateQueued)
@@ -1512,7 +1490,7 @@ namespace Robust.Client.GameObjects
_inertUpdateQueued = true;
// Yes that null check is valid because of that stupid fucking dummy IEntity.
// Who thought that was a good idea.
Owner?.EntityManager?.EventBus?.RaiseEvent(EventSource.Local, new SpriteUpdateInertEvent {Sprite = this});
(Owner != default ? entities : null)?.EventBus?.RaiseEvent(EventSource.Local, new SpriteUpdateInertEvent {Sprite = this});
}
internal void DoUpdateIsInert()
@@ -1548,58 +1526,13 @@ namespace Robust.Client.GameObjects
return rsi["error"];
}
private static RSI.State.Direction OffsetRsiDir(RSI.State.Direction dir, DirectionOffset offset)
{
// There is probably a better way to do this.
// Eh.
switch (offset)
{
case DirectionOffset.None:
return dir;
case DirectionOffset.Clockwise:
return dir switch
{
RSI.State.Direction.North => RSI.State.Direction.East,
RSI.State.Direction.East => RSI.State.Direction.South,
RSI.State.Direction.South => RSI.State.Direction.West,
RSI.State.Direction.West => RSI.State.Direction.North,
_ => throw new NotImplementedException()
};
case DirectionOffset.CounterClockwise:
return dir switch
{
RSI.State.Direction.North => RSI.State.Direction.West,
RSI.State.Direction.East => RSI.State.Direction.North,
RSI.State.Direction.South => RSI.State.Direction.East,
RSI.State.Direction.West => RSI.State.Direction.South,
_ => throw new NotImplementedException()
};
case DirectionOffset.Flip:
switch (dir)
{
case RSI.State.Direction.North:
return RSI.State.Direction.South;
case RSI.State.Direction.East:
return RSI.State.Direction.West;
case RSI.State.Direction.South:
return RSI.State.Direction.North;
case RSI.State.Direction.West:
return RSI.State.Direction.East;
default:
throw new NotImplementedException();
}
default:
throw new NotImplementedException();
}
}
public string GetDebugString()
{
var builder = new StringBuilder();
builder.AppendFormat(
"vis/depth/scl/rot/ofs/col/norot/override/dir: {0}/{1}/{2}/{3}/{4}/{5}/{6}/{8}/{7}\n",
Visible, DrawDepth, Scale, Rotation, Offset,
Color, NoRotation, GetDir(RSI.State.DirectionType.Dir8, Owner.Transform.WorldRotation),
Color, NoRotation, entities.GetComponent<TransformComponent>(Owner).WorldRotation.ToRsiDirection(RSI.State.DirectionType.Dir8),
DirectionOverride
);
@@ -1653,7 +1586,7 @@ namespace Robust.Client.GameObjects
internal void UpdateBounds()
{
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
entities.EventBus.RaiseLocalEvent(Owner, new SpriteUpdateEvent());
}
/// <summary>
@@ -1723,7 +1656,7 @@ namespace Robust.Client.GameObjects
}
}
private Vector2 _offset;
internal Vector2 _offset;
[ViewVariables]
public DirectionOffset DirOffset { get; set; }
@@ -1840,10 +1773,10 @@ namespace Robust.Client.GameObjects
}
else
{
dir = _parent.GetDir(state.Directions, worldRotation);
dir = worldRotation.ToRsiDirection(state.Directions);
}
return OffsetRsiDir(dir, DirOffset);
return dir.OffsetRsiDir(DirOffset);
}
}
@@ -2072,8 +2005,9 @@ namespace Robust.Client.GameObjects
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace).Uid;
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var spriteComponent = entityManager.EnsureComponent<SpriteComponent>(dummy);
EntitySystem.Get<AppearanceSystem>().OnChangeData(dummy);
var anyTexture = false;
foreach (var layer in spriteComponent.AllLayers)
@@ -2111,7 +2045,7 @@ namespace Robust.Client.GameObjects
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace).Uid;
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var spriteComponent = entityManager.EnsureComponent<SpriteComponent>(dummy);
var result = spriteComponent.Icon ?? GetFallbackState(resourceCache);
entityManager.DeleteEntity(dummy);

View File

@@ -1,5 +1,4 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
namespace Robust.Client.GameObjects
@@ -7,57 +6,7 @@ namespace Robust.Client.GameObjects
[RegisterComponent]
public sealed class RenderingTreeComponent : Component
{
public override string Name => "RenderingTree";
internal DynamicTree<SpriteComponent> SpriteTree { get; private set; } = new(SpriteAabbFunc);
internal DynamicTree<PointLightComponent> LightTree { get; private set; } = new(LightAabbFunc);
private static Box2 SpriteAabbFunc(in SpriteComponent value)
{
var worldPos = value.Owner.Transform.WorldPosition;
var worldRot = value.Owner.Transform.WorldRotation;
var bounds = new Box2Rotated(value.CalculateBoundingBox(worldPos), worldRot, worldPos);
var tree = RenderingTreeSystem.GetRenderTree(value.Owner);
var localAABB = tree?.Owner.Transform.InvWorldMatrix.TransformBox(bounds) ?? bounds.CalcBoundingBox();
return localAABB;
}
private static Box2 LightAabbFunc(in PointLightComponent value)
{
var worldPos = value.Owner.Transform.WorldPosition;
var tree = RenderingTreeSystem.GetRenderTree(value.Owner);
var boxSize = value.Radius * 2;
var localPos = tree?.Owner.Transform.InvWorldMatrix.Transform(worldPos) ?? worldPos;
return Box2.CenteredAround(localPos, (boxSize, boxSize));
}
internal static Box2 SpriteAabbFunc(SpriteComponent value, Vector2? worldPos = null, Angle? worldRot = null)
{
worldPos ??= value.Owner.Transform.WorldPosition;
worldRot ??= value.Owner.Transform.WorldRotation;
var bounds = new Box2Rotated(value.CalculateBoundingBox(worldPos.Value), worldRot.Value, worldPos.Value);
var tree = RenderingTreeSystem.GetRenderTree(value.Owner);
var localAABB = tree?.Owner.Transform.InvWorldMatrix.TransformBox(bounds) ?? bounds.CalcBoundingBox();
return localAABB;
}
internal static Box2 LightAabbFunc(PointLightComponent value, Vector2? worldPos = null)
{
// Lights are circles so don't need entity's rotation
worldPos ??= value.Owner.Transform.WorldPosition;
var tree = RenderingTreeSystem.GetRenderTree(value.Owner);
var boxSize = value.Radius * 2;
var localPos = tree?.Owner.Transform.InvWorldMatrix.Transform(worldPos.Value) ?? worldPos.Value;
return Box2.CenteredAround(localPos, (boxSize, boxSize));
}
internal DynamicTree<SpriteComponent> SpriteTree { get; set; } = default!;
internal DynamicTree<PointLightComponent> LightTree { get; set; } = default!;
}
}

View File

@@ -15,6 +15,8 @@ namespace Robust.Client.GameObjects
{
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
[Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly Dictionary<object, BoundUserInterface> _openInterfaces =
new();
@@ -87,15 +89,15 @@ namespace Robust.Client.GameObjects
_openInterfaces.Remove(uiKey);
boundUserInterface.Dispose();
var playerSession = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.Session;
var playerSession = _playerManager.LocalPlayer?.Session;
if(playerSession != null)
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new BoundUIClosedEvent(uiKey, Owner.Uid, playerSession));
_entityManager.EventBus.RaiseLocalEvent(Owner, new BoundUIClosedEvent(uiKey, Owner, playerSession));
}
internal void SendMessage(BoundUserInterfaceMessage message, object uiKey)
{
EntitySystem.Get<UserInterfaceSystem>()
.Send(new BoundUIWrapMessage(Owner.Uid, message, uiKey));
.Send(new BoundUIWrapMessage(Owner, message, uiKey));
}
}

View File

@@ -46,7 +46,7 @@ namespace Robust.Client.GameObjects
foreach (var key in remie)
{
component.PlayingAnimations.Remove(key);
EntityManager.EventBus.RaiseLocalEvent(component.Owner.Uid, new AnimationCompletedEvent {Uid = component.Owner.Uid, Key = key});
EntityManager.EventBus.RaiseLocalEvent(component.Owner, new AnimationCompletedEvent {Uid = component.Owner, Key = key});
component.AnimationComplete(key);
}
@@ -58,7 +58,7 @@ namespace Robust.Client.GameObjects
/// </summary>
public void Play(EntityUid uid, Animation animation, string key)
{
var component = EntityManager.EnsureComponent<AnimationPlayerComponent>(EntityManager.GetEntity(uid));
var component = EntityManager.EnsureComponent<AnimationPlayerComponent>(uid);
Play(component, animation, key);
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
@@ -7,9 +7,9 @@ namespace Robust.Client.GameObjects
[UsedImplicitly]
internal sealed class AppearanceSystem : EntitySystem
{
private readonly Queue<AppearanceComponent> _queuedUpdates = new();
private readonly Queue<ClientAppearanceComponent> _queuedUpdates = new();
public void EnqueueUpdate(AppearanceComponent component)
public void EnqueueUpdate(ClientAppearanceComponent component)
{
_queuedUpdates.Enqueue(component);
}
@@ -19,15 +19,21 @@ namespace Robust.Client.GameObjects
while (_queuedUpdates.TryDequeue(out var appearance))
{
if (appearance.Deleted)
return;
foreach (var visualizer in appearance.Visualizers)
{
visualizer.OnChangeData(appearance);
}
continue;
OnChangeData(appearance.Owner, appearance);
appearance.UnmarkDirty();
}
}
public void OnChangeData(EntityUid uid, ClientAppearanceComponent? appearanceComponent = null)
{
if (!Resolve(uid, ref appearanceComponent, false)) return;
foreach (var visualizer in appearanceComponent.Visualizers)
{
visualizer.OnChangeData(appearanceComponent);
}
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using JetBrains.Annotations;
using Robust.Client.Audio;
using Robust.Client.Graphics;
@@ -82,8 +81,8 @@ namespace Robust.Client.GameObjects
private void PlayAudioEntityHandler(PlayAudioEntityMessage ev)
{
var stream = EntityManager.TryGetEntity(ev.EntityUid, out var entity) ?
(PlayingStream?) Play(ev.FileName, entity, ev.FallbackCoordinates, ev.AudioParams)
var stream = EntityManager.EntityExists(ev.EntityUid) ?
(PlayingStream?) Play(ev.FileName, ev.EntityUid, ev.FallbackCoordinates, ev.AudioParams)
: (PlayingStream?) Play(ev.FileName, ev.Coordinates, ev.FallbackCoordinates, ev.AudioParams);
if (stream != null)
@@ -123,15 +122,15 @@ namespace Robust.Client.GameObjects
continue;
}
}
else if (stream.TrackingEntity != null)
else if (stream.TrackingEntity != default)
{
if (stream.TrackingEntity.Deleted)
if (EntityManager.Deleted(stream.TrackingEntity))
{
StreamDone(stream);
continue;
}
mapPos = stream.TrackingEntity.Transform.MapPosition;
mapPos = EntityManager.GetComponent<TransformComponent>(stream.TrackingEntity).MapPosition;
}
// TODO Remove when coordinates can't be NaN
@@ -211,7 +210,7 @@ namespace Robust.Client.GameObjects
}
}
if (stream.TrackingEntity != null)
if (stream.TrackingEntity != default)
{
stream.Source.SetVelocity(stream.TrackingEntity.GlobalLinearVelocity());
}
@@ -254,9 +253,15 @@ namespace Robust.Client.GameObjects
/// </summary>
/// <param name="stream">The audio stream to play.</param>
/// <param name="audioParams"></param>
private IPlayingAudioStream Play(AudioStream stream, AudioParams? audioParams = null)
private IPlayingAudioStream? Play(AudioStream stream, AudioParams? audioParams = null)
{
var source = _clyde.CreateAudioSource(stream);
if (source == null)
{
return null;
}
ApplyAudioParams(audioParams, source);
source.SetGlobal();
@@ -281,7 +286,7 @@ namespace Robust.Client.GameObjects
/// <param name="entity">The entity "emitting" the audio.</param>
/// <param name="fallbackCoordinates">The map or grid coordinates at which to play the audio when entity is invalid.</param>
/// <param name="audioParams"></param>
private IPlayingAudioStream? Play(string filename, IEntity entity, EntityCoordinates fallbackCoordinates,
private IPlayingAudioStream? Play(string filename, EntityUid entity, EntityCoordinates fallbackCoordinates,
AudioParams? audioParams = null)
{
if (_resourceCache.TryGetResource<AudioResource>(new ResourcePath(filename), out var audio))
@@ -300,11 +305,17 @@ namespace Robust.Client.GameObjects
/// <param name="entity">The entity "emitting" the audio.</param>
/// <param name="fallbackCoordinates">The map or grid coordinates at which to play the audio when entity is invalid.</param>
/// <param name="audioParams"></param>
private IPlayingAudioStream? Play(AudioStream stream, IEntity entity, EntityCoordinates fallbackCoordinates,
private IPlayingAudioStream? Play(AudioStream stream, EntityUid entity, EntityCoordinates fallbackCoordinates,
AudioParams? audioParams = null)
{
var source = _clyde.CreateAudioSource(stream);
if (!source.SetPosition(entity.Transform.WorldPosition))
if (source == null)
{
return null;
}
if (!source.SetPosition(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition))
{
return Play(stream, fallbackCoordinates, fallbackCoordinates, audioParams);
}
@@ -357,6 +368,12 @@ namespace Robust.Client.GameObjects
EntityCoordinates fallbackCoordinates, AudioParams? audioParams = null)
{
var source = _clyde.CreateAudioSource(stream);
if (source == null)
{
return null;
}
if (!source.SetPosition(fallbackCoordinates.Position))
{
source.Dispose();
@@ -407,7 +424,7 @@ namespace Robust.Client.GameObjects
{
public uint? NetIdentifier;
public IClydeAudioSource Source = default!;
public IEntity TrackingEntity = default!;
public EntityUid TrackingEntity = default!;
public EntityCoordinates? TrackingCoordinates;
public EntityCoordinates? TrackingFallbackCoordinates;
public bool Done;
@@ -440,9 +457,6 @@ namespace Robust.Client.GameObjects
}
}
/// <inheritdoc />
public int DefaultSoundRange => 25;
/// <inheritdoc />
public int OcclusionCollisionMask { get; set; }
@@ -453,15 +467,9 @@ namespace Robust.Client.GameObjects
}
/// <inheritdoc />
public IPlayingAudioStream? Play(Filter playerFilter, string filename, IEntity entity, AudioParams? audioParams = null)
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityUid entity, AudioParams? audioParams = null)
{
return Play(filename, entity, GetFallbackCoordinates(entity.Transform.MapPosition), audioParams);
}
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityUid uid, AudioParams? audioParams = null)
{
return EntityManager.TryGetEntity(uid, out var entity)
? Play(filename, entity, GetFallbackCoordinates(entity.Transform.MapPosition), audioParams) : null;
return Play(filename, entity, GetFallbackCoordinates(EntityManager.GetComponent<TransformComponent>(entity).MapPosition), audioParams);
}
/// <inheritdoc />

View File

@@ -70,14 +70,14 @@ namespace Robust.Client.GameObjects
private void HandleDirtyEvent(OccluderDirtyEvent ev)
{
var sender = ev.Sender;
if (sender.IsValid() &&
sender.TryGetComponent(out ClientOccluderComponent? iconSmooth)
&& iconSmooth.Running)
if (EntityManager.EntityExists(sender) &&
EntityManager.TryGetComponent(sender, out ClientOccluderComponent? iconSmooth)
&& iconSmooth.Initialized)
{
var grid1 = _mapManager.GetGrid(sender.Transform.GridID);
var coords = sender.Transform.Coordinates;
var grid1 = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(sender).GridID);
var coords = EntityManager.GetComponent<TransformComponent>(sender).Coordinates;
_dirtyEntities.Enqueue(sender.Uid);
_dirtyEntities.Enqueue(sender);
AddValidEntities(grid1.GetInDir(coords, Direction.North));
AddValidEntities(grid1.GetInDir(coords, Direction.South));
AddValidEntities(grid1.GetInDir(coords, Direction.East));
@@ -85,7 +85,7 @@ namespace Robust.Client.GameObjects
}
// Entity is no longer valid, update around the last position it was at.
if (ev.LastPosition.HasValue && _mapManager.TryGetGrid(ev.LastPosition.Value.grid, out var grid))
else if (ev.LastPosition.HasValue && _mapManager.TryGetGrid(ev.LastPosition.Value.grid, out var grid))
{
var pos = ev.LastPosition.Value.pos;
@@ -113,13 +113,13 @@ namespace Robust.Client.GameObjects
/// </summary>
internal sealed class OccluderDirtyEvent : EntityEventArgs
{
public OccluderDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition)
public OccluderDirtyEvent(EntityUid sender, (GridId grid, Vector2i pos)? lastPosition)
{
LastPosition = lastPosition;
Sender = sender;
}
public (GridId grid, Vector2i pos)? LastPosition { get; }
public IEntity Sender { get; }
public EntityUid Sender { get; }
}
}

View File

@@ -15,7 +15,7 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IRobustSerializer _serializer = default!;
[Dependency] private readonly IDynamicTypeFactoryInternal _dynFactory = default!;
private readonly HashSet<IEntity> _updateQueue = new();
private readonly HashSet<EntityUid> _updateQueue = new();
public readonly Dictionary<EntityUid, IContainer> ExpectedEntities = new();
@@ -37,10 +37,10 @@ namespace Robust.Client.GameObjects
private void HandleEntityInitialized(EntityInitializedMessage ev)
{
if (!ExpectedEntities.TryGetValue(ev.Entity.Uid, out var container))
if (!ExpectedEntities.TryGetValue(ev.Entity, out var container))
return;
RemoveExpectedEntity(ev.Entity.Uid);
RemoveExpectedEntity(ev.Entity);
if (container.Deleted)
return;
@@ -89,12 +89,12 @@ namespace Robust.Client.GameObjects
container.OccludesLight = occludesLight;
// Remove gone entities.
List<IEntity>? toRemove = null;
List<EntityUid>? toRemove = null;
foreach (var entity in container.ContainedEntities)
{
if (!entityUids.Contains(entity.Uid))
if (!entityUids.Contains(entity))
{
toRemove ??= new List<IEntity>();
toRemove ??= new List<EntityUid>();
toRemove.Add(entity);
}
}
@@ -123,11 +123,11 @@ namespace Robust.Client.GameObjects
}
// Add new entities.
foreach (var entityUid in entityUids)
foreach (var entity in entityUids)
{
if (!EntityManager.TryGetEntity(entityUid, out var entity))
if (!EntityManager.EntityExists(entity))
{
AddExpectedEntity(entityUid, container);
AddExpectedEntity(entity, container);
continue;
}
@@ -172,7 +172,7 @@ namespace Robust.Client.GameObjects
foreach (var toUpdate in _updateQueue)
{
if (toUpdate.Deleted)
if (EntityManager.Deleted(toUpdate))
{
continue;
}
@@ -183,22 +183,22 @@ namespace Robust.Client.GameObjects
_updateQueue.Clear();
}
private static void UpdateEntityRecursively(IEntity entity)
private void UpdateEntityRecursively(EntityUid entity)
{
// TODO: Since we are recursing down,
// we could cache ShowContents data here to speed it up for children.
// Am lazy though.
UpdateEntity(entity);
foreach (var child in entity.Transform.Children)
foreach (var child in EntityManager.GetComponent<TransformComponent>(entity).Children)
{
UpdateEntityRecursively(child.Owner);
}
}
private static void UpdateEntity(IEntity entity)
private void UpdateEntity(EntityUid entity)
{
if (entity.TryGetComponent(out SpriteComponent? sprite))
if (EntityManager.TryGetComponent(entity, out SpriteComponent? sprite))
{
sprite.ContainerOccluded = false;
@@ -216,7 +216,7 @@ namespace Robust.Client.GameObjects
}
}
if (entity.TryGetComponent(out PointLightComponent? light))
if (EntityManager.TryGetComponent(entity, out PointLightComponent? light))
{
light.ContainerOccluded = false;

View File

@@ -1,133 +0,0 @@
#if DEBUG
using System;
using System.Text;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Robust.Client.GameObjects
{
internal sealed class DebugGridTileLookupSystem : EntitySystem
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
public bool Enabled
{
get => _enabled;
set
{
if (_enabled == value) return;
_enabled = value;
if (_enabled)
{
_label.Visible = true;
LastTile = default;
}
else
{
_label.Text = null;
_label.Visible = false;
}
}
}
private bool _enabled;
private (GridId Grid, Vector2i Indices) LastTile;
// Label and shit that follows cursor
private Label _label = new()
{
Visible = false,
};
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<SendGridTileLookupMessage>(HandleSentEntities);
IoCManager.Resolve<IUserInterfaceManager>().StateRoot.AddChild(_label);
}
public override void Shutdown()
{
base.Shutdown();
IoCManager.Resolve<IUserInterfaceManager>().StateRoot.RemoveChild(_label);
}
private void RequestEntities(GridId gridId, Vector2i indices)
{
if (gridId == GridId.Invalid) return;
RaiseNetworkEvent(new RequestGridTileLookupMessage(gridId, indices));
}
private void HandleSentEntities(SendGridTileLookupMessage message)
{
if (!Enabled) return;
var text = new StringBuilder();
text.AppendLine($"GridId: {LastTile.Grid}, Tile: {LastTile.Indices}");
for (var i = 0; i < message.Entities.Count; i++)
{
var uid = message.Entities[i];
if (!EntityManager.TryGetEntity(uid, out var entity)) continue;
text.AppendLine(entity.ToString());
}
_label.Text = text.ToString();
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
if (!Enabled) return;
var mousePos = _inputManager.MouseScreenPosition;
var worldPos = _eyeManager.ScreenToMap(mousePos);
GridId gridId;
Vector2i tile;
if (_mapManager.TryFindGridAt(worldPos, out var grid))
{
gridId = grid.Index;
tile = grid.WorldToTile(worldPos.Position);
}
else
{
gridId = GridId.Invalid;
tile = new Vector2i((int) MathF.Floor(worldPos.Position.X), (int) MathF.Floor(worldPos.Position.Y));
}
LayoutContainer.SetPosition(_label, mousePos.Position);
if ((gridId, tile).Equals(LastTile)) return;
_label.Text = null;
LastTile = (gridId, tile);
RequestEntities(gridId, tile);
}
}
internal sealed class RequestTileEntities : IConsoleCommand
{
public string Command => "tilelookup";
public string Description => "Used for debugging GridTileLookupSystem";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
EntitySystem.Get<DebugGridTileLookupSystem>().Enabled ^= true;
}
}
}
#endif

View File

@@ -23,7 +23,6 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IOverlayManager overlayManager = default!;
[Dependency] private readonly IPrototypeManager prototypeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly List<Effect> _Effects = new();
@@ -35,7 +34,7 @@ namespace Robust.Client.GameObjects
SubscribeNetworkEvent<EffectSystemMessage>(CreateEffect);
SubscribeLocalEvent<EffectSystemMessage>(CreateEffect);
var overlay = new EffectOverlay(this, prototypeManager, _mapManager, _playerManager, _entityManager);
var overlay = new EffectOverlay(this, prototypeManager, _playerManager, EntityManager);
overlayManager.AddOverlay(overlay);
}
@@ -65,13 +64,8 @@ namespace Robust.Client.GameObjects
}
//Create effect from creation message
var effect = new Effect(message, resourceCache, _mapManager, _entityManager);
var effect = new Effect(message, resourceCache, _mapManager, EntityManager);
effect.Deathtime = gameTiming.CurTime + message.LifeTime;
if (effect.AttachedEntityUid != null
&& _entityManager.TryGetEntity(effect.AttachedEntityUid.Value, out var attachedEntity))
{
effect.AttachedEntity = attachedEntity;
}
_Effects.Add(effect);
}
@@ -119,8 +113,6 @@ namespace Robust.Client.GameObjects
/// <summary>
/// Entity that the effect is attached to
/// </summary>
public IEntity? AttachedEntity { get; set; }
public EntityUid? AttachedEntityUid { get; }
/// <summary>
@@ -335,14 +327,12 @@ namespace Robust.Client.GameObjects
private readonly ShaderInstance _unshadedShader;
private readonly EffectSystem _owner;
private readonly IMapManager _mapManager;
private readonly IEntityManager _entityManager;
public EffectOverlay(EffectSystem owner, IPrototypeManager protoMan, IMapManager mapMan, IPlayerManager playerMan, IEntityManager entityManager)
public EffectOverlay(EffectSystem owner, IPrototypeManager protoMan, IPlayerManager playerMan, IEntityManager entityManager)
{
_owner = owner;
_unshadedShader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
_mapManager = mapMan;
_playerManager = playerMan;
_entityManager = entityManager;
}
@@ -353,12 +343,21 @@ namespace Robust.Client.GameObjects
var worldHandle = args.WorldHandle;
ShaderInstance? currentShader = null;
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (_playerManager.LocalPlayer?.ControlledEntity is not {} playerEnt)
return;
var playerXform = _entityManager.GetComponent<TransformComponent>(playerEnt);
foreach (var effect in _owner._Effects)
{
if (effect.AttachedEntity?.Transform.MapID != player?.Transform.MapID &&
effect.Coordinates.GetMapId(_entityManager) != map)
TransformComponent? attachedXform = null;
if ((effect.AttachedEntityUid is {} attached &&
_entityManager.TryGetComponent(attached, out attachedXform) &&
attachedXform.MapID != playerXform.MapID) ||
(effect.AttachedEntityUid == null &&
effect.Coordinates.GetMapId(_entityManager) != map))
{
continue;
}
@@ -371,13 +370,20 @@ namespace Robust.Client.GameObjects
currentShader = newShader;
}
// TODO: Should be doing matrix transformations
var effectSprite = effect.EffectSprite;
var effectOrigin = effect.AttachedEntity?.Transform.MapPosition.Position + effect.AttachedOffset ??
effect.Coordinates.ToMapPos(_entityManager);
var coordinates =
(attachedXform?.Coordinates ?? effect.Coordinates)
.Offset(effect.AttachedOffset);
// ???
var rotation = attachedXform?.WorldRotation ?? _entityManager.GetComponent<TransformComponent>(coordinates.EntityId).WorldRotation;
var effectOrigin = coordinates.ToMapPos(_entityManager);
var effectArea = Box2.CenteredAround(effectOrigin, effect.Size);
var rotatedBox = new Box2Rotated(effectArea, effect.Rotation, effectOrigin);
var rotatedBox = new Box2Rotated(effectArea, effect.Rotation + rotation, effectOrigin);
worldHandle.DrawTextureRect(effectSprite, rotatedBox, ToColor(effect.Color));
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.Physics;
@@ -7,6 +7,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
@@ -19,26 +20,8 @@ namespace Robust.Client.GameObjects
/// Updates the position of every Eye every frame, so that the camera follows the player around.
/// </summary>
[UsedImplicitly]
internal class EyeUpdateSystem : EntitySystem
public class EyeUpdateSystem : EntitySystem
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private TransformComponent? _lastParent;
private TransformComponent? _lerpTo;
private Angle LerpStartRotation;
private float _accumulator;
public bool IsLerping { get => _lerpTo != null; }
// How fast the camera rotates in radians / s
private const float CameraRotateSpeed = MathF.PI;
// PER THIS AMOUNT OF TIME MILLISECONDS
private const float CameraRotateTimeUnit = 1.2f;
// Safety override
private const float _lerpTimeMax = CameraRotateTimeUnit + 0.4f;
/// <inheritdoc />
public override void Initialize()
{
@@ -66,69 +49,6 @@ namespace Robust.Client.GameObjects
/// <inheritdoc />
public override void FrameUpdate(float frameTime)
{
var currentEye = _eyeManager.CurrentEye;
// TODO: Content should have its own way of handling this. We should have a default behavior that they can overwrite.
var playerTransform = _playerManager.LocalPlayer?.ControlledEntity?.Transform;
if (playerTransform == null) return;
var gridId = playerTransform.GridID;
var parent = gridId != GridId.Invalid && EntityManager.TryGetEntity(_mapManager.GetGrid(gridId).GridEntityId, out var gridEnt) ?
gridEnt.Transform
: _mapManager.GetMapEntity(playerTransform.MapID).Transform;
// Make sure that we don't fire the vomit carousel when we spawn in
if (_lastParent is null)
_lastParent = parent;
// Set a default for target rotation
var parentRotation = -parent.WorldRotation;
// Reuse current rotation when stepping into space
if (parent.GridID == GridId.Invalid)
parentRotation = currentEye.Rotation;
// Handle grid change in general
if (_lastParent != parent)
_lerpTo = parent;
// And we are up and running!
if (_lerpTo is not null)
{
// Handle a case where we have beeing spinning around, but suddenly got off onto a different grid
if (parent != _lerpTo) {
LerpStartRotation = currentEye.Rotation;
_lerpTo = parent;
_accumulator = 0f;
}
_accumulator += frameTime;
var changeNeeded = (float) (LerpStartRotation - parentRotation).Theta;
var changeLerp = _accumulator / (Math.Abs(changeNeeded % MathF.PI) / CameraRotateSpeed * CameraRotateTimeUnit);
currentEye.Rotation = Angle.Lerp(LerpStartRotation, parentRotation, changeLerp);
// Either we have overshot, or we have taken way too long on this, emergency reset time
if (changeLerp > 1.0f || _accumulator >= _lerpTimeMax)
{
_lastParent = parent;
_lerpTo = null;
_accumulator = 0f;
}
}
// We are just fine, or we finished a lerp (and probably overshot)
if (_lerpTo is null)
{
currentEye.Rotation = parentRotation;
LerpStartRotation = parentRotation;
}
foreach (var eyeComponent in EntityManager.EntityQuery<EyeComponent>(true))
{
eyeComponent.UpdateEyePosition();

View File

@@ -4,12 +4,18 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Utility;
namespace Robust.Client.GameObjects
{
public class GridChunkBoundsDebugSystem : EntitySystem
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
private GridChunkBoundsOverlay? _overlay;
public bool Enabled
@@ -25,15 +31,15 @@ namespace Robust.Client.GameObjects
{
DebugTools.Assert(_overlay == null);
_overlay = new GridChunkBoundsOverlay(
IoCManager.Resolve<IEntityManager>(),
IoCManager.Resolve<IEyeManager>(),
IoCManager.Resolve<IMapManager>());
EntityManager,
_eyeManager,
_mapManager);
IoCManager.Resolve<IOverlayManager>().AddOverlay(_overlay);
_overlayManager.AddOverlay(_overlay);
}
else
{
IoCManager.Resolve<IOverlayManager>().RemoveOverlay(_overlay!);
_overlayManager.RemoveOverlay(_overlay!);
_overlay = null;
}
}
@@ -60,24 +66,39 @@ namespace Robust.Client.GameObjects
protected internal override void Draw(in OverlayDrawArgs args)
{
var currentMap = _eyeManager.CurrentMap;
var viewport = _eyeManager.GetWorldViewport();
var viewport = args.WorldBounds;
var worldHandle = args.WorldHandle;
foreach (var grid in _mapManager.FindGridsIntersecting(currentMap, viewport))
{
var gridEnt = _entityManager.GetEntity(grid.GridEntityId);
var gridInternal = (IMapGridInternal)grid;
var worldMatrix = _entityManager.GetComponent<TransformComponent>(grid.GridEntityId).WorldMatrix;
worldHandle.SetTransform(worldMatrix);
var transform = new Transform(Vector2.Zero, Angle.Zero);
if (!_entityManager.TryGetComponent<PhysicsComponent>(gridEnt.Uid, out var body)) continue;
gridInternal.GetMapChunks(viewport, out var chunkEnumerator);
var transform = body.GetTransform();
foreach (var fixture in body.Fixtures)
while (chunkEnumerator.MoveNext(out var chunk))
{
for (var i = 0; i < fixture.Shape.ChildCount; i++)
foreach (var fixture in chunk.Fixtures)
{
var aabb = fixture.Shape.ComputeAABB(transform, i);
var poly = (PolygonShape) fixture.Shape;
args.WorldHandle.DrawRect(aabb, Color.Green.WithAlpha(0.2f));
args.WorldHandle.DrawRect(aabb, Color.Red.WithAlpha(0.5f), false);
var verts = new Vector2[poly.Vertices.Length];
for (var i = 0; i < poly.Vertices.Length; i++)
{
verts[i] = Transform.Mul(transform, poly.Vertices[i]);
}
worldHandle.DrawPrimitives(DrawPrimitiveTopology.TriangleFan, verts, Color.Green.WithAlpha(0.2f));
for (var i = 0; i < fixture.Shape.ChildCount; i++)
{
var aabb = fixture.Shape.ComputeAABB(transform, i);
args.WorldHandle.DrawRect(aabb, Color.Red.WithAlpha(0.5f), false);
}
}
}
}

View File

@@ -1,7 +1,9 @@
using System;
using System;
using Robust.Client.GameStates;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.IoC;
@@ -62,6 +64,9 @@ namespace Robust.Client.GameObjects
// handle local binds before sending off
foreach (var handler in BindRegistry.GetHandlers(function))
{
if (!_stateManager.IsPredictionEnabled && !handler.FireOutsidePrediction)
continue;
// local handlers can block sending over the network.
if (handler.HandleCmdMessage(session, message))
{
@@ -107,7 +112,7 @@ namespace Robust.Client.GameObjects
private void OnAttachedEntityChanged(PlayerAttachSysMessage message)
{
if (message.AttachedEntity != null) // attach
if (message.AttachedEntity != default) // attach
{
SetEntityContextActive(_inputManager, message.AttachedEntity);
}
@@ -117,14 +122,14 @@ namespace Robust.Client.GameObjects
}
}
private static void SetEntityContextActive(IInputManager inputMan, IEntity entity)
private void SetEntityContextActive(IInputManager inputMan, EntityUid entity)
{
if(entity == null || !entity.IsValid())
if(entity == default || !EntityManager.EntityExists(entity))
throw new ArgumentNullException(nameof(entity));
if (!entity.TryGetComponent(out InputComponent? inputComp))
if (!EntityManager.TryGetComponent(entity, out InputComponent? inputComp))
{
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity.Uid}, entProto={entity.Prototype}. Setting default \"{InputContextContainer.DefaultContextName}\" context...");
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity}, entProto={EntityManager.GetComponent<MetaDataComponent>(entity).EntityPrototype}. Setting default \"{InputContextContainer.DefaultContextName}\" context...");
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
return;
}
@@ -135,7 +140,7 @@ namespace Robust.Client.GameObjects
}
else
{
Logger.ErrorS("input.context", $"Unknown context: entId={entity.Uid}, entProto={entity.Prototype}, context={inputComp.ContextName}. . Setting default \"{InputContextContainer.DefaultContextName}\" context...");
Logger.ErrorS("input.context", $"Unknown context: entId={entity}, entProto={EntityManager.GetComponent<MetaDataComponent>(entity).EntityPrototype}, context={inputComp.ContextName}. . Setting default \"{InputContextContainer.DefaultContextName}\" context...");
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
}
}
@@ -145,12 +150,13 @@ namespace Robust.Client.GameObjects
/// </summary>
public void SetEntityContextActive()
{
if (_playerManager.LocalPlayer?.ControlledEntity == null)
var controlled = _playerManager.LocalPlayer?.ControlledEntity ?? EntityUid.Invalid;
if (controlled == EntityUid.Invalid)
{
return;
}
SetEntityContextActive(_inputManager, _playerManager.LocalPlayer.ControlledEntity);
SetEntityContextActive(_inputManager, controlled);
}
}
@@ -162,13 +168,13 @@ namespace Robust.Client.GameObjects
/// <summary>
/// New entity the player is attached to.
/// </summary>
public IEntity? AttachedEntity { get; }
public EntityUid AttachedEntity { get; }
/// <summary>
/// Creates a new instance of <see cref="PlayerAttachSysMessage"/>.
/// </summary>
/// <param name="attachedEntity">New entity the player is attached to.</param>
public PlayerAttachSysMessage(IEntity? attachedEntity)
public PlayerAttachSysMessage(EntityUid attachedEntity)
{
AttachedEntity = attachedEntity;
}
@@ -176,21 +182,21 @@ namespace Robust.Client.GameObjects
public class PlayerAttachedEvent : EntityEventArgs
{
public PlayerAttachedEvent(IEntity entity)
public PlayerAttachedEvent(EntityUid entity)
{
Entity = entity;
}
public IEntity Entity { get; }
public EntityUid Entity { get; }
}
public class PlayerDetachedEvent : EntityEventArgs
{
public PlayerDetachedEvent(IEntity entity)
public PlayerDetachedEvent(EntityUid entity)
{
Entity = entity;
}
public IEntity Entity { get; }
public EntityUid Entity { get; }
}
}

View File

@@ -8,6 +8,7 @@ namespace Robust.Client.GameObjects
public sealed class PointLightSystem : SharedPointLightSystem
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly RenderingTreeSystem _renderingTreeSystem = default!;
public override void Initialize()
{
@@ -19,17 +20,14 @@ namespace Robust.Client.GameObjects
private void HandleInit(EntityUid uid, PointLightComponent component, ComponentInit args)
{
UpdateMask(component);
RaiseLocalEvent(uid, new PointLightUpdateEvent());
}
private void HandleRemove(EntityUid uid, PointLightComponent component, ComponentRemove args)
{
var ent = EntityManager.GetEntity(uid);
var map = ent.Transform.MapID;
// TODO: Just make this update the tree directly and not allocate
if (map != MapId.Nullspace)
if (Transform(uid).MapID != MapId.Nullspace)
{
EntityManager.EventBus.RaiseEvent(EventSource.Local,
new RenderTreeRemoveLightEvent(component, map));
_renderingTreeSystem.ClearLight(component);
}
}

View File

@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using JetBrains.Annotations;
using Robust.Client.Physics;
using Robust.Shared;
@@ -11,7 +9,6 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Utility;
namespace Robust.Client.GameObjects
{
@@ -30,7 +27,7 @@ namespace Robust.Client.GameObjects
private readonly List<SpriteComponent> _spriteQueue = new();
private readonly List<PointLightComponent> _lightQueue = new();
private HashSet<EntityUid> _checkedChildren = new();
private readonly HashSet<EntityUid> _checkedChildren = new();
/// <summary>
/// <see cref="CVars.MaxLightRadius"/>
@@ -43,10 +40,12 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
{
yield return EntityManager.GetEntity(grid.GridEntityId).GetComponent<RenderingTreeComponent>();
var tempQualifier = grid.GridEntityId;
yield return EntityManager.GetComponent<RenderingTreeComponent>(tempQualifier);
}
yield return _mapManager.GetMapEntity(mapId).GetComponent<RenderingTreeComponent>();
var tempQualifier1 = _mapManager.GetMapEntityId(mapId);
yield return EntityManager.GetComponent<RenderingTreeComponent>(tempQualifier1);
}
internal IEnumerable<RenderingTreeComponent> GetRenderTrees(MapId mapId, Box2 worldAABB)
@@ -55,10 +54,12 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
{
yield return EntityManager.GetEntity(grid.GridEntityId).GetComponent<RenderingTreeComponent>();
var tempQualifier = grid.GridEntityId;
yield return EntityManager.GetComponent<RenderingTreeComponent>(tempQualifier);
}
yield return _mapManager.GetMapEntity(mapId).GetComponent<RenderingTreeComponent>();
var tempQualifier1 = _mapManager.GetMapEntityId(mapId);
yield return EntityManager.GetComponent<RenderingTreeComponent>(tempQualifier1);
}
public override void Initialize()
@@ -83,15 +84,21 @@ namespace Robust.Client.GameObjects
SubscribeLocalEvent<PointLightComponent, EntMapIdChangedMessage>(LightMapChanged);
SubscribeLocalEvent<PointLightComponent, EntParentChangedMessage>(LightParentChanged);
SubscribeLocalEvent<PointLightComponent, PointLightRadiusChangedEvent>(PointLightRadiusChanged);
SubscribeLocalEvent<PointLightComponent, RenderTreeRemoveLightEvent>(RemoveLight);
SubscribeLocalEvent<PointLightComponent, PointLightUpdateEvent>(HandleLightUpdate);
SubscribeLocalEvent<RenderingTreeComponent, ComponentRemove>(HandleTreeRemove);
SubscribeLocalEvent<RenderingTreeComponent, ComponentInit>(OnTreeInit);
SubscribeLocalEvent<RenderingTreeComponent, ComponentRemove>(OnTreeRemove);
var configManager = IoCManager.Resolve<IConfigurationManager>();
configManager.OnValueChanged(CVars.MaxLightRadius, value => MaxLightRadius = value, true);
}
private void OnTreeInit(EntityUid uid, RenderingTreeComponent component, ComponentInit args)
{
component.LightTree = new DynamicTree<PointLightComponent>(LightAabbFunc);
component.SpriteTree = new DynamicTree<SpriteComponent>(SpriteAabbFunc);
}
private void HandleLightUpdate(EntityUid uid, PointLightComponent component, PointLightUpdateEvent args)
{
if (component.TreeUpdateQueued) return;
@@ -106,26 +113,27 @@ namespace Robust.Client.GameObjects
private void AnythingMoved(ref MoveEvent args)
{
AnythingMovedSubHandler(args.Sender.Transform);
AnythingMovedSubHandler(args.Sender);
}
private void AnythingMovedSubHandler(TransformComponent sender)
private void AnythingMovedSubHandler(EntityUid uid, TransformComponent? xform = null)
{
// To avoid doing redundant updates (and we don't need to update a grid's children ever)
if (!_checkedChildren.Add(sender.Owner.Uid) ||
sender.Owner.HasComponent<RenderingTreeComponent>()) return;
if (!_checkedChildren.Add(uid) || EntityManager.HasComponent<RenderingTreeComponent>(uid)) return;
// This recursive search is needed, as MoveEvent is defined to not care about indirect events like children.
// WHATEVER YOU DO, DON'T REPLACE THIS WITH SPAMMING EVENTS UNLESS YOU HAVE A GUARANTEE IT WON'T LAG THE GC.
// (Struct-based events ok though)
// Ironically this was lagging the GC lolz
if (sender.Owner.TryGetComponent(out SpriteComponent? sprite))
if (EntityManager.TryGetComponent(uid, out SpriteComponent? sprite))
QueueSpriteUpdate(sprite);
if (sender.Owner.TryGetComponent(out PointLightComponent? light))
if (EntityManager.TryGetComponent(uid, out PointLightComponent? light))
QueueLightUpdate(light);
foreach (TransformComponent child in sender.Children)
if (!Resolve(uid, ref xform)) return;
foreach (var child in xform.ChildEntities)
{
AnythingMovedSubHandler(child);
}
@@ -185,12 +193,7 @@ namespace Robust.Client.GameObjects
QueueLightUpdate(component);
}
private void RemoveLight(EntityUid uid, PointLightComponent component, RenderTreeRemoveLightEvent args)
{
ClearLight(component);
}
private void ClearLight(PointLightComponent component)
public void ClearLight(PointLightComponent component)
{
if (component.RenderTree == null) return;
@@ -214,7 +217,7 @@ namespace Robust.Client.GameObjects
_mapManager.OnGridCreated -= MapManagerOnGridCreated;
}
private void HandleTreeRemove(EntityUid uid, RenderingTreeComponent component, ComponentRemove args)
private void OnTreeRemove(EntityUid uid, RenderingTreeComponent component, ComponentRemove args)
{
foreach (var sprite in component.SpriteTree)
{
@@ -237,27 +240,31 @@ namespace Robust.Client.GameObjects
return;
}
_mapManager.GetMapEntity(e.Map).EnsureComponent<RenderingTreeComponent>();
EntityManager.EnsureComponent<RenderingTreeComponent>(_mapManager.GetMapEntityId(e.Map));
}
private void MapManagerOnGridCreated(MapId mapId, GridId gridId)
{
EntityManager.GetEntity(_mapManager.GetGrid(gridId).GridEntityId).EnsureComponent<RenderingTreeComponent>();
EntityManager.EnsureComponent<RenderingTreeComponent>(_mapManager.GetGrid(gridId).GridEntityId);
}
internal static RenderingTreeComponent? GetRenderTree(IEntity entity)
// TODO: Pass in TransformComponent directly: mainly interested in getting this shit working atm.
private RenderingTreeComponent? GetRenderTree(EntityUid entity)
{
if (entity.Transform.MapID == MapId.Nullspace ||
entity.HasComponent<RenderingTreeComponent>()) return null;
if (!EntityManager.EntityExists(entity) ||
!EntityManager.TryGetComponent(entity, out TransformComponent? xform) ||
xform.MapID == MapId.Nullspace ||
EntityManager.HasComponent<RenderingTreeComponent>(entity)) return null;
var parent = entity.Transform.Parent?.Owner;
var parent = xform.ParentUid;
while (true)
{
if (parent == null) break;
if (!parent.IsValid())
break;
if (parent.TryGetComponent(out RenderingTreeComponent? comp)) return comp;
parent = parent.Transform.Parent?.Owner;
if (EntityManager.TryGetComponent(parent, out RenderingTreeComponent? comp)) return comp;
parent = EntityManager.GetComponent<TransformComponent>(parent).ParentUid;
}
return null;
@@ -265,7 +272,7 @@ namespace Robust.Client.GameObjects
private bool IsVisible(SpriteComponent component)
{
return component.Visible && !component.ContainerOccluded;
return component.Visible && !component.ContainerOccluded && !component.Deleted;
}
public override void FrameUpdate(float frameTime)
@@ -284,7 +291,8 @@ namespace Robust.Client.GameObjects
var oldMapTree = sprite.RenderTree;
var newMapTree = GetRenderTree(sprite.Owner);
// TODO: Temp PVS guard
var worldPos = sprite.Owner.Transform.WorldPosition;
var xform = EntityManager.GetComponent<TransformComponent>(sprite.Owner);
var (worldPos, worldRot) = xform.GetWorldPositionRotation();
if (float.IsNaN(worldPos.X) || float.IsNaN(worldPos.Y))
{
@@ -292,7 +300,7 @@ namespace Robust.Client.GameObjects
continue;
}
var aabb = RenderingTreeComponent.SpriteAabbFunc(sprite, worldPos);
var aabb = SpriteAabbFunc(sprite, worldPos, worldRot);
// If we're on a new map then clear the old one.
if (oldMapTree != newMapTree)
@@ -312,7 +320,7 @@ namespace Robust.Client.GameObjects
{
light.TreeUpdateQueued = false;
if (!light.Enabled || light.ContainerOccluded)
if (light.Deleted || !light.Enabled || light.ContainerOccluded)
{
ClearLight(light);
continue;
@@ -321,7 +329,7 @@ namespace Robust.Client.GameObjects
var oldMapTree = light.RenderTree;
var newMapTree = GetRenderTree(light.Owner);
// TODO: Temp PVS guard
var worldPos = light.Owner.Transform.WorldPosition;
var worldPos = EntityManager.GetComponent<TransformComponent>(light.Owner).WorldPosition;
if (float.IsNaN(worldPos.X) || float.IsNaN(worldPos.Y))
{
@@ -336,7 +344,7 @@ namespace Robust.Client.GameObjects
Logger.WarningS(LoggerSawmill, $"Light radius for {light.Owner} set above max radius of {MaxLightRadius}. This may lead to pop-in.");
}
var aabb = RenderingTreeComponent.LightAabbFunc(light, worldPos);
var aabb = LightAabbFunc(light, worldPos);
// If we're on a new map then clear the old one.
if (oldMapTree != newMapTree)
@@ -355,17 +363,73 @@ namespace Robust.Client.GameObjects
_spriteQueue.Clear();
_lightQueue.Clear();
}
}
internal class RenderTreeRemoveLightEvent : EntityEventArgs
{
public RenderTreeRemoveLightEvent(PointLightComponent light, MapId map)
private Box2 SpriteAabbFunc(in SpriteComponent value)
{
Light = light;
Map = map;
var xform = EntityManager.GetComponent<TransformComponent>(value.Owner);
var (worldPos, worldRot) = xform.GetWorldPositionRotation();
var bounds = new Box2Rotated(value.CalculateBoundingBox(worldPos), worldRot, worldPos);
var tree = GetRenderTree(value.Owner);
if (tree == null)
{
return bounds.CalcBoundingBox();
}
else
{
return EntityManager.GetComponent<TransformComponent>(tree.Owner).InvWorldMatrix.TransformBox(bounds);
}
}
public PointLightComponent Light { get; }
public MapId Map { get; }
private Box2 LightAabbFunc(in PointLightComponent value)
{
var worldPos = EntityManager.GetComponent<TransformComponent>(value.Owner).WorldPosition;
var tree = GetRenderTree(value.Owner);
var boxSize = value.Radius * 2;
Vector2 localPos;
if (tree == null)
{
localPos = worldPos;
}
else
{
// TODO: Need a way to just cache this InvWorldMatrix
localPos = EntityManager.GetComponent<TransformComponent>(tree.Owner).InvWorldMatrix.Transform(worldPos);
}
return Box2.CenteredAround(localPos, (boxSize, boxSize));
}
private Box2 SpriteAabbFunc(SpriteComponent value, Vector2 worldPos, Angle worldRot)
{
var bounds = new Box2Rotated(value.CalculateBoundingBox(worldPos), worldRot, worldPos);
var tree = GetRenderTree(value.Owner);
if (tree == null)
{
return bounds.CalcBoundingBox();
}
else
{
return EntityManager.GetComponent<TransformComponent>(tree.Owner).InvWorldMatrix.TransformBox(bounds);
}
}
private Box2 LightAabbFunc(PointLightComponent value, Vector2 worldPos)
{
// Lights are circles so don't need entity's rotation
var tree = GetRenderTree(value.Owner);
var boxSize = value.Radius * 2;
Vector2 localPos;
if (tree == null)
{
localPos = worldPos;
} else
{
localPos = EntityManager.GetComponent<TransformComponent>(tree.Owner).InvWorldMatrix.Transform(worldPos);
}
return Box2.CenteredAround(localPos, (boxSize, boxSize));
}
}
}

View File

@@ -55,7 +55,7 @@ namespace Robust.Client.GameObjects
foreach (var comp in _treeSystem.GetRenderTrees(currentMap, pvsBounds))
{
var bounds = comp.Owner.Transform.InvWorldMatrix.TransformBox(pvsBounds);
var bounds = EntityManager.GetComponent<TransformComponent>(comp.Owner).InvWorldMatrix.TransformBox(pvsBounds);
comp.SpriteTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) =>
{

View File

@@ -14,7 +14,7 @@ namespace Robust.Client.GameObjects
/// Handles interpolation of transform positions.
/// </summary>
[UsedImplicitly]
internal sealed class TransformSystem : SharedTransformSystem
public sealed class TransformSystem : SharedTransformSystem
{
// Max distance per tick how far an entity can move before it is considered teleporting.
// TODO: Make these values somehow dependent on server TPS.

View File

@@ -35,13 +35,13 @@ namespace Robust.Client.GameObjects
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !player.TryGetComponent(out PhysicsComponent? body))
if (player == null || !EntityManager.TryGetComponent(player.Value, out PhysicsComponent? body))
{
_label.Visible = false;
return;
}
var screenPos = _eyeManager.WorldToScreen(player.Transform.WorldPosition);
var screenPos = _eyeManager.WorldToScreen(EntityManager.GetComponent<TransformComponent>(player.Value).WorldPosition);
LayoutContainer.SetPosition(_label, screenPos + new Vector2(0, 50));
_label.Visible = true;

View File

@@ -6,10 +6,10 @@ namespace Robust.Client.GameObjects
{
// These methods are used by the Game State Manager.
IEntity CreateEntity(string? prototypeName, EntityUid? uid = null);
EntityUid CreateEntity(string? prototypeName, EntityUid uid = default);
void InitializeEntity(IEntity entity);
void InitializeEntity(EntityUid entity);
void StartEntity(IEntity entity);
void StartEntity(EntityUid entity);
}
}

View File

@@ -7,7 +7,6 @@ using System.Linq;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Input;
using Robust.Client.Map;
using Robust.Client.Player;
using Robust.Client.Timing;
using Robust.Shared;
@@ -18,6 +17,7 @@ using Robust.Shared.GameStates;
using Robust.Shared.Input;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
using Robust.Shared.Players;
@@ -39,6 +39,8 @@ namespace Robust.Client.GameStates
_pendingSystemMessages
= new();
private readonly Dictionary<EntityUid, MapId> _hiddenEntities = new();
private uint _metaCompNetId;
[Dependency] private readonly IComponentFactory _compFactory = default!;
@@ -47,7 +49,7 @@ namespace Robust.Client.GameStates
[Dependency] private readonly IPlayerManager _players = default!;
[Dependency] private readonly IClientNetManager _network = default!;
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IClientMapManager _mapManager = default!;
[Dependency] private readonly INetworkedMapManager _mapManager = default!;
[Dependency] private readonly IClientGameTiming _timing = default!;
[Dependency] private readonly INetConfigurationManager _config = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
@@ -57,6 +59,8 @@ namespace Robust.Client.GameStates
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
#endif
private ISawmill _sawmill = default!;
/// <inheritdoc />
public int MinBufferSize => _processor.MinBufferSize;
@@ -66,7 +70,7 @@ namespace Robust.Client.GameStates
/// <inheritdoc />
public int CurrentBufferSize => _processor.CalculateBufferSize(CurServerTick);
public bool Predicting { get; private set; }
public bool IsPredictionEnabled { get; private set; }
public int PredictTickBias { get; private set; }
public float PredictLagBias { get; private set; }
@@ -84,6 +88,7 @@ namespace Robust.Client.GameStates
/// <inheritdoc />
public void Initialize()
{
_sawmill = Logger.GetSawmill(CVars.NetPredict.Name);
_processor = new GameStateProcessor(_timing);
_network.RegisterNetMessage<MsgState>(HandleStateMessage);
@@ -93,7 +98,7 @@ namespace Robust.Client.GameStates
_config.OnValueChanged(CVars.NetInterp, b => _processor.Interpolation = b, true);
_config.OnValueChanged(CVars.NetInterpRatio, i => _processor.InterpRatio = i, true);
_config.OnValueChanged(CVars.NetLogging, b => _processor.Logging = b, true);
_config.OnValueChanged(CVars.NetPredict, b => Predicting = b, true);
_config.OnValueChanged(CVars.NetPredict, b => IsPredictionEnabled = b, true);
_config.OnValueChanged(CVars.NetPredictTickBias, i => PredictTickBias = i, true);
_config.OnValueChanged(CVars.NetPredictLagBias, i => PredictLagBias = i, true);
_config.OnValueChanged(CVars.NetStateBufMergeThreshold, i => StateBufferMergeThreshold = i, true);
@@ -101,7 +106,7 @@ namespace Robust.Client.GameStates
_processor.Interpolation = _config.GetCVar(CVars.NetInterp);
_processor.InterpRatio = _config.GetCVar(CVars.NetInterpRatio);
_processor.Logging = _config.GetCVar(CVars.NetLogging);
Predicting = _config.GetCVar(CVars.NetPredict);
IsPredictionEnabled = _config.GetCVar(CVars.NetPredict);
PredictTickBias = _config.GetCVar(CVars.NetPredictTickBias);
PredictLagBias = _config.GetCVar(CVars.NetPredictLagBias);
@@ -132,7 +137,7 @@ namespace Robust.Client.GameStates
public void InputCommandDispatched(FullInputCmdMessage message)
{
if (!Predicting)
if (!IsPredictionEnabled)
{
return;
}
@@ -140,16 +145,15 @@ namespace Robust.Client.GameStates
message.InputSequence = _nextInputCmdSeq;
_pendingInputs.Enqueue(message);
var inputMan = IoCManager.Resolve<IInputManager>();
inputMan.NetworkBindMap.TryGetKeyFunction(message.InputFunctionId, out var boundFunc);
Logger.DebugS(CVars.NetPredict.Name,
_inputManager.NetworkBindMap.TryGetKeyFunction(message.InputFunctionId, out var boundFunc);
_sawmill.Debug(
$"CL> SENT tick={_timing.CurTick}, sub={_timing.TickFraction}, seq={_nextInputCmdSeq}, func={boundFunc.FunctionName}, state={message.State}");
_nextInputCmdSeq++;
}
public uint SystemMessageDispatched<T>(T message) where T : EntityEventArgs
{
if (!Predicting)
if (!IsPredictionEnabled)
{
return default;
}
@@ -212,7 +216,7 @@ namespace Robust.Client.GameStates
// TODO: If Predicting gets disabled *while* the world state is dirty from a prediction,
// this won't run meaning it could potentially get stuck dirty.
if (Predicting && i == 0)
if (IsPredictionEnabled && i == 0)
{
// Disable IsFirstTimePredicted while re-running HandleComponentState here.
// Helps with debugging.
@@ -236,7 +240,7 @@ namespace Robust.Client.GameStates
if (_lastProcessedSeq < curState.LastProcessedInput)
{
Logger.DebugS(CVars.NetPredict.Name, $"SV> RCV tick={_timing.CurTick}, seq={_lastProcessedSeq}");
_sawmill.Debug($"SV> RCV tick={_timing.CurTick}, seq={_lastProcessedSeq}");
_lastProcessedSeq = curState.LastProcessedInput;
}
}
@@ -255,8 +259,7 @@ namespace Robust.Client.GameStates
var inCmd = _pendingInputs.Dequeue();
_inputManager.NetworkBindMap.TryGetKeyFunction(inCmd.InputFunctionId, out var boundFunc);
Logger.DebugS(CVars.NetPredict.Name,
$"SV> seq={inCmd.InputSequence}, func={boundFunc.FunctionName}, state={inCmd.State}");
_sawmill.Debug($"SV> seq={inCmd.InputSequence}, func={boundFunc.FunctionName}, state={inCmd.State}");
}
while (_pendingSystemMessages.Count > 0 && _pendingSystemMessages.Peek().sequence <= _lastProcessedSeq)
@@ -266,13 +269,13 @@ namespace Robust.Client.GameStates
DebugTools.Assert(_timing.InSimulation);
if (Predicting)
if (IsPredictionEnabled)
{
using var _ = _timing.StartPastPredictionArea();
if (_pendingInputs.Count > 0)
{
Logger.DebugS(CVars.NetPredict.Name, "CL> Predicted:");
_sawmill.Debug("CL> Predicted:");
}
var pendingInputEnumerator = _pendingInputs.GetEnumerator();
@@ -297,7 +300,7 @@ namespace Robust.Client.GameStates
_inputManager.NetworkBindMap.TryGetKeyFunction(inputCmd.InputFunctionId, out var boundFunc);
Logger.DebugS(CVars.NetPredict.Name,
_sawmill.Debug(
$" seq={inputCmd.InputSequence}, sub={inputCmd.SubTick}, dTick={tick}, func={boundFunc.FunctionName}, " +
$"state={inputCmd.State}");
@@ -322,37 +325,43 @@ namespace Robust.Client.GameStates
// Don't run EntitySystemManager.TickUpdate if this is the target tick,
// because the rest of the main loop will call into it with the target tick later,
// and it won't be a past prediction.
_entitySystemManager.TickUpdate((float) _timing.TickPeriod.TotalSeconds);
_entitySystemManager.TickUpdate((float) _timing.TickPeriod.TotalSeconds, noPredictions: false);
((IBroadcastEventBusInternal) _entities.EventBus).ProcessEventQueue();
}
}
}
_entities.TickUpdate((float) _timing.TickPeriod.TotalSeconds);
_entities.TickUpdate((float) _timing.TickPeriod.TotalSeconds, noPredictions: !IsPredictionEnabled);
_lookup.Update();
}
private void ResetPredictedEntities(GameTick curTick)
{
foreach (var entity in _entities.GetEntities())
foreach (var meta in _entityManager.EntityQuery<MetaDataComponent>(true))
{
var entity = meta.Owner;
// TODO: 99% there's an off-by-one here.
if (entity.Uid.IsClientSide() || entity.LastModifiedTick < curTick)
if (entity.IsClientSide() || meta.EntityLastModifiedTick < curTick)
{
continue;
}
Logger.DebugS(CVars.NetPredict.Name, $"Entity {entity.Uid} was made dirty.");
// Check log level first to avoid the string alloc.
if (_sawmill.Level <= LogLevel.Debug)
{
_sawmill.Debug($"Entity {entity} was made dirty.");
}
if (!_processor.TryGetLastServerStates(entity.Uid, out var last))
if (!_processor.TryGetLastServerStates(entity, out var last))
{
// Entity was probably deleted on the server so do nothing.
continue;
}
// TODO: handle component deletions/creations.
foreach (var (netId, comp) in _entityManager.GetNetComponents(entity.Uid))
foreach (var (netId, comp) in _entityManager.GetNetComponents(entity))
{
DebugTools.AssertNotNull(netId);
@@ -361,7 +370,7 @@ namespace Robust.Client.GameStates
continue;
}
Logger.DebugS(CVars.NetPredict.Name, $" And also its component {comp.Name}");
_sawmill.Debug($" And also its component {comp.GetType()}");
// TODO: Handle interpolation.
var handleState = new ComponentHandleState(compState, null);
_entities.EventBus.RaiseComponentEvent(comp, ref handleState);
@@ -379,7 +388,6 @@ namespace Robust.Client.GameStates
var outputData = new Dictionary<EntityUid, Dictionary<uint, ComponentState>>();
Debug.Assert(_players.LocalPlayer != null, "_players.LocalPlayer != null");
var player = _players.LocalPlayer.Session;
var bus = _entityManager.EventBus;
@@ -390,7 +398,7 @@ namespace Robust.Client.GameStates
foreach (var (netId, component) in _entityManager.GetNetComponents(createdEntity))
{
var state = _entityManager.GetComponentState(bus, component, player);
var state = _entityManager.GetComponentState(bus, component);
if(state.GetType() == typeof(ComponentState))
continue;
@@ -425,44 +433,47 @@ namespace Robust.Client.GameStates
private List<EntityUid> ApplyEntityStates(ReadOnlySpan<EntityState> curEntStates, ReadOnlySpan<EntityUid> deletions,
ReadOnlySpan<EntityState> nextEntStates)
{
var toApply = new Dictionary<IEntity, (EntityState?, EntityState?)>();
var toInitialize = new List<Entity>();
var toApply = new Dictionary<EntityUid, (EntityState?, EntityState?)>();
var toInitialize = new List<EntityUid>();
var created = new List<EntityUid>();
foreach (var es in curEntStates)
{
var uid = es.Uid;
//Known entities
if (_entities.TryGetEntity(es.Uid, out var entity))
if (_entities.EntityExists(uid))
{
// Logger.Debug($"[{IGameTiming.TickStampStatic}] MOD {es.Uid}");
toApply.Add(entity, (es, null));
toApply.Add(uid, (es, null));
}
else //Unknown entities
{
var metaState = (MetaDataComponentState?) es.ComponentChanges.Value?.FirstOrDefault(c => c.NetID == _metaCompNetId).State;
if (metaState == null)
{
throw new InvalidOperationException($"Server sent new entity state for {es.Uid} without metadata component!");
throw new InvalidOperationException($"Server sent new entity state for {uid} without metadata component!");
}
// Logger.Debug($"[{IGameTiming.TickStampStatic}] CREATE {es.Uid} {metaState.PrototypeId}");
var newEntity = (Entity)_entities.CreateEntity(metaState.PrototypeId, es.Uid);
var newEntity = _entities.CreateEntity(metaState.PrototypeId, uid);
toApply.Add(newEntity, (es, null));
toInitialize.Add(newEntity);
created.Add(newEntity.Uid);
created.Add(newEntity);
}
}
foreach (var es in nextEntStates)
{
if (_entities.TryGetEntity(es.Uid, out var entity))
var uid = es.Uid;
if (_entities.EntityExists(uid))
{
if (toApply.TryGetValue(entity, out var state))
if (toApply.TryGetValue(uid, out var state))
{
toApply[entity] = (state.Item1, es);
toApply[uid] = (state.Item1, es);
}
else
{
toApply[entity] = (null, es);
toApply[uid] = (null, es);
}
}
}
@@ -471,7 +482,7 @@ namespace Robust.Client.GameStates
foreach (var kvStates in toApply)
{
var ent = kvStates.Key;
var entity = (Entity) ent;
var entity = ent;
HandleEntityState(entity, _entities.EventBus, kvStates.Value.Item1,
kvStates.Value.Item2);
}
@@ -483,7 +494,7 @@ namespace Robust.Client.GameStates
}
#if EXCEPTION_TOLERANCE
HashSet<Entity> brokenEnts = new HashSet<Entity>();
HashSet<EntityUid> brokenEnts = new HashSet<EntityUid>();
#endif
foreach (var entity in toInitialize)
@@ -497,7 +508,7 @@ namespace Robust.Client.GameStates
}
catch (Exception e)
{
Logger.ErrorS("state", $"Server entity threw in Init: uid={entity.Uid}, proto={entity.Prototype}\n{e}");
Logger.ErrorS("state", $"Server entity threw in Init: ent={_entityManager.ToPrettyString(entity)}\n{e}");
brokenEnts.Add(entity);
}
#endif
@@ -517,34 +528,27 @@ namespace Robust.Client.GameStates
}
catch (Exception e)
{
Logger.ErrorS("state", $"Server entity threw in Start: uid={entity.Uid}, proto={entity.Prototype}\n{e}");
Logger.ErrorS("state", $"Server entity threw in Start: ent={_entityManager.ToPrettyString(entity)}\n{e}");
brokenEnts.Add(entity);
}
#endif
}
foreach (var entity in toInitialize)
{
#if EXCEPTION_TOLERANCE
if (brokenEnts.Contains(entity))
continue;
#endif
}
#if EXCEPTION_TOLERANCE
foreach (var entity in brokenEnts)
{
entity.Delete();
_entityManager.DeleteEntity(entity);
}
#endif
return created;
}
private void HandleEntityState(IEntity entity, IEventBus bus, EntityState? curState,
private void HandleEntityState(EntityUid entity, IEventBus bus, EntityState? curState,
EntityState? nextState)
{
var compStateWork = new Dictionary<ushort, (ComponentState? curState, ComponentState? nextState)>();
var entityUid = entity.Uid;
var entityUid = entity;
if (curState != null)
{
@@ -595,7 +599,7 @@ namespace Robust.Client.GameStates
foreach (var (netId, (cur, next)) in compStateWork)
{
if (_entityManager.TryGetComponent(entityUid, (ushort) netId, out var component))
if (_entityManager.TryGetComponent(entityUid, netId, out var component))
{
try
{
@@ -606,7 +610,7 @@ namespace Robust.Client.GameStates
catch (Exception e)
{
var wrapper = new ComponentStateApplyException(
$"Failed to apply comp state: entity={component.Owner}, comp={component.Name}", e);
$"Failed to apply comp state: entity={component.Owner}, comp={component.GetType()}", e);
#if EXCEPTION_TOLERANCE
_runtimeLog.LogException(wrapper, "Component state apply");
#else

View File

@@ -1,4 +1,5 @@
using System;
using Robust.Shared;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Timing;
@@ -44,6 +45,13 @@ namespace Robust.Client.GameStates
/// </summary>
int StateBufferMergeThreshold { get; }
/// <summary>
/// Whether prediction is currently enabled on the client entirely.
/// This is NOT equal to <see cref="IGameTiming.InPrediction"/> or <see cref="IGameTiming.IsFirstTimePredicted"/>.
/// </summary>
/// <remarks>This is effectively an alias of <see cref="CVars.NetPredict"/>.</remarks>
bool IsPredictionEnabled { get; }
/// <summary>
/// This is called after the game state has been applied for the current tick.
/// </summary>

View File

@@ -9,6 +9,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -109,7 +110,8 @@ namespace Robust.Client.GameStates
if(_entityManager.EntityExists(netEnt.Id))
{
//TODO: Whoever is working on PVS remake, change the InPVS detection.
var position = _entityManager.GetEntity(netEnt.Id).Transform.MapPosition;
var uid = netEnt.Id;
var position = _entityManager.GetComponent<TransformComponent>(uid).MapPosition;
netEnt.InPVS = !pvsEnabled || (pvsBox.Contains(position.Position) && position.MapId == pvsCenter.MapId);
_netEnts[i] = netEnt; // copy struct back
continue;
@@ -166,8 +168,9 @@ namespace Robust.Client.GameStates
for (int i = 0; i < _netEnts.Count; i++)
{
var netEnt = _netEnts[i];
var uid = netEnt.Id;
if (!_entityManager.TryGetEntity(netEnt.Id, out var ent))
if (!_entityManager.EntityExists(uid))
{
_netEnts.RemoveSwap(i);
i--;
@@ -176,7 +179,7 @@ namespace Robust.Client.GameStates
var xPos = 100;
var yPos = 10 + _lineHeight * i;
var name = $"({netEnt.Id}) {ent.Prototype?.ID}";
var name = $"({netEnt.Id}) {_entityManager.GetComponent<MetaDataComponent>(uid).EntityPrototype?.ID}";
var color = CalcTextColor(ref netEnt);
screenHandle.DrawString(_font, new Vector2(xPos + (TrafficHistorySize + 4), yPos), name, color);
DrawTrafficBox(screenHandle, ref netEnt, xPos, yPos);

View File

@@ -35,7 +35,7 @@ namespace Robust.Client.GameStates
foreach (var boundingBox in _entityManager.EntityQuery<IPhysBody>(true))
{
// all entities have a TransformComponent
var transform = boundingBox.Owner.Transform;
var transform = _entityManager.GetComponent<TransformComponent>(boundingBox.Owner);
// if not on the same map, continue
if (transform.MapID != _eyeManager.CurrentMap || boundingBox.Owner.IsInContainer())

View File

@@ -1,4 +1,4 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
@@ -31,5 +31,14 @@ namespace Robust.Client.Graphics
/// Our sub region within our source, in pixel coordinates.
/// </summary>
public UIBox2 SubRegion { get; }
public override Color GetPixel(int x, int y)
{
DebugTools.Assert(x < SubRegion.Right);
DebugTools.Assert(y < SubRegion.Top);
int xTranslated = x + (int) SubRegion.Left;
int yTranslated = y + (int) SubRegion.Top;
return this.SourceTexture[xTranslated, yTranslated];
}
}
}

View File

@@ -0,0 +1,59 @@
using System.Collections.Concurrent;
using OpenToolkit.Audio.OpenAL;
namespace Robust.Client.Graphics.Audio
{
internal partial class ClydeAudio
{
// Used to track audio sources that were disposed in the finalizer thread,
// so we need to properly send them off in the main thread.
private readonly ConcurrentQueue<(int sourceHandle, int filterHandle)> _sourceDisposeQueue = new();
private readonly ConcurrentQueue<(int sourceHandle, int filterHandle)> _bufferedSourceDisposeQueue = new();
private readonly ConcurrentQueue<int> _bufferDisposeQueue = new();
private void _flushALDisposeQueues()
{
// Clear out finalized audio sources.
while (_sourceDisposeQueue.TryDequeue(out var handles))
{
_openALSawmill.Debug("Cleaning out source {0} which finalized in another thread.", handles.sourceHandle);
if (IsEfxSupported) RemoveEfx(handles);
AL.DeleteSource(handles.sourceHandle);
_checkAlError();
_audioSources.Remove(handles.sourceHandle);
}
// Clear out finalized buffered audio sources.
while (_bufferedSourceDisposeQueue.TryDequeue(out var handles))
{
_openALSawmill.Debug("Cleaning out buffered source {0} which finalized in another thread.", handles.sourceHandle);
if (IsEfxSupported) RemoveEfx(handles);
AL.DeleteSource(handles.sourceHandle);
_checkAlError();
_bufferedAudioSources.Remove(handles.sourceHandle);
}
// Clear out finalized audio buffers.
while (_bufferDisposeQueue.TryDequeue(out var handle))
{
AL.DeleteBuffer(handle);
_checkAlError();
}
}
private void DeleteSourceOnMainThread(int sourceHandle, int filterHandle)
{
_sourceDisposeQueue.Enqueue((sourceHandle, filterHandle));
}
private void DeleteBufferedSourceOnMainThread(int bufferedSourceHandle, int filterHandle)
{
_bufferedSourceDisposeQueue.Enqueue((bufferedSourceHandle, filterHandle));
}
private void DeleteAudioBufferOnMainThread(int bufferHandle)
{
_bufferDisposeQueue.Enqueue(bufferHandle);
}
}
}

View File

@@ -10,436 +10,20 @@ using OpenToolkit.Audio.OpenAL.Extensions.Creative.EFX;
using OpenToolkit.Mathematics;
using Robust.Client.Audio;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Audio;
using Robust.Shared.Log;
using Vector2 = Robust.Shared.Maths.Vector2;
namespace Robust.Client.Graphics.Clyde
namespace Robust.Client.Graphics.Audio
{
internal partial class Clyde
internal partial class ClydeAudio
{
private ALDevice _openALDevice;
private ALContext _openALContext;
private readonly List<LoadedAudioSample> _audioSampleBuffers = new();
private readonly Dictionary<int, WeakReference<AudioSource>> _audioSources =
new();
private readonly Dictionary<int, WeakReference<BufferedAudioSource>> _bufferedAudioSources =
new();
private readonly HashSet<string> _alcDeviceExtensions = new();
private readonly HashSet<string> _alContextExtensions = new();
// Used to track audio sources that were disposed in the finalizer thread,
// so we need to properly send them off in the main thread.
private readonly ConcurrentQueue<(int sourceHandle, int filterHandle)> _sourceDisposeQueue = new();
private readonly ConcurrentQueue<(int sourceHandle, int filterHandle)> _bufferedSourceDisposeQueue = new();
private readonly ConcurrentQueue<int> _bufferDisposeQueue = new();
// The base gain value for a listener, used to boost the default volume.
private const float _baseGain = 2f;
public bool HasAlDeviceExtension(string extension) => _alcDeviceExtensions.Contains(extension);
public bool HasAlContextExtension(string extension) => _alContextExtensions.Contains(extension);
internal bool IsEfxSupported;
private ISawmill _openALSawmill = default!;
private void _initializeAudio()
{
_openALSawmill = Logger.GetSawmill("clyde.oal");
_audioOpenDevice();
// Create OpenAL context.
_audioCreateContext();
IsEfxSupported = HasAlDeviceExtension("ALC_EXT_EFX");
_cfg.OnValueChanged(CVars.AudioMasterVolume, SetMasterVolume, true);
_cfg.OnValueChanged(CVars.AudioAttenuation, SetAudioAttenuation, true);
}
private void _audioCreateContext()
{
unsafe
{
_openALContext = ALC.CreateContext(_openALDevice, (int*) 0);
}
ALC.MakeContextCurrent(_openALContext);
_checkAlcError(_openALDevice);
_checkAlError();
// Load up AL context extensions.
var s = ALC.GetString(ALDevice.Null, AlcGetString.Extensions) ?? "";
foreach (var extension in s.Split(' '))
{
_alContextExtensions.Add(extension);
}
_openALSawmill.Debug("OpenAL Vendor: {0}", AL.Get(ALGetString.Vendor));
_openALSawmill.Debug("OpenAL Renderer: {0}", AL.Get(ALGetString.Renderer));
_openALSawmill.Debug("OpenAL Version: {0}", AL.Get(ALGetString.Version));
}
private void _audioOpenDevice()
{
var preferredDevice = _cfg.GetCVar(CVars.AudioDevice);
// Open device.
if (!string.IsNullOrEmpty(preferredDevice))
{
_openALDevice = ALC.OpenDevice(preferredDevice);
if (_openALDevice == IntPtr.Zero)
{
_openALSawmill.Warning("Unable to open preferred audio device '{0}': {1}. Falling back default.",
preferredDevice, ALC.GetError(ALDevice.Null));
_openALDevice = ALC.OpenDevice(null);
}
}
else
{
_openALDevice = ALC.OpenDevice(null);
}
_checkAlcError(_openALDevice);
if (_openALDevice == IntPtr.Zero)
{
throw new InvalidOperationException($"Unable to open OpenAL device! {ALC.GetError(ALDevice.Null)}");
}
// Load up ALC extensions.
var s = ALC.GetString(_openALDevice, AlcGetString.Extensions) ?? "";
foreach (var extension in s.Split(' '))
{
_alcDeviceExtensions.Add(extension);
}
}
private void _shutdownAudio()
{
foreach (var source in _audioSources.Values.ToArray())
{
if (source.TryGetTarget(out var target))
{
target.Dispose();
}
}
foreach (var source in _bufferedAudioSources.Values.ToArray())
{
if (source.TryGetTarget(out var target))
{
target.Dispose();
}
}
if (_openALContext != ALContext.Null)
{
ALC.DestroyContext(_openALContext);
}
if (_openALDevice != IntPtr.Zero)
{
ALC.CloseDevice(_openALDevice);
}
}
private void _updateAudio()
{
var eye = _eyeManager.CurrentEye;
var (x, y) = eye.Position.Position;
AL.Listener(ALListener3f.Position, x, y, -5);
var rot2d = eye.Rotation.ToVec();
AL.Listener(ALListenerfv.Orientation, new []{0, 0, -1, rot2d.X, rot2d.Y, 0});
// Default orientation: at: (0, 0, -1) up: (0, 1, 0)
var (rotX, rotY) = eye.Rotation.ToVec();
var at = new Vector3(0f, 0f, -1f);
var up = new Vector3(rotY, rotX, 0f);
AL.Listener(ALListenerfv.Orientation, ref at, ref up);
// Clear out finalized audio sources.
while (_sourceDisposeQueue.TryDequeue(out var handles))
{
_openALSawmill.Debug("Cleaning out source {0} which finalized in another thread.", handles.sourceHandle);
if (IsEfxSupported) RemoveEfx(handles);
AL.DeleteSource(handles.sourceHandle);
_checkAlError();
_audioSources.Remove(handles.sourceHandle);
}
// Clear out finalized buffered audio sources.
while (_bufferedSourceDisposeQueue.TryDequeue(out var handles))
{
_openALSawmill.Debug("Cleaning out buffered source {0} which finalized in another thread.", handles.sourceHandle);
if (IsEfxSupported) RemoveEfx(handles);
AL.DeleteSource(handles.sourceHandle);
_checkAlError();
_bufferedAudioSources.Remove(handles.sourceHandle);
}
// Clear out finalized audio buffers.
while (_bufferDisposeQueue.TryDequeue(out var handle))
{
AL.DeleteBuffer((int) handle);
_checkAlError();
}
}
private static void RemoveEfx((int sourceHandle, int filterHandle) handles)
{
if (handles.filterHandle != 0) EFX.DeleteFilter(handles.filterHandle);
}
public void SetMasterVolume(float newVolume)
{
AL.Listener(ALListenerf.Gain, _baseGain * newVolume);
}
public void SetAudioAttenuation(int value)
{
var attenuation = (Attenuation) value;
switch (attenuation)
{
case Attenuation.NoAttenuation:
AL.DistanceModel(ALDistanceModel.None);
break;
case Attenuation.InverseDistance:
AL.DistanceModel(ALDistanceModel.InverseDistance);
break;
case Attenuation.Default:
case Attenuation.InverseDistanceClamped:
AL.DistanceModel(ALDistanceModel.InverseDistanceClamped);
break;
case Attenuation.LinearDistance:
AL.DistanceModel(ALDistanceModel.LinearDistance);
break;
case Attenuation.LinearDistanceClamped:
AL.DistanceModel(ALDistanceModel.LinearDistanceClamped);
break;
case Attenuation.ExponentDistance:
AL.DistanceModel(ALDistanceModel.ExponentDistance);
break;
case Attenuation.ExponentDistanceClamped:
AL.DistanceModel(ALDistanceModel.ExponentDistanceClamped);
break;
default:
throw new ArgumentOutOfRangeException($"No implementation to set {attenuation.ToString()} for DistanceModel!");
}
var attToString = attenuation == Attenuation.Default ? Attenuation.InverseDistanceClamped : attenuation;
_openALSawmill.Info($"Set audio attenuation to {attToString.ToString()}");
}
public IClydeAudioSource CreateAudioSource(AudioStream stream)
{
var source = AL.GenSource();
// ReSharper disable once PossibleInvalidOperationException
// TODO: This really shouldn't be indexing based on the ClydeHandle...
AL.Source(source, ALSourcei.Buffer, _audioSampleBuffers[(int) stream.ClydeHandle!.Value.Value].BufferHandle);
var audioSource = new AudioSource(this, source, stream);
_audioSources.Add(source, new WeakReference<AudioSource>(audioSource));
return audioSource;
}
public IClydeBufferedAudioSource CreateBufferedAudioSource(int buffers, bool floatAudio=false)
{
var source = AL.GenSource();
// ReSharper disable once PossibleInvalidOperationException
var audioSource = new BufferedAudioSource(this, source, AL.GenBuffers(buffers), floatAudio);
_bufferedAudioSources.Add(source, new WeakReference<BufferedAudioSource>(audioSource));
return audioSource;
}
private void _checkAlcError(ALDevice device,
[CallerMemberName] string callerMember = "",
[CallerLineNumber] int callerLineNumber = -1)
{
var error = ALC.GetError(device);
if (error != AlcError.NoError)
{
_openALSawmill.Error("[{0}:{1}] ALC error: {2}", callerMember, callerLineNumber, error);
}
}
private void _checkAlError([CallerMemberName] string callerMember = "",
[CallerLineNumber] int callerLineNumber = -1)
{
var error = AL.GetError();
if (error != ALError.NoError)
{
_openALSawmill.Error("[{0}:{1}] AL error: {2}", callerMember, callerLineNumber, error);
}
}
public AudioStream LoadAudioOggVorbis(Stream stream, string? name = null)
{
var vorbis = _readOggVorbis(stream);
var buffer = AL.GenBuffer();
ALFormat format;
// NVorbis only supports loading into floats.
// If this becomes a problem due to missing extension support (doubt it but ok),
// check the git history, I originally used libvorbisfile which worked and loaded 16 bit LPCM.
if (vorbis.Channels == 1)
{
format = ALFormat.MonoFloat32Ext;
}
else if (vorbis.Channels == 2)
{
format = ALFormat.StereoFloat32Ext;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
unsafe
{
fixed (float* ptr = vorbis.Data.Span)
{
AL.BufferData(buffer, format, (IntPtr) ptr, vorbis.Data.Length * sizeof(float),
(int) vorbis.SampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
var length = TimeSpan.FromSeconds(vorbis.TotalSamples / (double) vorbis.SampleRate);
return new AudioStream(handle, length, (int) vorbis.Channels, name);
}
public AudioStream LoadAudioWav(Stream stream, string? name = null)
{
var wav = _readWav(stream);
var buffer = AL.GenBuffer();
ALFormat format;
if (wav.BitsPerSample == 16)
{
if (wav.NumChannels == 1)
{
format = ALFormat.Mono16;
}
else if (wav.NumChannels == 2)
{
format = ALFormat.Stereo16;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
}
else if (wav.BitsPerSample == 8)
{
if (wav.NumChannels == 1)
{
format = ALFormat.Mono8;
}
else if (wav.NumChannels == 2)
{
format = ALFormat.Stereo8;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
}
else
{
throw new InvalidOperationException("Unable to load wav with bits per sample different from 8 or 16");
}
unsafe
{
fixed (byte* ptr = wav.Data.Span)
{
AL.BufferData(buffer, format, (IntPtr) ptr, wav.Data.Length, wav.SampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
var length = TimeSpan.FromSeconds(wav.Data.Length / (double) wav.BlockAlign / wav.SampleRate);
return new AudioStream(handle, length, wav.NumChannels, name);
}
public AudioStream LoadAudioRaw(ReadOnlySpan<short> samples, int channels, int sampleRate, string? name = null)
{
var fmt = channels switch
{
1 => ALFormat.Mono16,
2 => ALFormat.Stereo16,
_ => throw new ArgumentOutOfRangeException(
nameof(channels), "Only stereo and mono is currently supported")
};
var buffer = AL.GenBuffer();
_checkAlError();
unsafe
{
fixed (short* ptr = samples)
{
AL.BufferData(buffer, fmt, (IntPtr) ptr, samples.Length * sizeof(short), sampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
var length = TimeSpan.FromSeconds((double) samples.Length / channels / sampleRate);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
return new AudioStream(handle, length, channels, name);
}
private sealed class LoadedAudioSample
{
public readonly int BufferHandle;
public LoadedAudioSample(int bufferHandle)
{
BufferHandle = bufferHandle;
}
}
private void DeleteSourceOnMainThread(int sourceHandle, int filterHandle)
{
_sourceDisposeQueue.Enqueue((sourceHandle, filterHandle));
}
private void DeleteBufferedSourceOnMainThread(int bufferedSourceHandle, int filterHandle)
{
_bufferedSourceDisposeQueue.Enqueue((bufferedSourceHandle, filterHandle));
}
private void DeleteAudioBufferOnMainThread(int bufferHandle)
{
_bufferDisposeQueue.Enqueue(bufferHandle);
}
private sealed class AudioSource : IClydeAudioSource
{
private int SourceHandle;
private readonly Clyde _master;
private readonly ClydeAudio _master;
private readonly AudioStream _sourceStream;
private int FilterHandle;
#if DEBUG
@@ -450,7 +34,7 @@ namespace Robust.Client.Graphics.Clyde
private bool IsEfxSupported => _master.IsEfxSupported;
public AudioSource(Clyde master, int sourceHandle, AudioStream sourceStream)
public AudioSource(ClydeAudio master, int sourceHandle, AudioStream sourceStream)
{
_master = master;
SourceHandle = sourceHandle;
@@ -700,7 +284,7 @@ namespace Robust.Client.Graphics.Clyde
private int? SourceHandle = null;
private int[] BufferHandles;
private Dictionary<int, int> BufferMap = new();
private readonly Clyde _master;
private readonly ClydeAudio _master;
private bool _mono = true;
private bool _float = false;
private int FilterHandle;
@@ -711,7 +295,7 @@ namespace Robust.Client.Graphics.Clyde
private bool IsEfxSupported => _master.IsEfxSupported;
public BufferedAudioSource(Clyde master, int sourceHandle, int[] bufferHandles, bool floatAudio = false)
public BufferedAudioSource(ClydeAudio master, int sourceHandle, int[] bufferHandles, bool floatAudio = false)
{
_master = master;
SourceHandle = sourceHandle;

View File

@@ -1,9 +1,9 @@
using System;
using System.IO;
namespace Robust.Client.Graphics.Clyde
namespace Robust.Client.Graphics.Audio
{
internal partial class Clyde
internal partial class ClydeAudio
{
private OggVorbisData _readOggVorbis(Stream stream)
{

View File

@@ -3,9 +3,9 @@ using System.IO;
using JetBrains.Annotations;
using Robust.Shared.Utility;
namespace Robust.Client.Graphics.Clyde
namespace Robust.Client.Graphics.Audio
{
internal partial class Clyde
internal partial class ClydeAudio
{
/// <summary>
/// Load up a WAVE file.

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using OpenToolkit.Audio.OpenAL;
using OpenToolkit.Audio.OpenAL.Extensions.Creative.EFX;
using OpenToolkit.Mathematics;
using Robust.Client.Audio;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Audio;
using Robust.Shared.Log;
using Robust.Shared.Timing;
using Vector2 = Robust.Shared.Maths.Vector2;
namespace Robust.Client.Graphics.Audio
{
internal partial class ClydeAudio
{
[Robust.Shared.IoC.Dependency] private readonly IConfigurationManager _cfg = default!;
[Robust.Shared.IoC.Dependency] private readonly IEyeManager _eyeManager = default!;
private Thread? _gameThread;
public bool InitializePostWindowing()
{
_gameThread = Thread.CurrentThread;
return _initializeAudio();
}
public void FrameProcess(FrameEventArgs eventArgs)
{
_updateAudio();
}
public void Shutdown()
{
_shutdownAudio();
}
private bool IsMainThread()
{
return Thread.CurrentThread == _gameThread;
}
}
}

View File

@@ -0,0 +1,406 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using OpenToolkit.Audio.OpenAL;
using OpenToolkit.Audio.OpenAL.Extensions.Creative.EFX;
using OpenToolkit.Mathematics;
using Robust.Client.Audio;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Audio;
using Robust.Shared.Log;
using Vector2 = Robust.Shared.Maths.Vector2;
namespace Robust.Client.Graphics.Audio
{
internal partial class ClydeAudio : IClydeAudio, IClydeAudioInternal
{
private ALDevice _openALDevice;
private ALContext _openALContext;
private readonly List<LoadedAudioSample> _audioSampleBuffers = new();
private readonly Dictionary<int, WeakReference<AudioSource>> _audioSources =
new();
private readonly Dictionary<int, WeakReference<BufferedAudioSource>> _bufferedAudioSources =
new();
private readonly HashSet<string> _alcDeviceExtensions = new();
private readonly HashSet<string> _alContextExtensions = new();
// The base gain value for a listener, used to boost the default volume.
private const float _baseGain = 2f;
public bool HasAlDeviceExtension(string extension) => _alcDeviceExtensions.Contains(extension);
public bool HasAlContextExtension(string extension) => _alContextExtensions.Contains(extension);
internal bool IsEfxSupported;
private ISawmill _openALSawmill = default!;
private bool _initializeAudio()
{
_openALSawmill = Logger.GetSawmill("clyde.oal");
if (!_audioOpenDevice())
return false;
// Create OpenAL context.
_audioCreateContext();
IsEfxSupported = HasAlDeviceExtension("ALC_EXT_EFX");
_cfg.OnValueChanged(CVars.AudioMasterVolume, SetMasterVolume, true);
_cfg.OnValueChanged(CVars.AudioAttenuation, SetAudioAttenuation, true);
return true;
}
private void _audioCreateContext()
{
unsafe
{
_openALContext = ALC.CreateContext(_openALDevice, (int*) 0);
}
ALC.MakeContextCurrent(_openALContext);
_checkAlcError(_openALDevice);
_checkAlError();
// Load up AL context extensions.
var s = ALC.GetString(ALDevice.Null, AlcGetString.Extensions) ?? "";
foreach (var extension in s.Split(' '))
{
_alContextExtensions.Add(extension);
}
_openALSawmill.Debug("OpenAL Vendor: {0}", AL.Get(ALGetString.Vendor));
_openALSawmill.Debug("OpenAL Renderer: {0}", AL.Get(ALGetString.Renderer));
_openALSawmill.Debug("OpenAL Version: {0}", AL.Get(ALGetString.Version));
}
private bool _audioOpenDevice()
{
var preferredDevice = _cfg.GetCVar(CVars.AudioDevice);
// Open device.
if (!string.IsNullOrEmpty(preferredDevice))
{
_openALDevice = ALC.OpenDevice(preferredDevice);
if (_openALDevice == IntPtr.Zero)
{
_openALSawmill.Warning("Unable to open preferred audio device '{0}': {1}. Falling back default.",
preferredDevice, ALC.GetError(ALDevice.Null));
_openALDevice = ALC.OpenDevice(null);
}
}
else
{
_openALDevice = ALC.OpenDevice(null);
}
_checkAlcError(_openALDevice);
if (_openALDevice == IntPtr.Zero)
{
_openALSawmill.Error("Unable to open OpenAL device! {1}", ALC.GetError(ALDevice.Null));
return false;
}
// Load up ALC extensions.
var s = ALC.GetString(_openALDevice, AlcGetString.Extensions) ?? "";
foreach (var extension in s.Split(' '))
{
_alcDeviceExtensions.Add(extension);
}
return true;
}
private void _shutdownAudio()
{
foreach (var source in _audioSources.Values.ToArray())
{
if (source.TryGetTarget(out var target))
{
target.Dispose();
}
}
foreach (var source in _bufferedAudioSources.Values.ToArray())
{
if (source.TryGetTarget(out var target))
{
target.Dispose();
}
}
if (_openALContext != ALContext.Null)
{
ALC.DestroyContext(_openALContext);
}
if (_openALDevice != IntPtr.Zero)
{
ALC.CloseDevice(_openALDevice);
}
}
private void _updateAudio()
{
var eye = _eyeManager.CurrentEye;
var (x, y) = eye.Position.Position;
AL.Listener(ALListener3f.Position, x, y, -5);
var rot2d = eye.Rotation.ToVec();
AL.Listener(ALListenerfv.Orientation, new []{0, 0, -1, rot2d.X, rot2d.Y, 0});
// Default orientation: at: (0, 0, -1) up: (0, 1, 0)
var (rotX, rotY) = eye.Rotation.ToVec();
var at = new Vector3(0f, 0f, -1f);
var up = new Vector3(rotY, rotX, 0f);
AL.Listener(ALListenerfv.Orientation, ref at, ref up);
_flushALDisposeQueues();
}
private static void RemoveEfx((int sourceHandle, int filterHandle) handles)
{
if (handles.filterHandle != 0) EFX.DeleteFilter(handles.filterHandle);
}
public void SetMasterVolume(float newVolume)
{
AL.Listener(ALListenerf.Gain, _baseGain * newVolume);
}
public void SetAudioAttenuation(int value)
{
var attenuation = (Attenuation) value;
switch (attenuation)
{
case Attenuation.NoAttenuation:
AL.DistanceModel(ALDistanceModel.None);
break;
case Attenuation.InverseDistance:
AL.DistanceModel(ALDistanceModel.InverseDistance);
break;
case Attenuation.Default:
case Attenuation.InverseDistanceClamped:
AL.DistanceModel(ALDistanceModel.InverseDistanceClamped);
break;
case Attenuation.LinearDistance:
AL.DistanceModel(ALDistanceModel.LinearDistance);
break;
case Attenuation.LinearDistanceClamped:
AL.DistanceModel(ALDistanceModel.LinearDistanceClamped);
break;
case Attenuation.ExponentDistance:
AL.DistanceModel(ALDistanceModel.ExponentDistance);
break;
case Attenuation.ExponentDistanceClamped:
AL.DistanceModel(ALDistanceModel.ExponentDistanceClamped);
break;
default:
throw new ArgumentOutOfRangeException($"No implementation to set {attenuation.ToString()} for DistanceModel!");
}
var attToString = attenuation == Attenuation.Default ? Attenuation.InverseDistanceClamped : attenuation;
_openALSawmill.Info($"Set audio attenuation to {attToString.ToString()}");
}
public IClydeAudioSource? CreateAudioSource(AudioStream stream)
{
var source = AL.GenSource();
if (!AL.IsSource(source))
{
_openALSawmill.Error("Failed to generate source. Too many simultaneous audio streams?");
return null;
}
// ReSharper disable once PossibleInvalidOperationException
// TODO: This really shouldn't be indexing based on the ClydeHandle...
AL.Source(source, ALSourcei.Buffer, _audioSampleBuffers[(int) stream.ClydeHandle!.Value.Value].BufferHandle);
var audioSource = new AudioSource(this, source, stream);
_audioSources.Add(source, new WeakReference<AudioSource>(audioSource));
return audioSource;
}
public IClydeBufferedAudioSource CreateBufferedAudioSource(int buffers, bool floatAudio=false)
{
var source = AL.GenSource();
// ReSharper disable once PossibleInvalidOperationException
var audioSource = new BufferedAudioSource(this, source, AL.GenBuffers(buffers), floatAudio);
_bufferedAudioSources.Add(source, new WeakReference<BufferedAudioSource>(audioSource));
return audioSource;
}
private void _checkAlcError(ALDevice device,
[CallerMemberName] string callerMember = "",
[CallerLineNumber] int callerLineNumber = -1)
{
var error = ALC.GetError(device);
if (error != AlcError.NoError)
{
_openALSawmill.Error("[{0}:{1}] ALC error: {2}", callerMember, callerLineNumber, error);
}
}
private void _checkAlError([CallerMemberName] string callerMember = "",
[CallerLineNumber] int callerLineNumber = -1)
{
var error = AL.GetError();
if (error != ALError.NoError)
{
_openALSawmill.Error("[{0}:{1}] AL error: {2}", callerMember, callerLineNumber, error);
}
}
public AudioStream LoadAudioOggVorbis(Stream stream, string? name = null)
{
var vorbis = _readOggVorbis(stream);
var buffer = AL.GenBuffer();
ALFormat format;
// NVorbis only supports loading into floats.
// If this becomes a problem due to missing extension support (doubt it but ok),
// check the git history, I originally used libvorbisfile which worked and loaded 16 bit LPCM.
if (vorbis.Channels == 1)
{
format = ALFormat.MonoFloat32Ext;
}
else if (vorbis.Channels == 2)
{
format = ALFormat.StereoFloat32Ext;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
unsafe
{
fixed (float* ptr = vorbis.Data.Span)
{
AL.BufferData(buffer, format, (IntPtr) ptr, vorbis.Data.Length * sizeof(float),
(int) vorbis.SampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
var length = TimeSpan.FromSeconds(vorbis.TotalSamples / (double) vorbis.SampleRate);
return new AudioStream(handle, length, (int) vorbis.Channels, name);
}
public AudioStream LoadAudioWav(Stream stream, string? name = null)
{
var wav = _readWav(stream);
var buffer = AL.GenBuffer();
ALFormat format;
if (wav.BitsPerSample == 16)
{
if (wav.NumChannels == 1)
{
format = ALFormat.Mono16;
}
else if (wav.NumChannels == 2)
{
format = ALFormat.Stereo16;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
}
else if (wav.BitsPerSample == 8)
{
if (wav.NumChannels == 1)
{
format = ALFormat.Mono8;
}
else if (wav.NumChannels == 2)
{
format = ALFormat.Stereo8;
}
else
{
throw new InvalidOperationException("Unable to load audio with more than 2 channels.");
}
}
else
{
throw new InvalidOperationException("Unable to load wav with bits per sample different from 8 or 16");
}
unsafe
{
fixed (byte* ptr = wav.Data.Span)
{
AL.BufferData(buffer, format, (IntPtr) ptr, wav.Data.Length, wav.SampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
var length = TimeSpan.FromSeconds(wav.Data.Length / (double) wav.BlockAlign / wav.SampleRate);
return new AudioStream(handle, length, wav.NumChannels, name);
}
public AudioStream LoadAudioRaw(ReadOnlySpan<short> samples, int channels, int sampleRate, string? name = null)
{
var fmt = channels switch
{
1 => ALFormat.Mono16,
2 => ALFormat.Stereo16,
_ => throw new ArgumentOutOfRangeException(
nameof(channels), "Only stereo and mono is currently supported")
};
var buffer = AL.GenBuffer();
_checkAlError();
unsafe
{
fixed (short* ptr = samples)
{
AL.BufferData(buffer, fmt, (IntPtr) ptr, samples.Length * sizeof(short), sampleRate);
}
}
_checkAlError();
var handle = new ClydeHandle(_audioSampleBuffers.Count);
var length = TimeSpan.FromSeconds((double) samples.Length / channels / sampleRate);
_audioSampleBuffers.Add(new LoadedAudioSample(buffer));
return new AudioStream(handle, length, channels, name);
}
private sealed class LoadedAudioSample
{
public readonly int BufferHandle;
public LoadedAudioSample(int bufferHandle)
{
BufferHandle = bufferHandle;
}
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Robust.Client.Audio;
using Robust.Client.Input;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using Color = Robust.Shared.Maths.Color;
namespace Robust.Client.Graphics.Audio
{
/// <summary>
/// Hey look, it's ClydeAudio's evil twin brother!
/// </summary>
[UsedImplicitly]
internal sealed class ClydeAudioHeadless : IClydeAudio, IClydeAudioInternal
{
public bool InitializePostWindowing()
{
return true;
}
public void FrameProcess(FrameEventArgs eventArgs)
{
}
public void Shutdown()
{
}
public AudioStream LoadAudioOggVorbis(Stream stream, string? name = null)
{
// TODO: Might wanna actually load this so the length gets reported correctly.
return new(default, default, 1, name);
}
public AudioStream LoadAudioWav(Stream stream, string? name = null)
{
// TODO: Might wanna actually load this so the length gets reported correctly.
return new(default, default, 1, name);
}
public AudioStream LoadAudioRaw(ReadOnlySpan<short> samples, int channels, int sampleRate, string? name = null)
{
// TODO: Might wanna actually load this so the length gets reported correctly.
return new(default, default, channels, name);
}
public IClydeAudioSource CreateAudioSource(AudioStream stream)
{
return DummyAudioSource.Instance;
}
public IClydeBufferedAudioSource CreateBufferedAudioSource(int buffers, bool floatAudio = false)
{
return DummyBufferedAudioSource.Instance;
}
public void SetMasterVolume(float newVolume)
{
// Nada.
}
}
}

Some files were not shown because too many files have changed in this diff Show More