mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Actor addons and animation
- Includes addons for hands and sex toys - WIP and very buggy
This commit is contained in:
parent
d9e6288e3a
commit
cd4711a8e5
400 changed files with 10269 additions and 661 deletions
|
@ -107,6 +107,7 @@ namespace RimWorldAnimationStudio
|
|||
{ Debug.LogWarning("Cannot make new actor - there is no AnimationDef"); return false; }
|
||||
|
||||
Workspace.animationDef.actors.Add(this);
|
||||
Workspace.actorID = Workspace.animationDef.actors.Count - 1;
|
||||
|
||||
foreach (AnimationStage stage in Workspace.animationDef.animationStages)
|
||||
{
|
||||
|
@ -116,6 +117,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
stage.animationClips.Add(clip);
|
||||
stage.Initialize();
|
||||
stage.OnPostLoad();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
31
Assets/Scripts/AnimationComponents/ActorAddon.cs
Normal file
31
Assets/Scripts/AnimationComponents/ActorAddon.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorAddon
|
||||
{
|
||||
public string addonName;
|
||||
public int anchoringActor;
|
||||
public string anchorName;
|
||||
public string layer = "Pawn";
|
||||
public float scale;
|
||||
public bool render;
|
||||
|
||||
[XmlIgnore] public SimpleCurve PosX = new SimpleCurve();
|
||||
[XmlIgnore] public SimpleCurve PosZ = new SimpleCurve();
|
||||
[XmlIgnore] public SimpleCurve Rotation = new SimpleCurve();
|
||||
|
||||
public ActorAddon() { }
|
||||
|
||||
public ActorAddon(string addonName, float scale = 1f)
|
||||
{
|
||||
this.addonName = addonName;
|
||||
this.scale = scale;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/AnimationComponents/ActorAddon.cs.meta
Normal file
11
Assets/Scripts/AnimationComponents/ActorAddon.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4d87003a570d5241affe4170ae91045
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -9,6 +9,9 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class PawnAnimationClip : AnimationClip
|
||||
{
|
||||
[XmlArray("addons"), XmlArrayItem("li")] public List<ActorAddon> _addons = new List<ActorAddon>();
|
||||
[XmlIgnore] public List<ActorAddon> addons = new List<ActorAddon>();
|
||||
|
||||
[XmlAttribute("Class")] public string className = "Rimworld_Animations.PawnAnimationClip";
|
||||
[XmlArray("keyframes"), XmlArrayItem("li")] public List<PawnKeyframe> keyframes = new List<PawnKeyframe>();
|
||||
|
||||
|
@ -35,6 +38,13 @@ namespace RimWorldAnimationStudio
|
|||
HeadBob.Clear();
|
||||
GenitalAngle.Clear();
|
||||
|
||||
foreach (ActorAddon addon in addons)
|
||||
{
|
||||
addon.PosX.Clear();
|
||||
addon.PosZ.Clear();
|
||||
addon.Rotation.Clear();
|
||||
}
|
||||
|
||||
int keyframePosition = 0;
|
||||
int duration = 0;
|
||||
|
||||
|
@ -61,6 +71,16 @@ namespace RimWorldAnimationStudio
|
|||
HeadBob.Add((float)keyframe.atTick / (float)duration, keyframe.headBob, true);
|
||||
GenitalAngle.Add((float)keyframe.atTick / (float)duration, keyframe.genitalAngle, true);
|
||||
|
||||
foreach (ActorAddon addon in addons)
|
||||
{
|
||||
if (keyframe.addonKeyframes.Any(x => x.addonName == addon.addonName) == false)
|
||||
{ keyframe.addonKeyframes.Add(new AddonKeyframe(addon.addonName)); }
|
||||
|
||||
addon.PosX.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posX, true);
|
||||
addon.PosZ.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posZ, true);
|
||||
addon.Rotation.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).rotation, true);
|
||||
}
|
||||
|
||||
if (i + 1 < keyframes.Count)
|
||||
{ keyframes[i].tickDuration = keyframes[i + 1].atTick.Value - keyframes[i].atTick.Value; }
|
||||
}
|
||||
|
@ -76,6 +96,16 @@ namespace RimWorldAnimationStudio
|
|||
HeadBob.Add((float)keyframePosition / (float)duration, keyframe.headBob, true);
|
||||
GenitalAngle.Add((float)keyframePosition / (float)duration, keyframe.genitalAngle, true);
|
||||
|
||||
foreach (ActorAddon addon in addons)
|
||||
{
|
||||
if (keyframe.addonKeyframes.Any(x => x.addonName == addon.addonName) == false)
|
||||
{ keyframe.addonKeyframes.Add(new AddonKeyframe(addon.addonName)); }
|
||||
|
||||
addon.PosX.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posX, true);
|
||||
addon.PosZ.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).posZ, true);
|
||||
addon.Rotation.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.addonName).rotation, true);
|
||||
}
|
||||
|
||||
if (keyframe.tickDuration != 1 && keyframe.quiver.HasValue)
|
||||
{
|
||||
quiver.Add(keyframePosition, true);
|
||||
|
@ -88,7 +118,57 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
public override void ValidateData() { }
|
||||
public void AddActorAddon(string addonName, float scale = 1f)
|
||||
{
|
||||
if (addons.Any(x => x.addonName == addonName) == false)
|
||||
{
|
||||
addons.Add(new ActorAddon(addonName, scale));
|
||||
}
|
||||
|
||||
foreach (PawnKeyframe keyframe in keyframes)
|
||||
{
|
||||
if (keyframe.addonKeyframes.Any(x => x.addonName == addonName) == false)
|
||||
{ keyframe.addonKeyframes.Add(new AddonKeyframe(addonName)); }
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowOrHideActorAddon(string addonName, bool flag)
|
||||
{
|
||||
ActorAddon addon = GetActorAddon(addonName);
|
||||
|
||||
if (addon != null)
|
||||
{ addon.render = flag; }
|
||||
}
|
||||
|
||||
public bool IsActorAddonVisible(string addonName)
|
||||
{
|
||||
ActorAddon addon = GetActorAddon(addonName);
|
||||
|
||||
if (addon != null)
|
||||
{ return addon.render; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ActorAddon GetActorAddon(string addonName)
|
||||
{
|
||||
return addons.FirstOrDefault(x => x.addonName == addonName);
|
||||
}
|
||||
|
||||
public override void ValidateData()
|
||||
{
|
||||
_addons.Clear();
|
||||
|
||||
foreach (ActorAddon addon in addons)
|
||||
{
|
||||
Debug.Log(addon.anchorName);
|
||||
|
||||
if (addon.render)
|
||||
{
|
||||
_addons.Add(addon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetOwningActorID()
|
||||
{
|
||||
|
@ -132,5 +212,19 @@ namespace RimWorldAnimationStudio
|
|||
BuildSimpleCurves();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnPostLoad()
|
||||
{
|
||||
addons = _addons.Copy();
|
||||
|
||||
foreach (PawnKeyframe keyframe in keyframes)
|
||||
{
|
||||
keyframe.OnPostLoad();
|
||||
}
|
||||
|
||||
AddActorAddon("left hand", 0.667f);
|
||||
AddActorAddon("right hand", 0.667f);
|
||||
AddActorAddon("dildo");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace RimWorldAnimationStudio
|
|||
foreach (PawnAnimationClip clip in animationClips)
|
||||
{
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
|
||||
// Select playTimeTicks as longest playtime of all the animations
|
||||
if (clip.duration > playTimeTicks)
|
||||
{ playTimeTicks = clip.duration; }
|
||||
{ playTimeTicks = clip.duration; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,15 +53,23 @@ namespace RimWorldAnimationStudio
|
|||
foreach (Actor actor in Workspace.animationDef.actors)
|
||||
{
|
||||
PawnAnimationClip clip = new PawnAnimationClip();
|
||||
|
||||
|
||||
if (clip.MakeNew(actor.GetActorID()))
|
||||
{ animationClips.Add(clip); }
|
||||
}
|
||||
|
||||
Initialize();
|
||||
playTimeTicksQuick = playTimeTicks;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnPostLoad()
|
||||
{
|
||||
foreach (PawnAnimationClip clip in animationClips)
|
||||
{
|
||||
clip.OnPostLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class AddonKeyframe
|
||||
{
|
||||
public string addonName;
|
||||
public float posX;
|
||||
public float posZ;
|
||||
public float rotation;
|
||||
|
||||
public AddonKeyframe() { }
|
||||
|
||||
public AddonKeyframe(string addonName)
|
||||
{
|
||||
this.addonName = addonName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 60509e7cd8e74e6419c5c93304440a17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
@ -19,6 +20,10 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public float genitalAngle;
|
||||
public bool? quiver;
|
||||
|
||||
[XmlArray("addonKeyframes"), XmlArrayItem("li")] public List<AddonKeyframe> _addonKeyframes = new List<AddonKeyframe>();
|
||||
|
||||
[XmlIgnore] public List<AddonKeyframe> addonKeyframes = new List<AddonKeyframe>();
|
||||
[XmlIgnore] public int keyframeID;
|
||||
[XmlIgnore] public int actorID = -1;
|
||||
|
||||
|
@ -28,12 +33,32 @@ namespace RimWorldAnimationStudio
|
|||
public override void ValidateData()
|
||||
{
|
||||
soundEffect = Tags.soundDefs.Concat(CustomTags.soundDefs).Contains(soundEffect) ? soundEffect : null;
|
||||
|
||||
_addonKeyframes.Clear();
|
||||
|
||||
foreach (AddonKeyframe addonKeyframe in addonKeyframes)
|
||||
{
|
||||
ActorAddon addon = Workspace.Instance.GetAnimationClipThatOwnsKeyframe(keyframeID, out int clipID).GetActorAddon(addonKeyframe.addonName);
|
||||
|
||||
if (addon.render)
|
||||
{ _addonKeyframes.Add(addonKeyframe.Copy()); }
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPostLoad()
|
||||
{
|
||||
addonKeyframes.Clear();
|
||||
|
||||
foreach (AddonKeyframe addonKeyframe in _addonKeyframes)
|
||||
{
|
||||
addonKeyframes.Add(addonKeyframe.Copy());
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateKeyframeID(int actorID)
|
||||
{
|
||||
this.actorID = actorID;
|
||||
int _keyframeID = Random.Range(100000, 1000000);
|
||||
int _keyframeID = UnityEngine.Random.Range(100000, 1000000);
|
||||
|
||||
if (Workspace.animationDef.animationStages.Any(x => x.animationClips.Any(y => y.keyframes.Any(z => z.keyframeID == _keyframeID))))
|
||||
{
|
||||
|
@ -51,5 +76,10 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
return Selectable.allSelectablesArray.FirstOrDefault(x => x.GetComponent<KeyframeSlider>()?.keyframeID == keyframeID)?.GetComponent< KeyframeSlider>();
|
||||
}
|
||||
|
||||
public AddonKeyframe GetAddonKeyframe(string addonName)
|
||||
{
|
||||
return addonKeyframes.FirstOrDefault(x => x.addonName == addonName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue