Last active
October 6, 2017 06:43
-
-
Save AndrewWeston9/3dec18afa06e7e369b51f6ecad891ae8 to your computer and use it in GitHub Desktop.
WorldManager.cs Snippet: Update Flag, checks if flag object was created by the requesting player and deletes it with a network message to client confirming.
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 updateFlag(float x, float y, float z, int connid) | |
{ | |
int rx = ((int) x) % blockSize; | |
int ry = ((int) y) % blockSize; | |
int rz = ((int) z); | |
RegionBlock rb = getRegion (x, y); | |
if (rb != null) | |
{ | |
if (rb.removeFlag (rx, ry, rz + 1, connid)) | |
{ | |
rb.deleteBlock (rx, ry, rz + 1); | |
PlayerFlagMessage m = new PlayerFlagMessage (); | |
m.removed = true; | |
NetworkServer.SendToClient (connid, LevelMsgType.PlayerFlagRequest, m); | |
refreshMesh (); | |
} | |
else | |
{ | |
PlayerFlagMessage m = new PlayerFlagMessage (); | |
m.removed = false; | |
NetworkServer.SendToClient (connid, LevelMsgType.PlayerFlagRequest, m); | |
} | |
} | |
refreshMesh (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment