Skip to content

Commit

Permalink
Merge pull request #3186 from CombatExtended-Continued/RenderChanges
Browse files Browse the repository at this point in the history
Render changes
  • Loading branch information
N7Huntsman authored Jun 23, 2024
2 parents d9c849a + 5706024 commit 17553ee
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 485 deletions.
55 changes: 53 additions & 2 deletions Defs/ThingDefs_Misc/Apparel_Shield.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,36 @@
<MeleeParryChance>1.0</MeleeParryChance>
</equippedStatOffsets>
<apparel>
<developmentalStageFilter>Child, Adult</developmentalStageFilter>
<developmentalStageFilter>Child, Adult</developmentalStageFilter>
<tags>
<li>TribalShield</li>
</tags>
<renderNodeProperties>
<li>
<nodeClass>CombatExtended.PawnRenderNode_Apparel</nodeClass>
<workerClass>CombatExtended.PawnRenderNodeWorker_Drafted</workerClass>
<texPath>Things/Apparel/Shield/CE_Shield</texPath>
<shaderTypeDef>CutoutComplex</shaderTypeDef>
<parentTagDef>ApparelBody</parentTagDef>
<drawData>
<scale>0.8</scale>
<defaultData>
<layer>91</layer>
</defaultData>
<dataEast>
<layer>-5</layer>
<offset>(0, 0, -0.1)</offset>
</dataEast>
<dataNorth>
<layer>-5</layer>
<offset>(0.15, 0, -0.1)</offset>
</dataNorth>
<dataSouth>
<offset>(0.3, 0, -0.2)</offset>
</dataSouth>
</drawData>
</li>
</renderNodeProperties>
</apparel>
<modExtensions>
<li Class="CombatExtended.ShieldDefExtension">
Expand Down Expand Up @@ -130,6 +156,32 @@
<tags>
<li>OutlanderShield</li>
</tags>
<renderNodeProperties>
<li>
<nodeClass>CombatExtended.PawnRenderNode_Apparel</nodeClass>
<workerClass>CombatExtended.PawnRenderNodeWorker_Drafted</workerClass>
<texPath>Things/Apparel/BallisticShield/CE_BallisticShield</texPath>
<shaderTypeDef>CutoutComplex</shaderTypeDef>
<parentTagDef>ApparelBody</parentTagDef>
<drawData>
<scale>0.8</scale>
<defaultData>
<layer>91</layer>
</defaultData>
<dataEast>
<layer>-5</layer>
<offset>(0, 0, -0.1)</offset>
</dataEast>
<dataNorth>
<layer>-5</layer>
<offset>(0.15, 0, -0.1)</offset>
</dataNorth>
<dataSouth>
<offset>(0.15, 0, -0.1)</offset>
</dataSouth>
</drawData>
</li>
</renderNodeProperties>
</apparel>
<modExtensions>
<li Class="CombatExtended.ShieldDefExtension">
Expand All @@ -144,7 +196,6 @@
<crouchCoverage>
<li>Legs</li>
</crouchCoverage>
<drawAsTall>true</drawAsTall>
</li>
</modExtensions>
<tradeTags>
Expand Down
2 changes: 1 addition & 1 deletion Source/BetterTurretsCompat/BetterTurretsCompat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4061" GeneratePathProperty="true" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4104" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.3.3" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Source/CombatExtended/CombatExtended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4061" GeneratePathProperty="true" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4104" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.3.3" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace CombatExtended
{
public class PawnRenderNodeWorker_Drafted : PawnRenderNodeWorker
{
public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms)
{
var pawn = node.tree.pawn;
return pawn != null && pawn.Spawned && (pawn.Drafted || (pawn.CurJob?.def.alwaysShowWeapon ?? false) || (pawn.mindState?.duty?.def.alwaysShowWeapon ?? false)) && base.CanDrawNow(node, parms);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;

namespace CombatExtended
{
public class PawnRenderNode_Apparel : Verse.PawnRenderNode_Apparel
{
public PawnRenderNode_Apparel(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree)
{
}
public PawnRenderNode_Apparel(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree, Apparel apparel) : base(pawn, props, tree)
{
}
public PawnRenderNode_Apparel(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree, Apparel apparel, bool useHeadMesh) : base(pawn, props, tree)
{
}
public override IEnumerable<Graphic> GraphicsFor(Pawn pawn)
{
yield return GraphicDatabase.Get((apparel.def.graphicData?.graphicClass ?? typeof(Graphic_Multi)), TexPathFor(pawn), ShaderFor(pawn), apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColorTwo);
}
public override string ToString()
{
return apparel?.ToString() ?? base.ToString();
}
}
}
10 changes: 9 additions & 1 deletion Source/CombatExtended/CombatExtended/Things/Apparel_Shield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ public class Apparel_Shield : Apparel
private const float YOffsetStatus = 0.04296875f;

public const string OneHandedTag = "CE_OneHandedWeapon";
private bool drawShield => Wearer.Drafted || (Wearer.CurJob?.def.alwaysShowWeapon ?? false) || (Wearer.mindState.duty?.def.alwaysShowWeapon ?? false); // Copied from PawnRenderer.CarryWeaponOpenly(), we show the shield whenever weapons are drawn
private bool drawShield => this.def.apparel.renderNodeProperties.NullOrEmpty() && (Wearer.Drafted || (Wearer.CurJob?.def.alwaysShowWeapon ?? false) || (Wearer.mindState.duty?.def.alwaysShowWeapon ?? false)); // Copied from PawnRenderer.CarryWeaponOpenly(), we show the shield whenever weapons are drawn
private bool IsTall => def.GetModExtension<ShieldDefExtension>()?.drawAsTall ?? false;

public override void PostMake()
{
base.PostMake();
if (this.def.apparel.renderNodeProperties.NullOrEmpty())
{
Log.WarningOnce($"{def.defName} using obsolete render system", def.defName.GetHashCodeSafe());
}
}

public override bool AllowVerbCast(Verb verb)
{
Expand Down
Loading

0 comments on commit 17553ee

Please sign in to comment.