public void ZoneStateChangedEvent(LuaTable zoneList) { IDataContainer zones = zoneList == null?_dataFactory.CreateContainer() : _dataFactory.GetContainer(zoneList); _engine.HandleZoneStateChanged(_dataFactory.GetWherigoObjectList <Zone>(zones)); }
private void readTable(BinaryReader input, LuaDataContainer obj) { string className = "unknown"; IDataProvider rawset = null; LuaDataContainer tab; object key = 1; if (obj != null) { className = obj.GetString("ClassName"); if (className != null) { rawset = obj.GetProvider("rawset", false); } } byte b = input.ReadByte(); while (b != 6) { // Key switch (b) { case 1: key = input.ReadByte() == 0 ? false : true; break; case 2: key = input.ReadDouble(); break; case 3: key = readString(input); break; default: throw new Exception(String.Format("Unsupported table key: {0} at byte {1}", b, input.BaseStream.Position)); } b = input.ReadByte(); // Value switch (b) { case 1: SetField(obj, key, input.ReadBoolean(), rawset); break; case 2: SetField(obj, key, input.ReadDouble(), rawset); break; case 3: SetField(obj, key, readByteArray(input), rawset); break; case 4: byte[] chunk = input.ReadBytes(input.ReadInt32()); SetField(obj, key, _dataFactory.LoadProvider(chunk, key.ToString()), rawset); break; case 5: tab = _dataFactory.CreateContainer(); SetField(obj, key, tab, rawset); readTable(input, tab); break; case 6: // End of table return; case 7: var objIndex = input.ReadInt16(); if (objIndex == -21555) { SetField(obj, key, _player, rawset); } else { SetField(obj, key, _allZObjects.GetContainer(objIndex), rawset); } break; case 8: tab = (LuaDataContainer)_dataFactory.CreateWherigoObject(readString(input)).DataContainer; SetField(obj, key, tab, rawset); // After an object, there is always a table with the content input.ReadByte(); readTable(input, tab); break; } b = input.ReadByte(); } }