Esempio n. 1
0
        internal static void ValidationRulesCheck(MechDef mechDef, ref Dictionary <MechValidationType, List <string> > errorMessages)
        {
            if (locations == null)
            {
                return;
            }

            if (CurrentMechDef == null || mechDef != CurrentMechDef)
            {
                var total = 60; //!TODO get data from mechdef!
                var used  = mechDef.Inventory.Where(i => i.Def != null).Sum(i => i.Def.InventorySize);
                var need  = mechDef.GetReservedSlots();

                if (need > total - used)
                {
                    errorMessages[MechValidationType.InvalidInventorySlots].Add(string.Format("RESERVED: {0} slots requred, you have only {1}", need, total - used));
                }
            }
            else
            {
                var total = locations.Sum(i => i.Value.MaxSlots);
                var used  = locations.Sum(i => i.Value.UsedSlots);
                var need  = CurrentMechDef.GetReservedSlots();

                if (need > total - used)
                {
                    errorMessages[MechValidationType.InvalidInventorySlots].Add(string.Format("RESERVED: {0} slots requred, you have only {1}", need, total - used));
                }
            }
        }
Esempio n. 2
0
        public static void RefreshData(MechDef def)
        {
            if (CurrentMechDef == null)
            {
                return;
            }

            //Control.mod.Logger.Log("refresh required");

            var total = locations.Sum(i => i.Value.MaxSlots);
            var used  = locations.Sum(i => i.Value.UsedSlots);
            var need  = def.GetReservedSlots();
            var slots = need;

            //Control.mod.Logger.Log(string.Format("Refresh slots total:{0} used:{1} free:{2} need:{3}", total, used, total - used, need));

            foreach (var pair in locations)
            {
                slots = pair.Value.Refresh(slots, need <= total - used);
            }
        }