Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render changes #3186

Merged
merged 14 commits into from
Jun 23, 2024
27 changes: 26 additions & 1 deletion Defs/ThingDefs_Misc/Apparel_Shield.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,35 @@
<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>
</dataEast>
<dataNorth>
<layer>-5</layer>
<offset>(.15, 0, -.1)</offset>
</dataNorth>
<dataSouth>
<offset>(.3, 0, -.2)</offset>
</dataSouth>
</drawData>
</li>
</renderNodeProperties>
</apparel>
<modExtensions>
<li Class="CombatExtended.ShieldDefExtension">
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();
}
}
}
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
Loading