internal void AdjustComponentDef(MechComponentDef def)
        {
            if (change == null)
            {
                return;
            }

            if (!identifier.IsCustomType(def))
            {
                return;
            }

            var newSize = change.Change(def.InventorySize);

            if (!newSize.HasValue)
            {
                return;
            }

            var value     = newSize.Value;
            var propInfo  = typeof(UpgradeDef).GetProperty("InventorySize");
            var propValue = Convert.ChangeType(value, propInfo.PropertyType);

            propInfo.SetValue(def, propValue, null);
        }
示例#2
0
        internal void AdjustComponentDef(MechComponentDef def)
        {
            if (change == null)
            {
                return;
            }

            if (!identifier.IsCustomType(def))
            {
                return;
            }

            var newTonnage = change.Change(def.Tonnage);

            if (newTonnage < 0)
            {
                return;
            }

            var value     = newTonnage;
            var propInfo  = typeof(UpgradeDef).GetProperty("Tonnage");
            var propValue = Convert.ChangeType(value, propInfo.PropertyType);

            propInfo.SetValue(def, propValue, null);
        }
示例#3
0
        public void AutoFixMechDef(MechDef mechDef)
        {
            if (mechDef.Inventory.Any(x => x.Def != null && identifier.IsCustomType(x.Def)))
            {
                return;
            }

            var componentRefs = new List <MechComponentRef>(mechDef.Inventory);

            var componentRef = new MechComponentRef(adder.ComponentDefId, null, adder.ComponentType, adder.ChassisLocation);

            componentRefs.Add(componentRef);

            mechDef.SetInventory(componentRefs.ToArray());
        }