Last active
October 6, 2017 06:45
-
-
Save AndrewWeston9/67661a60fd8b3d803d7cd73a652c6e0d to your computer and use it in GitHub Desktop.
LocalWorld.cs Snippet: Placing a block in the world.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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