示例#1
0
    //called by blocks if they have been modified, alerting the chunk that their content has changed
    public void blockUpdated(Block b, bool meshChange)
    {
        modifiedSinceSave = true;
        untouchedChunk    = false;
        if (meshChange)
        {
            fluidMeshRebuildingNeeded   = fluidMeshRebuildingNeeded || b is Liquid;
            terrainMeshRebuildingNeeded = terrainMeshRebuildingNeeded || b is Solid;
            if (isInstantiated)
            {
                MainThread.runAction(() => rebuildMesh());
            }
        }

        lock (blockChangeListeners)
        {
            foreach (Position n in b.getPosition().getNeighbours())
            {
                if (blockChangeListeners.Contains(n.getBlock()))
                {
                    BlockThread.queueAction(new BlockChanged(b, n.getBlock()));
                }
            }
        }
    }
示例#2
0
 void OnApplicationQuit()
 {
     lock (chunks)
     {
         shutdown();
         if (ServerNetworkManager.isServer())
         {
             Account.saveAccounts();
             ServerNetworkManager.shutdown();
         }
         ClientNetworkManager.shutdown();
         BlockThread.shutdown();
         BackgroundThread.shutdown();
         foreach (Chunk c in chunks.Values)
         {
             c.unload();
         }
         ChunkManager.shutdown();
     }
 }
示例#3
0
 public void setPressure(float value)
 {
     if (!isServerBlock)
     {
         data.pressure = value;
         return;
     }
     lock (BlockThread.actionLock)
     {
         data.pressure      = value;
         lastPressureUpdate = DateTime.Now;
         if (level < MIN_LEVEL)
         {
             if (data.pressure > 0)
             {
                 Debug.LogWarning("Lost water " + data.pressure + " in " + this);
             }
             pos.getChunk().setBlock(pos, new Air(coords, true));
         }
         else
         {
             pos.getChunk().blockUpdated(this, true);
         }
         foreach (Position x in getPosition().getNeighbours())
         {
             Block block = x.getBlock();
             if (block is Solid)
             {
                 BlockThread.queueAction(new UpdatePressure(this, block));
             }
             else if (block is Air)
             {
                 BlockThread.queueAction(new BlockChanged(block, this));
             }
         }
     }
 }