Comments (8)
I don't think there is any point in exposing NodeSynchCompleted in the framework itself as the event mentioned above pretty much gives you that information. Of course if you really want it I would suggest just overriding the MDGameSynchronizer and exposing it.
from mdframework.
-
Did you check the MDStatics class? It has a few methods such as
MDStatics.IsNetworkActive()
,MDStatics.IsServer()
andMDStatics.IsClient()
. Documenation is a bit lacking at the moment. I do plan on making some video tutorials and writing some guides in the wiki once the framework is in a bit more of a complete state. -
I agree with this one, in theory you could use
MDGameSession.GetAllPlayerInfos()
and do a count on that, but exposing player count directly would be better. -
I agree with this as well, I think we should just swap the order of the MDPlayerInfo being removed and the event being sent out. It would make a lot more sense to send out the event while the player info still exists.
-
Probably also worth adding.
I would wait to see what @DoubleDeez says about this, but I would think you could just make those three changes on your fork and just create a pull request.
from mdframework.
- The helpers Beider mentioned are probably what you want. As for the synch'd event, there's OnSynchCompleteEvent on MDGameSynchronize. We do need to improve our documentation so these are easier to find.
MDFramework/MDNetworking/MDGameSynchronizer.cs
Lines 30 to 31 in 3a72a95
- Yup, I agree we should add this.
- I can't think of any reason to remove the object before sending the event so yeah I think we should just swap the order
private void OnPlayerLeft_Internal(int PeerId)
{
OnPlayerLeftEvent(PeerId);
RemovePlayerObject(PeerId);
}
- That's a good idea. There's probably other settings we should be exposing too, but instead of having to add a bunch of parameters I wonder if we should have a
virtual void ConfigurePeer(peer);
function or something along those lines.
and yeah, if you can, please create a pull request with these changes, otherwise we'll get to it when we have the time.
from mdframework.
Ok i will make pull request, but:
- The helpers Beider mentioned are probably what you want. As for the synch'd event, there's OnSynchCompleteEvent on MDGameSynchronize. We do need to improve our documentation so these are easier to find.
MDFramework/MDNetworking/MDGameSynchronizer.cs
Lines 30 to 31 in 3a72a95
This does work, but this triggers every time synch is happening, for every player every time someone joins.
- Did you check the MDStatics class? It has a few methods such as
MDStatics.IsNetworkActive()
,MDStatics.IsServer()
andMDStatics.IsClient()
. Documenation is a bit lacking at the moment. I do plan on making some video tutorials and writing some guides in the wiki once the framework is in a bit more of a complete state.
MDStatics.IsNetworkActive()
seems only count that we're connected but isn't synched yet. For event this needs custom logic, i've used this to actually know if i'm synched or not and exposed this to my GameSynchronizer
.
I'm planning to expose this var and make event that happends inside OnSynchCompleteEvent
. Not sure if that's right to do nested events.
from mdframework.
Alright so if I get you right you want an event that tells you the first time a player has finished synching? Should this be on master, the joining player or all players?
I would suggest adding a completely new event called something like OnPlayerSynchComplete(int PeerId)
The best place to add this is probably to this method in the game synchronizer,
[Puppet]
protected void UpdateSynchStatus(int PeerId, float SynchStatus)
{
OnPlayerSynchStatusUpdateEvent(PeerId, SynchStatus);
}
Just change OnPlayerSynchStatusUpdateEvent(Multiplayer.GetRpcSenderId(), 1f);
in ClientSynchDone()
so it also calls UpdateSynchStatus(...)
Then just check if the synch status is 1f, which means it is done, in which case you can send the event. You would probably have to introduce another list like the ClientSynchList
, something like InitialSychDoneList
to track so it only happens the first time. And remove them from the synch list if they leave.
Other alternative would be simply to subscribe to the OnPlayerSynchStatusUpdateEvent
somewhere in your own code, then check when it is 1f and send your event there. Then you would also have to track which peers this event has been sent for already but would be the best solution if you don't want to change the framework.
from mdframework.
Alright so if I get you right you want an event that tells you the first time a player has finished synching? Should this be on master, the joining player or all players?
This event should be invoked on player who joins to server, only one time when he finished connection and finished synching.
from mdframework.
The easiest way to do this without changing the framework would be for you to subscribe to the OnPlayerSynchStatusUpdateEvent
Then just do something like this
protected bool AlreadySynched = false;
protected void SynchStatusUpdate(int PeerId, float ProgressPercentage)
{
if (AlreadySynched)
{
return;
}
// Float compares are annoying
if (PeerId == MDStatics.GetPeerId() && ProgressPercentage >= 0.99f)
{
// Do your stuff here
AlreadySynched = true;
}
}
Edit: I added this example to the wiki page for the Game Synchronizer.
from mdframework.
The easiest way to do this without changing the framework would be for you to subscribe to the
OnPlayerSynchStatusUpdateEvent
Then just do something like this
protected bool AlreadySynched = false; protected void SynchStatusUpdate(int PeerId, float ProgressPercentage) { if (AlreadySynched) { return; } // Float compares are annoying if (PeerId == MDStatics.GetPeerId() && ProgressPercentage >= 0.99f) { // Do your stuff here AlreadySynched = true; } }
This is actually nice, i might just use that for my event.
Is that good idea to make NodeSynchCompleted exposed in case user needs to know or it is not?
from mdframework.
Related Issues (20)
- Hosting standalone, disconnecting, then hosting server causing infinite-synchronizing for new players HOT 2
- MDReplicatedMember OnValueChangedEvent not called locally
- Console Variable System
- Console doesn't allow inputting a string with spaces as arguments
- Caching of reflection data HOT 1
- Godot 3.3 support? HOT 2
- Support Multiple Local Players (Splitscreen)
- Add Integration Test GitHub Action
- Add Unit Test GitHub Action
- Resolving of Method for MDRpc should be more accurate HOT 1
- GameClock RPCs don't set SenderRpcId + Remove config settings to disable GameClock/Synchronizer HOT 5
- Support Events as MDReplicate OnChange callbacks
- Support categories for OnScreenDebug and toggling rendering of individual categories
- MDRpcId variants should call the function if the passed in Id is the local peer HOT 1
- MDReplicatorNetworkKeyIdMap should consider things outside of session immutable HOT 1
- Resolving private members & methods in inheriting classes HOT 1
- Exported game couldn't find default configuration, crash
- Method number could not be found for class method HOT 3
- Add command to auto generate CustomMDConfigDebug.ini and CustomMDConfigExport.ini
- Naming Conventions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mdframework.