Skip to content

Instantly share code, notes, and snippets.

@AndrewWeston9
Last active October 6, 2017 06:43
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/3dec18afa06e7e369b51f6ecad891ae8 to your computer and use it in GitHub Desktop.
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.
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