static void LerpRemotePlayer(Player player, PlayerSnapshot A, PlayerSnapshot B, float t) { if (player.m_lerp_wait_for_respawn_pos) { player.LerpRemotePlayer(A, B, t); return; } var lookahead = 1f + (GameManager.m_local_player.m_avg_ping_ms / (1000f / 60f)) * 0.75f; player.c_player_ship.c_transform.localPosition = Vector3.LerpUnclamped(A.m_pos, B.m_pos, t + lookahead); player.c_player_ship.c_transform.rotation = Quaternion.SlerpUnclamped(A.m_rot, B.m_rot, t + lookahead); player.c_player_ship.c_mesh_collider_trans.localPosition = player.c_player_ship.c_transform.localPosition; //// Bail if we're observing. //var factor = MPClientExtrapolation.GetFactor(); //if (factor == 0f || GameManager.m_local_player.m_avg_ping_ms <= 0f) { // // Reposition ship 1 frame ahead to compensate for showing old position data. // __instance.c_player_ship.c_transform.localPosition = Vector3.LerpUnclamped(A.m_pos, B.m_pos, t + 1); // __instance.c_player_ship.c_transform.rotation = Quaternion.SlerpUnclamped(A.m_rot, B.m_rot, t + 1); // __instance.c_player_ship.c_mesh_collider_trans.localPosition = __instance.c_player_ship.c_transform.localPosition; // return false; //} //// Queue to simulate physics. //B.m_rot.ToAngleAxis(out var B_angle, out var B_axis); //A.m_rot.ToAngleAxis(out var A_angle, out var A_axis); //MPClientExtrapolation.players_to_resolve[__instance] = new MPClientExtrapolation_Velocities { // Velocity = __instance.c_player_ship.c_rigidbody.velocity = (B.m_pos - A.m_pos) / Time.fixedDeltaTime, // AngularVelocity = ((B_angle * B_axis * Mathf.Deg2Rad) / Time.fixedDeltaTime) - ((A_angle * A_axis * Mathf.Deg2Rad) / Time.fixedDeltaTime), // Drag = __instance.c_player_ship.c_rigidbody.drag, // LocalPosition = Vector3.LerpUnclamped(A.m_pos, B.m_pos, t + 1), // Rotation = Quaternion.SlerpUnclamped(A.m_rot, B.m_rot, t + 1) //}; }
public override void OnClientInbound(PlayerSnapshot snapshot) { if (ItemManager.SelectedItem != null && ItemManager.SelectedItemIndex == snapshot.SelectedItem) { if (ItemManager.SelectedItem is Gun gun) { gun.ServerMag = snapshot.CurrentMag; gun.ServerStoredAmmo = snapshot.StoredAmmo; } } Health = snapshot.Health; NumBlocks = snapshot.NumBlocks; NumGrenades = snapshot.NumGrenades; NumMelons = snapshot.NumMelons; HitFeedbackPositions.Clear(); foreach (Vector3 vec in snapshot.HitFeedbackSnapshot.Hits) { HitFeedbackPositions.Add(vec); } HitPlayer = snapshot.HitEnemy > 0; if (HitFeedbackPositions.Count > 0) { hitAudioSource?.Play(); if (!camfx.IsShaking) { camfx.ShakeCamera(0.2f, 0.05f); } } }
public override void OnClientInbound(PlayerSnapshot snapshot) { ItemManager.Equip(snapshot.SelectedItem, forceEquip: true); ItemManager.MuzzleFlashIterations += snapshot.TimesShot; yawAnim.SetTarget(snapshot.CamYaw); pitchAnim.SetTarget(snapshot.CamPitch); interpPos.SetTarget(new Vector3(snapshot.X, snapshot.Y, snapshot.Z)); flashlight.Visible = snapshot.IsFlashlightOn; reload = snapshot.IsReloading; CharacterController.IsCrouching = snapshot.IsCrouching; IsSprinting = snapshot.IsSprinting; isMoving = snapshot.IsMoving; IsAiming = snapshot.IsAiming; isGrounded = snapshot.IsGrounded; jump = snapshot.IsJumping; if (isGrounded && !lastGrounded) { land = true; } lastGrounded = snapshot.IsGrounded; }
static bool Prefix() { if (Client.m_InterpolationBuffer[0] == null || Client.m_InterpolationBuffer[1] == null || Client.m_InterpolationBuffer[2] == null) { return(true); } float num = CalculateLerpParameter(); PlayerSnapshotToClientMessage msg; PlayerSnapshotToClientMessage msg2; msg = Client.m_InterpolationBuffer[1]; msg2 = Client.m_InterpolationBuffer[2]; foreach (Player player in Overload.NetworkManager.m_Players) { if (player != null && !player.isLocalPlayer && !player.m_spectator) { PlayerSnapshot playerSnapshotFromInterpolationBuffer = (PlayerSnapshot)_Client_GetPlayerSnapshotFromInterpolationBuffer_Method.Invoke(null, new object[] { player, msg }); PlayerSnapshot playerSnapshotFromInterpolationBuffer2 = (PlayerSnapshot)_Client_GetPlayerSnapshotFromInterpolationBuffer_Method.Invoke(null, new object[] { player, msg2 }); if (playerSnapshotFromInterpolationBuffer != null && playerSnapshotFromInterpolationBuffer2 != null) { LerpRemotePlayer(player, playerSnapshotFromInterpolationBuffer, playerSnapshotFromInterpolationBuffer2, num); } } } return(false); }
// Loads a snapshot of a previous state public void LoadSnapshot(PlayerSnapshot snapshot) { //Debug.Log("rewinding... Cost before: " + costSoFar); MoveToMapPosition(snapshot.position); costSoFar = snapshot.costSoFar; //Debug.Log("Cost after: " + costSoFar); }
public void MergeFrom(GetChamberStateResponse other) { if (other == null) { return; } if (other.Status != 0) { Status = other.Status; } if (other.state_ != null) { if (state_ == null) { State = new global::WUProtos.Data.ChamberState(); } State.MergeFrom(other.State); } if (other.playerSnapshot_ != null) { if (playerSnapshot_ == null) { PlayerSnapshot = new global::WUProtos.Data.Client.ClientPlayerSnapshot(); } PlayerSnapshot.MergeFrom(other.PlayerSnapshot); } if (other.NextCallTimestamp != 0L) { NextCallTimestamp = other.NextCallTimestamp; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public override int GetHashCode() { int hash = 1; if (Status != 0) { hash ^= Status.GetHashCode(); } if (state_ != null) { hash ^= State.GetHashCode(); } if (playerSnapshot_ != null) { hash ^= PlayerSnapshot.GetHashCode(); } if (PartnerId.Length != 0) { hash ^= PartnerId.GetHashCode(); } if (FortressCooldownLeftMs != 0UL) { hash ^= FortressCooldownLeftMs.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// TODO: If you ever figure out how to find the end of a BitStream, remove the count header from this. public static void Serialize(this BitStream @this, IDictionary<string, PlayerSnapshot> value) { if (@this.isWriting) { // Write count to stream first int count = value.Count(); @this.Serialize(ref count); // Then write all deltas foreach (var item in value) { string guid = item.Key; @this.Serialize(ref guid); @this.Serialize(item.Value); } } else { // Read count from stream first int count = 0; @this.Serialize(ref count); // Then read all deltas for (int i = 0; i < count; i++) { string guid = null; @this.Serialize(ref guid); PlayerSnapshot snapshot = new PlayerSnapshot(); @this.Serialize(snapshot); value.Add(guid, snapshot); } } }
public static void act(PlayerSnapshot ps) { if (duration[ps.id] == 0) { double action = rands[ps.id].NextDouble(); PlayerAction act = PlayerAction.MoveBack; if (action < 0.25) { act = PlayerAction.MoveForward; } else if (action < 0.5) { act = PlayerAction.MoveRight; } else if (action < 0.75) { act = PlayerAction.MoveBack; } else if (action < 1) { act = PlayerAction.MoveLeft; } actions[ps.id] = act; duration[ps.id] = GlobalSettings.AIDuration; } Mover.GetInstance().ApplyAction(ps, actions[ps.id], 1.0f / GlobalSettings.Fps); duration[ps.id]--; }
public override int GetHashCode() { int hash = 1; if (Status != 0) { hash ^= Status.GetHashCode(); } if (state_ != null) { hash ^= State.GetHashCode(); } if (playerSnapshot_ != null) { hash ^= PlayerSnapshot.GetHashCode(); } if (NextCallTimestamp != 0L) { hash ^= NextCallTimestamp.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
void Start() { player = GetComponent <Player>(); animUpdater = GetComponent <PlayerAnimationUpdate>(); current = new PlayerSnapshot(); scale = Mathf.Abs(transform.localScale.x); if (!isLocalPlayer) { GetComponent <Rigidbody2D>().isKinematic = true; GetComponent <SpriteRenderer>().enabled = false; //player.t_hand.GetComponent<SpriteRenderer>().enabled = false; //player.t_weapon.GetComponent<SpriteRenderer>().enabled = false; GameObject go = GameSystem.LoadPool("puppet", transform.position); puppet = go.GetComponent <MyNetworkPuppet>(); puppet.target = gameObject; puppet.player = GetComponent <Player>(); puppet.LoadWeapon(GameManager.weapon); GameSystem.CopyComponent(GetComponent <PlayerAnimationUpdate>(), go); animUpdater = puppet.GetComponent <PlayerAnimationUpdate>(); InputSystem.listPuppet.Add(puppet); } InvokeRepeating("TransmitPosition", 0.2f, 0.2f); }
// TODO: If you ever figure out how to find the end of a BitStream, remove the count header from this. public static void Serialize(this BitStream @this, IDictionary <string, PlayerSnapshot> value) { if (@this.isWriting) { // Write count to stream first int count = value.Count(); @this.Serialize(ref count); // Then write all deltas foreach (var item in value) { string guid = item.Key; @this.Serialize(ref guid); @this.Serialize(item.Value); } } else { // Read count from stream first int count = 0; @this.Serialize(ref count); // Then read all deltas for (int i = 0; i < count; i++) { string guid = null; @this.Serialize(ref guid); PlayerSnapshot snapshot = new PlayerSnapshot(); @this.Serialize(snapshot); value.Add(guid, snapshot); } } }
public void SyncToSnapshot(PlayerSnapshot playerSnapshot) { transform.position = playerSnapshot.position; transform.rotation = playerSnapshot.rotation; MouseOrbit.transform.position = playerSnapshot.mouseOrbitPosition; MouseOrbit.transform.rotation = playerSnapshot.mouseOrbitrotation; MouseOrbit.x = playerSnapshot.mouseOrbitX; MouseOrbit.y = playerSnapshot.mouseOrbitY; XMovement = playerSnapshot.xMovement; ZMovement = playerSnapshot.zMovement; EquipWeaponByName(playerSnapshot.equippedWeapon); IsWeaponRaised = playerSnapshot.isWeaponRaised; IsWeaponBlocking = playerSnapshot.isWeaponBlocking; UpdatePointOfAim(); lastAppliedCommandTime = playerSnapshot.lastAppliedCommandTime; hp = playerSnapshot.hp; isDead = playerSnapshot.isDead; hasSwingStruck = playerSnapshot.hasSwingStruck; }
public void ApplyAction(PlayerSnapshot ps, PlayerAction action, float duration) { switch (action) { case PlayerAction.MoveForward: ps.player.transform.Translate(Vector3.forward * GlobalSettings.speed * duration); break; case PlayerAction.MoveRight: ps.player.transform.Translate(Vector3.right * GlobalSettings.speed * duration); break; case PlayerAction.MoveBack: ps.player.transform.Translate(Vector3.back * GlobalSettings.speed * duration); break; case PlayerAction.MoveLeft: ps.player.transform.Translate(Vector3.left * GlobalSettings.speed * duration); break; case PlayerAction.Shoot: break; default: throw new NotImplementedException(); break; } ps.position = ps.player.transform.position; }
private void FixedUpdate() { PlayerSnapshot snapshot = NetworkManager.Instance.snapshot; if (snapshot != null) { // rotation Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); Vector2 inputDir = input.normalized; Vector3 euler = player.transform.eulerAngles; if (inputDir != Vector2.zero) { float targetRotation = Mathf.Atan2(inputDir.x, inputDir.y) * Mathf.Rad2Deg + cameraT.eulerAngles.y; euler = Vector3.up * Mathf.SmoothDampAngle(player.transform.eulerAngles.y, targetRotation, ref turnSmoothVelocity, turnSmoothTime); } // Client-side prediction rb.position = snapshot.player.position; Vector3 newPosition = new Vector3(0, 0, 0); PlayerRequest request; if (NetworkManager.Instance.requests.TryPeek(out request)) { while (request.sequenceNumber < snapshot.acknowledgmentNumber) { NetworkManager.Instance.requests.TryDequeue(out request); } float speed = 0; float magnitude = 0; float timeDelta = 0; Vector3 direction = new Vector3(0, 0, 0); foreach (PlayerRequest r in new List <PlayerRequest>(NetworkManager.Instance.requests)) { speed = ((r.isRunning) ? runSpeed : walkSpeed); magnitude = r.magnitude; timeDelta += r.timeDelta; direction = r.direction; newPosition = rb.position + r.direction * speed * r.magnitude * r.timeDelta; Ray ray = new Ray(rb.position + new Vector3(0, 1.7f, 0), r.direction); RaycastHit hit; if (!Physics.Raycast(ray, out hit, 0.5f + speed * r.magnitude * r.timeDelta)) { lineRenderer.enabled = false; rb.MovePosition(newPosition); } } rb.MoveRotation(Quaternion.Euler(euler)); } } }
private void LogSyncToSnapshot(string context, double snapshotTime, PlayerSnapshot playerSnapshot) { if (_isLogging) { _logStreamWriter.WriteLine("{0:0.000}: {1}=[time={2:0.000}, lastack={3:0.000}], {4}]", Network.time, context, snapshotTime, playerSnapshot.lastAppliedCommandTime, playerSnapshot); } }
internal static NewPlayerSnapshot FromOldSnapshot(PlayerSnapshot s) { return(s == null ? new NewPlayerSnapshot() : new NewPlayerSnapshot { m_net_id = s.m_net_id, m_pos = s.m_pos, m_rot = s.m_rot, m_vel = new Vector3(), m_vrot = new Vector3() }); }
public void handleSelfSnapshot(PlayerSnapshot playerSnapshot) { Player p = self; p.Health = playerSnapshot.Health; p.Invulnerable = playerSnapshot.Invulnerable; p.gameObject.transform.position = playerSnapshot.position; if (prediction) { p.prediction(playerSnapshot.lastId); } }
private static PlayerSnapshot GetPlayerSnapshotFromInterpolationBuffer(Player p, PlayerSnapshotToClientMessage msg) { for (int i = 0; i < msg.m_num_snapshots; i++) { PlayerSnapshot playerSnapshot = msg.m_snapshots[i]; if (GetPlayerFromNetId(playerSnapshot.m_net_id) == p) { return(playerSnapshot); } } return(null); }
public void OnServerOutbound(PlayerSnapshot snapshot) { if (snapshot.NetId != StateInfo.Id) { throw new Exception( string.Format("PlayerSnapshot initId does not match ServerMPPlayer's netId! initId {0} != netId {1}", snapshot.NetId, StateInfo.Id)); } snapshot.NetId = StateInfo.Id; snapshot.SelectedItem = (byte)ItemManager.SelectedItemIndex; if (snapshot.IsOwner) { // Owner-only data if (ItemManager.SelectedItem != null) { if (ItemManager.SelectedItem is Gun gun) { snapshot.CurrentMag = (byte)gun.CurrentMag; snapshot.StoredAmmo = (ushort)gun.StoredAmmo; } } snapshot.Health = Health; snapshot.NumBlocks = (ushort)NumBlocks; snapshot.NumGrenades = (byte)NumGrenades; snapshot.NumMelons = (byte)NumMelons; } else { // Replicated-only data snapshot.X = Transform.Position.X; snapshot.Y = Transform.Position.Y; snapshot.Z = Transform.Position.Z; snapshot.IsFlashlightOn = ClientSnapshot.IsFlashlightVisible; snapshot.IsReloading = reloaded; snapshot.IsCrouching = ClientSnapshot.IsCrouching; snapshot.IsSprinting = ClientSnapshot.IsSprinting; snapshot.IsMoving = ClientSnapshot.IsMoving; snapshot.IsAiming = ClientSnapshot.IsAiming; snapshot.IsGrounded = ClientSnapshot.IsGrounded; snapshot.IsJumping = jumped; snapshot.CamYaw = ClientSnapshot.CamYaw; snapshot.CamPitch = ClientSnapshot.CamPitch; snapshot.TimesShot = (byte)ItemManager.MuzzleFlashIterations; } }
public static PlayerSnapshot SnapshotDeserialize(Decompressor decompressor) { int id = decompressor.GetNumber(GlobalSettings.MaxPlayers); PlayerSnapshot playerSnapshot = new PlayerSnapshot(id); playerSnapshot._TimeStamp = CompressingUtils.GetTime(decompressor); playerSnapshot.Health = decompressor.GetNumber(GlobalSettings.MaxHealth); playerSnapshot.Invulnerable = decompressor.GetBoolean(); playerSnapshot.position = CompressingUtils.GetPosition(decompressor); playerSnapshot.lastId = decompressor.GetNumber(GlobalSettings.MaxACK); return(playerSnapshot); }
static bool Prefix(Player __instance, PlayerSnapshot A, PlayerSnapshot B, float t) { if (__instance.m_lerp_wait_for_respawn_pos) { return(true); } Vector3 C_pos = B.m_pos + (B.m_pos - A.m_pos); __instance.c_player_ship.c_transform.localPosition = Vector3.Lerp(B.m_pos, C_pos, t); __instance.c_player_ship.c_transform.rotation = Quaternion.Slerp(A.m_rot, B.m_rot, t); __instance.c_player_ship.c_mesh_collider_trans.localPosition = __instance.c_player_ship.c_transform.localPosition; return(false); }
public PlayerSnapshot interpolate(PlayerSnapshot past, PlayerSnapshot future, float time) { float timeRatio = (time - past._TimeStamp) / (future._TimeStamp - past._TimeStamp); PlayerSnapshot interpolatedPlayerSnapshot = new PlayerSnapshot(past.id); interpolatedPlayerSnapshot._TimeStamp = time; interpolatedPlayerSnapshot.Health = past.Health; interpolatedPlayerSnapshot.Invulnerable = past.Invulnerable; interpolatedPlayerSnapshot.position = Vector3.Lerp(past.position, future.position, timeRatio); Vector3 interpolatedRotation = Vector3.Lerp(past.rotation.eulerAngles, future.rotation.eulerAngles, timeRatio); interpolatedPlayerSnapshot.rotation = Quaternion.Euler(interpolatedRotation); return(interpolatedPlayerSnapshot); }
public void UpdateState(string jsonOld, string jsonNew) { if (isLocalPlayer) { return; } current = JsonUtility.FromJson <PlayerSnapshot>(jsonNew); player.state = current.state; player.direction = current.direction; animUpdater.UpdateAnim(current.state); updateTime = Time.time; }
/// <summary> /// Deserialize the snapshot without compression. /// </summary> /// <param name="reader"></param> public override void Deserialize(NetworkReader reader) { m_num_snapshots = (int)reader.ReadByte(); for (int i = 0; i < m_num_snapshots; i++) { NetworkInstanceId net_id = reader.ReadNetworkId(); Vector3 pos = default(Vector3); pos.x = reader.ReadSingle(); pos.y = reader.ReadSingle(); pos.z = reader.ReadSingle(); Quaternion rot = reader.ReadQuaternion(); m_snapshots[i] = new PlayerSnapshot(net_id, pos, rot); } }
public static void Main(string[] args) { ApplicationLogging.LoggerFactory.AddConsole(); var logger = ApplicationLogging.CreateLogger <Program>(); var importer = new Importer(SettingsManager.ApplicationSettings.ServerPath); var f = Parallel.ForEach( SettingsManager.ApplicationSettings.Profiles, new ParallelOptions { MaxDegreeOfParallelism = SettingsManager.ApplicationSettings.MaxScrapperThreads }, (s, state, arg3) => { Console.WriteLine("Fetching profile " + s); try { var task = importer.ImportAndSaveProfileToCacheAsync(BattleNetProfile.ParseTag(s)); task.Wait(); } catch (Exception ex) { logger.LogError(new EventId(ApplicationLogging.ImportEvent), string.Format("Failed to import profile {0}. Error: {1}", s, ex.Message)); } }); // Debug / code can be remove for production... var dateDirs = Directory.GetDirectories(SettingsManager.ApplicationSettings.SaveLocation); foreach (var dir in dateDirs) { var date = new DateTime(Convert.ToInt64(Path.GetFileName(dir))); foreach (var p in SettingsManager.ApplicationSettings.Profiles) { var filename = dir + Path.DirectorySeparatorChar + p.Replace('#', '-') + ".html"; if (File.Exists(filename)) { var snapshot = new PlayerSnapshot(File.ReadAllText(filename)); snapshot.ParseHtml(); logger.LogInformation(new EventId(ApplicationLogging.ImportEvent), "{0} has won {1} games as of {2}", p, snapshot.GamesWon, date.ToString("D")); logger.LogInformation(snapshot.PlayerIcon.ToString()); } } } Console.WriteLine("Completed fetching profiles."); }
private void SetupTest() { player = TestingTools.ConstructPlayer(); player.transform.position = Vector3.zero; player.transform.eulerAngles = Vector3.one * 10; player.transform.localScale = Vector3.zero; player.SetFacing(Facing.Left); player.gameObject.SetActive(true); snapshot = new PlayerSnapshot(player); player.transform.position = Vector3.one; player.transform.eulerAngles = Vector3.one; player.transform.localScale = Vector3.one; player.SetFacing(Facing.Left); player.gameObject.SetActive(true); absA = new AbsolutePoseInfo(); absA.Position = new Vector3(-10, -10, -10); absA.Rotation = Vector3.zero; absA.Scale = new Vector3(-10, -10, -10); absA.State = typeof(SingleJumpFall); absA.Flipped = true; absA.Active = true; absB = new AbsolutePoseInfo(); absB.Position = new Vector3(10, 10, 10); absB.Rotation = new Vector3(20, 20, 20); absB.Scale = new Vector3(10, 10, 10); absB.State = typeof(Running); absB.Flipped = false; absB.Active = false; relA = new RelativePoseInfo(); relA.Position = new Vector3(-10, -10, -10); relA.Rotation = Vector3.zero; relA.Scale = new Vector3(-10, -10, -10); relA.State = typeof(SingleJumpFall); relA.Flipped = true; relA.Active = true; relB = new RelativePoseInfo(); relB.Position = new Vector3(10, 10, 10); relB.Rotation = new Vector3(20, 20, 20); relB.Scale = new Vector3(10, 10, 10); relB.State = typeof(Running); relB.Flipped = false; relB.Active = false; }
internal void Add(ulong gcNID, Protos.GC2BS_EndBattle endBattle) { //检查玩家是否重复提交 if (this._playerSnapshots.Any(snapshot => snapshot.gcNID == gcNID)) { Logger.Error($"user:{gcNID} duplicate commit snapshot!"); return; } PlayerSnapshot playerSnapshot = new PlayerSnapshot(); playerSnapshot.gcNID = gcNID; playerSnapshot.data = endBattle.Snapshot; playerSnapshot.crc = CRC32.Compute(endBattle.Snapshot.ToByteArray()); this._playerSnapshots.Add(playerSnapshot); }
internal void AppendNextSnapshot(int snapshotIndex) { if (!recordingComplete) { PlayerSnapshot snapshot = playerController.GetSnapshot(); snapshots.Add(snapshot); if (snapshot.Firing) { fireEvents.Add(snapshotIndex); } if (snapshot.UsingEquipment) { equipmentEvents.Add(snapshotIndex); } } }
private void UpdatePlayer(int id, float time) { List <PlayerInputMessage> playerActions = actions[id]; PlayerSnapshot ps = players[id]; ps._TimeStamp = this.time; while (playerActions.Count > 0) { PlayerInputMessage mssg = playerActions[0]; playerActions.RemoveAt(0); Mover.GetInstance().ApplyAction(ps, mssg.Action, time); ps.lastId = mssg._MessageId; } }
public static void Serialize(this BitStream @this, PlayerSnapshot value) { @this.Serialize(ref value.position); @this.Serialize(ref value.xMovement); @this.Serialize(ref value.zMovement); @this.Serialize(ref value.rotation); @this.Serialize(ref value.mouseOrbitPosition); @this.Serialize(ref value.mouseOrbitrotation); @this.Serialize(ref value.mouseOrbitX); @this.Serialize(ref value.mouseOrbitY); @this.Serialize(ref value.equippedWeapon); @this.Serialize(ref value.isWeaponRaised); @this.Serialize(ref value.isWeaponBlocking); @this.Serialize(ref value.lastAppliedCommandTime); @this.Serialize(ref value.hp); @this.Serialize(ref value.isDead); @this.Serialize(ref value.hasSwingStruck); }
public static void Serialize(this BitStream @this, PlayerSnapshot value) { @this.Serialize(ref value.position); @this.Serialize(ref value.xMovement); @this.Serialize(ref value.zMovement); @this.Serialize(ref value.rotation); @this.Serialize(ref value.mouseOrbitPosition); @this.Serialize(ref value.mouseOrbitrotation); @this.Serialize(ref value.mouseOrbitX); @this.Serialize(ref value.mouseOrbitY); @this.Serialize(ref value.equippedWeapon); @this.Serialize(ref value.isWeaponRaised); @this.Serialize(ref value.isWeaponBlocking); @this.Serialize(ref value.lastAppliedCommandTime); @this.Serialize(ref value.hp); @this.Serialize(ref value.isDead); @this.Serialize(ref value.hasSwingStruck); }
public void SyncToSnapshot(PlayerSnapshot playerSnapshot) { transform.position = playerSnapshot.position; transform.rotation = playerSnapshot.rotation; MouseOrbit.transform.position = playerSnapshot.mouseOrbitPosition; MouseOrbit.transform.rotation = playerSnapshot.mouseOrbitrotation; MouseOrbit.x = playerSnapshot.mouseOrbitX; MouseOrbit.y = playerSnapshot.mouseOrbitY; XMovement = playerSnapshot.xMovement; ZMovement = playerSnapshot.zMovement; EquipWeaponByName(playerSnapshot.equippedWeapon); IsWeaponRaised = playerSnapshot.isWeaponRaised; IsWeaponBlocking = playerSnapshot.isWeaponBlocking; UpdatePointOfAim(); lastAppliedCommandTime = playerSnapshot.lastAppliedCommandTime; hp = playerSnapshot.hp; isDead = playerSnapshot.isDead; hasSwingStruck = playerSnapshot.hasSwingStruck; }
private void LogSyncToSnapshot(string context, double snapshotTime, PlayerSnapshot playerSnapshot) { if (_isLogging) { _logStreamWriter.WriteLine("{0:0.000}: {1}=[time={2:0.000}, lastack={3:0.000}], {4}]", Network.time, context, snapshotTime, playerSnapshot.lastAppliedCommandTime, playerSnapshot); } }