Skip to content

Commit

Permalink
Minor fixes and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
IceRaptor committed Jan 20, 2021
1 parent 41126d3 commit d736317
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 103 deletions.
4 changes: 3 additions & 1 deletion IRTweaks/IRTweaks/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public class FixesFlags
public bool DisableCombatRestarts = true;
public bool DisableCombatSaves = true;
public bool MechbayLayout = true;
public bool MechbayLayoutDisableStore = true;
public bool SkirmishAlwaysUnlimited = true;
public bool SimGameDifficultyLabelsReplacer = true;
public bool StreamlinedMainMenu = true;
Expand Down Expand Up @@ -176,7 +177,8 @@ public void LogConfig()
Mod.Log.Info?.Write($" DisableMPHashCalculation: {this.Fixes.DisableMPHashCalculation}");
Mod.Log.Info?.Write($" ExtendedStats: {this.Fixes.ExtendedStats}");
Mod.Log.Info?.Write($" FlexibleSensorLock: {this.Fixes.FlexibleSensorLock}");
Mod.Log.Info?.Write($" MechbayLayoutFix: {this.Fixes.MechbayLayout}");
Mod.Log.Info?.Write($" MechbayLayout: {this.Fixes.MechbayLayout}");
Mod.Log.Info?.Write($" MechbayLayoutDisableStore: {this.Fixes.MechbayLayoutDisableStore}");
Mod.Log.Info?.Write($" PainTolerance: {this.Fixes.PainTolerance}");
Mod.Log.Info?.Write($" PathfinderTeamFix: {this.Fixes.PathfinderTeamFix}");
Mod.Log.Info?.Write($" RandomStartByDifficulty: {this.Fixes.RandomStartByDifficulty}");
Expand Down
130 changes: 68 additions & 62 deletions IRTweaks/IRTweaks/Modules/UI/MapBoundary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,81 @@

namespace IRTweaks.Modules.UI
{
[HarmonyPatch(typeof(EncounterLayerData), "GetEncounterBoundaryTexture")]
static class MapBoundary
{
// TODO: Add real conditional gate here.
static bool Prepare() => true;
// [HarmonyPatch(typeof(EncounterLayerData), "GetEncounterBoundaryTexture")]
// static class MapBoundary
// {
// // TODO: Add real conditional gate here.
// static bool Prepare() => true;

static void Prefix(EncounterLayerData __instance,
ref Texture2D ___encounterBoundaryTexture, EncounterBoundaryChunkGameLogic ___encounterBoundaryChunk)
{
// Override the default texture composition if it's not already been created. The vanilla method will then return it.
if (___encounterBoundaryTexture == null)
{
int mapBoundaryWidth = SplatMapInfo.mapBoundaryWidth;
//int num = 2048 - SplatMapInfo.mapBoundaryWidth;
int num = 2048 - (SplatMapInfo.mapBoundaryWidth * 2);
Mod.Log.Info?.Write($"Generating boundary texture with mapBoundaryWidth:{mapBoundaryWidth} num: {num}");
// static void Prefix(EncounterLayerData __instance,
// ref Texture2D ___encounterBoundaryTexture, EncounterBoundaryChunkGameLogic ___encounterBoundaryChunk)
// {
// // Override the default texture composition if it's not already been created. The vanilla method will then return it.
// if (___encounterBoundaryTexture == null)
// {
// int mapBoundaryWidth = SplatMapInfo.mapBoundaryWidth;
// int num = 2048 - SplatMapInfo.mapBoundaryWidth;
// Mod.Log.Info?.Write($"Generating boundary texture with mapBoundaryWidth:{mapBoundaryWidth} num: {num}");

// Recalculate the rectHolders for the encounter boundaries
__instance.CalculateEncounterBoundary();
// // Recalculate the rectHolders for the encounter boundaries
// __instance.CalculateEncounterBoundary();

if (___encounterBoundaryChunk != null && ___encounterBoundaryChunk.encounterBoundaryRectList.Count > 0)
{
___encounterBoundaryTexture = new Texture2D(512, 512, TextureFormat.ARGB32, mipChain: false);
// if (___encounterBoundaryChunk != null && ___encounterBoundaryChunk.encounterBoundaryRectList.Count > 0)
// {
// ___encounterBoundaryTexture = new Texture2D(512, 512, TextureFormat.ARGB32, mipChain: false);

// Initialize the map to a flat black
Color[] pixels = ___encounterBoundaryTexture.GetPixels();
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Color.black;
}
___encounterBoundaryTexture.SetPixels(pixels);
// // Initialize the map to a flat black
// Color[] pixels = ___encounterBoundaryTexture.GetPixels();
// for (int i = 0; i < pixels.Length; i++)
// {
// pixels[i] = Color.black;
// }
// ___encounterBoundaryTexture.SetPixels(pixels);

// Iterate all the encounter boundaries
for (int rectIdx = 0; rectIdx < ___encounterBoundaryChunk.encounterBoundaryRectList.Count; rectIdx++)
{
Rect rect = ___encounterBoundaryChunk.encounterBoundaryRectList[rectIdx].rect;
int rectXOrigin = (int)rect.x;
int rectYOrigin = (int)rect.y;
Mod.Log.Info?.Write($"Texturing encounterBoundaryRect at idx: {rectIdx} with coordinates: {rectXOrigin}, {rectYOrigin} ");
// // Iterate the rectangle for each encounter boundary and paint it white, to allow
// // the texture to take effect
// for (int rectIdx = 0; rectIdx < ___encounterBoundaryChunk.encounterBoundaryRectList.Count; rectIdx++)
// {
// Rect rect = ___encounterBoundaryChunk.encounterBoundaryRectList[rectIdx].rect;
// int rectXOrigin = (int)rect.x;
// int rectYOrigin = (int)rect.y;
// Mod.Log.Info?.Write($"Texturing encounterBoundaryRect at idx: {rectIdx} with coordinates: {rectXOrigin}, {rectYOrigin} ");
// Mod.Log.Info?.Write($" -- painting pixels up to x=> {rectXOrigin + 1024 + rect.width}, y=> {rectYOrigin + 1024 + rect.height}");

for (int heightIdx = 0; (float)heightIdx < rect.height; heightIdx++)
{
for (int widthIdx = 0; (float)widthIdx < rect.width; widthIdx++)
{
int posX = widthIdx + 1024 + rectXOrigin;
int posY = heightIdx + 1024 + rectYOrigin;
if (mapBoundaryWidth < posX && posX < num && mapBoundaryWidth < posY && posY < num)
{
Mod.Log.Info?.Write($"Setting pixel at: {posX / 4}, {posY / 4} to white.");
___encounterBoundaryTexture.SetPixel(posX / 4, posY / 4, Color.white);
}
}
}
}
___encounterBoundaryTexture.Apply();
// for (int heightIdx = 0; (float)heightIdx < rect.height; heightIdx++)
// {
// for (int widthIdx = 0; (float)widthIdx < rect.width; widthIdx++)
// {
// int posX = widthIdx + 1024 + rectXOrigin;
// int posY = heightIdx + 1024 + rectYOrigin;
// if (mapBoundaryWidth < posX && posX < num && mapBoundaryWidth < posY && posY < num)
// {
// // Divide by 4 to get the corresponding position on the blit map. So the map will be 4 pixels wide when applied
// // a 2048 texture?
// Mod.Log.Info?.Write($"Setting pixel at: {posX / 4}, {posY / 4} to white.");
// //___encounterBoundaryTexture.SetPixel(posX / 4, posY / 4, Color.white);
// ___encounterBoundaryTexture.SetPixel(posX / 4, posY / 4, Color.red);

// Apply a shader (presumably that illuminates as you get closer?)
Material mat = new Material(Shader.Find("Hidden/BT-ConvertToSDF"));
// }
// }
// }
// }
// ___encounterBoundaryTexture.Apply();

// Blit the shader onto map and update mipmaps
RenderTexture temporary = RenderTexture.GetTemporary(___encounterBoundaryTexture.width, ___encounterBoundaryTexture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
Graphics.Blit(___encounterBoundaryTexture, temporary, mat, 0);
RenderTexture.active = temporary;
//___encounterBoundaryTexture.ReadPixels(new Rect(0f, 0f, ___encounterBoundaryTexture.width, ___encounterBoundaryTexture.height), 0, 0);
___encounterBoundaryTexture.Apply(updateMipmaps: true, makeNoLongerReadable: false);
// // Apply a shader (presumably that illuminates as you get closer?)
// //Material mat = new Material(Shader.Find("Hidden/BT-ConvertToSDF"));
// Material mat = new Material(Shader.Find("Standard"));

RenderTexture.active = null;
}
}
}
}
// // Blit the shader onto map and update mipmaps
// RenderTexture temporary = RenderTexture.GetTemporary(___encounterBoundaryTexture.width, ___encounterBoundaryTexture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
// Graphics.Blit(___encounterBoundaryTexture, temporary, mat, 0);
// RenderTexture.active = temporary;
// ___encounterBoundaryTexture.ReadPixels(new Rect(0f, 0f, ___encounterBoundaryTexture.width, ___encounterBoundaryTexture.height), 0, 0);
// ___encounterBoundaryTexture.Apply(updateMipmaps: true, makeNoLongerReadable: false);

// RenderTexture.active = null;
// }
// }
// }
// }
}
9 changes: 6 additions & 3 deletions IRTweaks/IRTweaks/Modules/UI/MechBayChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ static void Postfix(MechLabPanel __instance)
buttonText.SetText("VALIDATE");

// Disable the store button
Transform storeButtonT = __instance.gameObject.transform.Find("Representation/OBJGROUP_LEFT/OBJ_inventoryLong/OBJ_storeButton");
if (storeButtonT == null) Mod.Log.Error?.Write("Failed to find OBJ_storeButton!");
storeButtonT.gameObject.SetActive(false);
if (Mod.Config.Fixes.MechbayLayoutDisableStore)
{
Transform storeButtonT = __instance.gameObject.transform.Find("Representation/OBJGROUP_LEFT/OBJ_inventoryLong/OBJ_storeButton");
if (storeButtonT == null) Mod.Log.Error?.Write("Failed to find OBJ_storeButton!");
storeButtonT.gameObject.SetActive(false);
}
}
catch (Exception e)
{
Expand Down
55 changes: 32 additions & 23 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Name": "IRTweaks",
"Enabled": true,
"Hidden": true,
"Version": "0.8.2",
"Version": "0.8.7",
"Description": "Miscellaneous Tweaks and Fixes",
"Author": "IceRaptor",
"Website": "https://github.com/IceRaptor/IRTweaks",
Expand All @@ -19,66 +19,75 @@
"AlternateMechNamingStyle": false,
"BuildingDamageColorChange": false,
"BraceOnMeleeWithJuggernaut" : true,
"BulkPurchasing": true,
"BulkScrapping" : true,
"BulkPurchasing": false,
"BulkScrapping" : true,
"CombatLog": false,
"DisableCampaign": true,
"DisableCombatSaves": true,
"DisableCombatRestarts": false,
"DisableMPHashCalculation" : true,
"ExtendedStats": false,
"FlexibleSensorLock": false,
"MechbayLayout" : true,
"MechbayLayoutDisableStore" : true,
"MultiTargetStat": true,
"PainTolerance": true,
"PathfinderTeamFix": true,
"PreventHeadShots": false,
"RandomStartByDifficulty": true,
"ReduceSaveCompression": true,
"ScaleObjectiveBuildingStructure" : true,
"ScaleObjectiveBuildingStructure" : true,
"ShowAllArgoUpgrades": true,
"SimGameDifficultyLabelsReplacer" : false,
"SkirmishAlwaysUnlimited": true,
"SkirmishReset": false,
"SkipDeleteSavePopup": true,
"SpawnProtection": false,
"SpawnProtection": true,
"StreamlinedMainMenu": true,
"UrbanExplosionsFix" : false,
"WeaponTooltip": false
"WeaponTooltip": true
},
"Abilities": {
"FlexibleSensorLockId": "AbilityDefT5A",
"JuggernautId" : "AbilityDefGu8",
"MultiTargetId": "AbilityDefG5"
},
"Combat": {
"CalledShot": {
"DisableAllLocations": true,
"DisableHeadshots": true,
"EnableTacticsModifier": true,
"BaseModifier": -4,
"PilotTags": {}
},
"FlexibleSensorLock": {
"FreeActionWithAbility": false
},
"PainTolerance": {
"ResistPerGuts": 15,
"HeadDamageResistPenaltyPerArmorPoint": 3,
"HeadHitArmorOnlyResistPenaltyMulti": 0.35,
"HeadDamageResistPenaltyPerArmorPoint": 2,
"HeadHitArmorOnlyResistPenaltyMulti": 0.3,
"AmmoExplosionResistPenaltyPerCapacityPercentile": 1,
"OverheatResistPenaltyPerHeatPercentile": 1,
"KnockdownResistPenalty": 6,
"SideLocationDestroyedResistPenalty": 10
},
"ScaledStructure" : {
"ScaledStructure" : {
"DefaultScale" : { "Mod" : 0, "Multi" : 1.0 },
"DifficultyScaling" : {
1 : { "Mod" : 5, "Multi" : 1.0 },
2 : { "Mod" : 10, "Multi" : 1.25 },
3 : { "Mod" : 15, "Multi" : 1.5 },
4 : { "Mod" : 20, "Multi" : 2.0 },
5 : { "Mod" : 25, "Multi" : 2.5 },
6 : { "Mod" : 30, "Multi" : 3.0 },
7 : { "Mod" : 35, "Multi" : 3.5 },
8 : { "Mod" : 40, "Multi" : 4.0 },
9 : { "Mod" : 45, "Multi" : 4.5 },
10 : { "Mod" : 50, "Multi" : 5.0 },
11 : { "Mod" : 55, "Multi" : 5.5 },
12 : { "Mod" : 60, "Multi" : 6.0 }
}
"1" : { "Mod" : 5, "Multi" : 1.0 },
"2" : { "Mod" : 10, "Multi" : 1.25 },
"3" : { "Mod" : 15, "Multi" : 1.5 },
"4" : { "Mod" : 20, "Multi" : 2.0 },
"5" : { "Mod" : 25, "Multi" : 2.5 },
"6" : { "Mod" : 30, "Multi" : 3.0 },
"7" : { "Mod" : 35, "Multi" : 3.5 },
"8" : { "Mod" : 40, "Multi" : 4.0 },
"9" : { "Mod" : 45, "Multi" : 4.5 },
"10" : { "Mod" : 50, "Multi" : 5.0 },
"11" : { "Mod" : 55, "Multi" : 5.5 },
"12" : { "Mod" : 60, "Multi" : 6.0 }
}
},
"SpawnProtection": {
"ApplyGuard": true,
Expand All @@ -94,4 +103,4 @@
"QuantityOnControl": 20
}
}
}
}
29 changes: 15 additions & 14 deletions mod_localized_text.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{

"Dialog" : {
"SCRAP_ALL_TITLE" : "SCRAP ALL IN STORAGE",
"SCRAP_ALL_ASSAULT" : "SCRAP ASSAULTS IN STORAGE",
"SCRAP_ALL_HEAVY" : "SCRAP HEAVIES IN STORAGE",
"SCRAP_ALL_LIGHT" : "SCRAP LIGHTS IN STORAGE",
"SCRAP_ALL_MEDIUM" : "SCRAP MEDIUMS IN STORAGE",

"SCRAP_ALL_DESC" : "This will scrap units currently in storage, gaining {0} c-bills. This action cannot be reversed, you will need to load an earlier save. Are you sure?",

"BUTTON_CANCEL" : "CANCEL",
"BUTTON_SCRAP" : "SCRAP"
},
"Dialog": {
"SCRAP_ALL_TITLE": "SCRAP ALL IN STORAGE",
"SCRAP_ALL_ASSAULT": "SCRAP ASSAULTS IN STORAGE",
"SCRAP_ALL_HEAVY": "SCRAP HEAVIES IN STORAGE",
"SCRAP_ALL_LIGHT": "SCRAP LIGHTS IN STORAGE",
"SCRAP_ALL_MEDIUM": "SCRAP MEDIUMS IN STORAGE",
"SCRAP_ALL_DESC": "This will scrap units currently in storage, gaining {0} c-bills. This action cannot be reversed, you will need to load an earlier save. Are you sure?",
"BUTTON_CANCEL": "CANCEL",
"BUTTON_SCRAP": "SCRAP"
},

"Floaties": {
"INJURY_RESIST": "INJURY RESISTED!"
},

"Labels" : {
"MECHBAY_CONFIRM_TEXT" : "Validate"
},

"Modifiers": {
"CALLED_SHOT": "Called Shot"
},
Expand All @@ -32,4 +33,4 @@
"COMBAT_RESTART_TITLE": "Mission Restarts Disabled",
"COMBAT_RESTART_DETAILS": "Restarting a missing during combat is disabled to prevent errors in modded games. Restarting often leads to corruption at the salvage screen."
}
}
}

0 comments on commit d736317

Please sign in to comment.