public void CopyFrom(object rightComponent) { var right = rightComponent as SendUserCmdComponent; //Seq = right.Seq; FrameInterval = right.FrameInterval; MoveHorizontal = right.MoveHorizontal; MoveUpDown = right.MoveUpDown; MoveVertical = right.MoveVertical; DeltaYaw = right.DeltaYaw; DeltaPitch = right.DeltaPitch; RenderTime = right.RenderTime; ClientTime = right.ClientTime; ChangedSeat = right.ChangedSeat; //SnapshotId = right.SnapshotId; BeState = right.BeState; Buttons = right.Buttons; SwitchNumber = right.SwitchNumber; CurWeapon = right.CurWeapon; UseEntityId = right.UseEntityId; ManualPickUpEquip = right.ManualPickUpEquip; AutoPickUpEquip = UserCmd.CopyList(AutoPickUpEquip, right.AutoPickUpEquip); UseVehicleSeat = right.UseVehicleSeat; UseType = right.UseType; ChangeChannel = right.ChangeChannel; BagIndex = right.BagIndex; }
public static void CopyForm(this SendUserCmdComponent component, IUserCmd right) { //component.Seq = right.Seq; component.FrameInterval = right.FrameInterval; component.MoveHorizontal = right.MoveHorizontal; component.MoveUpDown = right.MoveUpDown; component.MoveVertical = right.MoveVertical; component.DeltaYaw = right.DeltaYaw; component.DeltaPitch = right.DeltaPitch; component.RenderTime = right.RenderTime; component.ChangedSeat = right.ChangedSeat; //component.SnapshotId = right.SnapshotId; component.BeState = right.BeState; component.Buttons = right.Buttons; component.SwitchNumber = right.SwitchNumber; component.CurWeapon = right.CurWeapon; component.UseEntityId = right.UseEntityId; component.ManualPickUpEquip = right.ManualPickUpEquip; component.AutoPickUpEquip = UserCmd.CopyList(component.AutoPickUpEquip, right.AutoPickUpEquip); component.UseVehicleSeat = right.UseVehicleSeat; component.UseType = right.UseType; component.ChangeChannel = right.ChangeChannel; component.BagIndex = right.BagIndex; }
private void MergeUserCmd(PlayerEntity player) { var tempList = player.userCmd.UserCmdStepList; UserCmd last = UserCmd.Allocate(); last.ReInit(); ((UserCmd)tempList.Last()).CopyTo(last); last.Seq = _userCmdSeq++; last.FrameInterval = 0; last.DeltaYaw = 0; last.DeltaPitch = 0; foreach (var cmd in tempList) { last.DeltaYaw += cmd.DeltaYaw; last.DeltaPitch += cmd.DeltaPitch; last.FrameInterval += cmd.FrameInterval; last.Buttons |= cmd.Buttons; last.RenderTime = cmd.RenderTime; last.ClientTime = cmd.ClientTime; last.SnapshotId = cmd.SnapshotId; last.PredicatedOnce = cmd.PredicatedOnce; last.MoveHorizontal = cmd.MoveHorizontal; last.MoveVertical = cmd.MoveVertical; last.MoveUpDown = cmd.MoveUpDown; last.ChangedSeat = cmd.ChangedSeat > 0 ? cmd.ChangedSeat : last.ChangedSeat; last.ChangeChannel = cmd.ChangeChannel > 0 ? cmd.ChangeChannel : last.ChangeChannel; last.CurWeapon = cmd.CurWeapon == 0 ? last.CurWeapon : cmd.CurWeapon; last.ManualPickUpEquip = cmd.ManualPickUpEquip > 0 ? cmd.ManualPickUpEquip : last.ManualPickUpEquip; last.AutoPickUpEquip = UserCmd.CopyList(last.AutoPickUpEquip, cmd.AutoPickUpEquip); last.UseEntityId = cmd.UseEntityId > 0 ? cmd.UseEntityId : last.UseEntityId; last.UseVehicleSeat = cmd.UseVehicleSeat > 0 ? cmd.UseVehicleSeat : last.UseVehicleSeat; last.UseType = cmd.UseType > 0 ? cmd.UseType : last.UseType; last.BagIndex = cmd.BagIndex > 0 ? cmd.BagIndex : last.BagIndex; //_logger.ErrorFormat("cmd;{0} {1}",cmd.CurWeapon,last.CurWeapon); cmd.ReleaseReference(); } tempList.Clear(); player.userCmd.AddLatest(last); last.ReleaseReference(); }
protected override void InternalExecute() { while (true) { var item = _contexts.session.clientSessionObjects.Replay.GetItem(EReplayMessageType.OUT, MyGameTime.stage, MyGameTime.seq, _contexts.session.clientSessionObjects.NetworkChannel.Id); if (item == null) { return; } if (item.MessageBody is ReusableList <UpdateLatestPacakge> && item.ProcessSeq == MyGameTime.seq) { var last = _contexts.player.flagSelfEntity.userCmd.Latest as UserCmd; ReusableList <UpdateLatestPacakge> reusableList = item.MessageBody as ReusableList <UpdateLatestPacakge>; var current = reusableList.Value.Last(); foreach (var updateComponent in current.UpdateComponents) { if (updateComponent is SendUserCmdComponent) { var right = updateComponent as SendUserCmdComponent; _logger.DebugFormat("replay usercmd: last:{0}, timeseq:{1}, msgSeq:{2} {3}", last.Seq, MyGameTime.seq, current.Head.LastUserCmdSeq, item); //last.Seq = current.Head.UserCmdSeq; //last.SnapshotId = current.Head.LastSnapshotId; _contexts.session.clientSessionObjects.TimeManager.RenderTime = right.RenderTime; last.FrameInterval = right.FrameInterval; last.MoveHorizontal = right.MoveHorizontal; last.MoveUpDown = right.MoveUpDown; last.MoveVertical = right.MoveVertical; last.DeltaYaw = right.DeltaYaw; last.DeltaPitch = right.DeltaPitch; last.RenderTime = right.RenderTime; last.ClientTime = right.ClientTime; last.ChangedSeat = right.ChangedSeat; last.BeState = right.BeState; last.Buttons = right.Buttons; last.SwitchNumber = right.SwitchNumber; last.CurWeapon = right.CurWeapon; last.UseEntityId = right.UseEntityId; last.ManualPickUpEquip = right.ManualPickUpEquip; last.AutoPickUpEquip = UserCmd.CopyList(last.AutoPickUpEquip, right.AutoPickUpEquip); last.UseVehicleSeat = right.UseVehicleSeat; last.UseType = right.UseType; last.ChangeChannel = right.ChangeChannel; last.BagIndex = right.BagIndex; } } } if (item.MessageBody is ReusableList <IVehicleCmd> && item.ProcessSeq == MyGameTime.seq) { var cmd = (item.MessageBody as ReusableList <IVehicleCmd>).Value.Last(); var controlledVehicle = PlayerVehicleUtility.GetControlledVehicle(_contexts.player.flagSelfEntity, _contexts.vehicle); if (controlledVehicle != null) { controlledVehicle.vehicleCmd.AddLatest(cmd); } } if (item.MessageBody is ReusableList <IRefCounter> ) { foreach (var updateLatestPacakge in (item.MessageBody as ReusableList <UpdateLatestPacakge>).Value) { updateLatestPacakge.ReleaseReference(); } } item.ReleaseReference(); } }