Commit Graph

2757 Commits

Author SHA1 Message Date
MrGadget1024
a9efaf1ad2 Added ServerTeleport to Experimental NetworkTransform 2020-10-27 19:53:23 -04:00
MrGadget1024
c306a9d5ef fixed typo 2020-10-27 19:52:34 -04:00
James Frowen
8e772a2077
fix(weaver): Fixing weaver not writing when assemble didn't have NetworkBehaviour (#2373)
* Making ReaderWriterProcessor return if it found custom functions (not counting ones in mirror.dll)
* Always writing generateContainerClass if modified
* processing PropertySiteProcessor if either ReaderWriterProcessor or WeaveModule are successful
* creating generateContainerClass in WeaverList constructor
* Moving new WeaverList to after WeaverTypes.SetupTargetTypes
2020-10-26 15:51:38 +01:00
James Frowen
4efd19c4ff
feat: Middleware transport (#2362)
* feat: adding MiddlewareTransport

* Allows Middleware to be created at the transport layer
* Middleware can choice which methods they want to override and which to let inner handle

* using expression bodies
2020-10-25 21:42:00 +01:00
MrGadget1024
4628685a62 fixed outdated comment 2020-10-25 15:25:34 -04:00
MrGadget1024
8c08ecf84d Empty braces on same line 2020-10-25 13:44:07 -04:00
MrGadget
75ce277a68
Add Accept and Reject methods to Authenticator (#2370)
* Add Accept and Reject methods to Authenticator

* Tabs To Spaces

* Removed `base.`

Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-25 12:55:29 -04:00
James Frowen
b19a8ccd12 fix(SimpleWebTransport): making sure that ReadHelper.Read reads exactly number of bytes
Docs say that stream.Read could return less than length. Keep reading stream untill length is reached.
2020-10-25 16:05:35 +00:00
James Frowen
414030d023
fix: making ClientAuthorityCallback an event (#2363)
* stops error prone behaviour of using = from multiple scripts

BREAKING CHANGE: `= callback` now needs to be `+= callback`
2020-10-25 17:01:53 +01:00
MrGadget
8f4ff423cb
Basic Authenticator code organization and comments (#2369)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-25 09:52:16 -04:00
James Frowen
a833f5c29f
Running code clean up (#2364)
* removing un-needed using
* whitespace
* using explicit types
2020-10-24 20:24:54 +01:00
James Frowen
28fc75140c
fix: improving errors in SendTargetRPCInternal (#2358)
* fix: improving errors in SendTargetRPCInternal

* now give error when connection is null
* updating error message to accurately explain what went wrong
2020-10-24 20:18:59 +01:00
MrGadget
77c844184e
Remove Obsoletes (#2361)
BREAKING CHANGE: Removed Obsolete Methods and Tests
2020-10-24 11:36:44 -05:00
MrGadget1024
60bc1555a5 Added Deprecated date to SyncList 2020-10-24 11:37:54 -04:00
MrGadget
749c9ee970
Make SerializeSyncVars & DeserializeSyncVars protected virtual (#2360)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-24 16:18:31 +02:00
MrGadget
cf3cf6a1ab
Remove EditorBrowsable Never Attributes (#2359)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-24 16:18:05 +02:00
James Frowen
0c6b63a2b1 simpleweb refactor changes 2020-10-22 19:13:58 +01:00
vis2k
d940db7e65 fix: #2357 (the second bug): NetworkServer.DisconnectAllConnections now iterates a copy of connections.Values to InvalidOperationException in cases where Transport.ServerDisconnect calls Mirror's OnServerDisconnect event immediately, which calls NetworkServer.OnDisconnected(connectionId), which would remove the connection while DisconnectAllConnections is iterating over them. 2020-10-22 11:36:18 +02:00
James Frowen
06ae90878d
Removing IDisposable from NetworkConnection (#2345)
* clientOwnedObjects is a hash set which doesn't need to be disposed
* DestroyOwnedObjects already clears list which is called by networkmanager when connection disconnects

Co-authored-by: vis2k <info@noobtuts.com>
2020-10-22 09:50:37 +02:00
James Frowen
46d8077780
Simplifing IsClientAlive check (#2346)
* moving check to base connection because it could be used for either
* renaming to IsAlive
* passing in timeout so it doesn't need to check NetworkServer
* updating doc comment
2020-10-22 09:48:35 +02:00
Chris Langsenkamp
2439af8c5e Applied Mirror Icon 2020-10-21 17:56:14 -04:00
vis2k
d3f1ee9819 fix: NetworkClient.Disconnect avoids NullReferenceException if Transport ClientDisconnect calls OnDisconnected immediately. Related to: https://github.com/vis2k/Mirror/issues/2353 2020-10-21 20:41:40 +02:00
Paul Pacheco
71dc3a2481 fix: recursive types with collections 2020-10-20 09:47:43 -05:00
Paul Pacheco
3bf41c89ea
simplify serializing collections (#416) (#2348)
The code to serialize lists, arrays, and array segments is now in the runtime instead of generated in the weaver.

removes about 300 LOC of weaver witchcraft
2020-10-20 09:47:00 +02:00
James Frowen
c789e2a510
using null propagation for RemoveOwnedObject (#2347) 2020-10-20 01:33:20 +01:00
James Frowen
25be44840e
checking if incoming message has length 0 before checking its id (#2336) 2020-10-18 23:07:10 +02:00
James Frowen
5eac88aa38 feat: adding NetworkRigidbody2D (#2322)(#2342)
* using angularVelocitySensitivity
* removing un-needed using
* using vec2 instead of vec3
2020-10-17 20:46:58 +01:00
pitaya4
b0430efa40
Added support for 2D rigidbodies (#2322)
Added `Mirror.Experimental.NetworkRigidbody2D`, which supports 2D rigid bodies instead of regular ones.
2020-10-17 20:24:30 +01:00
Paul Pacheco
ea7594e558
perf: use built in == instead of unity one (#2339)
* perf: use built in == instead of unity one

should be the same performance as #2325 without the complexity

* more readable version

* more readable version
2020-10-17 13:50:38 -05:00
James Frowen
92c7196f69
feat: Adding SimpleWebTransport v0.6.1 to mirror repo (#2323)
* Intial commit

see https://github.com/MirrorNetworking/SimpleWebTransport  for full git histroy

* Update main.yml

Adding SimpleWebTransport to coverage exclusions

* fully ignoring SimpleWebTransport from sonarcloud

SimpleWebTransport has sonarcloud running on its own repo

* using Buffer.BlockCopy

* SimpleWebTransport v0.4.1

* making error messages use LogError (MirrorNetworking/SimpleWebTransport@5f0096c)
* messages with length of 1 can be recieved by the client (MirrorNetworking/SimpleWebTransport@4237fc4)
* stopping un-needed error logs after disconnect (MirrorNetworking/SimpleWebTransport@25ff190)

* updating readme

* SimpleWebTransport v0.5.0

* adding missing warn level to Log.Levels (MirrorNetworking/SimpleWebTransport@0f68498)
* Allowing multiple instances of javascript client (MirrorNetworking/SimpleWebTransport#14) (MirrorNetworking/SimpleWebTransport@cc6e513)

* SimpleWebTransport v0.5.8

* Stopping send error when client disconnects
* Adding buffer pool
* Using ArrayBuffer for receive
* Removing info and verbose logging by default so performance isnt effected in editor or development builds.
* Making WebSocketClientStandAlone use timeouts from inspector
* Removing incorrect header from inspector
* Removing readonly from logger so that it can be set
* Fixing use of Interlocked in buffer pools
* using ManualResetEventSlim
* making Log.Exception always be logged

* SimpleWebTransport v0.6.0

* Trying to fix error when connection is closed
* Increase arraybuffer speed
* Removing shared buffers from server handshake
* Improving debug logging

* fixing code smells

* SimpleWebTransport v0.6.1

* making sure pending connection work when stop serve is called

* removing exception that isnt directly thrown by this method

this breaks docfx for some reason
2020-10-16 16:46:45 +01:00
James Frowen
f3f0403005
Removing websockets from mirror repo (#2268)
* Adding new websocket transport soon that doesn't depend on library
* Code for old transport can now be found here https://github.com/MirrorNetworking/NinjaWebSocketsTransport
* We shouldn't need to replace with empty files from store as having this in project should not break things
2020-10-16 16:46:04 +01:00
James Frowen
a2b64a4d1d
Update cloud readme
making examples a link
2020-10-15 17:57:48 +01:00
vis2k
31758e668f
perf: NetworkIdentity DirtyComponentsMask code removed entirely. OnSerialize now includes the component index as byte before serializing each component. Faster because we avoid GetDirtyComponentsMask() and GetSyncModeObserversMask() calculations. Increases allowed NetworkBehaviour components from 64 to 255. Code is significantly more simple. (#2331)
* perf: NetworkIdentity DirtyComponentsMask code removed entirely. OnSerialize now includes the component index as byte before serializing each component. Faster because we avoid GetDirtyComponentsMask() and GetSyncModeObserversMask() calculations. Increases allowed NetworkBehaviour components from 64 to 255. Bandwidth is now smaller if <8 components, and larger if >8 components. Code is significantly more simple.

* Update Assets/Mirror/Runtime/NetworkIdentity.cs

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

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-13 16:21:06 +02:00
Paul Pacheco
3c82ff0cb2
breaking: Users must initialize synclists (#391) (#2330)
* Users must initialize syncobjects (#391)

Previously we initialized syncobjects, so this is valid:
```cs
public class Pepe : NetworkBehavior {

    public SyncList<int> mylist;
}
```

With this change,  users must initialize their own fields:
```cs
public class Pepe : NetworkBehavior {

    public SyncList<int> mylist = new SyncList<int>();
}
```

BREAKING CHANGE: You must initialize all your SyncLists

* Add null check

* This is no longer a weaver error

* Update Assets/Mirror/Runtime/NetworkBehaviour.cs

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

* Remove unnecesary using

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-12 09:37:26 +02:00
James Frowen
1da023dfd3
Update NetworkIdentity.cs
checking cache instead of property
2020-10-11 22:45:48 +01:00
James Frowen
9bf8817245
fix: fixing Initializer for generic synclists (#2328)
Weaver should initialize `public SyncList<int> myList;`  in the same way it does for `SyncListInt`
2020-10-10 18:04:35 -05:00
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
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
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
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
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
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
Paul Pacheco
69161144a0 Fix comments 2020-09-28 21:02:53 -05:00
Paul Pacheco
4a710b2eea Add some comments 2020-09-28 20:44:18 -05:00
Paul Pacheco
86df5954ac Add some comments 2020-09-28 20:32:38 -05:00
Paul Pacheco
3ccb7d9da4
feat: Support recursive data types (#2288)
Remove all the recursionCount nonsense.
This was added to prevent infinite recursion with types that reference themselves.

No need to check anymore, the weaver can generate readers and writers for types that reference themselves such as:

```cs
class Tree {
    Tree child1;
    Tree child2;
}
```

This works by the weaver doing it the way the compiler does: Create a function first, memoize it, then write the body. If the body needs the function, it will get itself and issue a call to itself.
2020-09-28 20:18:56 -05:00
Paul Pacheco
513a0f9945
feat: support null when serializing classes (#2290) 2020-09-28 19:55:29 -05:00
Paul Pacheco
fe641adae8
Refactor writer function generation (#2289) 2020-09-28 17:07:16 -05:00
Paul Pacheco
6fc5a4effc remove TODO comment 2020-09-28 16:43:48 -05:00
Paul Pacheco
7aa47f14be Simplify reader registration 2020-09-28 15:52:36 -05:00
Paul Pacheco
2dc280d292 Refactor reader function generation 2020-09-28 15:50:40 -05:00
Paul Pacheco
fe061ac792 Simplify generated writer name 2020-09-28 15:32:06 -05:00
Paul Pacheco
5e78e27c8f Simplify generated reader name 2020-09-28 15:09:19 -05:00
Paul Pacheco
664d5f7f99
Generate reader and writer functions for enums (#2283)
Currently,  whenever we want to serialize an enum,
we simply serialize the underlying type (byte, short, int)

This works fine,  but in order to get the reader and writer
at runtime I need a function for each type.

With this PR, we generate a reader and writer function for enums too,
the function body simply calls the underlying reader and writer.
2020-09-28 14:51:13 -05:00
James Frowen
fa059b59bf
Squashed (#2187)
* throwing Exception instead of returning null
* re-adding null check until later PR
* removing error from test
* removing extra error
* adding comment
* replacing error with throw for abstact
2020-09-28 21:29:10 +02:00
James Frowen
796aa3baf8
moving WeaverLists functions to WeaverLists (#2285)
The plan is to remove WeaverLists at some point so moving the functions
out of weaver to here for now and then move them closer to where they
are actaully used when we start to remove WeaverLists.
2020-09-28 21:21:30 +02:00
Paul Pacheco
694de7255b Cannot use generics as declared reader and writers 2020-09-28 09:17:33 -05:00
Paul Pacheco
f9ecc64468 Simplify type check 2020-09-28 09:13:25 -05:00
Paul Pacheco
b0d1d9aac0 Rename method for clarity 2020-09-28 08:52:15 -05:00
Paul Pacheco
59566588b1 Simplify type check 2020-09-28 07:39:03 -05:00
Paul Pacheco
54f96309da Simplify type check 2020-09-28 07:38:24 -05:00
vis2k
9077cc7fd7 Add comments 2020-09-27 18:51:23 +02:00
James Frowen
8b3e509c3b
Update Transport.cs 2020-09-23 16:52:11 +01:00
James Frowen
bdd81e33ba
fix: fixing new import
see https://github.com/vis2k/Mirror/pull/2259
2020-09-23 16:30:32 +01:00
Paul Pacheco
a0aecf11fb Linting 2020-09-22 13:07:03 -05:00
Paul Pacheco
25b2fa9af8 KISS 2020-09-22 13:03:33 -05:00
Paul Pacheco
c868561822 Remove passthrough method 2020-09-22 12:49:38 -05:00
Paul Pacheco
3fec9ec880 Remove static weaver state 2020-09-22 12:33:48 -05:00
Paul Pacheco
116336fbf1 Remmove passthrough method 2020-09-22 12:33:18 -05:00
Paul Pacheco
3d331b4c61 Simplify set initialization 2020-09-22 12:21:58 -05:00
Paul Pacheco
34fa002099 Remove comment that does not apply 2020-09-22 12:20:37 -05:00
Paul Pacheco
a126bfd4dd Simplify method signature 2020-09-22 11:56:54 -05:00
Paul Pacheco
fdc21582db simplify module weaving 2020-09-22 11:45:31 -05:00
Paul Pacheco
e79ffeaa8e Use string interpolation 2020-09-22 11:40:13 -05:00
Paul Pacheco
b113fd4ecf KISS 2020-09-22 11:23:24 -05:00
Paul Pacheco
6c7e578d5a Remove redundant validations 2020-09-22 11:22:36 -05:00
Paul Pacheco
3e8870f791 we only weave one assembly at a time, no need for array 2020-09-22 10:11:07 -05:00
Paul Pacheco
eaf6ac66f0 output directory is always null, no need to pass it around 2020-09-22 10:06:13 -05:00
Paul Pacheco
eadb029393 Rename methods for clarity 2020-09-22 09:53:23 -05:00
Paul Pacheco
9d7c9069d7 Simplify namespace 2020-09-22 08:17:06 -05:00
Paul Pacheco
0fbcefe8df Follow naming convention 2020-09-22 08:16:04 -05:00
Paul Pacheco
85d26ebce6 type safe type comparison 2020-09-21 23:00:30 -05:00
Paul Pacheco
541b516d60 Remove unused parameter 2020-09-21 17:09:13 -05:00
Paul Pacheco
030dc86ea9 Namespace simplifications 2020-09-21 17:08:46 -05:00
Paul Pacheco
12debf1c8c Simplify namespace 2020-09-21 17:05:20 -05:00
Paul Pacheco
f77186e1d1 Simplify namespace 2020-09-21 17:00:57 -05:00
Paul Pacheco
d123e03915 Simplify namespace 2020-09-21 17:00:10 -05:00
Paul Pacheco
8fcbba50c4 Remove unused parameter 2020-09-21 16:59:05 -05:00
Paul Pacheco
7347e5700d Remove unused parameter 2020-09-21 16:58:33 -05:00
Paul Pacheco
76ce3796eb Simplify attribute namespace 2020-09-21 16:58:08 -05:00
Paul Pacheco
ca418457e8 Simplify guard check 2020-09-21 16:57:22 -05:00
Paul Pacheco
65f6e42b53 Simplify namespaces 2020-09-21 16:53:01 -05:00
James Frowen
94419ba003
Update ApiConnector.cs
adding null check for when listserver fails to be created
2020-09-20 00:44:13 +01:00
James Frowen
44401ab3bf
Update NetworkHeadlessLogger.cs 2020-09-19 11:30:41 +01:00
vis2k
d559bcfea7 Icon updated to half M 2020-09-19 10:01:10 +02:00
Paul Pacheco
07d290fd8c
Enhance code readability by using extension method (#2260)
# Before

This is hard to read:
```
if (ca.AttributeType.FullName == typeof(Mirror.CommandAttribute).FullName) {
...
}
```

# After

```
if (ca.AttributeType.Is<Mirror.CommandAttribute>()) {
...
}
```
2020-09-18 14:54:51 -05:00
James Frowen
7919942110
Splitting up test function
* Update NetworkServerTest.cs

splitting up test

* Update NetworkServer.cs

using string interpolation
2020-09-18 20:47:54 +01:00
Paul Pacheco
e50ea6318f
perf(weaver): No need to manually load mirror and unity assemblies (#2261) 2020-09-18 14:32:14 -05:00
James Frowen
a573bccc79
Update ApiUpdater.cs 2020-09-18 20:14:10 +01:00
Paul Pacheco
0b5989f87d Move overloads together 2020-09-18 13:06:34 -05:00
Paul Pacheco
6cfdd6469a
Simplify type lookup in weaver (#2258)
# Before
WeaverTypes declared a static variable like this:
```cs
public static TypeReference int32Type;
```
Weavertypes then loaded the variable in SetupTargetTypes like this:
```cs
int32Type = ImportSystemModuleType(currentAssembly, systemModule, "System.Int32");
```
Note we lookup the type with a string,  any typo there won't be detected until the code is executed.  It will also not be found by the IDE when you click "find references",  or when you refactor.

Then we use it like this:
```cs
var intType = WeaverTypes.int32Type;
```
This is a DRY violation: I have to modify 3 different code sections just to say that I want the int32 type.

# After
Get rid of all the duplication, and use the type instead of a string:
```cs
var intType = WeaverTypes.Import<int>();
```
No need for static variable,  or to add it in SetupTargetTypes.
2020-09-18 13:05:16 -05:00
James Frowen
8dac53ce3c
making InvokeUserCode use correct type in argument (#2259) 2020-09-17 22:41:37 +01:00
James Frowen
c69d8cca0b
flip equals to return early (#2245)
* flip equals to return early

* flip equals to return early

* removing un-needed comment
2020-09-16 12:05:43 +01:00
James Frowen
23bd9559d3
pref: increasing performance when Send is called on no observers (#2244)
* pref increasing performance when sending to no observers

* pref increasing performance when sending to no observers
2020-09-16 10:32:16 +02:00
James Frowen
5eb5ff6601
fix: fixing NullReferenceException when loading scene (#2240)
* fixing null ref error when local player is destroyed

* removing null objects

* fixing InvalidOperationException

* moving code to its own function

* Update Assets/Mirror/Runtime/ClientScene.cs
2020-09-16 10:30:10 +02:00
James Frowen
7580e9a6f5
Update ClientScene.cs (#2250)
* Update ClientScene.cs

Improving logging
- making sure sceneId is always hex
- only logging "Client spawn for ..." if it was successful

* Update ClientSceneTests_OnSpawn.cs
2020-09-14 22:35:41 +01:00
James Frowen
833c329ab2
Update ApiUpdater.cs
- Adding handlers in Awake instead of Start to make sure they are added before start on headless
- using GetComponent for NetworkManagerListServer
- Adding asserts to make sure values are set
2020-09-14 21:58:33 +01:00
James Frowen
b4fea1bfa3
Update NetworkServer.cs (#2247) 2020-09-13 19:07:59 +01:00
James Frowen
aec9b8a2ec
Update NetworkIdentity.cs
fixing block not being in remarks
2020-09-13 15:44:25 +01:00
James Frowen
d5c2387d1d
Update SyncObject.cs 2020-09-13 14:33:32 +01:00
James Frowen
ae9d2e35a9
docs: adding debug notes on list server (#2246) 2020-09-13 02:47:57 +01:00
James Frowen
844904dae5
adding doc comment (#2243) 2020-09-13 01:54:23 +01:00
James Frowen
94da8aec34
fix: Fixing IndexChanged hook not being called for NetworkRoomPlayer (#2242)
* adding Server to make sure index is only changed on the server

* removing calls to RecalculateRoomPlayerIndices on client
2020-09-13 01:52:32 +01:00
James Frowen
0c78fa0d7a
making sure CallOnClientExitRoom is called when object is disabled/destroyed (#2241) 2020-09-12 23:36:46 +01:00
Paul Pacheco
992129e5b6 Simplify string interpolation 2020-09-12 09:04:52 -05:00
James Frowen
5edba81dee
fix: ClientScene.localplayer is now set to null when it is destroyed (#2227)
* moving FakeNetworkConnection to common test folder

* adding test for local player destroy

* adding method to clear local player

* temp move test functions

* adding test for destroying non player

* moving asset to setup

* adding tests for destroy message and host mode

* adding ClearLocalPlayer to reset
2020-09-08 09:45:24 +02:00
James Frowen
2033f7d009
breaking: Removing manual invoke for Cmd and RPC (#2223)
* Removing manual invoke for Cmd and RPC

There should be no reason to manaully invoke remote code
they are marked with EditorBrowsableState.Never which implies they should not be called by the user

* removing tests
2020-09-06 16:14:05 +02:00
vis2k
a30e8fcd85 adding empty SyncEventProcessor file for deleted file 2020-09-06 16:07:52 +02:00
James Frowen
a232c539a7 adding empty program file for deleted file 2020-09-06 16:05:50 +02:00
James Frowen
bfa482fde7
Adding Network Lerp Rigidbody docs and change log (#2226)
* adding NetworkLerpRigidbody to change log

* adding docs for  Network Lerp Rigidbody
2020-09-05 13:09:06 +01:00
James Frowen
f326999d50
removing methods that only set enum (#2221) 2020-09-04 22:41:38 +01:00
James Frowen
622b52124b
Refactoring handle remote call (#2222)
* using string interpolation for logs

* return early instead of if/else
2020-09-04 22:40:56 +01:00
James Frowen
eac69ab5f6
docs: sync event obsolete (#2216)
* adding note to guides about removed SyncEvent

* updating Obsolete

making Obsolete error whe used
updating text to say it has been removed
linking to issue

* adding Obsolete note to other references to SyncEvent
2020-09-04 16:29:46 +01:00
vis2k
e67cef6666
Remove ScriptTemplates to clean up folder (#2213)
* Remove ScriptTemplates to clean up folder

* Update main.yml

Removing script templates from CI

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-09-04 07:55:11 +02:00
James Frowen
24e3ea099c
adding version define from v18 breaking change (#2214) 2020-09-03 15:46:15 +01:00
James Frowen
e79e340e0d
fixing typo in NetworkIdentity.cs 2020-09-03 11:51:05 +01:00
vis2k
cd3d9c2144 Delete old file 2020-09-03 09:05:47 +02:00
vis2k
fc1096d66c
breaking: Removed [SyncEvent] because ClientRpc/TargetRpc does the same thing, and it's an enormous effort to support the Weaver code. (#2178) 2020-09-03 09:04:29 +02:00
James Frowen
ad8af783dc
Replacing prefabAssetPath with assetPath for PrefabStage to stop warning (#2210) 2020-09-03 08:48:06 +02:00
James Frowen
1ade82d435
feat: making NetworkBehaviour.IsDirty public (#2208) 2020-08-31 12:26:50 +01:00
James Frowen
5701369e84
feat: adding script to help debug list server (#2202)
Script uses OnGui so can be used to check if server has been added to list server
2020-08-27 23:15:43 +01:00
James Frowen
fc530782cc
fix: fixing width and layout group on cloud example (#2201) 2020-08-27 23:10:11 +01:00
vis2k
f6dbf8c19e Fix broken Weaver test 2020-08-27 00:18:01 +02:00
vis2k
594aec45bf Weaver RpcProcessor validation moved to NetworkBeahviourProcessor.ProcessClientRpc 2020-08-26 13:15:23 +02:00
vis2k
25ef6ac36a Weaver TargetRpcProcessor validation moved to NetworkBehaviourProcessor.ProcessTargetRpc 2020-08-26 13:13:56 +02:00
vis2k
820d0daa29 Weaver CommandProcessor validation moved to NetworkBehaviourProcessor.ProcessCommand 2020-08-26 13:12:56 +02:00
vis2k
5e7257d7bc Weaver ValidateRemoteCallAndParameters IsStatic check added so we don't need to check in Command/Rpc/TargetRpcProcessors 2020-08-26 13:11:56 +02:00
vis2k
2e178b7eaf Weaver NetworkBehaviourProcessor: ValidateRemoteCallAndParameters function added to be used from Command/Rpc/TargetRpcProcessors 2020-08-26 13:08:46 +02:00
vis2k
fbad5d2401 Add comment 2020-08-26 13:04:39 +02:00
vis2k
68ebaf1756 Weaver TargetRpcProcessor: ValidateTargetRpc simplified 2020-08-26 13:03:44 +02:00
vis2k
e6ffe6d6bf Weaver: Simplify ValidateParameters 2020-08-26 13:02:25 +02:00
vis2k
ce3dd51d81 Weaver NetworkBehaviourProcessor: ProcessMethodsValidateParameters renamed to ValidateParameters 2020-08-26 13:01:43 +02:00
vis2k
ee8ad1d750 Weaver TargetRpcProcessor: ProcessMethodsValidateTargetRpc renamed to ValidateTargetRpc 2020-08-26 13:01:43 +02:00
vis2k
1b49a21d49 Weaver RpcProcessor: ProcessMethodsValidateRpc renamed to ValidateRpc 2020-08-26 13:01:43 +02:00
vis2k
9131586f5c Weaver NetworkBehaviourProcessor: ProcessMethodsValidateFunction renamed to ValidateFunction 2020-08-26 13:01:43 +02:00
vis2k
3dab0ec7c5 Weaver CommandProcessor: ProcessMethodsValidateCommand renamed to ValidateCommand 2020-08-26 13:01:43 +02:00
James Frowen
a9d21ea9ab
fix: adding error for generated read writer for abstract class (#2191)
* fix adding error for gernated read writer for abstract class

weaver can not initialize class abstract class so cant not create a reader
this gives a helpful error telling the server to make a custom reader

* adding tests for error message

* fixing typo

* renaming

* fixing expected error messages
2020-08-25 17:14:39 +01:00
James Frowen
c9a9f92c7c
commenting out reader error checks (#2196)
Reader code doesn't run on Rpc now if a valid writer can not be found
In future PR write and read functions should be generated together as they share most of the same checks
2020-08-25 01:39:03 +01:00
James Frowen
d73de03eca
renaming variables in Readers to match writers (#2195) 2020-08-24 14:48:15 +01:00
James Frowen
11a8d41464
fixng ArgumentNullException (#2193) 2020-08-24 14:43:51 +01:00
James Frowen
771f1fea13
fixing typo (#2192)
variable should start with lower case
2020-08-23 19:30:20 +01:00
James Frowen
1045b1f2ed
tests using HasError (#2188)
* replacing assert with haserror

* adding IsSuccess and HasWarning functions

* using IsSuccess

* checking weaverWarnings empty in success

* using HasWarning

* replacing asserts missed by regex

* fixing typo

* adding HasNoErrors function to be used when tests only have warnings

* fixing typo

* making fields public to stop warnings

* simplifying more test files
2020-08-22 20:20:16 +01:00
James Frowen
bd7c93674e
Error with message overloads (#2168)
* weaver error with message overloads

* finding method with 1 arg
2020-08-22 21:07:33 +02:00
James Frowen
d5d434cf13
weaver: renaming variables and changing order things happen (#2172)
* renaming variables

* adding todo

* moving order that things happen
2020-08-22 21:05:01 +02:00
James Frowen
ea0b9e1215
returning lists instead of passing them in as args (#2183) 2020-08-22 20:51:47 +02:00
James Frowen
f051c4b911
Simplify weaver tests (#2186)
* Simplifying weaver test files

* updating error messages
2020-08-22 19:00:11 +01:00
James Frowen
c312874bcb
renaming test folder in order to use WeaverTestsBuildFromTestName (#2189) 2020-08-22 18:59:06 +01:00
James Frowen
f1d7f207c3
adding HasError method (#2185)
Makes it easier to write error message within weaver tests because there is mess syntax to worry about
2020-08-22 16:23:56 +01:00
vis2k
9ec5eadd51 Weaver: PropertySiteProcessor.ProcessSitesModule renamed to Process for consistency 2020-08-22 13:59:17 +02:00
vis2k
ed60e592dc Syntax 2020-08-22 13:57:52 +02:00
vis2k
16f8f05abe Weaver: ReaderWriterProcessor.ProcessReadersAndWriters renamed to Process for consistency 2020-08-22 13:56:52 +02:00