internal void AdjustComponentDef(MechComponentDef def) { if (change == null) { return; } if (!identifier.IsCustomType(def)) { return; } var newSize = change.Change(def.InventorySize); if (newSize < 1) { return; } var value = newSize; var propInfo = typeof(UpgradeDef).GetProperty("InventorySize"); var propValue = Convert.ChangeType(value, propInfo.PropertyType); propInfo.SetValue(def, propValue, null); }
internal void AdjustComponentDef(MechComponentDef def) { if (change == null) { return; } if (!identifier.IsCustomType(def)) { return; } var newTonnage = change.Change(def.Tonnage); if (!newTonnage.HasValue) { return; } var value = newTonnage.Value; var propInfo = typeof(UpgradeDef).GetProperty("Tonnage"); var propValue = Convert.ChangeType(value, propInfo.PropertyType); propInfo.SetValue(def, propValue, null); }
private static void ModifyInventorySlots(ref LocationDef locationDef, ChassisLocations location, ValueChange <int> change) { if (locationDef.Location != location) { return; } var newValue = change.Change(locationDef.InventorySlots); if (newValue < 1) { return; } var info = typeof(LocationDef).GetField("InventorySlots"); var value = Convert.ChangeType(newValue, info.FieldType); var box = (object)locationDef; info.SetValue(box, value); locationDef = (LocationDef)box; //Control.mod.Logger.LogDebug("ModifyInventorySlots InventorySlots=" + locationDef.InventorySlots); }