mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
56 lines
No EOL
2.1 KiB
C#
56 lines
No EOL
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using RimWorld;
|
|
using Verse;
|
|
using UnityEngine;
|
|
using Rimworld_Animations;
|
|
using HarmonyLib;
|
|
|
|
namespace Rimworld_Animations_Patch
|
|
{
|
|
public class CompApparelVisibility : ThingComp
|
|
{
|
|
public Apparel apparel => base.parent as Apparel;
|
|
public Vector3 position;
|
|
public float rotation = 0f;
|
|
|
|
public bool? isBeingWorn = null;
|
|
public bool coversChest = false;
|
|
public bool coversGroin = false;
|
|
public bool coversBelly = false;
|
|
public RimNudeDataStatus rimNudeDataStatus = RimNudeDataStatus.NotLoaded;
|
|
|
|
private IntVec3 cellPosition;
|
|
|
|
public override void PostExposeData()
|
|
{
|
|
base.PostExposeData();
|
|
|
|
Scribe_Values.Look(ref position, "position", default);
|
|
Scribe_Values.Look(ref rotation, "rotation", 0);
|
|
Scribe_Values.Look(ref cellPosition, "cellPosition", default);
|
|
}
|
|
|
|
// Used to find a place to have clothes thrown onto the floor
|
|
public void GenerateFloorPosition(IntVec3 apparelCell, Vector2 apparelOffset = default)
|
|
{
|
|
Pawn pawn = apparel.Wearer;
|
|
|
|
// Reuse an old location for thrown clothes if the wearer is not too far away from it
|
|
if ((cellPosition - pawn.Position).LengthManhattan <= 2 && cellPosition.GetRoom(pawn.Map) == pawn.GetRoom())
|
|
{ return; }
|
|
|
|
CompBodyAnimator comp = pawn.TryGetComp<CompBodyAnimator>();
|
|
if (comp == null || comp.isAnimating == false)
|
|
{ return; }
|
|
|
|
cellPosition = apparelCell;
|
|
apparel.Rotation = Rot4.Random;
|
|
|
|
Vector3 offset = new Vector3(Rand.Gaussian(apparelOffset.x, apparelOffset.y), 0f, Rand.Gaussian(apparelOffset.x, apparelOffset.y));
|
|
position = cellPosition.ToVector3() + offset + new Vector3(0.5f, AltitudeLayer.ItemImportant.AltitudeFor() - Mathf.Clamp(apparel.def.apparel.LastLayer.drawOrder/100000f, 0f, 1f), 0.5f);
|
|
rotation = 120 * (-1f + 2f * Rand.Value);
|
|
}
|
|
}
|
|
} |