Commit Graph

4457 Commits

Author SHA1 Message Date
vis2k
af99df3c4a Batching: respect channelId 2020-10-10 10:46:07 +02:00
vis2k
4b9a731fc3 perf: Batching. Mirror will batch up to Transport.GetMaxPacketSize messages into one batch and then send them all at once. Reduces transport calls by a factor of ~1000x assuming average of 64 byte message with Telepathy 64kb MaxMessageSize. 2020-10-10 10:19:15 +02:00
vis2k
fa53fa60f8 Unity 2020.1 for Editor in release mode (nearly doubles performance) 2020-10-08 15:38:47 +02:00
vis2k
7bc8a4773a perf: NetworkBehaviour.netIdentity cache: use bool instead of null check for significant performance improvement in 4k benchmark 2020-10-08 14:51:30 +02:00
vis2k
d40a6f6f7a perf: NetworkServer.Update avoid costly NetworkIdentity null check. Catch exception and log useful warning instead. This amounted to ~5% CPU in 4k monsters test before. 2020-10-08 14:44:04 +02:00
vis2k
389cf48064 perf: NetworkTransform bare metal position/rotation/scale sync. No more Cmd allocations and avoid redundant transform.transform call 2020-10-08 14:33:42 +02:00
vis2k
8561f67c12 Project Settings: IL2CPP reverted to Mono for faster build time 2020-10-08 12:36:41 +02:00
vis2k
941f6d262f Benchmark monsters doubled to 4k 2020-10-08 12:32:09 +02:00
vis2k
05c97094a4 Remove warning 2020-10-08 12:20:30 +02:00
vis2k
8c51319f5e DotNetCompatibility and StringHash merged into Extensions 2020-10-08 12:07:37 +02:00
vis2k
eeb1b3a469 Syntax 2020-10-08 12:05:37 +02:00
vis2k
63540998c9 Remove NetworkServer.Spawn version with assetId 2020-10-08 12:05:09 +02:00
vis2k
f4df75daee Remove unused AddPlayerForConnection version with assetId 2020-10-08 12:04:17 +02:00
vis2k
371121ef48 Syntax 2020-10-08 12:00:30 +02:00
vis2k
f59af28ccb MessagePacker.Unpack<T> moved to MessagePackerTests because it's only used for tests 2020-10-08 11:02:09 +02:00
vis2k
8d06b8737b Update comment 2020-10-08 10:47:14 +02:00
vis2k
7363de93ba MessagePacker: remove reundant GetId version. GetId<T> is enough. 2020-10-08 10:42:32 +02:00
vis2k
c709682344 Syntax 2020-10-08 10:38:35 +02:00
vis2k
1ad62db633 Update comment 2020-10-08 10:38:18 +02:00
vis2k
90d7ef65e0 Disable debug logs in ClientScene 2020-10-08 10:31:50 +02:00
vis2k
294c267472 perf: InterestManagement update time is now set in RebuildAll instead of Update. Avoids unnecessary updates if someone just called RebuildAll anyway 2020-10-08 10:23:34 +02:00
vis2k
2c41dc0ae5 Project Settings: default quality reduced to high 2020-10-08 10:04:33 +02:00
vis2k
72f5cdb6d7 InterestManagement: ensure player always sees himself and all his pets 2020-10-07 09:53:15 +02:00
vis2k
5a714c5605 Interest Management: Spatial Hashing aka Grid Checker 2020-10-07 09:31:16 +02:00
vis2k
5971eb7e05 BruteForce/InterestManagement: update interval / RemoveOldObservers / AddNewObservers moved into abstract InterestManagement for convenience. This allows us to reuse code for SpatialHashing and will allow us to set lastUpdateTime in RebuildAll() later in order to reduce rebuild load when people disconnected 2020-10-06 12:54:56 +02:00
vis2k
dfb60713cc update comment 2020-10-06 12:37:14 +02:00
vis2k
3f7aebb01f BruteForceInterestManagement moved into BruteForce folder 2020-10-06 11:39:27 +02:00
vis2k
d5582c6a47 NetworkServerTests: added missing InterestManagement 2020-10-06 11:35:06 +02:00
vis2k
f6ebc61102 Remove isSpawnFinished test since it doesn't exist anymore 2020-10-06 11:32:22 +02:00
Paul Pacheco
030028d5c8 breaking: no need to override Serialize/Deserialize in messages (#2317)
* breaking: no need to override Serialize/Deserialize in messages

Messages no longer serilize themselves.  This has been decoupled.  Serializing a message is now done
via readers and writers, which can be either generated or user provided.

This lifts some restrictions,
* you no longer need to have a default constructor in messages
* Messages types can be recursive
* struct Messages don't need to provide an empty Serialize and Deserialize method

Before:
```cs
public struct ReadyMessage : IMessageBase
{
    public void Deserialize(NetworkReader reader) { }

    public void Serialize(NetworkWriter writer) { }
}
```

After:
```cs
public struct ReadyMessage : IMessageBase
{
}
```

BREAKING CHANGE: Messages must be public
BREAKING CHANGE: Use custom reader and writer instead of Serialize/Deserialize methods

* Remove unused method

* remove unused methods

* remove unused methods

* make all messages struct

* Fix test code generator

* Get rid of MessageBase

* Rename IMessageBase -> NetworkMessage

* add MessageBase as obsolete

* Use a default request

* Empty file to make asset store happy

* Apply suggestions from code review

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-06 10:19:15 +02:00
Emre Bugday
3665a992d5 Fixed OnStopClient not being called on Client Side (#2308)
* Fixed OnStopClient not being called on Client Side

* Moved identity.OnStopClient() two scopes above

Co-authored-by: Emre Bugday <47198270+EmreB99@users.noreply.github.com>
2020-10-06 09:45:36 +02:00
James Frowen
b33e5228a3 Update Extensions.cs (#2310)
- only catching AssemblyResolutionException
- using null propagation instead of null ref
2020-10-06 09:44:35 +02:00
vis2k
b9c0ee144b InterestManagement: NetworkIdentity.forceHidden added again to replace NetworkProximityChecker.forceHidden 2020-10-05 17:35:20 +02:00
vis2k
a9b0254fcc InterestManagement global solution and removed NetworkProximityChecker/RebuildObservers 2020-10-05 15:32:07 +02:00
vis2k
0e324f5198 Remove unused import 2020-10-02 12:32:35 +02:00
vis2k
abe3ce194f fix tests after previous SyncLists commit 2020-10-02 12:24:27 +02:00
Paul Pacheco
df9fe83971 breaking: Use SyncLists directly (delete overrides) (#2307)
* feat: Use SyncLists directly

Previously,  you had to write an intermediary class to use synclists, syncsets and syncdictionaries.
The weaver would populate that intermediary class with a serialization and deserialization method

This PR gets rid of 90% of the weaver code for synclists.
There is no need to generate these methods anymore.
Instead the lists use `writer.Write<T>` and `read.read<T>` to serialize their Data.

Since there is no code generate in synclists, you can now use the synclists directly instead
of subclassing them.

BEFORE:

```cs
public class MyComponent : NetworkBehaviour {
    // nonsense class to make the weaver happy
    class SyncListData : Synclist<Data> {}

    SyncListData mySyncList;
}
```

AFTER:

```cs
public class MyComponent : NetworkBehaviour {
    Synclist<Data> mySyncList;
}
```

* linting

* feat: Use SyncLists directly (no overrides)

Previously,  you had to write an intermediary class to use synclists and syncdictionaries.

The weaver would populate that intermediary class with a serialization and deserialization method

This PR gets rid of 90% of the weaver code for synclists.
There is no need to generate these methods anymore.
Instead the lists use `writer.Write<T>` and `read.read<T>` to serialize their Data.

Since there is no code generate in synclists, you can now use the synclists directly instead
of subclassing them.

Same as #2305 ,but it removes the deprecated Serialize and Deserialize methods from syncobjects,
This way you get a nice compiler error for the code that no longer works, instead of a warning you might accidentally ignore.

BEFORE:

```cs
public class MyComponent : NetworkBehaviour {
    // nonsense class to make the weaver happy
    class SyncListData : Synclist<Data> {}

    SyncListData mySyncList;
}
```

AFTER:

```cs
public class MyComponent : NetworkBehaviour {
    Synclist<Data> mySyncList;
}
```

BREAKING CHANGE: Serialize and Deserialize methods in synclists don't do anything anymore

* Remove old comment

* Fix compilatio error
2020-10-02 09:50:35 +02:00
Paul Pacheco
55f64af196 feat: new generic Read and Write methods for all types (#2301)
Currently in mirror,  there is no way for Mirror itself to invoke
readers and writers for types it does not know about.

This causes us to have to generate code for lists, dictionaries and messages.

This PR makes it so that if there is a reader and writer anywhere in the
code for type X, then the writer can be invoked like this:

```cs
X x = ...;
writer.Write<X>(x);
```

and the reader can be invoked like this:
```cs
X x = reader.Read<X>();
```
2020-10-02 09:18:50 +02:00
vis2k
41f8644d1e Remove NetworkReader/Writer Read/WritePacked completely (note for backporting: requires moving WriteInt/UInt/etc. to extensions, otherwise weaver won't know how to write int/uint/etc.) 2020-10-01 16:12:42 +02:00
vis2k
7ef5b59fad perf: NetworkReader/NetworkWriter use Read/WriteBlittable<T> from DOTSNET (~10x faster) 2020-10-01 16:00:39 +02:00
vis2k
06256fd8d4 codecoverage settings saved 2020-10-01 14:49:55 +02:00
vis2k
56a054ba67 MessagePacker.MessageHandler renamed to WrapHandler because that's what it does 2020-10-01 14:49:48 +02:00
vis2k
99b3d95484 MessagePacker.MessageHandler refactored for consistency with DOTSNET 2020-10-01 14:41:41 +02:00
vis2k
3cb928fb30 Packages: CodeCoverage 0.3.1-preview added 2020-10-01 11:34:22 +02:00
vis2k
c5792ce837 Remove Transport.OnDataReceived channelId parameter 2020-10-01 11:33:05 +02:00
vis2k
1afdfd91d0 Remove unused 2020-09-30 12:12:46 +02:00
vis2k
304b201c6a Revert xml 2020-09-30 12:10:47 +02:00
vis2k
0f47b4bbe2 Remove unused disconnectInactiveTimeout 2020-09-30 12:05:20 +02:00
vis2k
076f9e0627 Add comment 2020-09-30 12:03:44 +02:00
vis2k
7a3ababf03 typo 2020-09-30 12:02:58 +02:00