Skip to content

Commit

Permalink
v3.0.3 supports Vehicle Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed May 13, 2024
1 parent f325b24 commit 8caf6e3
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
Binary file modified 1.5/Assemblies/CameraPlus.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</li>
</modDependencies>
<packageId>brrainz.cameraplus</packageId>
<modVersion>3.0.2.0</modVersion>
<modVersion>3.0.3.0</modVersion>
<steamAppId>867467808</steamAppId>
<url>https://github.com/pardeike/CameraPlus</url>
<description>You want more zoom and different paning?
Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.cameraplus</identifier>
<version>3.0.2.0</version>
<version>3.0.3.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ModName>Camera+</ModName>
<ModFileName>CameraPlus</ModFileName>
<Repository>https://github.com/pardeike/CameraPlus</Repository>
<ModVersion>3.0.2.0</ModVersion>
<ModVersion>3.0.3.0</ModVersion>
<ProjectGuid>{AC5EE7A1-16EA-498D-B21A-83ACF78F0E5A}</ProjectGuid>
</PropertyGroup>
</Project>
6 changes: 4 additions & 2 deletions Source/DotTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Postfix()

var markersTreshold = FastUI.CurUICellSize <= Settings.dotSize;
var altitute = AltitudeLayer.Silhouettes.AltitudeFor();
map.mapPawns.AllPawnsSpawned.OrderBy(pawn => pawn.thingIDNumber).DoIf(pawn => Tools.ShouldShowMarker(pawn, false), pawn =>
map.mapPawns.AllPawnsSpawned.DoIf(pawn => Tools.ShouldShowMarker(pawn, false), pawn =>
{
altitute -= 0.0001f;
Expand Down Expand Up @@ -148,7 +148,9 @@ static void DrawMarker(Pawn pawn, Material materialMarker)
var q = pawn.Downed ? downedRotation : Quaternion.identity;
var posMarker = pawn.Drawer.renderer.GetBodyPos(pawn.DrawPos, pawn.GetPosture(), out _);
_ = pawn.Drawer.renderer.renderTree.nodesByTag.TryGetValue(PawnRenderNodeTagDefOf.Body, out var bodyNode);
var size = (bodyNode?.Graphic ?? pawn.Graphic)?.drawSize ?? pawn.DrawSize;
var isAnimal = pawn.RaceProps.Animal && pawn.Name != null;
var miscPlayer = isAnimal == false && pawn.Faction == Faction.OfPlayer && pawn.IsColonistPlayerControlled == false;
var size = miscPlayer ? 1.5f * Vector2.one : (bodyNode?.Graphic ?? pawn.Graphic)?.drawSize ?? pawn.DrawSize;
var matrixMarker = Matrix4x4.TRS(posMarker, q, Vector3.one * Mathf.Pow((size.x + size.y) / 2, 1 / markerSizeScaler) * markerScale * Settings.dotRelativeSize);
var mesh = pawn.Rotation == Rot4.West ? meshWest : meshEast;
Graphics.DrawMesh(mesh, matrixMarker, materialMarker, 0);
Expand Down
19 changes: 19 additions & 0 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ public static bool Prefix(Pawn ___pawn)
}
}

[HarmonyPatch]
static class VehicleRenderer_RenderPawnAt_Patch
{
public static bool Prepare() => TargetMethod() != null;
public static MethodBase TargetMethod() => AccessTools.Method("Vehicles.VehicleRenderer:RenderPawnAt");

[HarmonyPriority(10000)]
public static bool Prefix(Pawn ___vehicle)
{
if (skipCustomRendering)
return true;

if (___vehicle.Dead)
return FastUI.CurUICellSize > Settings.hideDeadPawnsBelow;

return Tools.ShouldShowMarker(___vehicle, true) == false;
}
}

[HarmonyPatch(typeof(SelectionDrawer), nameof(SelectionDrawer.DrawSelectionBracketFor))]
static class SelectionDrawer_DrawSelectionBracketFor_Patch
{
Expand Down
16 changes: 15 additions & 1 deletion Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace CameraPlus
{
class Tools
{
static readonly Type vehicleType = AccessTools.TypeByName("Vehicles.VehiclePawn");

static readonly QuotaCache<Pawn, int, bool> shouldShowDotCache = new(60, pawn => pawn.thingIDNumber, pawn =>
{
if (Settings.customNameStyle == LabelStyle.HideAnimals && pawn.RaceProps.Animal)
Expand Down Expand Up @@ -241,7 +243,12 @@ public static bool GetMarkerColors(Pawn pawn, out Color innerColor, out Color ou
return true;
}

if (pawn.IsPlayerControlled == false)
if (pawn.IsColonistPlayerControlled == false)
{
outerColor = Settings.playerNormalOuterColors[selected].Value;
innerColor = Settings.playerNormalInnerColors[selected].Value;
}
else if (pawn.IsPlayerControlled == false)
{
outerColor = Settings.playerMentalOuterColors[selected].Value;
innerColor = Settings.playerMentalInnerColors[selected].Value;
Expand Down Expand Up @@ -274,6 +281,13 @@ public static void DefaultMarkerTextures(Pawn pawn, out Texture2D innerTexture,
return;
}

if (pawn.IsColonistPlayerControlled == false)
{
innerTexture = Assets.innerColonistTexture;
outerTexture = Assets.outerColonistTexture;
return;
}

var isAnimal = pawn.RaceProps.Animal;
var customAnimalStyle = Settings.customNameStyle == LabelStyle.AnimalsDifferent;
innerTexture = isAnimal && customAnimalStyle ? Assets.innerAnimalTexture : Assets.innerColonistTexture;
Expand Down

0 comments on commit 8caf6e3

Please # to comment.