Skip to content

Commit

Permalink
Merge pull request #2822 from CombatExtended-Continued/vehicledamage
Browse files Browse the repository at this point in the history
Vehicle Framework Armor
  • Loading branch information
perkinslr authored Oct 26, 2023
2 parents 5c5f658 + 05f91e4 commit 82fb16e
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 18 deletions.
Binary file modified Assemblies/0CombatExtendedLoader.dll
Binary file not shown.
10 changes: 9 additions & 1 deletion Languages/English/Keyed/ModMenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,12 @@
<CE_Settings_BipodAutoSetUp_Title>Toggle bipod autosetup</CE_Settings_BipodAutoSetUp_Title>
<CE_Settings_BipodAutoSetUp_Desc>Weapons with bipods will automatically start setting up when not set to snapshot.</CE_Settings_BipodAutoSetUp_Desc>

</LanguageData>
<!-- ========== Compatibility settings ========== -->

<CE_Settings_Vehicles>Vehicle settings</CE_Settings_Vehicles>

<CE_Settings_PatchArmorDamage_Title>Use New Vehicle Armor</CE_Settings_PatchArmorDamage_Title>
<CE_Settings_PatchArmorDamage_Desc>Vehicle Armor reduces damage based on relative values, but can be penetrated by high AP attacks..</CE_Settings_PatchArmorDamage_Desc>


</LanguageData>
13 changes: 6 additions & 7 deletions Source/CombatExtended/CombatExtended/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public class Settings : ModSettings, ISettingsCE

private bool lastAmmoSystemStatus;

#region Compatibility Modsettings
public bool patchArmorDamage = true;

#endregion

#region Methods

public override void ExposeData()
Expand Down Expand Up @@ -202,12 +207,8 @@ public override void ExposeData()
lastAmmoSystemStatus = enableAmmoSystem; // Store this now so we can monitor for changes
}

public void DoWindowContents(Rect canvas, ref int offset)
public void DoWindowContents(Listing_Standard list)
{
Listing_Standard list = new Listing_Standard();
list.ColumnWidth = (canvas.width - 17) / 2; // Subtract 17 for gap between columns
list.Begin(canvas);

// Do general settings
Text.Font = GameFont.Medium;
list.Label("CE_Settings_HeaderGeneral".Translate());
Expand Down Expand Up @@ -329,7 +330,6 @@ public void DoWindowContents(Rect canvas, ref int offset)
// list.Gap();
//}
#endif
list.End();

// Update ammo if setting changes
if (lastAmmoSystemStatus != enableAmmoSystem)
Expand All @@ -343,7 +343,6 @@ public void DoWindowContents(Rect canvas, ref int offset)
{
AmmoInjector.AddRemoveCaliberFromGunRecipes();
}

}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Source/Loader/Loader/ISettingsCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace CombatExtended.Loader
{
public interface ISettingsCE
{
public void DoWindowContents(Rect canvas, ref int offset);
public void DoWindowContents(Listing_Standard list);
}
}
27 changes: 21 additions & 6 deletions Source/Loader/Loader/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ required modules are loaded.
Then each IModPart's PostLoad method is called, with an ISettingsCE if desired (or null).
*/
private static List<ISettingsCE> settingList = new List<ISettingsCE>();
public static List<ISettingsCE> settingList = new List<ISettingsCE>();
private static Loader instance = null;
private Vector2 scrollPosition;

private ModContentPack content;

Expand Down Expand Up @@ -138,7 +139,14 @@ public Loader(ModContentPack content) : base(content)
ISettingsCE settings = null;
if (settingsType != null)
{
settings = (ISettingsCE)typeof(Loader).GetMethod(nameof(Loader.GetSettings)).MakeGenericMethod(settingsType).Invoke(instance, null);
if (typeof(ModSettings).IsAssignableFrom(settingsType))
{
settings = (ISettingsCE)typeof(Loader).GetMethod(nameof(Loader.GetSettings)).MakeGenericMethod(settingsType).Invoke(instance, null);
}
else
{
settings = (ISettingsCE)settingsType.GetConstructor(new Type[] { }).Invoke(new object[] { });
}
settingList.Add(settings);
}

Expand Down Expand Up @@ -168,15 +176,22 @@ public override string SettingsCategory()

public override void DoSettingsWindowContents(Rect inRect)
{
int offset = 0;
Rect inner = inRect.ContractedBy(20f);
inner.height = 800f;
inner.x += 10f;
Widgets.BeginScrollView(inRect, ref this.scrollPosition, inner, true);
Listing_Standard list = new Listing_Standard();
list.ColumnWidth = (inner.width - 17) / 2; // Subtract 17 for gap between columns
list.Begin(inner);

foreach (ISettingsCE settings in settingList)
{
settings.DoWindowContents(inRect, ref offset);
settings.DoWindowContents(list);
}
list.End();
Widgets.EndScrollView();
}



//Unused method is only here for reference, the repository assembly uses it to warn users to get a compiled build.
private static void ShowUncompiledBuildWarning()
{
Expand Down
8 changes: 7 additions & 1 deletion Source/VehiclesCompat/VehiclesCompat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@
<HintPath>..\packages\Vehicles-reference.dll</HintPath>
<Private>False</Private>
</Reference>

<Reference Include="VFESecurity">
<HintPath>..\packages\SmashTools-reference.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4.3704" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.2.2" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>

</Project>
Loading

0 comments on commit 82fb16e

Please sign in to comment.