adding addons to pawn animations

This commit is contained in:
c0ffee 2022-10-15 21:11:33 -07:00
parent 41608bde79
commit 90db02367f
8 changed files with 142 additions and 7 deletions

View File

@ -39,7 +39,54 @@
<animationClips>
<li Class="Rimworld_Animations.PawnAnimationClip">
<layer>LayingPawn</layer>
<keyframes></keyframes>
</li>
<li Class="Rimworld_Animations.PawnAnimationClip">
<addons>
<li>
<name>hand</name>
<path>path/to/texture</path>
</li>
<li>
<name>tail</tail>
<path>path/to/texture2</path>
</li>
</addons>
<keyframes>
<li>
<headBob>0</headBob>
<tickDuration>10</tickDuration>
<bodyAngle>27</bodyAngle>
<bodyOffsetX>0.298</bodyOffsetX>
<bodyOffsetZ>0.166</bodyOffsetZ>
<headAngle>0</headAngle>
<bodyFacing>1</bodyFacing>
<headFacing>2</headFacing>
<addonKeyframes>
<li>
<name>hand</name>
<render>true</render>
<posX>3.2</posX>
<posY>1<posY>
<rotation>30</rotation>
<scale>1.5</scale>
</li>
<li>
<name>tail</name>
<render>true</render>
<posX>3.2</posX>
<posY>1<posY>
<rotation>30</rotation>
<scale>1.5</scale>
</li>
...
</addonKeyframes>
</li>
...
</keyframes>
</li>
<li Class="Rimworld_Animations.PawnAnimationClip">
<keyframes></keyframes>

View File

@ -10,6 +10,10 @@ namespace Rimworld_Animations {
public class PawnAnimationClip : BaseAnimationClip {
public List<PawnKeyframe> keyframes;
public List<AddonInfo> addons = new List<AddonInfo>();
public List<AddonKeyframe> addonKeyframes = new List<AddonKeyframe>();
public AltitudeLayer layer = AltitudeLayer.Pawn;
public Dictionary<int, bool> quiver = new Dictionary<int, bool>();
@ -21,6 +25,13 @@ namespace Rimworld_Animations {
public SimpleCurve BodyOffsetZ = new SimpleCurve();
public SimpleCurve HeadFacing = new SimpleCurve();
public SimpleCurve BodyFacing = new SimpleCurve();
public Dictionary<string, SimpleCurve> addonsPosX = new Dictionary<string, SimpleCurve>();
public Dictionary<string, SimpleCurve> addonsPosY = new Dictionary<string, SimpleCurve>();
public Dictionary<string, SimpleCurve> addonsRotation = new Dictionary<string, SimpleCurve>();
public Dictionary<string, SimpleCurve> addonsScale = new Dictionary<string, SimpleCurve>();
public Dictionary<string, Dictionary<int, bool>> addonsShouldRender = new Dictionary<string, Dictionary<int, bool>>();
public override void buildSimpleCurves() {
@ -32,6 +43,16 @@ namespace Rimworld_Animations {
duration += frame.tickDuration;
}
foreach(AddonInfo addonInfo in addons)
{
addonsPosX.Add(addonInfo.name, new SimpleCurve());
addonsPosY.Add(addonInfo.name, new SimpleCurve());
addonsScale.Add(addonInfo.name, new SimpleCurve());
addonsRotation.Add(addonInfo.name, new SimpleCurve());
addonsShouldRender.Add(addonInfo.name, new Dictionary<int, bool>());
}
//guarantees loops don't get cut off mid-anim
this.duration = duration;
@ -66,7 +87,6 @@ namespace Rimworld_Animations {
if (frame.soundEffect != null) {
SoundEffects.Add((int)frame.atTick, frame.soundEffect);
}
}
else {
@ -98,13 +118,48 @@ namespace Rimworld_Animations {
SoundEffects.Add(keyframePosition, frame.soundEffect);
}
if(frame.tickDuration != 1 && frame.quiver.HasValue) {
foreach (AddonInfo addon in addons)
{
if (frame.addonKeyframes.Exists(addonKeyframe => addonKeyframe.name == addon.name))
{
AddonKeyframe addonKeyframe = frame.addonKeyframes.Find(element => element.name == addon.name);
if (addonKeyframe.posX != null)
{
addonsPosX[addon.name].Add((float)keyframePosition / (float)duration, addonKeyframe.posX.Value, true);
}
if (addonKeyframe.posY != null)
{
addonsPosX[addon.name].Add((float)keyframePosition / (float)duration, addonKeyframe.posY.Value, true);
}
if (addonKeyframe.rotation != null)
{
addonsPosX[addon.name].Add((float)keyframePosition / (float)duration, addonKeyframe.rotation.Value, true);
}
if (addonKeyframe.scale != null)
{
addonsScale[addon.name].Add((float)keyframePosition / (float)duration, addonKeyframe.scale.Value, true);
}
if (addonKeyframe.render != null)
{
addonsShouldRender[addon.name].Add(keyframePosition, addonKeyframe.render.Value);
}
}
}
if (frame.tickDuration != 1 && frame.quiver.HasValue) {
quiver.Add(keyframePosition, true);
quiver.Add(keyframePosition + frame.tickDuration - 1, false);
}
keyframePosition += frame.tickDuration;
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations
{
public class AddonInfo
{
public string name;
public string path;
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations
{
public class AddonKeyframe
{
public string name;
public bool? render;
public float? posX, posY, rotation, scale;
}
}

View File

@ -24,5 +24,7 @@ namespace Rimworld_Animations {
public bool? quiver;
public List<AddonKeyframe> addonKeyframes;
}
}

View File

@ -46,11 +46,11 @@
<Private>False</Private>
</Reference>
<Reference Include="RJW">
<HintPath>..\..\rjw-master\1.3\Assemblies\RJW.dll</HintPath>
<HintPath>..\..\rjw\1.3\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW-ToysAndMasturbation">
<HintPath>..\..\rjw-toys-and-masturbation-master\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
<HintPath>..\..\rjw-toys-and-masturbation\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />

View File

@ -44,11 +44,11 @@
<Private>False</Private>
</Reference>
<Reference Include="RJW">
<HintPath>..\rjw-master\1.3\Assemblies\RJW.dll</HintPath>
<HintPath>..\rjw\1.3\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW-ToysAndMasturbation">
<HintPath>..\rjw-toys-and-masturbation-master\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
<HintPath>..\rjw-toys-and-masturbation\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
@ -69,6 +69,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="1.3\Source\Animations\Keyframes\AddonInfo.cs" />
<Compile Include="1.3\Source\Animations\Keyframes\AddonKeyframe.cs" />
<Compile Include="1.3\Source\Extensions\PawnWoundDrawerExtension.cs" />
<Compile Include="1.3\Source\Patches\RimworldPatches\HarmonyPatch_Thing.cs" />
<Compile Include="1.3\Source\Utilities\PatchOperationAddOrReplace.cs" />