Ejemplo n.º 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()));
                }
            }
        }
    }
Ejemplo n.º 2
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));
             }
         }
     }
 }