private static void UpdateSub(SubRoot sub) { var gameObject = sub.gameObject; var res = new ClientVehicleMovement(); res.id = Multiplayer.main.self.id; res.vehicleGuid = GuidHelper.Get(gameObject); res.vehicleTech = TechType.Cyclops; res.position = gameObject.transform.position; res.rotation = gameObject.transform.rotation; var rigidbody = sub.GetComponent <Rigidbody>(); if (rigidbody != null) { res.velocity = rigidbody.velocity; res.angularVelocity = rigidbody.angularVelocity; } var subControl = sub.GetComponent <SubControl>(); if (subControl != null) { res.steeringWheelYaw = (float)subControl.ReflectionGet("steeringWheelYaw"); res.steeringWheelPitch = (float)subControl.ReflectionGet("steeringWheelPitch"); res.throttle = subControl.appliedThrottle && (bool)subControl.ReflectionGet("canAccel"); } Multiplayer.main.Send(res, DeliveryMethod.Sequenced); }
public override void SetAnimation(ClientVehicleMovement msg) { targetVelocity = msg.velocity; if (timeJetsChanged + 3f <= Time.time && lastThrottle != msg.throttle) { timeJetsChanged = Time.time; lastThrottle = msg.throttle; if (msg.throttle) { exosuit.loopingJetSound.Play(); exosuit.fxcontrol.Play(0); } else { exosuit.loopingJetSound.Stop(); exosuit.fxcontrol.Stop(0); } rigidbody.velocity = msg.velocity; } var animator = GetAnimator(); if (animator != null) { animator.SetBool("onGround", msg.grounded); animator.SetFloat("thrustIntensity", msg.thrust); } SetLeftArm(msg.useLeft); SetRightArm(msg.useRight); }
private void Process(ClientVehicleMovement msg) { var gameObject = GuidHelper.Find(msg.vehicleGuid, false); if (gameObject == null) { return; } SyncedVehicle mvc = null; var vehicle = (Vehicle)gameObject.GetComponent(typeof(Vehicle)); var subroot = (SubRoot)gameObject.GetComponent(typeof(SubRoot)); if (vehicle != null) { var seamoth = vehicle as SeaMoth; var exosuit = vehicle as Exosuit; if (seamoth != null) { mvc = seamoth.gameObject.EnsureComponent <SyncedSeamoth>(); } else if (exosuit != null) { mvc = exosuit.gameObject.EnsureComponent <SyncedExosuit>(); } } else if (subroot != null) { if (subroot.GetComponent <SubControl>() != null) { mvc = subroot.gameObject.EnsureComponent <SyncedCyclops>(); } } if (mvc != null) { mvc.Correct(msg.position, msg.rotation, msg.velocity, msg.timestamp); } RemotePlayer remotePlayer; if (remotePlayers.TryGetValue(msg.id, out remotePlayer)) { using (new MessageBlocker()) { remotePlayer.UpdateVehicleMovement(vehicle, subroot); } if (mvc != null) { mvc.SetAnimation(msg); mvc.SetSteeringWheel(msg.steeringWheelYaw, msg.steeringWheelPitch); } } }
private static void UpdateVehicle(Vehicle vehicle) { if (vehicle.docked) { return; } var gameObject = vehicle.gameObject; var res = new ClientVehicleMovement(); res.timestamp = DayNightCycle.main.timePassedAsDouble; res.id = Multiplayer.main.self.id; res.vehicleGuid = GuidHelper.Get(gameObject); res.vehicleTech = CraftData.GetTechType(gameObject); res.position = gameObject.transform.position; res.rotation = gameObject.transform.rotation; var rigidbody = vehicle.gameObject.GetComponent <Rigidbody>(); if (rigidbody != null) { res.velocity = rigidbody.velocity; res.angularVelocity = rigidbody.angularVelocity; } // Exosuit and Seamoth both have steering components. res.steeringWheelYaw = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelYaw"); res.steeringWheelPitch = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelPitch"); // Determine whether the vehicle movement is active or not. if (vehicle && AvatarInputHandler.main.IsEnabled()) { if (res.vehicleTech == TechType.Seamoth) { bool flag = vehicle.transform.position.y < Ocean.main.GetOceanLevel() && vehicle.transform.position.y < vehicle.worldForces.waterDepth && !vehicle.precursorOutOfWater; res.throttle = flag && GameInput.GetMoveDirection().sqrMagnitude > .1f; } else if (res.vehicleTech == TechType.Exosuit) { Exosuit exosuit = vehicle as Exosuit; if (exosuit) { res.throttle = (bool)exosuit.ReflectionGet("_jetsActive"); res.thrust = exosuit.mainAnimator.GetFloat("thrustIntensity"); res.grounded = exosuit.mainAnimator.GetBool("onGround"); res.useLeft = exosuit.mainAnimator.GetBool("use_tool_left"); res.useRight = exosuit.mainAnimator.GetBool("use_tool_right"); } } } Multiplayer.main.Send(res, DeliveryMethod.Sequenced); }
public override void SetAnimation(ClientVehicleMovement msg) { velocity = msg.velocity; angularVelocity = msg.angularVelocity; if (msg.throttle) { if (subThrottleHandlers != null) { foreach (var handler in subThrottleHandlers) { handler.OnSubAppliedThrottle(); } } } }
public override void SetAnimation(ClientVehicleMovement msg) { bool state = msg.throttle; if (state != lastThrottle) { if (state) { seamoth.bubbles.Play(); } else { seamoth.bubbles.Stop(); } lastThrottle = state; } }
private void Process(Client client, ClientVehicleMovement msg) { msg.id = client.id; SavedVehicle vehicle; if (state.history.vehicles.TryGetValue(msg.vehicleGuid, out vehicle)) { if (client.SetVehicle(vehicle)) { vehicle.position = msg.position; vehicle.rotation = msg.rotation; vehicle.movement = msg; SendToAll(client.peer, msg, DeliveryMethod.Sequenced); } } }
public abstract void SetAnimation(ClientVehicleMovement msg);