-
-
Notifications
You must be signed in to change notification settings - Fork 305
Quality of life improvements for use in stand-alone servers #393
base: develop
Are you sure you want to change the base?
Quality of life improvements for use in stand-alone servers #393
Conversation
…4 for the Code Generation
…ature/stand-alone-quality-of-life-improvements-continued
UnityNear will break on stand-alone servers as it depends on Unity. UnityNear already falls back to Near for everything but the Unity types, so consolidate them.
I mistakenly did not use an "else if".
Something that I also realized just now: currently I'm not sharing the behaviors with my stand-alone server - as they depend on Unity things and I don't need them -, but the behaviors contain the codes for the generated RPCs, which I then also lose. I can call RPCs through their name, but that's already been deprecated. Thinking about this some more: wouldn't it be more logical if we move the constants to the generated network object instead of the behavior? I'm talking specifically about these lines: public const byte RPC_YOUR_RPC_1 = 0 + 5;
public const byte RPC_YOUR_RPC_2 = 1 + 5; This would fix the sharing problem, and it would also make more sense, since you invoke the RPCs on the network object anyway, and not the behavior - the behavior also doesn't use them for anything else. Another option would be to generate a separate file (enum?) with these RPCs in, that could then be shared again. The registration of the RPCs itself is another thing that would be interesting to move to the network object instead, as now the stand-alone server needs to manually register the same RPCs (in the same order), as it cannot reuse the behavior. They could fire events from the network object that are caught by the behavior in order to call the methods you have to overload. |
ForgeUnity/Assets/BeardedManStudios/Scripts/StandAlone/Objects/InterpolateFloat4.cs
Outdated
Show resolved
Hide resolved
I updated the pull request to use .NET's The only downside so far is that System.Numeric is not a partial struct, so implicit operators to convert to Unity variants is no longer possible. I've introduced explicit extension methods to do this, instead. |
Hello @MrWatts-Anorak, are you on the Forge discord? |
This reduces the amount of custom code we need. .NET's Numeric classes also have many more built-in convenience functions. This also supports .NET's Quaternion next to .NET's Vector4, which will use Slerp instead of Lerp to fix interpolation issues.
10af805
to
96ee91d
Compare
This is a continuation of #310, as the original author is no longer interested in fixing the changes.
From the original PR:
I've processed some of the feedback on the pull request as well:
ToString
overrides were added for the new types for easy debugging.System.Numeric
types are now used instead of new custom types.UnityNear
was consolidated withNear
as the former already falls back to the latter, but the former doesn't work in stand-alone projects as it depends on Unity, and it was also used in network objects, which was also updated.StandAloneObjectMapper
are now part ofObjectMapper
as these new types don't conflict with the existing types and this prevents new users from being confused, as they would need to callStandAloneObjectMapper.Instance.UseAsDefault();
to get them recognized in network objects.Open questions:
Do we switch fromDone.FloatX
toSystem.Numerics.VectorX
, as suggested by @phalasz?StandAloneObjectMapper
andUnityNear
are gone, we can have a single generated version that works both stand-alone and inside Unity, though dropping the Unity types above would make be required.