mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
First commit
This commit is contained in:
parent
ddda70a258
commit
8e6918ae70
95 changed files with 20766 additions and 1 deletions
75
Source/Scripts/Comps/CompApparelVisibility.cs
Normal file
75
Source/Scripts/Comps/CompApparelVisibility.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
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 = true;
|
||||
|
||||
private IntVec3 cellPosition;
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
Scribe_Values.Look(ref position, "position", default);
|
||||
Scribe_Values.Look(ref cellPosition, "cellPosition", default);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*public bool IsBeingWorn()
|
||||
{
|
||||
Pawn pawn = apparel.Wearer;
|
||||
|
||||
if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
|
||||
{ return true; }
|
||||
|
||||
foreach (ApparelGraphicRecord record in pawn.Drawer.renderer.graphics.apparelGraphics)
|
||||
{
|
||||
if (record.sourceApparel == apparel)
|
||||
{ return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
//var methodInfo = AccessTools.Method(typeof(GenPlace), "TryFindPlaceSpotNear", null, null);
|
||||
//object[] parameters = new object[] { apparel.Wearer.Position, default(Rot4), apparel.Wearer.Map, apparel.Wearer, false, null, null };
|
||||
//object result = methodInfo.Invoke(null, parameters);
|
||||
|
||||
/*bool _result = (bool)result;
|
||||
if (_result)
|
||||
{
|
||||
bestSpot = (IntVec3)parameters[5];
|
||||
DebugMode.Message("Best position: " + bestSpot.ToString());
|
||||
}*/
|
15
Source/Scripts/Comps/CompProperties_ApparelVisibility.cs
Normal file
15
Source/Scripts/Comps/CompProperties_ApparelVisibility.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
public class CompProperties_ApparelVisibility : CompProperties
|
||||
{
|
||||
public CompProperties_ApparelVisibility()
|
||||
{
|
||||
base.compClass = typeof(CompApparelVisibility);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue