Skip to content

Commit

Permalink
add color options for the direct line of fire indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
janxious committed May 24, 2018
1 parent f9117c3 commit 294bcc1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
3 changes: 3 additions & 0 deletions BTMLColorLOSMod/BTMLColorLOSMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<Compile Include="WeaponRangeIndicators_DrawLine_Patch.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\README.md">
<Link>README.md</Link>
</Content>
<Content Include="mod.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
21 changes: 21 additions & 0 deletions BTMLColorLOSMod/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ namespace BTMLColorLOSMod
// into the C# variables used by the mod.
public class Settings
{
#region DirectLineOfFire

// The color to be patched into the game for the coloring direct Line of Fire (LOF)'s
// Defaults to magenta if the user gives us funky data so it should stand out
public Color DirectLineOfFireColor = Color.magenta;

public float[] directLineOfFireColor
{
set => DirectLineOfFireColor = new Color(value[0], value[1], value[2], value[3]);
}

// Controls whether we change the color of the near part of an obstructed LOF line.
public bool DirectLineOfFireActive = false;

public bool directLineOfFireActive
{
set => DirectLineOfFireActive = value;
}

#endregion

#region IndirectLineOfFireArcOptions

// The color to be patched into the game for coloring indirect lines of fire
Expand Down
25 changes: 24 additions & 1 deletion BTMLColorLOSMod/WeaponRangeIndicators_DrawLine_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,52 @@ public static class WeaponRangeIndicators_DrawLine_Patch
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
Color color5 = Color.Lerp(Color.clear, __instance.LOSInRange, shotQuality);
LineRenderer lineRenderer4 = line;
Color color2 = lineRenderer4.startColor = (line.endColor = color5);
Color color2 = lineRenderer4.startColor = line.endColor = color5;
}

line.material = __instance.MaterialInRange;
// straight line shot
if (previewInfo.HasLOF)
{
// LOF unobstructed
line.positionCount = 2;
line.SetPosition(0, vector);
Vector3 vector4 = vector - vector2;
vector4.Normalize();
vector4 *= __instance.LineEndOffset;
vector2 += vector4;

if (previewInfo.LOFLevel == LineOfFireLevel.LOFClear)
{
// ???
if (target == HUD.SelectionHandler.ActiveState.FacingEnemy)
{
Logger.LogLine("LOF facing");

if (ModSettings.DirectLineOfFireActive)
{

float shotQuality = (float) ReflectionHelper.InvokePrivateMethode(__instance,
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
line.material.color = Color.white;
line.endColor = line.startColor = Color.Lerp(Color.clear, ModSettings.DirectLineOfFireColor, shotQuality);
}
line.startWidth =
__instance.LOSWidthBegin * __instance.LOSWidthFacingTargetMultiplier;
line.endWidth = __instance.LOSWidthEnd * __instance.LOSWidthFacingTargetMultiplier;
}
else
{
// enemy in firing arc and have shot
if (ModSettings.DirectLineOfFireActive)
{

float shotQuality = (float) ReflectionHelper.InvokePrivateMethode(__instance,
"GetShotQuality", new object[] {selectedActor, position, rotation, target});
line.material.color = Color.white;
line.endColor = line.startColor = Color.Lerp(Color.clear, ModSettings.DirectLineOfFireColor, shotQuality);
}

line.startWidth = __instance.LOSWidthBegin;
line.endWidth = __instance.LOSWidthEnd;
}
Expand Down
9 changes: 6 additions & 3 deletions BTMLColorLOSMod/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Name": "BTMLColorLOSMod",
"Enabled": true,

"Version": "0.2.0",
"Version": "0.4.0",

"Author": "janxious",
"Website": "https://github.com/janxious/BTMLColorLOSMod",
Expand All @@ -13,14 +13,17 @@
"ConflictsWith": [],

"Settings": {
"directLineOfFireActive": false,
"directLineOfFireColor": [0, 1, 0.5, 1],

"indirectLineOfFireArcActive": true,
"indirectLineOfFireArcColor": [1, 0.5, 0, 1],
"indirectLineOfFireArcDashed": false,
"indirectLineOfFireArcDashedThicknessMultiplier": 1.75,

"obstructedLineOfFireAttackerSideActive": false,
"obstructedLineOfFireAttackerSideColor": [0, 0.25, 1, 1],

"obstructedLineOfFireTargetSideActive": true,
"obstructedLineOfFireTargetSideColor": [0.6, 0, 1, 0.9],
"obstructedLineOfFireTargetSiteThicknessMultiplier": 1.25
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ You've been in the situation where the lines are both red and you move and then

<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">

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.

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

Setting | Type | Default | Description
--- | --- | --- | ---
`directLineOfFireArcActive` | `bool` | `false` | change the look of the direct firing line arc
`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).
`indirectLineOfFireArcActive` | `bool` | `true` | change the look of the indirect firing line arc
`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).
`indirectLineOfFireArcDashed` | `bool` | `false` | make the indirect firing line arc a dashed line
Expand Down

0 comments on commit 294bcc1

Please sign in to comment.