Commit Graph

4374 Commits

Author SHA1 Message Date
James Frowen
ad48d511a1
Update NetworkConnection.cs
reverting comment
2020-10-10 15:34:46 +01:00
James Frowen
1c476f71b5
Update NetworkConnection.cs 2020-10-10 13:04:07 +01:00
vis2k
eb23bb76e0 Benchmark: custom NetworkManager with adjustable spawn amount for easier testing 2020-10-10 12:42:06 +02:00
vis2k
7529f5aedc Benchmark: namespace changed from OneK to Benchmark 2020-10-10 12:39:50 +02:00
vis2k
575f1f6071 Benchmark: SpawnPosition renamed and centered at 0,0,0 2020-10-10 12:39:06 +02:00
uwee
6e44e6e526
fix: NRE in tanks example when running in headless server only (#2326) 2020-10-09 13:23:47 +01:00
James Frowen
5db733e566
Update index.md 2020-10-09 02:35:31 +01:00
vis2k
d9f58d3439 Benchmark monsters doubled to 4k, everyone broadcasting to everyone 2020-10-08 15:19:44 +02:00
James Frowen
5ad3fb5807
feat: NetworkTranform Teleport (#2320)
* Server Teleport Enchancement for NetworkTransform

Related to this issue: https://github.com/vis2k/Mirror/issues/2200

* Improvements on NetworkTransformBase

We disable clientAuthority until teleportation is finished and acknowledged. We set the goal and start data points to null before teleportation.
We set the clientAuthority back to it's initial value registered on server, both on the server and client side; it seems like we don't need to change it to anything on Client side because to my understanding clientAuthortiy is not affecting anything on client side. I may be wrong but still it is a great practice to set it back to it's initial value just in case...

* Added teleportation with rotation

I forgot to add a rotation functionality on my previous commit. It wouldn't be a teleportation without also changing the rotation. If provided a rotation input it will teleport with a rotation, if not it will simply protect the original rotation before the teleportation.

* Removed my debug statement

I forgot to remove the debug log statement lol silly me

* fixing up code

* resetting goal and last pos on server and client
* renaming variables
* making sure TeleportFinished can't request authority at any time

* moving teleport block

* removing duplicate lines

Co-authored-by: Emre Bugday <47198270+EmreB99@users.noreply.github.com>
2020-10-06 18:47:16 +01:00
James Frowen
1b5cbb51d7
fix: fixing PR number in Obsolete message 2020-10-06 18:08:35 +01:00
Paul Pacheco
31b07ae02f
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 09:31:02 +02:00
Paul Pacheco
80e27627f7
jagged arrays are fine 2020-10-05 16:26:19 -05:00
James Frowen
6813360f93
feat: NetworkAnimator now syncs animator.speed (#2312)
* feat: NetworkAnimator now syncs animator.speed

* Update NetworkAnimator.cs

- adding previous speed field
- avoiding floating number equals

* Update NetworkAnimator.cs

- adding previousSpeed field
2020-10-03 20:51:08 +02:00
Emre Bugday
032012f9e1
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-03 02:57:37 +01:00
James Frowen
42f5a117ec
Update Extensions.cs (#2310)
- only catching AssemblyResolutionException
- using null propagation instead of null ref
2020-10-03 01:45:53 +01:00
James Frowen
181bab6bd0
fixing test names (#2309)
* fixing test names

* renaming test files
2020-10-03 01:45:40 +01:00
Paul Pacheco
90834d476b Document how to use new synclists 2020-10-02 13:56:20 -05:00
vis2k
e730e4baca fix tests after previous SyncLists commit 2020-10-02 10:03:07 +02:00
Paul Pacheco
fb49d19793
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:12:25 +02:00
Morten Nørgaard
49c2f1bc5c
Update Profiler.md (#2304)
Added missing info on how to download the profiler tool via Discord.
2020-10-02 09:10:05 +02:00
Paul Pacheco
85252c3d84
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-01 17:13:30 -05:00
James Frowen
16c919eae9
Update index.md 2020-10-01 17:03:15 +01:00
vis2k
efb9b21aa4 Revert xml 2020-09-30 12:11:08 +02:00
vis2k
ae95b0625d revert 2020-09-30 11:09:12 +02:00
vis2k
7fa8345b85 wtf 2020-09-30 11:02:27 +02:00
Paul Pacheco
16864f9ff0 It is fine to serialize empty struct 2020-09-29 21:26:53 -05:00
Paul Pacheco
0267dbe1f2 feat: support Jagged arrays
simplify the code for checking for multidimentional arrays
and lift the restriction on jagged arrays
2020-09-29 21:21:16 -05:00
Paul Pacheco
5e2d87685b Generated class does not need constructor 2020-09-29 15:22:21 -05:00
Paul Pacheco
c720055bce remove empty blocks 2020-09-29 12:26:24 -05:00
Paul Pacheco
7ca08924b5 Remove unused meta 2020-09-29 12:16:21 -05:00
Paul Pacheco
0132697513 Simplify obj initialization 2020-09-29 12:15:26 -05:00
Paul Pacheco
88ece20e68 Simplify IsDerivedFrom 2020-09-29 12:01:49 -05:00
Paul Pacheco
9889ed4f9c Remove unnecesary lists from WeaverLists 2020-09-29 11:22:46 -05:00
Paul Pacheco
8dbf46720e
fix: generic arguments resolution (#2300)
* fix: generic arguments lookup

The weaver was not able to figure out the synclist type in code like this:

```cs
    public class SomeList<G, T> : SyncList<T> { }
    public class SomeListInt : SomeList<string, int> { }
```

This code fixes that problem, and greatly reduces the complexity
of argument lookup.

* linting
2020-09-29 09:39:17 -05:00
vis2k
720a06ea70 MessagePacker.Pack<T> to byte[] moved out of MessagePacker and into MessagePackerTest to simplify code. It's only used in tests anyway. 2020-09-29 11:54:07 +02:00
vis2k
c947bc03e6 MessagePacker.GetId<T> reuses GetId(Type) 2020-09-29 10:55:02 +02:00
Cooper Saye
aba69ca4d0
fix: typos (#2297) 2020-09-29 09:16:30 +02:00
Paul Pacheco
bdb6ca07d2 linting 2020-09-28 23:11:50 -05:00
Paul Pacheco
3103266b44 space linting 2020-09-28 22:49:36 -05:00
Paul Pacheco
3e2c3f8ccc
Refactor reading array segment (#2296)
* Refactor reading array segment

Just deserialize the array and transform to array segment

* Fix comment

* Fix invalid IL
2020-09-28 22:43:44 -05:00
Paul Pacheco
59bc83f997 Fix more comments 2020-09-28 22:42:34 -05:00
Paul Pacheco
fe1064ce0b Remove redundant InitLocals 2020-09-28 22:37:25 -05:00
Paul Pacheco
53452cc003 Fix comments 2020-09-28 22:37:25 -05:00
Paul Pacheco
5c4d8a27cc Refactor writer for loops (#2294)
* Refactor writer for loops

* Remove unused variable
2020-09-28 22:37:25 -05:00
Paul Pacheco
fe2adc8d59 Deduplicate null check (#2295) 2020-09-28 22:37:25 -05:00
Paul Pacheco
0aea48cf06 Linting 2020-09-28 22:14:54 -05:00
Paul Pacheco
b9550cf6d3 Linting 2020-09-28 22:14:09 -05:00
Paul Pacheco
4ec84df494
Reuse checking for null (#2293) 2020-09-28 21:32:43 -05:00
Paul Pacheco
66be588512
reuse ReadLength (#2292) 2020-09-28 21:32:16 -05:00
Paul Pacheco
7c2a6595eb
refactor reader for loops (#2291)
* Fix comments

* refactor for loops

* Cleanup a bit
2020-09-28 21:29:52 -05:00