Inheritance: CountedInstance
Esempio n. 1
0
        public bool Add(LoadOutItem item)
        {
            if (itemCount >= 30) {
                Logger.LogDebug("[LoadOut] You may not add more then 30 items to one loadout.");

                return false;
            }

            items.Add(itemCount, item);
            itemCount++;

            if (Server.GetInstance().LoadOuts.ContainsKey(Name))
                Server.GetInstance().LoadOuts.Remove(Name);

            Server.GetInstance().LoadOuts.Add(Name, this);

            return true;
        }
Esempio n. 2
0
        public LoadOut(string name)
        {
            path = Path.Combine(Singleton<Rust.Util>.Instance.GetLoadoutFolder(), name + ".ini");
            bool nu = false;

            if (!File.Exists(path)) {
                File.AppendAllText(path, "");
                nu = true;
            }

            IniParser ini = new IniParser(path);
            Name = ini.Name;

            if (!nu) {
                itemCount = Int32.Parse(ini.GetSetting("Def", "itemCount"));
                OwnerUse = ini.GetBoolSetting("Def", "ownerCanUse");
                ModeratorUse = ini.GetBoolSetting("Def", "modCanUse");
                NormalUse = ini.GetBoolSetting("Def", "normalCanUse");
            } else {
                itemCount = 0;
                OwnerUse = true;
                NormalUse = true;
                ModeratorUse = true;
            }

            items = new Dictionary<int, LoadOutItem>(30);

            if (itemCount != 0) {
                for (int i = 0; i < itemCount; i++) {
                    string namee = ini.GetSetting(i.ToString(), "Name");
                    int amount;
                    if (!Int32.TryParse(ini.GetSetting(i.ToString(), "Amount"), out amount))
                        amount = Int32.MaxValue;
                    LoadOutItem current = new LoadOutItem(namee, amount);
                    items.Add(i, current);
                }
            }

            if (Server.GetInstance().LoadOuts.ContainsKey(Name))
                Server.GetInstance().LoadOuts.Remove(Name);

            Server.GetInstance().LoadOuts.Add(Name, this);
        }
Esempio n. 3
0
 public void Notice(LoadOutItem loItem) => Notice($"{InvItem.GetItemID(loItem.Name)} {loItem.Amount}");