diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj index a3c7d59..1aa4c87 100644 --- a/EdBPrepareCarefully.csproj +++ b/EdBPrepareCarefully.csproj @@ -7,7 +7,7 @@ Library EdB.PrepareCarefully EdBPrepareCarefully - 0.14.1.1 + 0.14.2.1 False v3.5 ScenPart_PlayerPawnsArriveMethodCarefully.manifest diff --git a/EdBPrepareCarefully.sln b/EdBPrepareCarefully.sln index 185eeec..68aa448 100644 --- a/EdBPrepareCarefully.sln +++ b/EdBPrepareCarefully.sln @@ -23,9 +23,9 @@ Global $2.FileWidth = 120 $2.TabsToSpaces = False $2.EolMarker = Unix - $2.inheritsSet = null + $2.inheritsSet = VisualStudio $2.inheritsScope = text/plain - $2.scope = application/xml + $2.scope = text/plain $0.CSharpFormattingPolicy = $3 $3.IndentSwitchBody = True $3.ElseNewLinePlacement = NewLine @@ -195,6 +195,6 @@ Global $29.IncludeStaticEntities = True $0.VersionControlPolicy = $31 $31.inheritsSet = Mono - version = 0.14.1.1 + version = 0.14.2.1 EndGlobalSection EndGlobal diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index e3fffe5..bafff0a 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -17,7 +17,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.14.1.1")] +[assembly: AssemblyVersion("0.14.2.1")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/Resources/About/About.xml b/Resources/About/About.xml index 2bfa7a6..f8e4719 100644 --- a/Resources/About/About.xml +++ b/Resources/About/About.xml @@ -3,11 +3,11 @@ EdB Prepare Carefully EdB - 0.14.1241 + 0.14.1249 Customize your colonists, choose your gear and prepare carefully for your crash landing! If you get a set of starting colonists that you like, save them as a preset so that you can start your game the same way next time. -[Version 0.14.1.1] +[Version 0.14.2.1] \ No newline at end of file diff --git a/Resources/CHANGELOG.txt b/Resources/CHANGELOG.txt index 1f3cd5d..a7d9ce9 100644 --- a/Resources/CHANGELOG.txt +++ b/Resources/CHANGELOG.txt @@ -1,3 +1,11 @@ + _____________________________________________________________________________ + + Version 0.14.2.1 + _____________________________________________________________________________ + + - Re-introduced the point system (without the old "fixed points" option). + - Various bug fixes. + _____________________________________________________________________________ Version 0.14.1.1 (2016-07-31) @@ -7,7 +15,7 @@ - Removed the point system. - Added support for the Accessory layer in the apparel selection UI. - _____________________________________________________________________________ + _____________________________________________________________________________ Version 0.13.1.1 (2016-06-13) _____________________________________________________________________________ diff --git a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml index df3869e..9f2e6ae 100644 --- a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml +++ b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml @@ -36,15 +36,15 @@ Points Remaining: {0} Points Spent: {0} Unlimited - Use Points - Enable points if you want to maintain a balanced start by paying for skills, additional colonists and equipment from a fixed number of points. Or disable points entirely to set up your starting colonists however you'd like! + Use Point Limits + Cost You've spent too many points. Failed to load colonists from the preset. Check that all required mods are enabled. Failed to load colonists from the preset. Was the preset created with an earlier version of the game? - Disable points - Enable points - The description for this backstory may not match the name and/or gender that you've selected for this colonist. + The description for this backstory may not match the name and/or gender that you've selected for this colonist. + +This has no impact on gameplay, but you may notice the mismatch when reading the backstory. Age: New Colonist Load Colonist @@ -86,10 +86,10 @@ Animals - Use Points - Enable points if you want to maintain a balanced start by paying for skills, additional colonists and equipment from a pool of available points. Disable points to prepare your starting colonists with no limitations. - Fixed Points - Enable this option to use a fixed number of {0} points instead of using a number of points that matches your random starting colonists. + Use Point Limits + Enable point limits if you want to maintain a balanced start by paying for skills, additional colonists and equipment from a fixed number of available points. Your starting points will match the point cost of the characters and resources that were randomly generated for your chosen scenario. + +Disable point limits to prepare your starting colonists with no limitations. Add Relation... Select a Colonist Select a Relationship @@ -138,5 +138,5 @@ Prepare Carefully is a map generation mod. It appears that you have another mod Your colonist customizations will be ignored. Accessory - + The starting colonists and resources that were randomly generated for this scenario were worth {0} points. \ No newline at end of file diff --git a/Source/Configuration.cs b/Source/Configuration.cs index 48adeaf..a81c1d5 100644 --- a/Source/Configuration.cs +++ b/Source/Configuration.cs @@ -13,7 +13,6 @@ public class Configuration public int maxColonists = 12; public Nullable hardMaxColonists = null; public bool pointsEnabled = false; - public bool fixedPointsEnabled = false; } } diff --git a/Source/CostCalculator.cs b/Source/CostCalculator.cs index 2496216..e4dce73 100644 --- a/Source/CostCalculator.cs +++ b/Source/CostCalculator.cs @@ -110,9 +110,11 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) cost.Clear(); cost.name = pawn.NickName; + // Start with the market value plus a bit of a mark-up. cost.marketValue = pawn.Pawn.MarketValue; cost.marketValue += 300; + // Reduce cost if random injuries have been chosen. if (pawn.RandomInjuries) { float ageMultiplier = pawn.BiologicalAge; if (ageMultiplier > 100) { @@ -124,6 +126,9 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) cost.marketValue -= injuryValue; } + // Calculate passion cost. Each passion above 8 makes all passions + // cost more. Minor passion counts as one passion. Major passion + // counts as 3. double skillCount = pawn.currentPassions.Keys.Count(); double passionLevelCount = 0; double passionLevelCost = 20; @@ -134,7 +139,7 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) int level = pawn.GetSkillLevel(def); if (passion == Passion.Major) { - passionLevelCount += 2.0; + passionLevelCount += 3.0; passionateSkillCount += 1.0; } else if (passion == Passion.Minor) { @@ -142,14 +147,14 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) passionateSkillCount += 1.0; } } - + double levelCost = passionLevelCost; if (passionLevelCount > 8) { double penalty = passionLevelCount - 8; - cost.marketValue += (passionLevelCost + 10) * penalty; - passionLevelCount -= 8; + levelCost += penalty * 0.4; } - cost.marketValue += passionLevelCost * passionLevelCount; + cost.marketValue += levelCost * passionLevelCount; + // Calculat cost of worn apparel. for (int layer = 0; layer < PawnLayers.Count; layer++) { if (PawnLayers.IsApparelLayer(layer)) { var def = pawn.GetAcceptedApparel(layer); @@ -176,7 +181,8 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) cost.apparel += c; } } - + + // Calculate cost for any materials needed for implants. foreach (Implant option in pawn.Implants) { // Check if there are any ancestor parts that override the selection. @@ -213,6 +219,8 @@ public void CalculatePawnCost(ColonistCostDetails cost, CustomPawn pawn) cost.apparel = Math.Ceiling(cost.apparel); cost.bionics = Math.Ceiling(cost.bionics); + // Use a multiplier to balance pawn cost vs. equipment cost. + // Disabled for now. cost.Multiply(1.0); cost.ComputeTotal(); diff --git a/Source/CustomPawn.cs b/Source/CustomPawn.cs index 5029b89..f43b150 100644 --- a/Source/CustomPawn.cs +++ b/Source/CustomPawn.cs @@ -264,7 +264,9 @@ public void ComputeSkillLevelModifiers() foreach (var record in pawn.skills.skills) { skillLevelModifiers[record.def] = ComputeSkillModifier(record.def); } + CopySkillLevelsToPawn(); } + protected int ComputeSkillModifier(SkillDef def) { int value = 0; @@ -343,7 +345,6 @@ protected void CopySkillLevelsToPawn() foreach (var record in pawn.skills.skills) { pawn.skills.GetSkill(record.def).level = GetSkillLevel(record.def); } - } // Set all unmodified skill levels to zero. @@ -561,13 +562,17 @@ public void ClearColorCache() { } public Color GetStuffColor(int layer) { - ThingDef apparelDef = this.selectedApparel[layer]; - if (apparelDef != null) { - Color color = this.colors[layer]; - if (apparelDef.MadeFromStuff) { - ThingDef stuffDef = this.selectedStuff[layer]; - if (!stuffDef.stuffProps.allowColorGenerators) { - return stuffDef.stuffProps.color; + if (this.selectedApparel.Count > layer) { + ThingDef apparelDef = this.selectedApparel[layer]; + if (apparelDef != null) { + Color color = this.colors[layer]; + if (apparelDef.MadeFromStuff) { + ThingDef stuffDef = this.selectedStuff[layer]; + if (stuffDef != null && stuffDef.stuffProps != null) { + if (!stuffDef.stuffProps.allowColorGenerators) { + return stuffDef.stuffProps.color; + } + } } } } diff --git a/Source/EquipmentDatabase.cs b/Source/EquipmentDatabase.cs index cb8ff12..16d4596 100644 --- a/Source/EquipmentDatabase.cs +++ b/Source/EquipmentDatabase.cs @@ -33,54 +33,6 @@ public void BuildEquipmentLists() if (type != -1) { AddThingDef(def, type); } - /* - if (def.weaponTags != null && def.weaponTags.Count > 0) { - if (def.equipmentType != EquipmentType.None && !def.destroyOnDrop && def.canBeSpawningInventory) { - AddThingDef(def, EquipmentDatabaseEntry.TypeWeapon); - } - continue; - } - - if (def.apparel != null) { - if (!def.destroyOnDrop) { - AddThingDef(def, EquipmentDatabaseEntry.TypeApparel); - } - continue; - } - - if (def.CountAsResource) { - if (def.ingestible != null) { - AddThingDef(def, EquipmentDatabaseEntry.TypeFood); - continue; - } - - if ("AIPersonaCore".Equals(def.defName)) { - AddThingDef(def, EquipmentDatabaseEntry.TypeUncategorized); - continue; - } - if ("Neurotrainer".Equals(def.defName)) { - continue; - } - - AddThingDef(def, EquipmentDatabaseEntry.TypeResource); - continue; - } - - if (def.building != null) { - if (def.Minifiable) { - AddThingDef(def, EquipmentDatabaseEntry.TypeBuilding); - } - } - - if (def.isBodyPartOrImplant) { - AddThingDef(def, EquipmentDatabaseEntry.TypeImplant); - continue; - } - - if (def.race != null && def.race.Animal == true) { - AddThingDef(def, EquipmentDatabaseEntry.TypeAnimal); - } - */ } } diff --git a/Source/InjuryManager.cs b/Source/InjuryManager.cs index bd95689..0f48dad 100644 --- a/Source/InjuryManager.cs +++ b/Source/InjuryManager.cs @@ -128,14 +128,13 @@ public void InitializeOptions() } } - // Sort injury options by their label before adding them to the full list of injury options. - oldInjuries.Sort((InjuryOption x, InjuryOption y) => { - return string.Compare(x.Label, y.Label); - }); + // Add old injuries to the full list of injury options + options.AddRange(oldInjuries); + + // Sort by name. options.Sort((InjuryOption x, InjuryOption y) => { return string.Compare(x.Label, y.Label); }); - options.AddRange(oldInjuries); } public void InitializePawnInjuries(Pawn pawn, CustomPawn customPawn) diff --git a/Source/ModController.cs b/Source/ModController.cs index f5b8efc..d3989da 100644 --- a/Source/ModController.cs +++ b/Source/ModController.cs @@ -12,7 +12,7 @@ namespace EdB.PrepareCarefully class ModController : UnityEngine.MonoBehaviour { public static readonly string ModName = "EdB Prepare Carefully"; - public static readonly string Version = "0.13.0.3"; + public static readonly string Version = "0.14.2.1"; Window currentLayer = null; bool gameplay = false; @@ -135,13 +135,10 @@ public void ResetTextures() public bool ModEnabled { get { - ModMetaData mod = ModLister.AllInstalledMods.First((ModMetaData m) => { - return m.Name.Equals(ModName); + ModMetaData mod = ModLister.AllInstalledMods.FirstOrDefault((ModMetaData m) => { + return m.Name.Equals(ModName) && m.Active; }); - if (mod == null) { - return false; - } - return mod.Active; + return mod != null; } } } diff --git a/Source/Page_ConfigureStartingPawnsCarefully.cs b/Source/Page_ConfigureStartingPawnsCarefully.cs index 54c609c..2e92158 100644 --- a/Source/Page_ConfigureStartingPawnsCarefully.cs +++ b/Source/Page_ConfigureStartingPawnsCarefully.cs @@ -178,7 +178,7 @@ public Page_ConfigureStartingPawnsCarefully() return x.label.CompareTo(y.label); } }); - femaleHairDefs.Sort((HairDef x, HairDef y) => { + maleHairDefs.Sort((HairDef x, HairDef y) => { if (x.label == null) { return -1; } diff --git a/Source/Page_Equipment.cs b/Source/Page_Equipment.cs index eade88d..732d159 100644 --- a/Source/Page_Equipment.cs +++ b/Source/Page_Equipment.cs @@ -168,12 +168,11 @@ public void ChangeTab(int index) private AcceptanceReport CanStart() { - // Removing points. - //if (Config.pointsEnabled) { - // if (PrepareCarefully.Instance.PointsRemaining < 0) { - // return new AcceptanceReport("EdB.NotEnoughPoints".Translate()); - // } - //} + if (Config.pointsEnabled) { + if (PrepareCarefully.Instance.PointsRemaining < 0) { + return new AcceptanceReport("EdB.NotEnoughPoints".Translate()); + } + } int pawnCount = PrepareCarefully.Instance.Pawns.Count; if (Config.hardMaxColonists != null && pawnCount > Config.hardMaxColonists) { if (Config.hardMaxColonists == 1) { @@ -456,33 +455,52 @@ protected void DrawEquipmentIcon(Rect rect, EquipmentDatabaseEntry entry) { GUI.color = entry.color; if (entry.thing == null) { - GUI.DrawTexture(rect, entry.def.uiIcon); + // EdB: Inline copy of static Widgets.ThingIcon(Rect, ThingDef) with the selected + // color based on the stuff. + GUI.color = entry.color; + // EdB: Inline copy of static private method with modifications to keep scaled icons within the + // bounds of the specified Rect and to draw them using the stuff color. + //Widgets.ThingIconWorker(rect, thing.def, thingDef.uiIcon); + float num = GenUI.IconDrawScale(entry.def); + Rect resizedRect = rect; + if (num != 1f) { + // For items that are going to scale out of the bounds of the icon rect, we need to shrink + // the bounds a little. + if (num > 1) { + resizedRect = rect.ContractedBy(4); + } + resizedRect.width *= num; + resizedRect.height *= num; + resizedRect.center = rect.center; + } + GUI.DrawTexture(resizedRect, entry.def.uiIcon); + GUI.color = Color.white; } else { - // EdB: Inline copy of static Widgets.ThingIcon() with graphics switched to show a side view instead of front view. + // EdB: Inline copy of static Widgets.ThingIcon(Rect, Thing) with graphics switched to show a side view + // instead of a front view. Thing thing = entry.thing; GUI.color = thing.DrawColor; Texture resolvedIcon; if (!thing.def.uiIconPath.NullOrEmpty()) { resolvedIcon = thing.def.uiIcon; } - else { - if (thing is Pawn) { - Pawn pawn = (Pawn)thing; - if (!pawn.Drawer.renderer.graphics.AllResolved) { - pawn.Drawer.renderer.graphics.ResolveAllGraphics(); - } - resolvedIcon = pawn.Drawer.renderer.graphics.nakedGraphic.MatSide.mainTexture; - } - else { - resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatSide.mainTexture; + else if (thing is Pawn) { + Pawn pawn = (Pawn)thing; + if (!pawn.Drawer.renderer.graphics.AllResolved) { + pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } + Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSide; + resolvedIcon = matSingle.mainTexture; + GUI.color = matSingle.color; + } + else { + resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatSide.mainTexture; } - // EdB: Inline copy of static private method. //Widgets.ThingIconWorker(rect, thing.def, resolvedIcon); float num = GenUI.IconDrawScale(thing.def); - if (num != 1) { + if (num != 1f) { Vector2 center = rect.center; rect.width *= num; rect.height *= num; diff --git a/Source/Page_PrepareCarefully.cs b/Source/Page_PrepareCarefully.cs index ec6eecc..016b8a0 100644 --- a/Source/Page_PrepareCarefully.cs +++ b/Source/Page_PrepareCarefully.cs @@ -70,6 +70,8 @@ protected void DrawCost(Rect parentRect) Widgets.Label(rect, label); string tooltipText = ""; + tooltipText += "EdB.PrepareCarefully.ScenarioPoints".Translate(new object[] { PrepareCarefully.Instance.StartingPoints }); + tooltipText += "\n\n"; foreach (var c in cost.colonistDetails) { tooltipText += "EdB.CostSummaryColonist".Translate(new object[] { c.name, (c.total - c.apparel - c.bionics)}) + "\n"; } @@ -84,8 +86,6 @@ protected void DrawCost(Rect parentRect) Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; - // Removed points. - /* string optionLabel; float optionTop = parentRect.height - 97; optionLabel = "EdB.PrepareCarefully.UsePoints".Translate(); @@ -95,16 +95,6 @@ protected void DrawCost(Rect parentRect) GUI.color = Color.white; TooltipHandler.TipRegion(optionRect, "EdB.PrepareCarefully.UsePoints.Tip".Translate()); Widgets.Checkbox(new Vector2(optionRect.x + optionRect.width, optionRect.y - 3), ref Config.pointsEnabled, 24, false); - - GUI.color = ColorText; - optionLabel = "EdB.PrepareCarefully.FixedPoints".Translate(); - Vector2 fixedPointsSize = Text.CalcSize(optionLabel); - Rect fixedPointsRect = new Rect(optionRect.x + optionRect.width + 40, optionTop, fixedPointsSize.x + 10, 32); - Widgets.Label(fixedPointsRect, optionLabel); - GUI.color = Color.white; - TooltipHandler.TipRegion(fixedPointsRect, "EdB.PrepareCarefully.FixedPoints.Tip".Translate(new object[] { Config.points })); - Widgets.Checkbox(new Vector2(fixedPointsRect.x + fixedPointsRect.width, fixedPointsRect.y - 3), ref Config.fixedPointsEnabled, 24, !Config.pointsEnabled); - */ } protected void DrawPresetButtons() diff --git a/Source/Panel_Health.cs b/Source/Panel_Health.cs index 30b788e..2dd16bc 100644 --- a/Source/Panel_Health.cs +++ b/Source/Panel_Health.cs @@ -391,7 +391,6 @@ Dialog_Options injuryOptionDialog protected void ResetInjuryOptionEnabledState(CustomPawn pawn) { - Log.Warning("ResetInjuryOptionEnabledState()"); disabledInjuryOptions.Clear(); InjuryManager injuryManager = PrepareCarefully.Instance.HealthManager.InjuryManager; foreach (var injuryOption in injuryManager.Options) { @@ -400,9 +399,6 @@ protected void ResetInjuryOptionEnabledState(CustomPawn pawn) continue; } Injury injury = pawn.Injuries.FirstOrDefault((Injury i) => { - if (i.Option == option) { - Log.Warning("Pawn has the injury already: " + i.Option.HediffDef.defName); - } return (i.Option == option); }); if (injury != null) { diff --git a/Source/PrepareCarefully.cs b/Source/PrepareCarefully.cs index c5ff31a..61a3172 100644 --- a/Source/PrepareCarefully.cs +++ b/Source/PrepareCarefully.cs @@ -93,12 +93,7 @@ public HealthManager HealthManager { public int PointsRemaining { get { - if (config.fixedPointsEnabled) { - return config.points - (int) Cost.total; - } - else { - return StartingPoints - (int) Cost.total; - } + return StartingPoints - (int) Cost.total; } } diff --git a/Source/Version3/PresetLoaderVersion3.cs b/Source/Version3/PresetLoaderVersion3.cs index ad407d5..4524ccd 100644 --- a/Source/Version3/PresetLoaderVersion3.cs +++ b/Source/Version3/PresetLoaderVersion3.cs @@ -28,7 +28,6 @@ public bool Load(PrepareCarefully loadout, string presetName) Scribe_Values.LookValue(ref usePoints, "usePoints", true, false); Scribe_Values.LookValue(ref startingPoints, "startingPoints", 0, false); - PrepareCarefully.Instance.StartingPoints = startingPoints; Scribe_Values.LookValue(ref ModString, "mods", "", false); try {