Components & Networking Update #975
Replies: 6 comments 8 replies
-
This is great, one thing that wasn't possible before that you can do now being able to directly network on a client. public static partial class ClientExtensions
{
public static Entity GetEntity( this Client self ) => Entity.FindByIndex( self.NetworkIdent );
}
partial class Game : GameBase
{
public override void ClientJoined( Client cl )
{
cl.GetEntity().Components.Add( new ReadyComponent() );
}
}
public partial class ReadyScreenPlayer : Panel
{
Client Client { get; set; }
public override void Tick()
{
var readyComponent = Client.GetEntity().Components.Get<ReadyComponent>();
SetClass( "ready", readyComponent.Ready );
}
} Would it be possible to expose Components directly on the Client interface @garrynewman ? |
Beta Was this translation helpful? Give feedback.
-
Awesome but it does seem that [Local] net vars are completely broke now. floats are always returning 0 for example but as soon as I remove [Local] it goes to the value expected. @garrynewman Edit: [Net, Local, Predicted] seems to work even if only the server sets it. Only [Net, Local] isn't working for me period. |
Beta Was this translation helpful? Give feedback.
-
What about lists of NetworkComponent? Would be useful for say an inventory (in the classic sense, not entities/weapons). Right now it works with structs but structs can't do inheritance, requiring some hacky workarounds to support say itemtype-specific variables or method overrides. Either that or a way to make components only networked to the client owner (each item can be a component but not every client needs to know about the 50 items some player owns). |
Beta Was this translation helpful? Give feedback.
-
If I wanna set a component and then directly run a RPC, is it reliable that the component is set and synced to the client before the ClientRPC is called? (So I can access the component in the client as well) Just a question to avoid edge-cases :D |
Beta Was this translation helpful? Give feedback.
-
Really useful update. One last bug though is that EntityComponent [Net] vars are being cleared out on the client if there's a hotreload. Not noticeable for vars that change frequently but definitely for things that don't. |
Beta Was this translation helpful? Give feedback.
-
Are components and BaseNetworkable supposed to have their NetworkIdent always return 0? |
Beta Was this translation helpful? Give feedback.
-
Components
We have a basic component system now.
Right now I'm not automatically iterating them and calling Simulate or anything. I don't know if that's particularly something that is desired. Other than that they have everything you would expect.
When you add on serverside, they're automatically networked and sent down clientside.
They can have network data
This is the first version of Components. I'd like to look at moving some stuff over to use components. Changing the Camera variable to be a component makes sense to me. The Glow stuff makes sense too.
Any ideas/requests on this just give a shout.
Network Changes
I changed how the replicated vars are handled. Everything should keep on working how it always has, but we have some extra features.
Callbacks
Change callbacks can now specify the function name to call (defaults to On[Property]Changed if unset). Also can provide old and new values where appropriate. The attribute changed to [Change] too (was [OnChangedCallback]).
Data Handling
We can handle child class with child classes now. I haven't tested how crazy this can get, but it should hold up.
It should be trivial to add support for other network variables now too, so if you have a request feel free to ask.
Beta Was this translation helpful? Give feedback.
All reactions