Skip to content

Commit 294bcc1

Browse files
committed
add color options for the direct line of fire indicator
1 parent f9117c3 commit 294bcc1

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

BTMLColorLOSMod/BTMLColorLOSMod.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
<Compile Include="WeaponRangeIndicators_DrawLine_Patch.cs" />
6565
</ItemGroup>
6666
<ItemGroup>
67+
<Content Include="..\README.md">
68+
<Link>README.md</Link>
69+
</Content>
6770
<Content Include="mod.json" />
6871
</ItemGroup>
6972
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

BTMLColorLOSMod/Settings.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ namespace BTMLColorLOSMod
66
// into the C# variables used by the mod.
77
public class Settings
88
{
9+
#region DirectLineOfFire
10+
11+
// The color to be patched into the game for the coloring direct Line of Fire (LOF)'s
12+
// Defaults to magenta if the user gives us funky data so it should stand out
13+
public Color DirectLineOfFireColor = Color.magenta;
14+
15+
public float[] directLineOfFireColor
16+
{
17+
set => DirectLineOfFireColor = new Color(value[0], value[1], value[2], value[3]);
18+
}
19+
20+
// Controls whether we change the color of the near part of an obstructed LOF line.
21+
public bool DirectLineOfFireActive = false;
22+
23+
public bool directLineOfFireActive
24+
{
25+
set => DirectLineOfFireActive = value;
26+
}
27+
28+
#endregion
29+
930
#region IndirectLineOfFireArcOptions
1031

1132
// The color to be patched into the game for coloring indirect lines of fire

BTMLColorLOSMod/WeaponRangeIndicators_DrawLine_Patch.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,52 @@ static bool Prefix(
113113
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
114114
Color color5 = Color.Lerp(Color.clear, __instance.LOSInRange, shotQuality);
115115
LineRenderer lineRenderer4 = line;
116-
Color color2 = lineRenderer4.startColor = (line.endColor = color5);
116+
Color color2 = lineRenderer4.startColor = line.endColor = color5;
117117
}
118118

119119
line.material = __instance.MaterialInRange;
120120
// straight line shot
121121
if (previewInfo.HasLOF)
122122
{
123+
// LOF unobstructed
123124
line.positionCount = 2;
124125
line.SetPosition(0, vector);
125126
Vector3 vector4 = vector - vector2;
126127
vector4.Normalize();
127128
vector4 *= __instance.LineEndOffset;
128129
vector2 += vector4;
130+
129131
if (previewInfo.LOFLevel == LineOfFireLevel.LOFClear)
130132
{
133+
// ???
131134
if (target == HUD.SelectionHandler.ActiveState.FacingEnemy)
132135
{
136+
Logger.LogLine("LOF facing");
137+
138+
if (ModSettings.DirectLineOfFireActive)
139+
{
140+
141+
float shotQuality = (float) ReflectionHelper.InvokePrivateMethode(__instance,
142+
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
143+
line.material.color = Color.white;
144+
line.endColor = line.startColor = Color.Lerp(Color.clear, ModSettings.DirectLineOfFireColor, shotQuality);
145+
}
133146
line.startWidth =
134147
__instance.LOSWidthBegin * __instance.LOSWidthFacingTargetMultiplier;
135148
line.endWidth = __instance.LOSWidthEnd * __instance.LOSWidthFacingTargetMultiplier;
136149
}
137150
else
138151
{
152+
// enemy in firing arc and have shot
153+
if (ModSettings.DirectLineOfFireActive)
154+
{
155+
156+
float shotQuality = (float) ReflectionHelper.InvokePrivateMethode(__instance,
157+
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
158+
line.material.color = Color.white;
159+
line.endColor = line.startColor = Color.Lerp(Color.clear, ModSettings.DirectLineOfFireColor, shotQuality);
160+
}
161+
139162
line.startWidth = __instance.LOSWidthBegin;
140163
line.endWidth = __instance.LOSWidthEnd;
141164
}

BTMLColorLOSMod/mod.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Name": "BTMLColorLOSMod",
33
"Enabled": true,
44

5-
"Version": "0.2.0",
5+
"Version": "0.4.0",
66

77
"Author": "janxious",
88
"Website": "https://github.com/janxious/BTMLColorLOSMod",
@@ -13,14 +13,17 @@
1313
"ConflictsWith": [],
1414

1515
"Settings": {
16+
"directLineOfFireActive": false,
17+
"directLineOfFireColor": [0, 1, 0.5, 1],
18+
1619
"indirectLineOfFireArcActive": true,
1720
"indirectLineOfFireArcColor": [1, 0.5, 0, 1],
1821
"indirectLineOfFireArcDashed": false,
1922
"indirectLineOfFireArcDashedThicknessMultiplier": 1.75,
20-
23+
2124
"obstructedLineOfFireAttackerSideActive": false,
2225
"obstructedLineOfFireAttackerSideColor": [0, 0.25, 1, 1],
23-
26+
2427
"obstructedLineOfFireTargetSideActive": true,
2528
"obstructedLineOfFireTargetSideColor": [0.6, 0, 1, 0.9],
2629
"obstructedLineOfFireTargetSiteThicknessMultiplier": 1.25

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ You've been in the situation where the lines are both red and you move and then
55

66
<img width="201" alt="screen shot 2018-05-20 at 6 53 02 pm" src="https://user-images.githubusercontent.com/50124/40288821-11b0066e-5c83-11e8-98c2-aba640c7dc73.png">
77

8+
The defaults for this mod setup the indirect line and the nearer target obstructed line to stand out. You can change settings as described below to make the lines very customized in appearance.
89

910
## Features
11+
- Change the color of direct line of fire indicator drawn between the currently controlled mech and enemy targets
1012
- Change the color of indirect line of fire indicator drawn between the currently controlled mech and enemy targets
1113
- Add dashes to the indirect line of fire indicator drawn between the currently controlled mech and enemy targets
1214
- Change the color of the line of fire indicator for obstructed targets on the attacker and target sides of the obstruction
@@ -27,6 +29,8 @@ The `Color` variables below (`float[4]`) are RGBA colors, where the intensity of
2729

2830
Setting | Type | Default | Description
2931
--- | --- | --- | ---
32+
`directLineOfFireArcActive` | `bool` | `false` | change the look of the direct firing line arc
33+
`directLineOfFireArcColor` | `float[4]` | `[0, 1, 0.5, 1]` (light blue) | the color of the direct firing line arc. The default in vanilla is `[1, 0, 0, 1]` (red).
3034
`indirectLineOfFireArcActive` | `bool` | `true` | change the look of the indirect firing line arc
3135
`indirectLineOfFireArcColor` | `float[4]` | `[1, 0.5, 0, 1]` (orange) | the color of the indirect firing line arc. The default in vanilla is `[1, 0, 0, 1]` (red).
3236
`indirectLineOfFireArcDashed` | `bool` | `false` | make the indirect firing line arc a dashed line

0 commit comments

Comments
 (0)