public void handle(CloudLandClient client, IMessage messageReceived) { ServerJoinGameMessage message = (ServerJoinGameMessage)messageReceived; Loom.QueueOnMainThread(() => { client.getClientComponent().playerObject.transform.position = new UnityEngine.Vector3(message.X, message.Y, message.Z); client.getClientComponent().username = message.Username; client.getClientComponent().uuid = message.Uuid; client.getClientComponent().playerObject.SetActive(true); UnityEngine.Debug.Log("Player location updated to: " + string.Format("({0}, {1}, {2})", message.X, message.Y, message.Z)); client.loggedIn = true; }); }
public void handle(CloudLandClient client, IMessage messageReceived) { ServerEntityUpdateMessage message = (ServerEntityUpdateMessage)messageReceived; Loom.QueueOnMainThread(() => { Transform entityTransform = client.getClientComponent().entitiesParent.Find("entity|" + message.EntityId); if (entityTransform == null) { return; } if (message.FlagPosition) { entityTransform.localPosition = new Vector3((float)message.X, (float)message.Y, (float)message.Z); } if (message.FlagRotation) { if (entityTransform.GetComponent <HeadEntity>() != null) { entityTransform.localRotation = Quaternion.Euler(0f, message.Yaw, 0f); entityTransform.Find("Head").localRotation = Quaternion.Euler(message.Pitch, message.Yaw, 0f); } else { entityTransform.localRotation = Quaternion.Euler(message.Pitch, message.Yaw, 0f); } } if (message.FlagMeta) { entityTransform.GetComponent <Entity>().meta = message.Meta; entityTransform.GetComponent <Entity>().updateMeta = true; } }); }
public void handle(CloudLandClient client, IMessage messageReceived) { ServerAddEntityMessage message = (ServerAddEntityMessage)messageReceived; Loom.QueueOnMainThread(() => { if (client.getClientComponent().entitiesParent.Find("entity|" + message.EntityId) != null) { GameObject.Destroy(client.getClientComponent().entitiesParent.Find("entity|" + message.EntityId).gameObject); } GameObject prefab = (GameObject)Resources.Load("Entities/" + message.EntityType.ToString()); GameObject obj = GameObject.Instantiate(prefab, new Vector3((float)message.X, (float)message.Y, (float)message.Z), Quaternion.Euler(message.Pitch, message.Yaw, 0f), client.getClientComponent().entitiesParent); // An entity prefab MUST include a sub-class of Entity obj.GetComponent <Entity>().entityId = message.EntityId; obj.GetComponent <Entity>().meta = message.Meta; obj.transform.name = "entity|" + message.EntityId; }); }
public void handle(CloudLandClient client, IMessage messageReceived) { ServerChunkMessage chunk = (ServerChunkMessage)messageReceived; //UnityEngine.Debug.Log("Received chunk: (" + chunk.X + "," + chunk.Z + "), chunk size=" + chunk.Chunk.Length); //UnityEngine.Debug.Log("Processing chunk " + string.Format("({0}, {1}, {2})", chunk.X, chunk.Y, chunk.Z)); byte[] ids = new byte[8192]; Buffer.BlockCopy(chunk.Chunk.ToByteArray(), 0, ids, 0, 8192); client.getClientComponent().chunkManager.chunkQueue.QueueCreation( chunk.X, chunk.Y, chunk.Z, ids); }
public void handle(CloudLandClient client, IMessage messageReceived) { ServerRemoveEntityMessage message = (ServerRemoveEntityMessage)messageReceived; Loom.QueueOnMainThread(() => { Transform t = client.getClientComponent().entitiesParent.Find("entity|" + message.EntityId); if (t != null) { GameObject.Destroy(t.gameObject); } }); }
public void handle(CloudLandClient client, IMessage messageReceived) { ServerRemoveEntityMessage message = (ServerRemoveEntityMessage)messageReceived; Loom.QueueOnMainThread(() => { Transform t = client.getClientComponent().entitiesParent.Find("entity|" + message.EntityId); if (t != null) { ClientComponent.INSTANCE.entityManager.destroy(t.GetComponent <Entity>()); } }); }
private void handleSingle(CloudLandClient client, ServerUpdateBlockMessage message) { Loom.QueueOnMainThread(() => client.getClientComponent().chunkManager.setBlockAt(message.X, message.Y, message.Z, (int)(message.Id & 0xFFFF))); }