public void TestWritingAndReading() { // write all simple types once NetworkWriter writer = new NetworkWriter(); writer.Write((char)1); writer.Write((byte)2); writer.Write((sbyte)3); writer.Write((bool)true); writer.Write((short)4); writer.Write((ushort)5); writer.Write((int)6); writer.Write((uint)7); writer.Write((long)8L); writer.Write((ulong)9L); writer.Write((float)10); writer.Write((double)11); writer.Write((decimal)12); writer.Write((string)null); writer.Write((string)""); writer.Write((string)"13"); writer.Write(new byte[] { 14, 15 }, 0, 2); // just the byte array, no size info etc. writer.WriteBytesAndSize((byte[])null); // [SyncVar] struct values can have uninitialized byte arrays, null needs to be supported writer.WriteBytesAndSize(new byte[] { 17, 18 }, 0, 2); // buffer, no-offset, count writer.WriteBytesAndSize(new byte[] { 19, 20, 21 }, 1, 2); // buffer, offset, count writer.WriteBytesAndSize(new byte[] { 22, 23 }, 0, 2); // size, buffer byte[] data = writer.ToArray(); // read them NetworkReader reader = new NetworkReader(writer.ToArray()); Assert.That(reader.ReadChar(), Is.EqualTo(1)); Assert.That(reader.ReadByte(), Is.EqualTo(2)); Assert.That(reader.ReadSByte(), Is.EqualTo(3)); Assert.That(reader.ReadBoolean(), Is.True); Assert.That(reader.ReadInt16(), Is.EqualTo(4)); Assert.That(reader.ReadUInt16(), Is.EqualTo(5)); Assert.That(reader.ReadInt32(), Is.EqualTo(6)); Assert.That(reader.ReadUInt32(), Is.EqualTo(7)); Assert.That(reader.ReadInt64(), Is.EqualTo(8)); Assert.That(reader.ReadUInt64(), Is.EqualTo(9)); Assert.That(reader.ReadSingle(), Is.EqualTo(10)); Assert.That(reader.ReadDouble(), Is.EqualTo(11)); Assert.That(reader.ReadDecimal(), Is.EqualTo(12)); Assert.That(reader.ReadString(), Is.Null); // writing null string should write null in HLAPI Pro ("" in original HLAPI) Assert.That(reader.ReadString(), Is.EqualTo("")); Assert.That(reader.ReadString(), Is.EqualTo("13")); Assert.That(reader.ReadBytes(2), Is.EqualTo(new byte[] { 14, 15 })); Assert.That(reader.ReadBytesAndSize(), Is.Null); Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 17, 18 })); Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 20, 21 })); Assert.That(reader.ReadBytesAndSize(), Is.EqualTo(new byte[] { 22, 23 })); }
/// <summary> /// Used to deserialize a message received via networking. /// </summary> /// <param name="reader"></param> public override void Deserialize(NetworkReader reader) { byte[][] ByteArray = new byte[4][]; ByteArray[0] = reader.ReadBytesAndSize(); ByteArray[1] = reader.ReadBytesAndSize(); ByteArray[2] = reader.ReadBytesAndSize(); ByteArray[3] = reader.ReadBytesAndSize(); IntList = NetworkHelper.DeserializeIntArray(ByteArray); }
public override void Deserialize(NetworkReader reader) { if (reader.ReadBoolean()) { QuestsList = FromByteArray <List <QuestData> >(reader.ReadBytesAndSize()); } if (reader.ReadBoolean()) { FQuestList = FromByteArray <List <string> >(reader.ReadBytesAndSize()); } }
/// <summary> /// Used to deserialize a message received via networking. /// </summary> /// <param name="reader"></param> public override void Deserialize(NetworkReader reader) { EntityType = (EntityType)reader.ReadInt16(); Position = reader.ReadVector3(); OwnerID = reader.ReadInt32(); byte[][] ByteArray = new byte[4][]; ByteArray[0] = reader.ReadBytesAndSize(); ByteArray[1] = reader.ReadBytesAndSize(); ByteArray[2] = reader.ReadBytesAndSize(); ByteArray[3] = reader.ReadBytesAndSize(); SyncBaseIDList = NetworkHelper.DeserializeIntArray(ByteArray); }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.stateHash = (int)reader.ReadPackedUInt32(); this.normalizedTime = reader.ReadSingle(); this.parameters = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.stateHash = (int) reader.ReadPackedUInt32(); this.normalizedTime = reader.ReadSingle(); this.parameters = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { proxyId = reader.ReadInt16(); packet.Compression = (VoiceChatCompression)reader.ReadInt16(); packet.Length = reader.ReadInt32(); packet.Data = reader.ReadBytesAndSize(); }
// Token: 0x060020AE RID: 8366 RVA: 0x0008D6CB File Offset: 0x0008B8CB public override void Deserialize(NetworkReader reader) { this.steamId = GeneratedNetworkCode._ReadCSteamID_None(reader); this.authTicket = reader.ReadBytesAndSize(); this.password = reader.ReadString(); this.version = reader.ReadString(); }
public override void Deserialize(NetworkReader reader) { netId = reader.ReadNetworkId(); payload = reader.ReadBytesAndSize(); teleport = reader.ReadBoolean(); time = (int)reader.ReadPackedUInt32(); }
public void TestReading0LengthBytesAndSize() { writer.WriteBytesAndSize(new byte[] { }); var reader = new NetworkReader(writer.ToArray()); Assert.That(reader.ReadBytesAndSize().Length, Is.EqualTo(0)); }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.payload = reader.ReadBytesAndSize(); this.teleport = reader.ReadBoolean(); this.time = (int) reader.ReadPackedUInt32(); }
public override void Deserialize(NetworkReader reader) { proxyId = reader.ReadInt16(); packet.PacketId = reader.ReadUInt64(); packet.Length = reader.ReadInt32(); packet.Data = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.assetId = reader.ReadNetworkHash128(); this.position = reader.ReadVector3(); this.payload = reader.ReadBytesAndSize(); }
public static TileDefinition ReadNetworkableTileDefinition(this NetworkReader reader) { TileDefinition tileDefinition = new TileDefinition(); string turfName = reader.ReadString(); string fixtureName = reader.ReadString(); if (!string.IsNullOrEmpty(turfName)) { tileDefinition.turf = turfs.FirstOrDefault(turf => turf.name == turfName); if (tileDefinition.turf == null) { Debug.LogError($"Network recieved turf with name {turfName} could not be found"); } } if (!string.IsNullOrEmpty(fixtureName)) { tileDefinition.fixture = fixtures.FirstOrDefault(fixture => fixture.name == fixtureName); if (tileDefinition.fixture == null) { Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found"); } } // If the boolean is false, subStates should be null. if (reader.ReadBoolean()) { using (var stream = new MemoryStream(reader.ReadBytesAndSize())) { tileDefinition.subStates = new BinaryFormatter().Deserialize(stream) as object[]; } } return(tileDefinition); }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.sceneId = reader.ReadSceneId(); this.position = reader.ReadVector3(); this.payload = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { netId = reader.ReadNetworkId(); sceneId = reader.ReadSceneId(); position = reader.ReadVector3(); payload = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { netId = reader.ReadNetworkId(); assetId = reader.ReadNetworkHash128(); position = reader.ReadVector3(); rotation = reader.ReadQuaternion(); payload = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { netId = reader.ReadPackedUInt32(); assetId = reader.ReadGuid(); position = reader.ReadVector3(); rotation = reader.ReadQuaternion(); payload = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); TabProvider = reader.ReadUInt32(); NetTabType = (NetTabType)reader.ReadInt32(); ElementId = reader.ReadString(); ElementValue = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(reader.ReadBytesAndSize()); Content = (Pack)bf.Deserialize(ms); ms.Dispose(); }
public override void Deserialize(NetworkReader reader) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(reader.ReadBytesAndSize()); TestCases = (List <TestCase>)bf.Deserialize(ms); ms.Dispose(); }
public override void Deserialize(NetworkReader reader) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(reader.ReadBytesAndSize()); DeviceIdentification = (DeviceIdentification)bf.Deserialize(ms); ms.Dispose(); }
public void TestReadingLengthWrapAround() { // This is 1.5x int.MaxValue, in the negative range of int. writer.WritePackedUInt32(3221225472); var reader = new NetworkReader(writer.ToArray()); Assert.Throws <OverflowException>(() => reader.ReadBytesAndSize()); }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); msgId = reader.ReadInt32(); content = reader.ReadString(); pos = reader.ReadVector3(); bytes = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); this.IsReliable = reader.ReadBoolean(); this.PlayerId = reader.ReadInt64(); this.Data = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { oldConnectionId = (int)reader.ReadPackedUInt32(); playerControllerId = (short)reader.ReadPackedUInt32(); netId = reader.ReadNetworkId(); msgData = reader.ReadBytesAndSize(); msgSize = msgData.Length; }
public static TileDefinition ReadNetworkableTileDefinition(this NetworkReader reader) { TileDefinition tileDefinition = new TileDefinition(); tileDefinition.fixtures = new Fixture[TileDefinition.GetFixtureLayerSize()]; var layers = (FixtureLayers[])Enum.GetValues(typeof(FixtureLayers)); // Read plenum string plenumName = reader.ReadString(); if (!string.IsNullOrEmpty(plenumName)) { tileDefinition.plenum = plenums.FirstOrDefault(plenum => plenum.name == plenumName); if (tileDefinition.plenum == null) { Debug.LogError($"Network recieved plenum with name {plenumName} could not be found"); } } // Read turf string turfName = reader.ReadString(); if (!string.IsNullOrEmpty(turfName)) { tileDefinition.turf = turfs.FirstOrDefault(turf => turf.name == turfName); if (tileDefinition.turf == null) { Debug.LogError($"Network recieved turf with name {turfName} could not be found"); } } // Read fixtures foreach (FixtureLayers layer in layers) { string fixtureName = reader.ReadString(); if (!string.IsNullOrEmpty(fixtureName)) { tileDefinition.fixtures[(int)layer] = fixtures.FirstOrDefault(fixture => fixture.name == fixtureName); if (tileDefinition.fixtures[(int)layer] == null) { Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found"); } } } // If the boolean is false, subStates should be null. if (reader.ReadBoolean()) { using (var stream = new MemoryStream(reader.ReadBytesAndSize())) { tileDefinition.subStates = new BinaryFormatter().Deserialize(stream) as object[]; } } // TODO: Should substates be initialized to null array? return(tileDefinition); }
public override void Deserialize(NetworkReader reader) { this.playerControllerId = (short) reader.ReadUInt16(); this.msgData = reader.ReadBytesAndSize(); if (this.msgData == null) this.msgSize = 0; else this.msgSize = this.msgData.Length; }
// Token: 0x060020A9 RID: 8361 RVA: 0x0008D524 File Offset: 0x0008B724 protected static void InvokeCmdCmdSendLoadout(NetworkBehaviour obj, NetworkReader reader) { if (!NetworkServer.active) { Debug.LogError("Command CmdSendLoadout called on client."); return; } ((NetworkLoadout)obj).CmdSendLoadout(reader.ReadBytesAndSize()); }
// Token: 0x060026C5 RID: 9925 RVA: 0x0001C694 File Offset: 0x0001A894 protected static void InvokeCmdCmdSetAchievementTrackerRequests(NetworkBehaviour obj, NetworkReader reader) { if (!NetworkServer.active) { Debug.LogError("Command CmdSetAchievementTrackerRequests called on client."); return; } ((ServerAchievementTracker)obj).CmdSetAchievementTrackerRequests(reader.ReadBytesAndSize()); }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); found = reader.ReadBoolean(); anchorId = reader.ReadString(); //apiKey = reader.ReadString(); anchorData = reader.ReadBytesAndSize(); }
public void TestWritingHugeArray() { // try serializing array more than 64KB large and see what happens writer.WriteBytesAndSize(new byte[100000]); byte[] data = writer.ToArray(); var reader = new NetworkReader(data); byte[] deserialized = reader.ReadBytesAndSize(); Assert.That(deserialized.Length, Is.EqualTo(100000)); }
public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); gameName = reader.ReadString(); anchorId = reader.ReadString(); anchorPos = reader.ReadVector3(); anchorRot = reader.ReadQuaternion(); anchorData = reader.ReadBytesAndSize(); }
public override void Deserialize(NetworkReader reader) { if (reader == null) { return; } index = reader.ReadInt16(); bytes = reader.ReadBytesAndSize(); count = bytes == null ? 0 : bytes.Length; }
public override void Deserialize(NetworkReader reader) { this.oldConnectionId = (int) reader.ReadPackedUInt32(); this.playerControllerId = (short) reader.ReadPackedUInt32(); this.netId = reader.ReadNetworkId(); this.msgData = reader.ReadBytesAndSize(); if (this.msgData == null) this.msgSize = 0; else this.msgSize = this.msgData.Length; }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.assetId = reader.ReadNetworkHash128(); this.position = reader.ReadVector3(); this.payload = reader.ReadBytesAndSize(); uint num = 0x10; if ((reader.Length - reader.Position) >= num) { this.rotation = reader.ReadQuaternion(); } }
public override void Deserialize(NetworkReader reader) { m_id = reader.ReadNetworkId(); m_parentId = reader.ReadNetworkId(); m_childId = reader.ReadInt32(); m_position = reader.ReadVector3(); m_payload = reader.ReadBytesAndSize(); }
private void Update() { if (Input.GetKeyDown(KeyCode.LeftBracket)) { paletteEditor.gameObject.SetActive(!paletteEditor.gameObject.activeSelf); } bool editing = tileEditor.gameObject.activeSelf; bool chatting = chatOverlay.gameObject.activeSelf; bool mapping = Input.GetKey(KeyCode.Tab) && !chatting; if (editing && !chatting) { tileEditor.CheckInput(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (chatting) { chatOverlay.Hide(); } else if (editing) { tileEditor.OnClickedSave(); } else if (hostID != -1) { OnApplicationQuit(); SceneManager.LoadScene("Main"); return; } else { Application.Quit(); return; } } else if (Input.GetKeyDown(KeyCode.F12)) { string selfies = Application.persistentDataPath + "/selfies"; Directory.CreateDirectory(selfies); Application.CaptureScreenshot(string.Format("{0}/{1}.png", selfies, System.DateTime.Now.Ticks)); } else if (Input.GetKeyDown(KeyCode.F11)) { string maps = Application.persistentDataPath + "/maps"; Directory.CreateDirectory(maps); mapCamera.Render(); var old = RenderTexture.active; RenderTexture.active = mapTexture; mapTextureLocal.ReadPixels(Rect.MinMaxRect(0, 0, 1024, 1024), 0, 0); RenderTexture.active = old; File.WriteAllBytes(string.Format("{0}/{1}.png", maps, System.DateTime.Now.Ticks), mapTextureLocal.EncodeToPNG()); } else if (Input.GetKeyDown(KeyCode.F2)) { scale = 3 - scale; Screen.SetResolution(512 * scale, 512 * scale, false); } if (hostID == -1) return; config.hideTutorial |= !tutorialChat.activeSelf && !tutorialMove.activeSelf && !tutorialTile.activeSelf && !tutorialWall.activeSelf; tutorialObject.SetActive(!config.hideTutorial); mapCamera.gameObject.SetActive(mapping); mapObject.SetActive(mapping); camera.orthographicSize = Mathf.Lerp(128, 32, zoom); if (Input.GetKeyDown(KeyCode.Return)) { if (chatting) { chatOverlay.OnClickedSend(); } else { chatOverlay.Show(); } } if (!chatting && !editing) { if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) { Move(Vector2.up); } else if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { Move(Vector2.left); } else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { Move(Vector2.right); } else if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) { Move(Vector2.down); } } if (Input.GetKeyDown(KeyCode.Space) && stickypalette) { stickypalette = false; } if (!chatting && !editing && Input.GetKey(KeyCode.Space)) { if (!tilePalette.gameObject.activeSelf) { stickypalette = Input.GetKey(KeyCode.LeftControl); tilePalette.Show(); } } else if (!stickypalette) { tilePalette.Hide(); } if (!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() && Rect.MinMaxRect(0, 0, Screen.width, Screen.height).Contains(Input.mousePosition) && !editing) { bool picker = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt); bool waller = !picker && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)); tileCursor.gameObject.SetActive(true); pickerCursor.SetActive(picker); tileCursor.sprite = this.world.tiles[tilePalette.SelectedTile]; Vector2 mouse = Input.mousePosition; Vector3 world; RectTransformUtility.ScreenPointToWorldPointInRectangle(worldView.transform as RectTransform, mouse, camera, out world); int x = Mathf.FloorToInt(world.x / 32); int y = Mathf.FloorToInt(world.y / 32); tileCursor.transform.position = new Vector2(x * 32, y * 32); byte tile = tilePalette.SelectedTile; int location = (y + 16) * 32 + (x + 16); if (location >= 0 && location < 1024) { if (waller && Input.GetMouseButtonDown(0)) { tile = this.world.tilemap[location]; bool wall = !this.world.walls.Contains(tile); SendAll(SetWallMessage(tile, wall)); if (this.world.walls.Set(tile, wall)) { tutorialWall.SetActive(false); audio.PlayOneShot(placeSound); } worldView.RefreshWalls(); } else if (!waller && Input.GetMouseButton(0)) { if (!picker && this.world.tilemap[location] != tile) { audio.PlayOneShot(placeSound); worldView.SetTile(location, tile); if (tile != 0) tutorialTile.SetActive(false); SendAll(SetTileMessage(location, tile)); } else if (picker) { tilePalette.SetSelectedTile(this.world.tilemap[location]); } } } } else { tileCursor.gameObject.SetActive(false); } var eventType = NetworkEventType.Nothing; int connectionID; int channelId; int receivedSize; byte error; do { // Get events from the server/client game connection eventType = NetworkTransport.ReceiveFromHost(hostID, out connectionID, out channelId, recvBuffer, recvBuffer.Length, out receivedSize, out error); if ((NetworkError)error != NetworkError.Ok) { group.interactable = true; popups.Show("Network Error: " + (NetworkError)error, delegate { }); } if (eventType == NetworkEventType.ConnectEvent) { connected = true; if (hosting) { OnNewClientConnected(connectionID); } else { OnConnectedToHost(connectionID); } } else if (eventType == NetworkEventType.DisconnectEvent) { if (hosting) { OnClientDisconnected(connectionID); } else { OnDisconnectedFromHost(connectionID); } } else if (eventType == NetworkEventType.DataEvent) { var reader = new NetworkReader(recvBuffer); { Type type = (Type) reader.ReadByte(); if (type == Type.Tilemap) { world.tilemap = reader.ReadBytesAndSize(); worldView.SetWorld(world); } else if (type == Type.Palette) { for (int i = 0; i < 16; ++i) { world.palette[i] = reader.ReadColor32(); SetPalette((byte) i, world.palette[i]); } } else if (type == Type.PaletteEdit) { ReceivePaletteEdit(reader); } else if (type == Type.Walls) { world.walls.Clear(); foreach (var wall in reader.ReadBytesAndSize()) { world.walls.Add(wall); } worldView.RefreshWalls(); } else if (type == Type.Tileset) { int id = reader.ReadInt32(); tiledata[id] = reader.ReadBytesAndSize(); } else if (type == Type.ReplicateAvatar) { ReceiveCreateAvatar(reader); } else if (type == Type.DestroyAvatar) { ReceiveDestroyAvatar(reader); } else if (type == Type.GiveAvatar) { ReceiveGiveAvatar(reader); } else if (type == Type.MoveAvatar) { World.Avatar avatar = ID2Avatar(reader.ReadInt32()); Vector2 dest = reader.ReadVector2(); if (hosting) { if (connectionID == avatar.id && !Blocked(avatar, dest)) { avatar.source = avatar.destination; avatar.destination = dest; avatar.u = 0; SendAll(MoveAvatarMessage(avatar, avatar.destination), except: avatar.id); } else { Send(connectionID, MoveAvatarMessage(avatar, avatar.destination)); } } else { avatar.source = avatar.destination; avatar.destination = dest; avatar.u = 0; } } else if (type == Type.Chat) { World.Avatar avatar = ID2Avatar(reader.ReadInt32()); string message = reader.ReadString(); if (hosting) { if (connectionID == avatar.id) { SendAll(ChatMessage(avatar, message), except: connectionID); Chat(avatar, message); } } else { Chat(avatar, message); } } else if (type == Type.SetTile) { ReceiveSetTile(reader); } else if (type == Type.SetWall) { ReceiveSetWall(reader); } else if (type == Type.TileChunk) { ReceiveTileChunk(reader, connectionID); } else if (type == Type.LockTile) { ReceiveLockTile(reader); } else if (type == Type.AvatarChunk) { ReceiveAvatarChunk(reader, connectionID); } else if (type == Type.TileStroke) { ReceiveTileStroke(reader, connectionID); } } } } while (eventType != NetworkEventType.Nothing); }
private void ReceiveAvatarChunk(NetworkReader reader, int connectionID) { World.Avatar avatar = ID2Avatar(reader.ReadInt32()); int offset = reader.ReadInt32(); byte[] chunk = UncrunchBytes(reader.ReadBytesAndSize()); // if we're the host, disallow chunks not send by the owner if (hosting && avatar.id != connectionID) return; Color32[] colors = avatar.graphic.texture.GetPixels32(); for (int i = 0; i < chunk.Length; ++i) { byte index = chunk[i]; colors[i + offset] = index == 0 ? Color.clear : world.palette[index]; } avatar.graphic.texture.SetPixels32(colors); avatar.graphic.texture.Apply(); if (hosting) { SendAll(AvatarInChunksMessages(world, avatar)); } }
private void ReceiveTileChunk(NetworkReader reader, int connectionID) { byte tile = reader.ReadByte(); int offset = reader.ReadInt32(); byte[] chunk = UncrunchBytes(reader.ReadBytesAndSize()); int x = tile % 16; int y = tile / 16; bool locked = locks.ContainsKey(tile); // if we're the host, disallow chunks not send by someone with a lock if (hosting && (!locked || locks[tile].id != connectionID)) return; // we're editing this tile, so ignore it if (locked && locks[tile] == worldView.viewer) return; Color[] colors = world.tileset.GetPixels(x * 32, y * 32, 32, 32); for (int i = 0; i < chunk.Length; ++i) { colors[i + offset] = world.palette[chunk[i]]; } world.tileset.SetPixels(x * 32, y * 32, 32, 32, colors); world.tileset.Apply(); if (hosting) { SendAll(TileInChunksMessages(world, tile)); } }
public override void Deserialize(NetworkReader reader) { this.netId = reader.ReadNetworkId(); this.parameters = reader.ReadBytesAndSize(); }