Skip to content

Commit

Permalink
Working renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
RecompiledBirds committed Oct 24, 2022
1 parent e917928 commit 009a4c8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
Binary file modified 1.4/Assemblies/RimValiCore RW.dll
Binary file not shown.
5 changes: 2 additions & 3 deletions Source/RVR/Harmony/Renderer/PawnRendererPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ public static void RenderingPostfix(Vector3 rootLoc, float angle, bool renderBod
{
set = new TriColorSet(Color.red, Color.green, Color.blue, true);
}
// Graphic_Multi gra = (Graphic_Multi)GraphicDatabase.Get<Graphic_Multi>(comp.GetTexPath(renderableDef), TriColorShader.tricolorshader, pos.size, set[1], set[2]);

RVG_Graphic graphic = RVG_GraphicDataBase.Get<RVG_Graphic_Multi>(comp.GetTexPath(renderableDef), pos.size, set[0], set[1], set[2]);
GenDraw.DrawMeshNowOrLater(graphic.MeshAt(rotation), rootLoc + pos.position.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat) * 114.59156f)), quat, graphic.MatAt(rotation), flags.FlagSet(PawnRenderFlags.DrawNow));
// GenDraw.DrawMeshNowOrLater(gra.MeshAt(rotation), rootLoc + pos.position.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat) * 114.59156f)), quat, gra.MatAt(rotation), flags.FlagSet(PawnRenderFlags.DrawNow));
GenDraw.DrawMeshNowOrLater(graphic.MeshAt(rotation), rootLoc + pos.position.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 114.60f), Quaternion.AngleAxis(angle, Vector3.up) * quat, graphic.MatAt(rotation), portrait||flags.FlagSet(PawnRenderFlags.DrawNow));


}
Expand Down
5 changes: 4 additions & 1 deletion Source/RVR/Harmony/Renderer/ResolveGraphicsPostFix.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RVCRestructured.Graphics;
using RimWorld;
using RVCRestructured.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -33,6 +34,8 @@ public static void ResolveGraphicsPatch(PawnGraphicSet __instance)
if (!rDef.RaceGraphics.hasHair)
__instance.hairGraphic = RVG_GraphicDataBase.Get<RVG_Graphic_Multi>("RVC/Empty");
__instance.headGraphic = RVG_GraphicDataBase.Get<RVG_Graphic_Multi>(rDef.RaceGraphics.headTex,rDef.RaceGraphics.headSize,skinOne,skinTwo,skinThree);
__instance.SetApparelGraphicsDirty();
PortraitsCache.SetDirty(pawn);
}
}
}
29 changes: 24 additions & 5 deletions Source/RVR/RVRComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public RVRCP()
}
public class RVRComp : ThingComp
{
private List<RenderableDef> defList;

public List<RenderableDef> RenderableDefs
{
get
{
return defList;
}
}

private Dictionary<string, TriColorSet> sets = new Dictionary<string, TriColorSet>();
private Dictionary<string, int> masks = new Dictionary<string, int>();
private Dictionary<string, int> renderableIndexes = new Dictionary<string, int>();
Expand All @@ -38,12 +48,13 @@ public string GetTexPath(RenderableDef def) {
public TriColorSet this[string name]{
get
{
if (!sets.ContainsKey(name))
if (sets.ContainsKey(name))
{
RVCLog.Log($"ColorSet {name} is not on {parent.def.defName}!", RVCLogType.Error);
return null;
return sets[name];
}
return sets[name];
Pawn pawn = parent as Pawn;
RVCLog.Log($"ColorSet {name} is not on {pawn.Name.ToStringShort}!", RVCLogType.Error);
return null;
}
set
{
Expand All @@ -65,11 +76,19 @@ public override void PostExposeData()
Scribe_Collections.Look(ref sets, "sets", LookMode.Value, LookMode.Deep, ref lKeys, ref lSets);
Scribe_Collections.Look(ref masks, "masks", LookMode.Value, LookMode.Value, ref lKeys, ref lInts);
Scribe_Collections.Look(ref renderableIndexes, "renderableIndexes", LookMode.Value, LookMode.Value, ref lKeys, ref lInts);
Scribe_Collections.Look(ref defList, "renderableDefs", LookMode.Def);
}

public void GenGraphics()
{
Pawn pawn = this.parent as Pawn;

if (!(pawn.def is RaceDef raceDef))
return;

if (defList.NullOrEmpty()&& !raceDef.RaceGraphics.renderableDefs.NullOrEmpty())
defList = raceDef.raceGraphics.renderableDefs;

foreach(RenderableDef rDef in raceDef.RaceGraphics.renderableDefs)
{
if (renderableIndexes.ContainsKey(rDef.defName))
Expand Down Expand Up @@ -99,7 +118,7 @@ public void GenGraphics()
masks.Add(rDef.linkWith.defName, index);
}
}
foreach(RaceColors colors in raceDef.RaceGraphics.colorGenerators)
foreach(RaceColors colors in this.raceDef.RaceGraphics.colorGenerators)
{
Color c1 = colors.GeneratorToUse(pawn).colorOne.NewRandomizedColor();
Color c2 = colors.GeneratorToUse(pawn).colorTwo.NewRandomizedColor();
Expand Down

0 comments on commit 009a4c8

Please sign in to comment.