// 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); }
// 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(); }
// 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); } }
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); }
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); }
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); }