-
Notifications
You must be signed in to change notification settings - Fork 49
Custom InnerNetObjects #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
i just dont get the InnerNetObject attribute, it seems really unecessary since this can be done by checking subtypes in the assembly |
|
I think example class should be an actual simple example of what you can do with this instead of just a stub. |
The first reason is do to the issue with abstract monobehaviors and compiling it into il2cpp, second reason is I feel like it's more consistent using a attribute as the original class with Reactor, now I'm probably going to change the method of loading the prefab for it. If y'all really want it to just be a custom subclass then I'll rework the logic. |
Replaced InnerNetObjectAttribute with IgnoreInnerNetObjectAttribute, now automatically registers InnerNetObjects. Added more methods to load prefab.
I've added some changes. |
miniduikboot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there, sorry for the lack of feedback. I've been busy and hoped other Reactor devs would've been active as well. I've read through the PR and made a few comments. I'm not fundamentally opposed to an API like this, but I think this has a few limitations that make it unsuitable for an environment where optional mods exist.
Let me know if you still want to push this PR forward
| // Example 1: Directly assign a prefab | ||
| // This is the simplest method, where the prefab is assigned directly to a static field or property. | ||
| [InnerNetObjectPrefab] | ||
| public static InnerNetObject? PrefabField; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the check warnings
| { | ||
| if (!AmongUsClient.Instance.AmHost) | ||
| { | ||
| Warning("You can only spawn a InnerNetObject as Host."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the decision to squash this error here? TOCTOU concerns?
InnerNetClient logs an error when AUClient.Instance.Spawn is called on clients
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought it would be better to know that the warning is directly coming from reactor
| /// This method searches through the AmongUsClient.Instance.NonAddressableSpawnableObjects array | ||
| /// to find a prefab of the specified type. If no matching prefab is found, an exception is thrown. | ||
| /// </remarks> | ||
| public static InnerNetObject? GetNetObjPrefab<T>() where T : InnerNetObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for this object id to desync between clients? For example, when multiple mods add objects, they may load in a different order, or a mod that is declared optional declares a net object as well (which shouldn't happen, but I think it is reasonable foreseable misuse)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory it shouldn't be possible because in IgnoreInnerNetObjectAttribute Register collects all the valid innernet object with prefabs then on IL2CPPChainloader.Finished everything is loaded in alphabetical order to try to prevent this problem, as long as everyone has the same mods everything should be synced up.
| namespace Reactor.Example; | ||
|
|
||
| // The `IgnoreInnerNetObject` attribute is used to prevent this custom InnerNetObject | ||
| // from being automatically registered by Reactor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should users of this API also declare this attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only to stop reactor automatically registering the innernet object
Co-authored-by: miniduikboot <mini@duikbo.at>
Introducing Custom InnerNetObjects
This PR introduces a set of improvements to make working with custom
InnerNetObjecteasier, and more intuitive. The changes include:Comprehensive XML Documentation:
InnerNetObjectprefabs.Utility Methods for Prefab Handling:
GetNetObjPrefab<T>,SpawnNewNetObject<T>, andSpawnNetObjectto simplify the process of retrieving, instantiating, and spawning customInnerNetObjectprefabs.Key Changes:
1.
GetNetObjPrefab<T>InnerNetObjectof typeT.2.
SpawnNewNetObject<T>InnerNetObjectlocally and on the network of type "T".3.
SpawnNetObject<T>(Extension Method)InnerNetObjectinstance on the network.