public static void Deserialize(ZPackage package) { ZoneT.Clear(); int tnum = package.ReadInt(); for (int i = 0; i < tnum; i++) { ZoneT.Add(new ZoneTypes { Name = package.ReadString(), PVP = package.ReadBool(), PVPEnforce = package.ReadBool(), ShowPosition = package.ReadBool(), PositionEnforce = package.ReadBool(), Admins = package.ReadString(), Configurations = package.ReadString() }); } Zones.Clear(); int num = package.ReadInt(); for (int i = 0; i < num; i++) { Zones.Add(new Zone { ID = package.ReadInt(), Name = package.ReadString(), Type = package.ReadString(), Priority = package.ReadInt(), Shape = package.ReadString(), Position = new Vector2(package.ReadSingle(), package.ReadSingle()), Radius = package.ReadSingle(), }); } }
public static SerializableVector3 FromPackage(ZPackage pkg) { var result = new SerializableVector3(); result.x = pkg.ReadSingle(); result.y = pkg.ReadSingle(); result.z = pkg.ReadSingle(); return(result); }
public void Load(ZPackage pkg) { int propertyCount = pkg.ReadInt(); for (int i = 0; i < propertyCount; i++) { var key = pkg.ReadString(); var dataType = (TyrDataType)Enum.ToObject(typeof(TyrDataType), pkg.ReadInt()); if (dataType == TyrDataType.FLOAT) { var val = pkg.ReadSingle(); m_properties[key] = new TyrProperty(key, val, true); } else if (dataType == TyrDataType.INT) { var val = pkg.ReadInt(); m_properties[key] = new TyrProperty(key, val, true); } else if (dataType == TyrDataType.LONG) { var val = pkg.ReadLong(); m_properties[key] = new TyrProperty(key, val, true); } else if (dataType == TyrDataType.STRING) { var val = pkg.ReadString(); m_properties[key] = new TyrProperty(key, val, true); } } }
// Token: 0x060004DD RID: 1245 RVA: 0x00028508 File Offset: 0x00026708 private void RPC_DamageText(long sender, ZPackage pkg) { Camera mainCamera = Utils.GetMainCamera(); if (!mainCamera) { return; } if (Hud.IsUserHidden()) { return; } DamageText.TextType type = (DamageText.TextType)pkg.ReadInt(); Vector3 vector = pkg.ReadVector3(); float dmg = pkg.ReadSingle(); bool flag = pkg.ReadBool(); float num = Vector3.Distance(mainCamera.transform.position, vector); if (num > this.m_maxTextDistance) { return; } bool mySelf = flag && sender == ZNet.instance.GetUID(); this.AddInworldText(type, vector, num, dmg, mySelf); }
// Token: 0x0600026D RID: 621 RVA: 0x00013B00 File Offset: 0x00011D00 public void Load(ZPackage pkg) { int num = pkg.ReadInt(); this.m_skillData.Clear(); int num2 = pkg.ReadInt(); for (int i = 0; i < num2; i++) { Skills.SkillType skillType = (Skills.SkillType)pkg.ReadInt(); float level = pkg.ReadSingle(); float accumulator = (num >= 2) ? pkg.ReadSingle() : 0f; if (this.IsSkillValid(skillType)) { Skills.Skill skill = this.GetSkill(skillType); skill.m_level = level; skill.m_accumulator = accumulator; } } }
public void Load(ZPackage pkg) { int num1 = pkg.ReadInt(); this.m_skillData.Clear(); int num2 = pkg.ReadInt(); for (int index = 0; index < num2; ++index) { Skills.SkillType skillType = (Skills.SkillType)pkg.ReadInt(); float num3 = pkg.ReadSingle(); float num4 = num1 >= 2 ? pkg.ReadSingle() : 0.0f; if (this.IsSkillValid(skillType)) { Skills.Skill skill = this.GetSkill(skillType); skill.m_level = num3; skill.m_accumulator = num4; } } }
// Token: 0x060006B0 RID: 1712 RVA: 0x000377B4 File Offset: 0x000359B4 public static Inventory Load(ZPackage pkg) { var inventory = new Inventory(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); inventory.m_inventory.Clear(); for (int i = 0; i < num2; i++) { string text = pkg.ReadString(); int stack = pkg.ReadInt(); float durability = pkg.ReadSingle(); Vector2i pos = pkg.ReadVector2i(); bool equiped = pkg.ReadBool(); int quality = 1; if (num >= 101) { quality = pkg.ReadInt(); } int variant = 0; if (num >= 102) { variant = pkg.ReadInt(); } long crafterID = 0L; string crafterName = ""; if (num >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (text != "") { var item = new InventoryItem() { prefabName = text, m_stack = stack, m_durability = durability, m_gridPos = pos, m_equiped = equiped, m_quality = quality, m_variant = variant, m_crafterID = crafterID, m_crafterName = crafterName }; inventory.m_inventory.Add(item); } } return(inventory); }
// Extract the data from the zipped data public static void Deserialize(ZPackage data) { Client.EnforceZones = data.ReadBool(); Client.PVPEnforced = data.ReadBool(); Client.PVPMode = data.ReadBool(); Client.PositionEnforce = data.ReadBool(); Client.ShowPosition = data.ReadBool(); Client.Ward.Damage = data.ReadBool(); Client.Ward.Drop = data.ReadBool(); Client.Ward.Pickup = data.ReadBool(); Client.NoItemLoss = data.ReadBool(); Client.RespawnTimer = data.ReadSingle(); }
// Token: 0x0600026C RID: 620 RVA: 0x000139B0 File Offset: 0x00011BB0 public static Skills Load(ZPackage pkg) { var skills = new Skills(); int num = pkg.ReadInt(); skills.m_skillData.Clear(); int num2 = pkg.ReadInt(); for (int i = 0; i < num2; i++) { var skillType = (SkillType)pkg.ReadInt(); float level = pkg.ReadSingle(); float accumulator = (num >= 2) ? pkg.ReadSingle() : 0f; var skill = new Skill(); skill.skillType = skillType; skill.m_level = level; skill.m_accumulator = accumulator; } return(skills); }
public static object ReadVariable(this ZPackage zp, Type t) { if (t == typeof(int)) { return(zp.ReadInt()); } if (t == typeof(uint)) { return(zp.ReadUInt()); } if (t == typeof(bool)) { return(zp.ReadBool()); } if (t == typeof(char)) { return(zp.ReadChar()); } if (t == typeof(sbyte)) { return(zp.ReadSByte()); } if (t == typeof(long)) { return(zp.ReadLong()); } if (t == typeof(ulong)) { return(zp.ReadULong()); } if (t == typeof(float)) { return(zp.ReadSingle()); } if (t == typeof(double)) { return(zp.ReadDouble()); } if (t == typeof(string)) { return(zp.ReadString()); } return(null); }
public static NoiseSettings Deserialize(ZPackage pkg) { float?ReadOptionalSingle() { float v = pkg.ReadSingle(); return(float.IsNegativeInfinity(v) ? (float?)null : v); } // Don't use object initializer, although it executes in lexical order, it isn't explicit in the spec // ReSharper disable once UseObjectOrCollectionInitializer var settings = new NoiseSettings(); settings.NoiseType = (FastNoiseLite.NoiseType)pkg.ReadInt(); settings.Frequency = pkg.ReadSingle(); settings.FractalType = (FastNoiseLite.FractalType)pkg.ReadInt(); settings.FractalOctaves = pkg.ReadInt(); settings.FractalLacunarity = pkg.ReadSingle(); settings.FractalGain = pkg.ReadSingle(); settings.FractalWeightedStrength = pkg.ReadSingle(); settings.FractalPingPongStrength = pkg.ReadSingle(); settings.CellularDistanceFunction = (FastNoiseLite.CellularDistanceFunction)pkg.ReadInt(); settings.CellularReturnType = (FastNoiseLite.CellularReturnType)pkg.ReadInt(); settings.CellularJitter = pkg.ReadSingle(); settings.DomainWarpType = (FastNoiseLite.DomainWarpType)pkg.ReadInt(); settings.DomainWarpAmp = pkg.ReadSingle(); settings.Invert = pkg.ReadBool(); settings.SmoothThresholdStart = ReadOptionalSingle(); settings.SmoothThresholdEnd = ReadOptionalSingle(); settings.Threshold = ReadOptionalSingle(); settings.RangeStart = ReadOptionalSingle(); settings.RangeEnd = ReadOptionalSingle(); settings.Opacity = ReadOptionalSingle(); settings.BlendMode = (BlendOperations.BlendModeType)pkg.ReadInt(); return(settings); }
// Token: 0x06000E1E RID: 3614 RVA: 0x00064BB8 File Offset: 0x00062DB8 private void LoadHealth() { byte[] byteArray = this.m_nview.GetZDO().GetByteArray("health"); if (byteArray != null) { ZPackage zpackage = new ZPackage(byteArray); int num = zpackage.ReadInt(); for (int i = 0; i < num; i++) { float health = zpackage.ReadSingle(); MineRock5.HitArea hitArea = this.GetHitArea(i); if (hitArea != null) { hitArea.m_health = health; } } } this.m_lastDataRevision = this.m_nview.GetZDO().m_dataRevision; }
// Token: 0x060006B8 RID: 1720 RVA: 0x00037B04 File Offset: 0x00035D04 public void Load(ZPackage pkg) { int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); this.m_inventory.Clear(); for (int i = 0; i < num2; i++) { string text = pkg.ReadString(); int stack = pkg.ReadInt(); float durability = pkg.ReadSingle(); Vector2i pos = pkg.ReadVector2i(); bool equiped = pkg.ReadBool(); int quality = 1; if (num >= 101) { quality = pkg.ReadInt(); } int variant = 0; if (num >= 102) { variant = pkg.ReadInt(); } long crafterID = 0L; string crafterName = ""; if (num >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (text != "") { this.AddItem(text, stack, durability, pos, equiped, quality, variant, crafterID, crafterName); } } this.Changed(); }
public void Deserialize(ZPackage pkg) { this.m_persistent = pkg.ReadBool(); this.m_distant = pkg.ReadBool(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); this.m_prefab = pkg.ReadInt(); this.m_rotation = pkg.ReadQuaternion(); int num1 = pkg.ReadInt(); if ((num1 & 1) != 0) { this.InitFloats(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_floats[pkg.ReadInt()] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } if ((num1 & 2) != 0) { this.InitVec3(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_vec3[pkg.ReadInt()] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } if ((num1 & 4) != 0) { this.InitQuats(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_quats[pkg.ReadInt()] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } if ((num1 & 8) != 0) { this.InitInts(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_ints[pkg.ReadInt()] = pkg.ReadInt(); } } else { this.ReleaseInts(); } if ((num1 & 64) != 0) { this.InitLongs(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_longs[pkg.ReadInt()] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } if ((num1 & 16) != 0) { this.InitStrings(); int num2 = (int)pkg.ReadByte(); for (int index = 0; index < num2; ++index) { this.m_strings[pkg.ReadInt()] = pkg.ReadString(); } } else { this.ReleaseStrings(); } }
// Token: 0x060001C5 RID: 453 RVA: 0x0000F2F0 File Offset: 0x0000D4F0 public static Player Load(ZPackage pkg) { var player = new Player(); int num = pkg.ReadInt(); if (num >= 7) { player.MaxHealth = pkg.ReadSingle(); } player.Health = pkg.ReadSingle(); if (num >= 10) { player.MaxStamina = pkg.ReadSingle(); } if (num >= 8) { player.FirstSpawn = pkg.ReadBool(); } if (num >= 20) { player.TimeSinceDeath = pkg.ReadSingle(); } if (num >= 23) { player.GuardianPower = pkg.ReadString(); } if (num >= 24) { player.GuardianPowerCooldown = pkg.ReadSingle(); } if (num == 2) { pkg.ReadZDOID(); } player.Inventory = InventoryReaderWriter.Load(pkg); int num3 = pkg.ReadInt(); for (int i = 0; i < num3; i++) { string item = pkg.ReadString(); player.m_knownRecipes.Add(item); } if (num < 15) { int num4 = pkg.ReadInt(); for (int j = 0; j < num4; j++) { pkg.ReadString(); } } else { int num5 = pkg.ReadInt(); for (int k = 0; k < num5; k++) { string key = pkg.ReadString(); int value = pkg.ReadInt(); player.m_knownStations.Add(key, value); } } int num6 = pkg.ReadInt(); for (int l = 0; l < num6; l++) { string item2 = pkg.ReadString(); player.m_knownMaterial.Add(item2); } if (num < 19 || num >= 21) { int num7 = pkg.ReadInt(); for (int m = 0; m < num7; m++) { string item3 = pkg.ReadString(); player.m_shownTutorials.Add(item3); } } if (num >= 6) { int num8 = pkg.ReadInt(); for (int n = 0; n < num8; n++) { string item4 = pkg.ReadString(); player.m_uniques.Add(item4); } } if (num >= 9) { int num9 = pkg.ReadInt(); for (int num10 = 0; num10 < num9; num10++) { string item5 = pkg.ReadString(); player.m_trophies.Add(item5); } } if (num >= 18) { int num11 = pkg.ReadInt(); for (int num12 = 0; num12 < num11; num12++) { Biome item6 = (Biome)pkg.ReadInt(); player.m_knownBiome.Add(item6); } } if (num >= 22) { int num13 = pkg.ReadInt(); for (int num14 = 0; num14 < num13; num14++) { string key2 = pkg.ReadString(); string value2 = pkg.ReadString(); player.m_knownTexts.Add(key2, value2); } } if (num >= 4) { string beard = pkg.ReadString(); string hair = pkg.ReadString(); player.Beard = beard; player.Hair = hair; } if (num >= 5) { Vector3 skinColor = pkg.ReadVector3(); Vector3 hairColor = pkg.ReadVector3(); player.SkinColor = skinColor; player.HairColor = hairColor; } if (num >= 11) { int playerModel = pkg.ReadInt(); player.PlayerModel = playerModel; } if (num >= 12) { player.m_foods.Clear(); int num15 = pkg.ReadInt(); for (int num16 = 0; num16 < num15; num16++) { if (num >= 14) { var food = new Food(); food.m_name = pkg.ReadString(); food.m_health = pkg.ReadSingle(); if (num >= 16) { food.m_stamina = pkg.ReadSingle(); } player.m_foods.Add(food); } else { pkg.ReadString(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); if (num >= 13) { pkg.ReadSingle(); } } } } if (num >= 17) { player.Skills = SkillsReaderWriter.Load(pkg); } return(player); }
public void Load(ZPackage pkg, int version) { this.m_ownerRevision = pkg.ReadUInt(); this.m_dataRevision = pkg.ReadUInt(); this.m_persistent = pkg.ReadBool(); this.m_owner = pkg.ReadLong(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); if (version >= 16 && version < 24) { pkg.ReadInt(); } if (version >= 23) { this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); } if (version >= 22) { this.m_distant = pkg.ReadBool(); } if (version < 13) { int num1 = (int)pkg.ReadChar(); int num2 = (int)pkg.ReadChar(); } if (version >= 17) { this.m_prefab = pkg.ReadInt(); } this.m_sector = pkg.ReadVector2i(); this.m_position = pkg.ReadVector3(); this.m_rotation = pkg.ReadQuaternion(); int num3 = (int)pkg.ReadChar(); if (num3 > 0) { this.InitFloats(); for (int index = 0; index < num3; ++index) { this.m_floats[pkg.ReadInt()] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } int num4 = (int)pkg.ReadChar(); if (num4 > 0) { this.InitVec3(); for (int index = 0; index < num4; ++index) { this.m_vec3[pkg.ReadInt()] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } int num5 = (int)pkg.ReadChar(); if (num5 > 0) { this.InitQuats(); for (int index = 0; index < num5; ++index) { this.m_quats[pkg.ReadInt()] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } int num6 = (int)pkg.ReadChar(); if (num6 > 0) { this.InitInts(); for (int index = 0; index < num6; ++index) { this.m_ints[pkg.ReadInt()] = pkg.ReadInt(); } } else { this.ReleaseInts(); } int num7 = (int)pkg.ReadChar(); if (num7 > 0) { this.InitLongs(); for (int index = 0; index < num7; ++index) { this.m_longs[pkg.ReadInt()] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } int num8 = (int)pkg.ReadChar(); if (num8 > 0) { this.InitStrings(); for (int index = 0; index < num8; ++index) { this.m_strings[pkg.ReadInt()] = pkg.ReadString(); } } else { this.ReleaseStrings(); } if (version >= 17) { return; } this.m_prefab = this.GetInt("prefab", 0); }
// Token: 0x06000DBC RID: 3516 RVA: 0x00062418 File Offset: 0x00060618 public void Deserialize(ref ZPackage pkg) { this.m_damage.m_damage = pkg.ReadSingle(); this.m_damage.m_blunt = pkg.ReadSingle(); this.m_damage.m_slash = pkg.ReadSingle(); this.m_damage.m_pierce = pkg.ReadSingle(); this.m_damage.m_chop = pkg.ReadSingle(); this.m_damage.m_pickaxe = pkg.ReadSingle(); this.m_damage.m_fire = pkg.ReadSingle(); this.m_damage.m_frost = pkg.ReadSingle(); this.m_damage.m_lightning = pkg.ReadSingle(); this.m_damage.m_poison = pkg.ReadSingle(); this.m_damage.m_spirit = pkg.ReadSingle(); this.m_toolTier = pkg.ReadInt(); this.m_pushForce = pkg.ReadSingle(); this.m_backstabBonus = pkg.ReadSingle(); this.m_staggerMultiplier = pkg.ReadSingle(); this.m_dodgeable = pkg.ReadBool(); this.m_blockable = pkg.ReadBool(); this.m_point = pkg.ReadVector3(); this.m_dir = pkg.ReadVector3(); this.m_statusEffect = pkg.ReadString(); this.m_attacker = pkg.ReadZDOID(); this.m_skill = (Skills.SkillType)pkg.ReadInt(); }
static void Prefix(RoutedRPCData data) { var targetName = ""; ZDO targetZDO; if (!data.m_targetZDO.IsNone()) { try { targetZDO = ZDOMan.instance.GetZDO(data.m_targetZDO); targetName = targetZDO.m_type.ToString(); } catch { } } ZNetPeer peer = ZNet.instance.GetPeer(data.m_senderPeerID); var steamid = ""; try { steamid = peer.m_rpc.GetSocket().GetHostName(); } catch {} if (data?.m_methodHash == "Say".GetStableHashCode()) { // private void RPC_Say(long sender, int ctype, string user, string text) try { var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); var pos = zdoData.GetPosition(); ZPackage package = new ZPackage(data.m_parameters.GetArray()); int messageType = package.ReadInt(); string userName = package.ReadString(); string message = package.ReadString(); message = (message == null ? "" : message).Trim(); if (message.StartsWith("/pin")) { var messageParts = message.Split(' '); var pinType = "dot"; var startIdx = 1; if (messageParts.Length > 1 && ALLOWED_PINS.Contains(messageParts[1])) { pinType = messageParts[1]; startIdx = 2; } var pinText = ""; if (startIdx < messageParts.Length) { pinText = String.Join(" ", messageParts, startIdx, messageParts.Length - startIdx); } if (pinText.Length > 40) { pinText = pinText.Substring(0, 40); } var safePinsText = Regex.Replace(pinText, @"[^a-zA-Z0-9 ]", ""); var uuId = Guid.NewGuid(); var pinId = uuId.ToString(); mapDataServer.AddPin(steamid, pinId, pinType, userName, pos, safePinsText); var usersPins = mapDataServer.pins.FindAll(pin => pin.StartsWith(steamid)); var numOverflowPins = usersPins.Count - WebMapConfig.MAX_PINS_PER_USER; for (var t = numOverflowPins; t > 0; t--) { var pinIdx = mapDataServer.pins.FindIndex(pin => pin.StartsWith(steamid)); // mapDataServer.RemovePin(pinIdx); harmonyLog.LogInfo($"To many pins, deleting oldest one (ONLY DEBUG; WILL NOT DO)"); } SavePins(); } else if (message.StartsWith("/undoPin")) { var pinIdx = mapDataServer.pins.FindLastIndex(pin => pin.StartsWith(steamid)); if (pinIdx > -1) { mapDataServer.RemovePin(pinIdx); SavePins(); } } else if (message.StartsWith("/deletePin")) { var messageParts = message.Split(' '); var pinText = ""; if (messageParts.Length > 1) { pinText = String.Join(" ", messageParts, 1, messageParts.Length - 1); } var pinIdx = mapDataServer.pins.FindLastIndex(pin => { var pinParts = pin.Split(','); return(pinParts[0] == steamid && pinParts[pinParts.Length - 1] == pinText); }); if (pinIdx > -1) { mapDataServer.RemovePin(pinIdx); SavePins(); } } else if (!message.StartsWith("/")) { mapDataServer.Broadcast($"say\n{messageType}\n{userName}\n{message}"); harmonyLog.LogInfo($"say\n{messageType}\n{userName}\n{message} / target={targetName}"); } } catch { harmonyLog.LogError($"Say() exception"); } } else if (data?.m_methodHash == "ChatMessage".GetStableHashCode()) { // private void RPC_ChatMessage(long sender, Vector3 position, int type, string name, string text) try { ZPackage package = new ZPackage(data.m_parameters.GetArray()); Vector3 pos = package.ReadVector3(); int messageType = package.ReadInt(); string userName = package.ReadString(); string message = package.ReadString(); message = (message == null ? "" : message).Trim(); if (messageType == (int)Talker.Type.Ping) { mapDataServer.BroadcastPing(data.m_senderPeerID, userName, pos); } else { mapDataServer.Broadcast($"chat\n{messageType}\n{userName}\n{pos}\n{message}"); harmonyLog.LogInfo($"ChatMessage() chat\n{messageType}\n{userName}\n{pos}\n{message} / target={targetName}"); } } catch { harmonyLog.LogError($"ChatMessage() exception"); } } else if (data?.m_methodHash == "OnDeath".GetStableHashCode()) { // private void RPC_OnDeath(long sender) try { var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); var pos = zdoData.GetPosition(); ZPackage package = new ZPackage(data.m_parameters.GetArray()); mapDataServer.Broadcast($"ondeath\n{peer.m_playerName}"); harmonyLog.LogInfo($"RPC_OnDeath() -- {peer.m_playerName} / target={targetName}"); } catch { harmonyLog.LogError($"RPC_OnDeath() exception"); } } else if (data?.m_methodHash == "Message".GetStableHashCode()) { // private void RPC_Message(long sender, int type, string msg, int amount) try { var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); var pos = zdoData.GetPosition(); ZPackage package = new ZPackage(data.m_parameters.GetArray()); int messageType = package.ReadInt(); string msg = package.ReadString(); int amount = package.ReadInt(); mapDataServer.Broadcast($"message\n{peer.m_playerName}\n{messageType}\n{msg}\n{amount}"); harmonyLog.LogInfo($"RPC_Message() -- {peer.m_playerName} / {msg} - {amount} / target={targetName}"); } catch { harmonyLog.LogError($"RPC_Message() exception"); } } else if (data?.m_methodHash == "DamageText".GetStableHashCode()) { try { var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); var pos = zdoData.GetPosition(); ZPackage package = new ZPackage(data.m_parameters.GetArray()); //float v = package.Read(); //bool alerted = package.ReadBool(); var pkg = package.ReadPackage(); DamageText.TextType type = (DamageText.TextType)pkg.ReadInt(); Vector3 vector = pkg.ReadVector3(); float dmg = pkg.ReadSingle(); bool flag = pkg.ReadBool(); harmonyLog.LogInfo($"RPC_DamageText() -- {peer.m_playerName} / type={type} / pos={vector} / dmg={dmg} / flag={flag} / target={targetName}"); } catch { harmonyLog.LogError($"RPC_DamageText() exception"); } } else if (data?.m_methodHash == "Damage".GetStableHashCode()) { try { var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); var pos = zdoData.GetPosition(); ZPackage package = new ZPackage(data.m_parameters.GetArray()); harmonyLog.LogInfo($"RPC_Damage() -- {peer.m_playerName} / target={targetName}"); } catch { harmonyLog.LogError($"RPC_Damage() exception"); } } else if (data?.m_methodHash == "DestroyZDO".GetStableHashCode()) { try { // supress //ZPackage pkg = new ZPackage(data.m_parameters.GetArray()); //var pkg2 = pkg.ReadPackage(); //var numberofitems = pkg2.ReadInt(); //for (int i = 0; i < numberofitems; i++) //{ // ZDOID uid = pkg.ReadZDOID(); //} //harmonyLog.LogInfo($"DestroyZDO() -- {peer.m_playerName} / numberofitems={numberofitems} / target={targetName}"); } catch (Exception e) { harmonyLog.LogError($"DestroyZDO() exception " + e); } } else if (data?.m_methodHash == "SetEvent".GetStableHashCode()) { try { // var zdoData = ZDOMan.instance.GetZDO(peer.m_characterID); // var pos = zdoData.GetPosition(); ZPackage pkg = new ZPackage(data.m_parameters.GetArray()); var eventName = pkg.ReadString(); var time = pkg.ReadSingle(); var eventPos = pkg.ReadVector3(); if (!eventName.IsNullOrEmpty()) { harmonyLog.LogInfo($"SetEvent() -- eventName={eventName} / time={time} / eventPos={eventPos} / target={targetName}"); } } catch (Exception e) { harmonyLog.LogError($"SetEvent() exception " + e); } } else { // Debug //var methods = new List<string>() { "Jump", "OnJump", "SetMoveDir", "AddDPS", "AddFire", "BlockAttack", "UseStamina", "OnTargeted", "SetHealth", "SetCrouch", // "SetLookDir","SetRun", "Stagger", "Grow", "Shake", "CreateFragments", "RemotePrint","Pickup","Move","Die","Destroy","Awake","Loot","AddOre","EmptyProcessed", // "Interact","Hit","Create","Start","UseItem","UpdateTeleport","UseDoor","DropItem","AddNoise","Alert","Pick","Forward","Stop","OnHit","AddStatusEffect", // "Heal","AddFuel","OnNearProjectileHit","SleepStop","SleepStart","Ping", "Pong","DiscoverLocationRespons", "DiscoverClosestLocation", // "DestroyZDO","RequestZDO","SpawnObject","SetGlobalKey","GlobalKeys","LocationIcons","SetOwner","Extract","ResetCloth","SetTamed","RequestOpen","OpenRespons", // "RequestTakeAll", "TakeAllRespons","RequestOpen","SetSlotVisual","RemoveDoneItem","AddItem","Tap","Pickup","RequestPickup","Nibble","Step","SetPicked", // "ApplyOperation" //}; //bool found = false; //foreach (string method in methods) //{ // if (data?.m_methodHash == method.GetStableHashCode()) // { // found = true; // harmonyLog.LogInfo($" -> DEBUG: {method}() "); // } //} //if (!found) //{ // // Unknown RPC message // harmonyLog.LogInfo($"<unknown rpc message> hash={data.m_methodHash}"); //} } }
public void ReadBiomeData(ref ZPackage package) { // mountain minMountainHeight = package.ReadSingle(); // ashlands/deepnorth minAshlandsDist = package.ReadSingle(); minDeepNorthDist = package.ReadSingle(); // swamp swampBiomeScaleX = package.ReadSingle(); swampBiomeScaleY = package.ReadSingle(); minSwampNoise = package.ReadSingle(); minSwampDist = package.ReadSingle(); maxSwampDist = package.ReadSingle(); minSwampHeight = package.ReadSingle(); maxSwampHeight = package.ReadSingle(); // mistlands mistlandsBiomeScaleX = package.ReadSingle(); mistlandsBiomeScaleY = package.ReadSingle(); minMistlandsNoise = package.ReadSingle(); minMistlandsDist = package.ReadSingle(); maxMistlandsDist = package.ReadSingle(); // plains plainsBiomeScaleX = package.ReadSingle(); plainsBiomeScaleY = package.ReadSingle(); minPlainsNoise = package.ReadSingle(); minPlainsDist = package.ReadSingle(); maxPlainsDist = package.ReadSingle(); // black forest blackForestBiomeScaleX = package.ReadSingle(); blackForestBiomeScaleY = package.ReadSingle(); minBlackForestNoise = package.ReadSingle(); minBlackForestDist = package.ReadSingle(); maxBlackForestDist = package.ReadSingle(); // switches meadowsSwitch = (Heightmap.Biome)package.ReadInt(); blackForestSwitch = (Heightmap.Biome)package.ReadInt(); swampSwitch = (Heightmap.Biome)package.ReadInt(); mountainSwitch = (Heightmap.Biome)package.ReadInt(); plainsSwitch = (Heightmap.Biome)package.ReadInt(); mistlandsSwitch = (Heightmap.Biome)package.ReadInt(); ashlandsSwitch = (Heightmap.Biome)package.ReadInt(); deepNorthSwitch = (Heightmap.Biome)package.ReadInt(); // river riverMultipleMaxDistance = package.ReadSingle(); riverExtremeMaxDistance = package.ReadSingle(); riverMaxHeight = package.ReadSingle(); riverWidthMaxLowerRange = package.ReadSingle(); riverWidthMaxUpperRange = package.ReadSingle(); riverWidthMinLowerRange = package.ReadSingle(); riverCurveWidth = package.ReadSingle(); riverWavelength = package.ReadSingle(); }
public static bool Prefix(Inventory __instance, ZPackage pkg) { var version = pkg.ReadInt(); var itemCount = pkg.ReadInt(); __instance.m_inventory.Clear(); OutsideItems.Clear(); GraveItems.Clear(); DroppedItems.Clear(); for (var index = 0; index < itemCount; ++index) { var name = pkg.ReadString(); var stack = pkg.ReadInt(); var durability = pkg.ReadSingle(); var pos = pkg.ReadVector2i(); var equiped = pkg.ReadBool(); var quality = 1; if (version >= 101) { quality = pkg.ReadInt(); } var variant = 0; if (version >= 102) { variant = pkg.ReadInt(); } long crafterID = 0; var crafterName = ""; if (version >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (name != "") { __instance.AddItem(name, stack, durability, pos, equiped, quality, variant, crafterID, crafterName); if (IsOutsideInventory(__instance, pos)) { Debug.LogWarning($"Item ({name}) was outside inventory ({pos}), finding new position."); var item = __instance.GetItemAt(pos.x, pos.y); OutsideItems.Add(item); } } } foreach (var item in OutsideItems) { var addedItem = __instance.AddItem(item); if (!addedItem) { Debug.LogWarning($"Could not add item ({item.m_shared.m_name}) to regular inventory, adding item to grave"); GraveItems.Add(item); } } if (GraveItems.Count > 0) { if (Player.m_localPlayer.GetInventory() == __instance) { var graveInventory = CreateTempGrave(Player.m_localPlayer); foreach (var item in GraveItems) { bool addedItem = graveInventory.AddItem(item); if (!addedItem) { Debug.LogWarning($"Could not add item ({item.m_shared.m_name}) to temp grave, dropping on ground"); DroppedItems.Add(item); } } } else { DroppedItems.AddRange(GraveItems); } } foreach (var item in DroppedItems) { if (Player.m_localPlayer.GetInventory() == __instance) { Player.m_localPlayer.DropItem(__instance, item, item.m_stack); } else { Debug.LogError($"Could not recover item from non-Player inventory ({__instance.GetName()}), dropping at origin?!?!"); ItemDrop.DropItem(item, item.m_stack, Vector3.zero + Vector3.up * 10, Quaternion.identity); } } __instance.Changed(); return(false); }
// Token: 0x06000791 RID: 1937 RVA: 0x0003B918 File Offset: 0x00039B18 public void Deserialize(ZPackage pkg) { this.m_persistent = pkg.ReadBool(); this.m_distant = pkg.ReadBool(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); this.m_prefab = pkg.ReadInt(); this.m_rotation = pkg.ReadQuaternion(); int num = pkg.ReadInt(); if ((num & 1) != 0) { this.InitFloats(); int num2 = (int)pkg.ReadByte(); for (int i = 0; i < num2; i++) { int key = pkg.ReadInt(); this.m_floats[key] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } if ((num & 2) != 0) { this.InitVec3(); int num3 = (int)pkg.ReadByte(); for (int j = 0; j < num3; j++) { int key2 = pkg.ReadInt(); this.m_vec3[key2] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } if ((num & 4) != 0) { this.InitQuats(); int num4 = (int)pkg.ReadByte(); for (int k = 0; k < num4; k++) { int key3 = pkg.ReadInt(); this.m_quats[key3] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } if ((num & 8) != 0) { this.InitInts(); int num5 = (int)pkg.ReadByte(); for (int l = 0; l < num5; l++) { int key4 = pkg.ReadInt(); this.m_ints[key4] = pkg.ReadInt(); } } else { this.ReleaseInts(); } if ((num & 64) != 0) { this.InitLongs(); int num6 = (int)pkg.ReadByte(); for (int m = 0; m < num6; m++) { int key5 = pkg.ReadInt(); this.m_longs[key5] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } if ((num & 16) != 0) { this.InitStrings(); int num7 = (int)pkg.ReadByte(); for (int n = 0; n < num7; n++) { int key6 = pkg.ReadInt(); this.m_strings[key6] = pkg.ReadString(); } return; } this.ReleaseStrings(); }
// Token: 0x06000793 RID: 1939 RVA: 0x0003BE94 File Offset: 0x0003A094 public void Load(ZPackage pkg, int version) { this.m_ownerRevision = pkg.ReadUInt(); this.m_dataRevision = pkg.ReadUInt(); this.m_persistent = pkg.ReadBool(); this.m_owner = pkg.ReadLong(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); if (version >= 16 && version < 24) { pkg.ReadInt(); } if (version >= 23) { this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); } if (version >= 22) { this.m_distant = pkg.ReadBool(); } if (version < 13) { pkg.ReadChar(); pkg.ReadChar(); } if (version >= 17) { this.m_prefab = pkg.ReadInt(); } this.m_sector = pkg.ReadVector2i(); this.m_position = pkg.ReadVector3(); this.m_rotation = pkg.ReadQuaternion(); int num = (int)pkg.ReadChar(); if (num > 0) { this.InitFloats(); for (int i = 0; i < num; i++) { int key = pkg.ReadInt(); this.m_floats[key] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } int num2 = (int)pkg.ReadChar(); if (num2 > 0) { this.InitVec3(); for (int j = 0; j < num2; j++) { int key2 = pkg.ReadInt(); this.m_vec3[key2] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } int num3 = (int)pkg.ReadChar(); if (num3 > 0) { this.InitQuats(); for (int k = 0; k < num3; k++) { int key3 = pkg.ReadInt(); this.m_quats[key3] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } int num4 = (int)pkg.ReadChar(); if (num4 > 0) { this.InitInts(); for (int l = 0; l < num4; l++) { int key4 = pkg.ReadInt(); this.m_ints[key4] = pkg.ReadInt(); } } else { this.ReleaseInts(); } int num5 = (int)pkg.ReadChar(); if (num5 > 0) { this.InitLongs(); for (int m = 0; m < num5; m++) { int key5 = pkg.ReadInt(); this.m_longs[key5] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } int num6 = (int)pkg.ReadChar(); if (num6 > 0) { this.InitStrings(); for (int n = 0; n < num6; n++) { int key6 = pkg.ReadInt(); this.m_strings[key6] = pkg.ReadString(); } } else { this.ReleaseStrings(); } if (version < 17) { this.m_prefab = this.GetInt("prefab", 0); } }
private void Deserialize(ZPackage pkg) { Version = pkg.ReadInt(); if (Version > LatestVersion) { LogError($"BetterContinents mod is out of date: world expects config version {Version}, mod config version is {LatestVersion}"); throw new Exception($"BetterContinents mod is out of date: world expects config version {Version}, mod config version is {LatestVersion}"); } WorldUId = pkg.ReadLong(); EnabledForThisWorld = pkg.ReadBool(); if (EnabledForThisWorld) { GlobalScale = pkg.ReadSingle(); MountainsAmount = pkg.ReadSingle(); SeaLevelAdjustment = pkg.ReadSingle(); MaxRidgeHeight = pkg.ReadSingle(); RidgeScale = pkg.ReadSingle(); RidgeBlendSigmoidB = pkg.ReadSingle(); RidgeBlendSigmoidXOffset = pkg.ReadSingle(); var heightmapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(heightmapFilePath)) { Heightmap = new ImageMapFloat(heightmapFilePath, pkg.ReadByteArray()); if (Version <= 4 && !Heightmap.CreateMapLegacy() || Version > 4 && !Heightmap.CreateMap()) { Heightmap = null; } HeightmapAmount = pkg.ReadSingle(); HeightmapBlend = pkg.ReadSingle(); HeightmapAdd = pkg.ReadSingle(); } OceanChannelsEnabled = pkg.ReadBool(); if (Version >= 2) { RiversEnabled = pkg.ReadBool(); //LakesEnabled = pkg.ReadBool(); var biomemapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(biomemapFilePath)) { Biomemap = new ImageMapBiome(biomemapFilePath, pkg.ReadByteArray()); if (!Biomemap.CreateMap()) { Biomemap = null; } } ForestScale = pkg.ReadSingle(); ForestAmountOffset = pkg.ReadSingle(); OverrideStartPosition = pkg.ReadBool(); StartPositionX = pkg.ReadSingle(); StartPositionY = pkg.ReadSingle(); } else { RiversEnabled = true; ForestScale = 1; ForestAmountOffset = 0; OverrideStartPosition = false; StartPositionX = 0; StartPositionY = 0; //LakesEnabled = true; } // Version 3 if (Version >= 3) { var spawnmapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(spawnmapFilePath)) { Spawnmap = new ImageMapSpawn(spawnmapFilePath, pkg); } } // Version 4 // (nothing) // Version 5 if (Version >= 5) { var roughmapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(roughmapFilePath)) { Roughmap = new ImageMapFloat(roughmapFilePath, pkg.ReadByteArray()); if (!Roughmap.CreateMap()) { Roughmap = null; } RoughmapBlend = pkg.ReadSingle(); } UseRoughInvertedAsFlat = pkg.ReadBool(); FlatmapBlend = pkg.ReadSingle(); if (!UseRoughInvertedAsFlat) { var flatmapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(flatmapFilePath)) { Flatmap = new ImageMapFloat(flatmapFilePath, pkg.ReadByteArray()); if (!Flatmap.CreateMap()) { Flatmap = null; } } } var forestmapFilePath = pkg.ReadString(); if (!string.IsNullOrEmpty(forestmapFilePath)) { Forestmap = new ImageMapFloat(forestmapFilePath, pkg.ReadByteArray()); if (!Forestmap.CreateMap()) { Forestmap = null; } ForestmapMultiply = pkg.ReadSingle(); ForestmapAdd = pkg.ReadSingle(); } DisableMapEdgeDropoff = pkg.ReadBool(); MountainsAllowedAtCenter = pkg.ReadBool(); ForestFactorOverrideAllTrees = pkg.ReadBool(); } // Version 6 if (Version >= 6) { HeightmapOverrideAll = pkg.ReadBool(); HeightmapMask = pkg.ReadSingle(); } else { HeightmapOverrideAll = false; HeightmapMask = 0; } } }
// Token: 0x06000918 RID: 2328 RVA: 0x0004377C File Offset: 0x0004197C public static void Deserialize(ParameterInfo[] paramInfo, ZPackage pkg, ref List <object> parameters) { for (int i = 1; i < paramInfo.Length; i++) { ParameterInfo parameterInfo = paramInfo[i]; if (parameterInfo.ParameterType == typeof(int)) { parameters.Add(pkg.ReadInt()); } else if (parameterInfo.ParameterType == typeof(uint)) { parameters.Add(pkg.ReadUInt()); } else if (parameterInfo.ParameterType == typeof(long)) { parameters.Add(pkg.ReadLong()); } else if (parameterInfo.ParameterType == typeof(float)) { parameters.Add(pkg.ReadSingle()); } else if (parameterInfo.ParameterType == typeof(double)) { parameters.Add(pkg.ReadDouble()); } else if (parameterInfo.ParameterType == typeof(bool)) { parameters.Add(pkg.ReadBool()); } else if (parameterInfo.ParameterType == typeof(string)) { parameters.Add(pkg.ReadString()); } else if (parameterInfo.ParameterType == typeof(ZPackage)) { parameters.Add(pkg.ReadPackage()); } else if (parameterInfo.ParameterType == typeof(List <string>)) { int num = pkg.ReadInt(); List <string> list = new List <string>(num); for (int j = 0; j < num; j++) { list.Add(pkg.ReadString()); } parameters.Add(list); } else if (parameterInfo.ParameterType == typeof(Vector3)) { Vector3 vector = new Vector3(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); parameters.Add(vector); } else if (parameterInfo.ParameterType == typeof(Quaternion)) { Quaternion quaternion = new Quaternion(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); parameters.Add(quaternion); } else if (parameterInfo.ParameterType == typeof(ZDOID)) { parameters.Add(pkg.ReadZDOID()); } else if (parameterInfo.ParameterType == typeof(HitData)) { HitData hitData = new HitData(); hitData.Deserialize(ref pkg); parameters.Add(hitData); } } }
static bool Load(ref Inventory __instance, ref ZPackage pkg) { int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); __instance.m_inventory.Clear(); for (int i = 0; i < num2; i++) { string text = pkg.ReadString(); int stack = pkg.ReadInt(); float durability = pkg.ReadSingle(); Vector2i pos = pkg.ReadVector2i(); bool equiped = pkg.ReadBool(); int quality = 1; if (num >= 101) { quality = pkg.ReadInt(); } int variant = 0; if (num >= 102) { variant = pkg.ReadInt(); } long crafterID = 0L; string crafterName = ""; if (num >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (text != "") { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if (itemPrefab == null) { ZLog.Log("Failed to find item prefab " + text); continue; } ZNetView.m_forceDisableInit = true; GameObject gameObject = UnityEngine.Object.Instantiate(itemPrefab); ZNetView.m_forceDisableInit = false; ItemDrop component = gameObject.GetComponent <ItemDrop>(); if (component == null) { ZLog.Log("Missing itemdrop in " + text); UnityEngine.Object.Destroy(gameObject); continue; } component.m_itemData.m_stack = Mathf.Min(stack, component.m_itemData.m_shared.m_maxStackSize); component.m_itemData.m_durability = durability; component.m_itemData.m_equiped = equiped; component.m_itemData.m_quality = quality; component.m_itemData.m_variant = variant; component.m_itemData.m_crafterID = crafterID; component.m_itemData.m_crafterName = crafterName; if (num == 10000 && component.m_itemData is TyrData) { var tyrData = (TyrData)component.m_itemData; tyrData.Load(pkg); } __instance.AddItem(component.m_itemData, component.m_itemData.m_stack, pos.x, pos.y); UnityEngine.Object.Destroy(gameObject); } } __instance.Changed(); return(false); }