Skip to content

Instantly share code, notes, and snippets.

@AndrewWeston9
Last active October 6, 2017 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewWeston9/67661a60fd8b3d803d7cd73a652c6e0d to your computer and use it in GitHub Desktop.
Save AndrewWeston9/67661a60fd8b3d803d7cd73a652c6e0d to your computer and use it in GitHub Desktop.
LocalWorld.cs Snippet: Placing a block in the world.
public void placeBlock (float x, float z, float height, int type)
{
// Coordinates for the region block - only horizontal elements.
Vector3 llbpos = new Vector3 (x, 0.0f, z);
LocalLevelBlock llb = findLevelBlock (llbpos);
int blockHeight = (int) (height - WorldManager.minLevelHeight);
if (llb != null)
{
Vector3 regionpos = new Vector3 (x - llb.region.blockCoordX, z - llb.region.blockCoordY, blockHeight);
// llb should now be valid.
// Make a local copy before signalling the change to the world.
//llb.region.placeSingleBlock (localBrick, regionpos, llb.gobject.transform);
}
else
// else no region - potential problem.
{
Debug.Log ("No level block at " + llbpos);
}
Debug.Log ("Add at " + x + " " + z + " " + blockHeight);
BlockAddMessage m = new BlockAddMessage ();
m.px = x;
m.pz = z;
m.height = blockHeight;
m.blocktype = type;
NetworkManager.singleton.client.Send (LevelMsgType.LevelUpdate, m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment