private void UninformHead(PushPull whoToInform, PushPull subject) { InformPullMessage.Send(whoToInform, subject, null); if (IsPullingSomethingServer) { PulledObjectServer.UninformHead(whoToInform, PulledObjectServer); } }
///inform new master puller about who's pulling who in the train public void InformHead(PushPull whoToInform, PushPull subject = null) { if (subject == null) { subject = this; } InformPullMessage.Send(whoToInform, subject, subject.PulledBy); if (IsPullingSomethingServer) { PulledObjectServer.InformHead(whoToInform, PulledObjectServer); } }
/// <param name="recipient">Send to whom</param> /// <param name="subject">Who is this message about</param> /// <param name="pulledBy">Who pulls the subject</param> public static InformPullMessage Send(PushPull recipient, PushPull subject, PushPull pulledBy) { //not sending message to non-players if (!recipient || recipient.registerTile.ObjectType != ObjectType.Player) { return(null); } InformPullMessage msg = new InformPullMessage { Subject = subject.gameObject.NetId(), PulledBy = pulledBy == null ? NetId.Invalid : pulledBy.gameObject.NetId(), }; msg.SendTo(recipient.gameObject); Logger.LogTraceFormat("Sent to {0}: {1} is {2}", Category.PushPull, recipient, subject, getStatus(pulledBy)); return(msg); }
public void NotifyPlayers(bool noLerp) { //Generally not sending mid-flight updates (unless there's a sudden change of course etc.) if (!serverState.ImportantFlightUpdate && consideredFloatingServer) { return; } //hack to make clients accept non-pull-breaking external pushes for stuff they're pulling //because they ignore updates for stuff they pull w/prediction bool isPullNudge = pushPull && pushPull.IsBeingPulled && !serverState.IsFollowUpdate && serverState.Impulse != Vector2.zero; if (isPullNudge) { //temporarily "break" pull so that puller would get the update InformPullMessage.Send(pushPull.PulledBy, this.pushPull, null); } serverState.NoLerp = noLerp; var msg = PlayerMoveMessage.SendToAll(gameObject, serverState); // Logger.LogTraceFormat("SentToAll {0}", Category.Movement, msg); //Clearing state flags serverState.ImportantFlightUpdate = false; serverState.ResetClientQueue = false; if (isPullNudge) { //restore pull for client. //previous fake break erases all pull train info from train head, so we make head aware again pushPull.InformHead(pushPull.PulledBy); // InformPullMessage.Send( pushPull.PulledBy, this.pushPull, pushPull.PulledBy ); } }