public override HashSet <IMyReplicable> GetDependencies()
        {
            m_dependencies.Clear();

            MyPlayerCollection playerCollection = MySession.Static.Players;
            var connectedPlayers = playerCollection.GetOnlinePlayers();

            foreach (var player in connectedPlayers)
            {
                if (player.Character == Instance)
                {
                    var broadcasters = Instance.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId);
                    foreach (var broadcaster in broadcasters)
                    {
                        IMyReplicable dep = MyExternalReplicable.FindByObject(broadcaster.Entity);
                        if (dep != null)
                        {
                            m_dependencies.Add(dep.GetParent() ?? dep);
                        }
                    }
                }
            }

            return(m_dependencies);
        }
        public override IMyReplicable GetDependency()
        {
            if (m_physicsSync == null || Grid.IsStatic)
            {
                return(null);
            }

            MyCubeGrid master = MyGridPhysicsStateGroup.GetMasterGrid(Grid);

            if (master != Grid)
            {
                return(MyExternalReplicable.FindByObject(master));
            }

            BoundingBoxD box   = Grid.PositionComp.WorldAABB;
            var          group = MyCubeGridGroups.Static.PhysicalDynamic.GetGroup(Grid);

            if (group != null)
            {
                foreach (var node in group.Nodes)
                {
                    box.Include(node.NodeData.PositionComp.WorldAABB);
                }
            }

            if (m_foundEntities == null)
            {
                m_foundEntities = new List <MyEntity>();
            }

            m_foundEntities.Clear();

            MyGamePruningStructure.GetTopMostEntitiesInBox(ref box, m_foundEntities);

            float      maxRadius   = 0;
            MyCubeGrid biggestGrid = null;

            foreach (var entity in m_foundEntities)
            {
                MyCubeGrid grid = entity as MyCubeGrid;
                if (grid != null)
                {
                    var rad = grid.PositionComp.LocalVolume.Radius;
                    if (rad > maxRadius || (rad == maxRadius && (biggestGrid == null || grid.EntityId > biggestGrid.EntityId)))
                    {
                        maxRadius   = rad;
                        biggestGrid = grid;
                    }
                }
            }

            if (biggestGrid != null && biggestGrid != Grid)
            {
                return(MyExternalReplicable.FindByObject(biggestGrid));
            }

            return(null);
        }
示例#3
0
 public static MyEntityPhysicsStateGroup FindPhysics(IMyEntity entity)
 {
     // We don't need to send position relative to static, it's useless
     if (entity != null && entity.Physics != null)
     {
         return(MyExternalReplicable.FindByObject(entity).FindStateGroup <MyEntityPhysicsStateGroup>());
     }
     return(null);
 }
        protected override void ClientWrite(VRage.Library.Collections.BitStream stream)
        {
            base.ClientWrite(stream);

            stream.WriteBool(m_character != null);
            if (m_character != null)
            {
                var  physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup <MyCharacterPhysicsStateGroup>();
                long?supportId = null;
                if (physGroup != null)
                {
                    physGroup.SetSupport(physGroup.FindSupportDelegate());
                    supportId = physGroup.GetSupportId();
                }

                stream.WriteBool(supportId.HasValue);
                if (supportId.HasValue)
                {
                    stream.WriteInt64(supportId.Value);
                }

                Vector3 position = m_character.MoveIndicator;
                stream.WriteHalf(position.X);
                stream.WriteHalf(position.Y);
                stream.WriteHalf(position.Z);

                Vector2 rotate = m_character.RotationIndicator;
                stream.WriteFloat(rotate.X);
                stream.WriteFloat(rotate.Y);

                stream.WriteFloat(m_character.RollIndicator);

                // Movement state, 2B
                stream.WriteUInt16((ushort)m_character.GetNetworkMovementState());
                // Movement flag.
                stream.WriteUInt16((ushort)m_character.PreviousMovementFlags);

                // Flags, 6 bits
                bool hasJetpack = m_character.JetpackComp != null;
                stream.WriteBool(hasJetpack ? m_character.JetpackComp.TurnedOn : false);
                stream.WriteBool(hasJetpack ? m_character.JetpackComp.DampenersTurnedOn : false);
                stream.WriteBool(m_character.LightEnabled);                      // TODO: Remove
                stream.WriteBool(m_character.ZoomMode == MyZoomModeEnum.IronSight);
                stream.WriteBool(m_character.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
                stream.WriteBool(m_character.TargetFromCamera);
                stream.WriteFloat(m_character.HeadLocalXAngle);
                stream.WriteFloat(m_character.HeadLocalYAngle);

                if ((hasJetpack && m_character.JetpackComp.TurnedOn) == false)
                {
                    MatrixD matrix = m_character.WorldMatrix;
                    stream.WriteQuaternionNorm(Quaternion.CreateFromForwardUp(matrix.Forward, matrix.Up));
                }
            }
        }
        public override IMyReplicable GetDependency()
        {
            Debug.Assert(!((MyEntity)Inventory.Owner).Closed, "Sending inventory of closed entity");

            if (Inventory.Owner is MyCubeBlock)
            {
                return(MyExternalReplicable.FindByObject((Inventory.Owner as MyCubeBlock).CubeGrid));
            }

            return(MyExternalReplicable.FindByObject(Inventory.Owner));
        }
示例#6
0
        public override float GetPriority(MyClientInfo client)
        {
            MyEntity owner  = Inventory.Owner.GetTopMostParent();
            var      parent = MyExternalReplicable.FindByObject(owner);

            if (parent != null && client.HasReplicable(parent) && parent.GetPriority(client) > 0.0f)
            {
                return(1.0f);
            }

            return(0.0f);
        }
        public override float GetPriority(MyClientInfo state, bool cached)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            ulong clientEndpoint = state.EndpointId.Value;

            if (cached)
            {
                if (m_cachedPriorityForClient != null && m_cachedPriorityForClient.ContainsKey(clientEndpoint))
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (m_cachedPriorityForClient == null)
            {
                m_cachedPriorityForClient = new Dictionary <ulong, float>();
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                priority = base.GetPriority(state, cached);
            }

            if (Instance.IsUsing is MyShipController)
            {
                if (priority < 0.01f)
                {
                    //force pilot to client wve when its too far away.
                    var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                    if (state.HasReplicable(parent))
                    {
                        priority = 1.0f;
                    }
                }
            }

            m_cachedPriorityForClient[clientEndpoint] = priority;
            return(priority);
        }
        public override IMyReplicable GetParent()
        {
            System.Diagnostics.Debug.Assert(!((MyEntity)CraftingComponent.Entity).Closed, "Sending inventory of closed entity");
            if (CraftingComponent.Entity is MyCharacter)
            {
                return(MyExternalReplicable.FindByObject(CraftingComponent.Entity));
            }

            if (CraftingComponent.Entity is MyCubeBlock)
            {
                return(MyExternalReplicable.FindByObject((CraftingComponent.Entity as MyCubeBlock).CubeGrid));
            }

            return(null);
        }
        public override IMyReplicable GetDependency()
        {
            if (Instance.IsUsing is MyShipController)
            {
                return(MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid));
            }

            if (MyPerGameSettings.BlockForVoxels)
            {
                foreach (var voxelMap in MySession.Static.VoxelMaps.Instances)
                {
                    return(MyExternalReplicable.FindByObject(voxelMap));
                }
            }
            return(null);
        }
        public override IMyReplicable GetParent()
        {
            Debug.Assert(Inventory.Entity != Inventory, "Inventory owner is inventory!");
            Debug.Assert(!((MyEntity)Inventory.Entity).Closed, "Sending inventory of closed entity");
            if (Inventory.Entity is MyCharacter)
            {
                return(MyExternalReplicable.FindByObject(Inventory.Entity));
            }

            if (Inventory.Entity is MyCubeBlock)
            {
                return(MyExternalReplicable.FindByObject((Inventory.Entity as MyCubeBlock).CubeGrid));
            }

            return(null);
        }
        public override float GetPriority(MyClientInfo client, bool cached)
        {
            MyEntity owner = Inventory.Owner.GetTopMostParent();

            if (owner != m_owner)
            {
                m_owner  = owner;
                m_parent = MyExternalReplicable.FindByObject(owner);
            }

            if (m_parent != null && client.HasReplicable(m_parent))
            {
                return(1.0f);
            }

            return(0.0f);
        }
示例#12
0
        public override void ClientUpdate(uint timestamp)
        {
            base.ClientUpdate(timestamp);

            if (MySession.Static.ControlledEntity != m_character)
            {
                if (m_supportTimeStamp != null)
                {
                    m_supportTimeStamp.Clear();
                }
                return;
            }

            var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup <MyCharacterPhysicsStateGroup>();

            if (physGroup == null)
            {
                if (m_supportTimeStamp != null)
                {
                    m_supportTimeStamp.Clear();
                }
                return;
            }

            m_supportPhysics = physGroup.FindSupportDelegate();
            physGroup.SetSupport(m_supportPhysics);
            if (m_supportPhysics != null)
            {
                if (m_supportTimeStamp == null)
                {
                    m_supportTimeStamp = new MyTimestampHelper(null);
                }

                m_supportTimeStamp.SetEntity(m_supportPhysics.Entity);
                m_supportTimeStamp.Update(timestamp);
            }
            else
            {
                if (m_supportTimeStamp != null)
                {
                    m_supportTimeStamp.Clear();
                }
            }
        }
        public override float GetPriority(MyClientInfo state)
        {
            if (Grid == null || Grid.Projector != null || Grid.IsPreview)
            {
                return(0.0f);
            }

            float priority = base.GetPriority(state);

            if (priority == 0.0f)
            {
                MyPlayerCollection playerCollection = MySession.Static.Players;

                var connectedPlayers = playerCollection.GetOnlinePlayers();

                foreach (var player in connectedPlayers)
                {
                    if (player.Client.SteamUserId == state.EndpointId.Value && player.Character != null)
                    {
                        var broadcasters = player.Character.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId);
                        foreach (var broadcaster in broadcasters)
                        {
                            var cubeblock = broadcaster.Entity as MyCubeBlock;
                            if (cubeblock != null && cubeblock.CubeGrid == Grid)
                            {
                                return(0.1f); // Minimal priority, update, but not that often
                            }
                        }
                    }
                }
            }

            if (MyFakes.ENABLE_SENT_GROUP_AT_ONCE)
            {
                MyCubeGrid master = MyGridPhysicsStateGroup.GetMasterGrid(Grid);
                if (master != Grid)
                {
                    return(MyExternalReplicable.FindByObject(master).GetPriority(state));
                }
            }
            return(priority);
        }
示例#14
0
        public override float GetPriority(MyClientInfo client)
        {
            if (m_clientList == null)
            {
                m_clientList = new HashSet <ulong>();
            }

            if (m_clientList.Contains(client.EndpointId.Value))
            {
                return(1.0f);
            }

            MyEntity owner  = Inventory.Owner.GetTopMostParent();
            var      parent = MyExternalReplicable.FindByObject(owner);

            if (parent != null && client.HasReplicable(parent))
            {
                m_clientList.Add(client.EndpointId.Value);
                return(1.0f);
            }

            return(0.0f);
        }
示例#15
0
        public override float GetPriority(MyClientInfo state)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                priority = base.GetPriority(state);
            }

            if (Instance.IsUsing is MyShipController)
            {
                if (priority < 0.01f)
                {
                    //force pilot to client wve when its too far away.
                    var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                    if (state.HasReplicable(parent))
                    {
                        priority = 1.0f;
                    }
                }
            }

            return(priority);
        }
 void DestroyReplicable(MyExternalReplicable obj)
 {
     ReplicationLayer.Destroy(obj);
 }
        public override IMyReplicable GetParent()
        {
            if (m_physicsSync == null || Grid == null || Grid.IsStatic)
            {
                return(null);
            }

            /*MyCubeGrid master = MyGridPhysicsStateGroup.GetMasterGrid(Grid);
             * if (master != Grid)
             * {
             *  if (master != null)
             *  {
             *      return MyExternalReplicable.FindByObject(master);
             *  }
             *  return null;
             * }*/

            float      maxRadius   = 0;
            MyCubeGrid biggestGrid = null;

            BoundingBoxD box   = Grid.PositionComp.WorldAABB;
            var          group = MyCubeGridGroups.Static.PhysicalDynamic.GetGroup(Grid);

            if (group != null)
            {
                foreach (var node in group.Nodes)
                {
                    // box.Include(node.NodeData.PositionComp.WorldAABB);

                    MyCubeGrid grid = node.NodeData as MyCubeGrid;

                    if (grid != null)
                    {
                        // Dont check for projections
                        if (grid.Projector != null)
                        {
                            continue;
                        }

                        var rad = grid.PositionComp.LocalVolume.Radius;
                        if (rad > maxRadius || (rad == maxRadius && (biggestGrid == null || grid.EntityId > biggestGrid.EntityId)))
                        {
                            maxRadius   = rad;
                            biggestGrid = grid;
                        }
                    }
                }
            }


            if (biggestGrid != null && biggestGrid != Grid)
            {
                return(MyExternalReplicable.FindByObject(biggestGrid));
            }

            return(null);

            //if(m_foundEntities == null)
            //{
            //    m_foundEntities = new List<MyEntity>();
            //}

            //m_foundEntities.Clear();

            //MyGamePruningStructure.GetTopMostEntitiesInBox(ref box, m_foundEntities);
        }
示例#18
0
        protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId, uint timestamp)
        {
            base.ServerRead(stream, clientId, timestamp);
            bool clientHasCharacter = stream.ReadBool();

            if (clientHasCharacter)
            {
                MyEntity support;
                bool     hasSupport      = stream.ReadBool();
                Vector3D supportPosition = Vector3D.Zero;

                if (m_character != null)
                {
                    var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup <MyCharacterPhysicsStateGroup>();
                    if (physGroup != null)
                    {
                        m_support = MySupportHelper.FindSupportForCharacterAABB(m_character);
                        physGroup.SetSupport(MySupportHelper.FindPhysics(m_support));
                    }
                }

                if (hasSupport)
                {
                    long supportId = stream.ReadInt64();
                    bool apply     = MyEntities.TryGetEntityById(supportId, out support);
                    supportPosition = stream.ReadVector3D();
                }


                if (m_additionalServerClientData == null)
                {
                    m_additionalServerClientData = new Dictionary <ulong, ClientData>();
                }

                m_additionalServerClientData[clientId] = new ClientData()
                {
                    HasSupport = hasSupport, SupportPosition = supportPosition
                };

                Vector3 move = new Vector3();
                move.X = stream.ReadHalf();
                move.Y = stream.ReadHalf();
                move.Z = stream.ReadHalf();

                Vector2 rotate = new Vector2();
                rotate.X = stream.ReadFloat();
                rotate.Y = stream.ReadFloat();

                float roll = stream.ReadFloat();

                MyCharacterMovementEnum  MovementState = (MyCharacterMovementEnum)stream.ReadUInt16();
                MyCharacterMovementFlags MovementFlag  = (MyCharacterMovementFlags)stream.ReadUInt16();

                bool  Jetpack          = stream.ReadBool();
                bool  Dampeners        = stream.ReadBool();
                bool  Lights           = stream.ReadBool(); // TODO: Remove
                bool  Ironsight        = stream.ReadBool();
                bool  Broadcast        = stream.ReadBool(); // TODO: Remove
                bool  TargetFromCamera = stream.ReadBool();
                float headXAngle       = stream.ReadFloat();
                float headYAngle       = stream.ReadFloat();

                if (m_character == null)
                {
                    return;
                }

                if (m_character.IsUsing != null)
                {
                    return;
                }

                var jetpack = m_character.JetpackComp;
                if (jetpack != null)
                {
                    if (Jetpack != jetpack.TurnedOn)
                    {
                        jetpack.TurnOnJetpack(Jetpack, true);
                    }
                    if (Dampeners != jetpack.DampenersTurnedOn)
                    {
                        jetpack.EnableDampeners(Dampeners, false);
                    }
                }

                if (Lights != m_character.LightEnabled)
                {
                    m_character.EnableLights(Lights);
                }

                if (m_character.RadioBroadcaster != null && Broadcast != m_character.RadioBroadcaster.Enabled)
                {
                    m_character.EnableBroadcasting(Broadcast);
                }

                m_character.TargetFromCamera = TargetFromCamera;

                // Set client movement state directly and don't perform other operations
                // that may have side-effects to let server side Character.UpdateAfterSimulation()
                // perform exactly same operations as on client
                m_character.MovementFlags = MovementFlag;
                if (m_character.IsDead == false)
                {
                    m_character.SetCurrentMovementState(MovementState);
                }
                m_character.HeadLocalXAngle = headXAngle;
                m_character.HeadLocalYAngle = headYAngle;
                if (m_commandsApplied == null)
                {
                    m_commandsApplied = new Dictionary <ulong, bool>();
                }

                if (Vector3.IsZero(move, 0.01f) == false || Vector2.IsZero(ref rotate, 0.01f) == false || Math.Abs(roll - 0.0) > 0.01f)
                {
                    m_commandsApplied[clientId] = true;
                }

                m_character.CacheMove(ref move, ref rotate, ref roll);
            }
        }
示例#19
0
        public override float GetPriority(MyClientInfo state, bool cached)
        {
            if (Grid == null || Grid.Projector != null || Grid.IsPreview)
            {
                return(0.0f);
            }


            ulong clientEndpoint = state.EndpointId.Value;

            if (cached)
            {
                if (m_cachedPriorityForClient != null && m_cachedPriorityForClient.ContainsKey(clientEndpoint))
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (m_cachedPriorityForClient == null)
            {
                m_cachedPriorityForClient = new Dictionary <ulong, float>();
            }

            float priority = base.GetPriority(state, cached);

            m_cachedPriorityForClient[clientEndpoint] = priority;

            if (priority < 0.1f)
            {
                if (m_clientState == null)
                {
                    m_clientState = new Dictionary <ulong, int>();
                }

                if (m_clientState.ContainsKey(clientEndpoint))
                {
                    m_clientState[state.EndpointId.Value]++;
                }
                else
                {
                    m_clientState[state.EndpointId.Value] = 0;
                }

                if (m_clientState[state.EndpointId.Value] % ANTENNA_UPDATE_TIME == 0)
                {
                    m_clientState[state.EndpointId.Value] = 0;
                    MyPlayerCollection playerCollection = MySession.Static.Players;
                    var connectedPlayers = playerCollection.GetOnlinePlayers();

                    foreach (var player in connectedPlayers)
                    {
                        if (player.Client.SteamUserId == state.EndpointId.Value && player.Character != null)
                        {
                            var broadcasters = player.Character.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId);
                            foreach (var broadcaster in broadcasters)
                            {
                                var cubeblock = broadcaster.Entity as MyCubeBlock;
                                if (cubeblock != null && cubeblock.CubeGrid == Grid)
                                {
                                    m_cachedPriorityForClient[clientEndpoint] = 0.1f;
                                    return(m_cachedPriorityForClient[clientEndpoint]); // Minimal priority, update, but not that often
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (MyFakes.ENABLE_SENT_GROUP_AT_ONCE)
            {
                MyCubeGrid master = MyGridPhysicsStateGroup.GetMasterGrid(Grid);
                if (master != Grid)
                {
                    return(MyExternalReplicable.FindByObject(master).GetPriority(state, cached));
                }
            }
            return(priority);
        }
        public override float GetPriority(MyClientInfo state, bool cached)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            ulong clientEndpoint = state.EndpointId.Value;

            if (cached)
            {
                if (m_cachedPriorityForClient != null && m_cachedPriorityForClient.ContainsKey(clientEndpoint))
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (m_cachedPriorityForClient == null)
            {
                m_cachedPriorityForClient = new Dictionary <ulong, float>();
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                //Sync all characters now, as they can serve as antenna relay
                priority = 0.1f;
                //priority = base.GetPriority(state, cached);
            }

            if (Instance.IsUsing is MyShipController)
            {
                //Pilot cannot have higher priority than the grid they control. Otherwise bugs ensue
                var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                if (state.HasReplicable(parent))
                {
                    priority = parent.GetPriority(state, cached);
                }
                else
                {
                    priority = 0.0f;
                }
            }

            if (MyFakes.MP_ISLANDS)
            {
                BoundingBoxD aabb;

                if (player.Character != null)
                {
                    if (MyIslandSyncComponent.Static.GetIslandAABBForEntity(player.Character, out aabb))
                    {
                        var ipriority = GetBasePriority(aabb.Center, aabb.Size, state);

                        MyIslandSyncComponent.Static.SetPriorityForIsland(player.Character, state.EndpointId.Value, ipriority);

                        return(ipriority);
                    }
                }
            }


            m_cachedPriorityForClient[clientEndpoint] = priority;
            return(priority);
        }
        protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId, uint timestamp)
        {
            base.ServerRead(stream, clientId, timestamp);
            bool clientHasCharacter = stream.ReadBool();

            if (clientHasCharacter)
            {
                MyEntity support;
                if (stream.ReadBool())
                {
                    bool apply = MyEntities.TryGetEntityById(stream.ReadInt64(), out support);

                    if (m_character != null)
                    {
                        var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup <MyCharacterPhysicsStateGroup>();
                        if (physGroup != null && apply)
                        {
                            physGroup.SetSupport(MySupportHelper.FindPhysics(support));
                        }
                    }
                }


                Vector3 move = new Vector3();
                move.X = stream.ReadHalf();
                move.Y = stream.ReadHalf();
                move.Z = stream.ReadHalf();

                Vector2 rotate = new Vector2();
                rotate.X = stream.ReadFloat();
                rotate.Y = stream.ReadFloat();

                float roll = stream.ReadFloat();

                MyCharacterMovementEnum  MovementState = (MyCharacterMovementEnum)stream.ReadUInt16();
                MyCharacterMovementFlags MovementFlag  = (MyCharacterMovementFlags)stream.ReadUInt16();

                bool  Jetpack          = stream.ReadBool();
                bool  Dampeners        = stream.ReadBool();
                bool  Lights           = stream.ReadBool(); // TODO: Remove
                bool  Ironsight        = stream.ReadBool();
                bool  Broadcast        = stream.ReadBool(); // TODO: Remove
                bool  TargetFromCamera = stream.ReadBool();
                float headXAngle       = stream.ReadFloat();
                float headYAngle       = stream.ReadFloat();

                Quaternion rotation = Quaternion.Identity;

                if (Jetpack == false)
                {
                    rotation = stream.ReadQuaternionNorm();
                }

                if (m_character == null)
                {
                    return;
                }

                if (m_character.IsDead || m_character.IsUsing != null)
                {
                    return;
                }

                var jetpack = m_character.JetpackComp;
                if (jetpack != null)
                {
                    if (Jetpack != jetpack.TurnedOn)
                    {
                        jetpack.TurnOnJetpack(Jetpack, true);
                    }
                    if (Dampeners != jetpack.DampenersTurnedOn)
                    {
                        jetpack.EnableDampeners(Dampeners, false);
                    }
                }
                if (Lights != m_character.LightEnabled)
                {
                    m_character.EnableLights(Lights);
                }

                if (m_character.RadioBroadcaster != null && Broadcast != m_character.RadioBroadcaster.Enabled)
                {
                    m_character.EnableBroadcasting(Broadcast);
                }

                m_character.TargetFromCamera = TargetFromCamera;

                // Set client movement state directly and don't perform other operations
                // that may have side-effects to let server side Character.UpdateAfterSimulation()
                // perform exactly same operations as on client
                m_character.MovementFlags = MovementFlag;
                m_character.SetCurrentMovementState(MovementState);
                m_character.HeadLocalXAngle = headXAngle;
                m_character.HeadLocalYAngle = headYAngle;


                m_character.CacheMove(ref move, ref rotate, ref roll);

                if (Jetpack == false)
                {
                    m_character.CacheRotation(ref rotation);
                }
            }
        }