ClientMsg code optimization

This commit is contained in:
Pascal Serrarens 2024-12-31 09:03:21 +01:00
parent 478d028c09
commit d6203e1dd1
2 changed files with 7 additions and 0 deletions

View File

@ -75,6 +75,12 @@ namespace Passer.Control.Core {
return true;
}
public static byte Serialized(byte[] buffer, byte networkId) {
byte ix = 0;
buffer[ix++] = ClientMsg.Id;
buffer[ix++] = networkId;
return ix;
}
public static bool SendTo(Participant participant, byte networkId) {
if (participant == null)
return false;

View File

@ -61,6 +61,7 @@ namespace Passer.Control.Core
public virtual void Update(float currentTime) {
if (currentTime > this.nextPublishMe) {
this.PublishBuffer(ClientMsg.Serialized(this.buffer, this.networkId));
ClientMsg.Publish(this, this.networkId);
this.nextPublishMe = currentTime + Participant.publishInterval;
}