public void CreateChunk(int x, int y, int z)
        {
            WorldPos worldPos = new WorldPos(x, y, z);

            //Instantiate the chunk at the coordinates using the chunk prefab
            GameObject newChunkObject = Instantiate(
                chunkPrefab, new Vector3(x, y, z),
                Quaternion.Euler(Vector3.zero)
                ) as GameObject;
            Chunk newChunk = newChunkObject.GetComponent <Chunk>();

            newChunkObject.name = "Chunk: " + x / 16f + ":" + y / 16f + ":" + z / 16f;
            newChunk.pos        = worldPos;
            newChunk.world      = this;

            //Add it to the chunks dictionary with the position as the key
            chunks.Add(worldPos, newChunk);

            bool HasLoadedChunk = false;


            if ((Network.isServer || (!Network.isServer && !Network.isClient)) && IsLoadChunks)
            {
                HasLoadedChunk = Serialization.Load(newChunk);
            }
            if (!HasLoadedChunk)
            {
                newChunk = MyTerrainGen.ChunkGen(newChunk);
            }
            newChunk.transform.parent = gameObject.transform;
            newChunk.SetBlocksUnmodified();
            GetManager.GetZoneManager().LoadZones(new Vector3(x, y, z));
            DebugChunksLoadedCount++;
        }
Exemplo n.º 2
0
 private void FixedUpdate()
 {
     _VertexPositions = GlobalCarCalculations.CalculateVertexPositonsOfBoxCollider(GetManager.GetBoxCollider, 0);
     Suspension();
     Gravity();
     GetManager.TranslateTransform(_SuspensionGravityVelocity, Space.World);
 }
        public void DestroyChunk(int x, int y, int z)
        {
            Chunk chunk = null;

            if (chunks.TryGetValue(new WorldPos(x, y, z), out chunk))
            {
                // atm it is saved when it is removed
                if (SaveFileName == "")                 // if default then update to the game file name
                {
                    SaveFileName = GetManager.GetGameManager().GameName;
                }
                DebugPolygonCount -= chunk.PolygonCount;
                Serialization.SaveChunk(chunk);
                Object.Destroy(chunk.gameObject);
                chunks.Remove(new WorldPos(x, y, z));
            }
            GetManager.GetZoneManager().DestroyZonesInCubeNotCentred(new Vector3(x, y, z),
                                                                     new Vector3(Chunk.chunkSize, Chunk.chunkSize, Chunk.chunkSize));
            DebugChunksLoadedCount--;
        }
Exemplo n.º 4
0
 public void TryDisconnect(Client client, DisconnectReason reason = DisconnectReason.UNKNOW_ERROR_INSTANCE)
 => GetManager.TryDisconnect(client, reason);
Exemplo n.º 5
0
 public ConnectionProtocol TryConnect(Client client) => GetManager.TryConnect(client);
Exemplo n.º 6
0
 ActorRef <Manager> On(GetManager x) => manager;
Exemplo n.º 7
0
 ActorRef On(GetManager x)
 {
     return(manager);
 }
Exemplo n.º 8
0
 ActorRef On(GetManager x) => manager;
Exemplo n.º 9
0
 private void RotateObjectToNormal(Vector3 combinedSurviceNormal)
 {
     transform.rotation = Quaternion.FromToRotation(transform.up, (_InterpolatedNormal)) * transform.rotation;
     GetManager.SetModelRotation(Quaternion.Slerp(GetManager.GetModelTransform.rotation, transform.rotation, 20 * Time.fixedDeltaTime));
     GetManager.SetUpOrientationRotation(Quaternion.Slerp(GetManager.GetOrientationLookAtTransform.rotation, transform.rotation, 7 * Time.fixedDeltaTime));
 }