private static void CoordSysCreated_Client(MyCreateCoordSysBuffer createBuffer)
        {
            MyTransformD origin = new MyTransformD();

            origin.Position = createBuffer.Position;
            origin.Rotation = createBuffer.Rotation;
            MyCoordinateSystem.Static.CreateCoordSys_ClientInternal(ref origin, createBuffer.Id);
        }
Example #2
0
        /// <summary>
        /// Creates coord system and sends it to clients. Should be called only on server.
        /// </summary>
        /// <param name="cubeGrid">Cube grid that is an origin.</param>
        /// <param name="staticGridAlignToCenter">Indcates if grid should be aligned to center or no.</param>
        public void CreateCoordSys(MyCubeGrid cubeGrid, bool staticGridAlignToCenter, bool sync = false)
        {
            //In me this system is not working for now (will change after implementing planets there)
            //if(MyPerGameSettings.Game == GameEnum.ME_GAME)
            //{
            //    return;
            //}

            Debug.Assert(Sync.IsServer, "Called on client. This method should be called only on server.");

            MyTransformD origin = new MyTransformD(cubeGrid.PositionComp.WorldMatrix);

            origin.Rotation.Normalize();
            float gridSize = cubeGrid.GridSize;

            if (!staticGridAlignToCenter)
            {
                origin.Position -= (origin.Rotation.Forward + origin.Rotation.Right + origin.Rotation.Up) * gridSize * 0.5f;
            }

            MyLocalCoordSys localCoordSys = new MyLocalCoordSys(origin, m_coorsSystemSize);
            long            newId         = m_lastCoordSysId++; // Just raise by one. There wont be so much id's for long to be overflooded.

            localCoordSys.Id = newId;
            m_localCoordSystems.Add(newId, localCoordSys);

            if (cubeGrid.LocalCoordSystem != 0)
            {
                this.UnregisterCubeGrid(cubeGrid);
            }

            this.RegisterCubeGrid(cubeGrid, localCoordSys);

            MyCreateCoordSysBuffer createCoordSysBuffer = new MyCreateCoordSysBuffer();

            createCoordSysBuffer.Position = origin.Position;
            createCoordSysBuffer.Rotation = origin.Rotation;
            createCoordSysBuffer.Id       = newId;

            if (sync)
            {
                MyMultiplayer.RaiseStaticEvent(x => CoordSysCreated_Client, createCoordSysBuffer);
            }
        }
        /// <summary>
        /// Creates coord system and sends it to clients. Should be called only on server.
        /// </summary>
        /// <param name="cubeGrid">Cube grid that is an origin.</param>
        /// <param name="staticGridAlignToCenter">Indcates if grid should be aligned to center or no.</param>
        public void CreateCoordSys(MyCubeGrid cubeGrid, bool staticGridAlignToCenter, bool sync = false)
        {
            //In me this system is not working for now (will change after implementing planets there)
            //if(MyPerGameSettings.Game == GameEnum.ME_GAME)
            //{
            //    return;
            //}
            
            Debug.Assert(Sync.IsServer, "Called on client. This method should be called only on server.");

            MyTransformD origin = new MyTransformD(cubeGrid.PositionComp.WorldMatrix);
            origin.Rotation.Normalize();
            float gridSize = cubeGrid.GridSize;

            if (!staticGridAlignToCenter)
            {
                origin.Position -= (origin.Rotation.Forward + origin.Rotation.Right + origin.Rotation.Up) * gridSize * 0.5f;
            }

            MyLocalCoordSys localCoordSys = new MyLocalCoordSys(origin, m_coorsSystemSize);
            long newId = m_lastCoordSysId++; // Just raise by one. There wont be so much id's for long to be overflooded.
            localCoordSys.Id = newId;
            m_localCoordSystems.Add(newId, localCoordSys);

            if (cubeGrid.LocalCoordSystem != 0)
                this.UnregisterCubeGrid(cubeGrid);

            this.RegisterCubeGrid(cubeGrid, localCoordSys);

            MyCreateCoordSysBuffer createCoordSysBuffer = new MyCreateCoordSysBuffer();
            createCoordSysBuffer.Position = origin.Position;
            createCoordSysBuffer.Rotation = origin.Rotation;
            createCoordSysBuffer.Id = newId;

            if(sync)
                MyMultiplayer.RaiseStaticEvent(x => CoordSysCreated_Client, createCoordSysBuffer);

        }
 private static void CoordSysCreated_Client(MyCreateCoordSysBuffer createBuffer)
 {
     MyTransformD origin = new MyTransformD();
     origin.Position = createBuffer.Position;
     origin.Rotation = createBuffer.Rotation;
     MyCoordinateSystem.Static.CreateCoordSys_ClientInternal(ref origin, createBuffer.Id);
 }