Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified 1.6/Assemblies/FactionLoadout.dll
Binary file not shown.
33 changes: 31 additions & 2 deletions 1.6/Source/Patches/ApparelGenPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,37 @@ private static Apparel GenerateNewApparel(Pawn pawn, SpecRequirementEdit spec)
if (spec.Style != null)
thing.SetStyleDef(spec.Style);

if (spec.Quality != null)
thing.TryGetComp<CompQuality>()?.SetQuality(spec.Quality.Value, ArtGenerationContext.Outsider);
CompQuality compQuality = thing.TryGetComp<CompQuality>();
if (compQuality != null)
{
if (spec.Quality != null)
{
compQuality.SetQuality(spec.Quality.Value, ArtGenerationContext.Outsider);
}
else
{
QualityCategory quality = QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef, thing.def);
if (pawn.royalty != null && pawn.Faction != null)
{
RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(pawn.Faction);
if (currentTitle != null)
{
quality = (QualityCategory)Mathf.Clamp((int)quality, (int)currentTitle.requiredMinimumApparelQuality, 6);
}
}
compQuality.SetQuality(quality, ArtGenerationContext.Outsider);
}
}

if (thing.def.useHitPoints)
{
float healthFactor = pawn.kindDef.gearHealthRange.RandomInRange;
if (healthFactor < 1f)
{
int hitPoints = Mathf.Max(1, Mathf.RoundToInt(healthFactor * (float)thing.MaxHitPoints));
thing.HitPoints = hitPoints;
}
}

if (spec.Color != default)
thing.SetColor(spec.Color, false);
Expand Down
34 changes: 32 additions & 2 deletions 1.6/Source/Patches/WeaponGenPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using HarmonyLib;
using RimWorld;
using UnityEngine;
using Verse;

namespace FactionLoadout.Patches;
Expand Down Expand Up @@ -160,8 +161,37 @@ static ThingWithComps GenerateNewWeapon(Pawn pawn, SpecRequirementEdit spec)
if (spec.Style != null)
thing.SetStyleDef(spec.Style);

if (spec.Quality != null)
thing.TryGetComp<CompQuality>()?.SetQuality(spec.Quality.Value, ArtGenerationContext.Outsider);
CompQuality compQuality = thing.TryGetComp<CompQuality>();
if (compQuality != null)
{
if (spec.Quality != null)
{
compQuality.SetQuality(spec.Quality.Value, ArtGenerationContext.Outsider);
}
else
{
QualityCategory quality = QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef, thing.def);
if (pawn.royalty != null && pawn.Faction != null)
{
RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(pawn.Faction);
if (currentTitle != null)
{
quality = (QualityCategory)Mathf.Clamp((int)quality, (int)currentTitle.requiredMinimumApparelQuality, 6);
}
}
compQuality.SetQuality(quality, ArtGenerationContext.Outsider);
}
}

if (thing.def.useHitPoints)
{
float healthFactor = pawn.kindDef.gearHealthRange.RandomInRange;
if (healthFactor < 1f)
{
int hitPoints = Mathf.Max(1, Mathf.RoundToInt(healthFactor * (float)thing.MaxHitPoints));
thing.HitPoints = hitPoints;
}
}

if (spec.Color != default)
thing.SetColor(spec.Color, false);
Expand Down