Ejemplo n.º 1
0
            public static Backpack Get(ulong id)
            {
                if (_instance._backpacks.ContainsKey(id))
                {
                    return(_instance._backpacks[id]);
                }

                var fileName = $"{_instance.Name}/{id}";

                TryMigrateData(fileName);

                Backpack backpack;

                if (Interface.Oxide.DataFileSystem.ExistsDatafile(fileName))
                {
                    LoadData(out backpack, fileName);
                }
                else
                {
                    backpack = new Backpack(id);
                    Backpacks.SaveData(backpack, fileName);
                }

                Interface.Oxide.DataFileSystem.GetDatafile(fileName).Settings = new JsonSerializerSettings
                {
                    DefaultValueHandling = DefaultValueHandling.Ignore
                };

                _instance._backpacks.Add(id, backpack);

                backpack.Initialize();

                return(backpack);
            }
Ejemplo n.º 2
0
            public void SaveData()
            {
                _itemDataCollection = _itemContainer.itemList
                                      .Select(ItemData.FromItem)
                                      .ToList();

                Backpacks.SaveData(this, $"{_instance.Name}/{_ownerId}");
            }
Ejemplo n.º 3
0
            public static Backpack Get(ulong id)
            {
                if (id == 0)
                {
                    _instance.PrintWarning("Accessing backpack for ID 0! Please report this to the author with as many details as possible.");
                }

                if (_instance._backpacks.ContainsKey(id))
                {
                    return(_instance._backpacks[id]);
                }

                var fileName = $"{_instance.Name}/{id}";

                TryMigrateData(fileName);

                Backpack backpack;

                if (Interface.Oxide.DataFileSystem.ExistsDatafile(fileName))
                {
                    LoadData(out backpack, fileName);
                }
                else
                {
                    backpack = new Backpack(id);
                    Backpacks.SaveData(backpack, fileName);
                }

                Interface.Oxide.DataFileSystem.GetDatafile(fileName).Settings = new JsonSerializerSettings
                {
                    DefaultValueHandling = DefaultValueHandling.Ignore
                };

                _instance._backpacks.Add(id, backpack);

                backpack.Initialize();

                return(backpack);
            }