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
51
Assets/Scripts/GUI/ActorAddonCard.cs
Normal file
51
Assets/Scripts/GUI/ActorAddonCard.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorAddonCard : MonoBehaviour
|
||||
{
|
||||
public string addonName;
|
||||
public InputField xOffsetField;
|
||||
public InputField zOffsetField;
|
||||
public InputField rotationField;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
xOffsetField.onEndEdit.AddListener(delegate { OnFieldValueChanged(); });
|
||||
zOffsetField.onEndEdit.AddListener(delegate { OnFieldValueChanged(); });
|
||||
rotationField.onEndEdit.AddListener(delegate { OnFieldValueChanged(); });
|
||||
|
||||
AnimationController.Instance.animationClipTimeField.onValueChanged.AddListener(delegate { OnKeyframeValueChanged(); });
|
||||
}
|
||||
|
||||
public void OnFieldValueChanged()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
|
||||
|
||||
keyframe.GetAddonKeyframe(addonName).posX = float.Parse(xOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).posZ = float.Parse(zOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).rotation = float.Parse(rotationField.text);
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
Workspace.Instance.RecordEvent("Actor addon position / orientation");
|
||||
}
|
||||
|
||||
public void OnKeyframeValueChanged()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
|
||||
xOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosX.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
|
||||
zOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosZ.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
|
||||
rotationField.SetTextWithoutNotify(clip.GetActorAddon(addonName).Rotation.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize).ToString());
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/GUI/ActorAddonCard.cs.meta
Normal file
11
Assets/Scripts/GUI/ActorAddonCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a63bb35c73985c46b65383f08d4afd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -32,6 +32,12 @@ namespace RimWorldAnimationStudio
|
|||
else
|
||||
{ bodyRenderer.color = Constants.ColorWhite; }
|
||||
|
||||
foreach (ActorAddon addon in Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID].addons)
|
||||
{
|
||||
ActorBodyPart bodyPart = GetComponentsInChildren<ActorBodyPart>(true).FirstOrDefault(x => x.addonName == addon.addonName);
|
||||
bodyPart?.gameObject?.SetActive(addon.render);
|
||||
}
|
||||
|
||||
//headRenderer.gameObject.SetActive(Workspace.animationDef.actors[actorID].GetAlienRaceDef().isHumanoid);
|
||||
//appendageRenderer.gameObject.SetActive(Workspace.animationDef.actors[actorID].requiredGenitals.Any(x => x == "Penis") || Workspace.animationDef.actors[actorID].isFucking);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace RimWorldAnimationStudio
|
|||
public SpriteRenderer bodyPartRenderer;
|
||||
public ActorBody parent;
|
||||
public bool isHead = false;
|
||||
public string addonName;
|
||||
public bool isSelected = false;
|
||||
|
||||
private Vector3 delta = new Vector3();
|
||||
|
@ -46,7 +47,56 @@ namespace RimWorldAnimationStudio
|
|||
if (delta == Vector3.zero)
|
||||
{ delta = mousePosition - transform.position; }
|
||||
|
||||
if (isHead)
|
||||
if (addonName != null && addonName != "")
|
||||
{
|
||||
AddonKeyframe addonKeyframe = keyframe.GetAddonKeyframe(addonName);
|
||||
ActorAddon addon = Workspace.Instance.GetCurrentPawnAnimationClip().GetActorAddon(addonName);
|
||||
|
||||
if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
|
||||
{
|
||||
Vector3 anchor;
|
||||
|
||||
ActorBody anchoringActorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.anchoringActor);
|
||||
Vector3 bodyPos = new Vector3(anchoringActorBody.transform.position.x, anchoringActorBody.transform.position.y, 0);
|
||||
AlienRaceDef alienRaceDef = Workspace.animationDef.actors[addon.anchoringActor].GetAlienRaceDef();
|
||||
Actor anchoringActor = Workspace.animationDef.actors[addon.anchoringActor];
|
||||
int bodyFacing = (int)Workspace.animationDef.animationStages[Workspace.stageID].animationClips[addon.anchoringActor].BodyFacing.Evaluate((float)AnimationController.Instance.stageTick / Workspace.StageWindowSize);
|
||||
|
||||
switch (addon.anchorName)
|
||||
{
|
||||
case "torso": anchor = bodyPos; break;
|
||||
case "head": anchor = new Vector3(anchoringActorBody.transform.Find("ActorHead").position.x, anchoringActorBody.transform.Find("ActorHead").position.y, 0); break;
|
||||
case "groin": anchor = bodyPos + Quaternion.AngleAxis(anchoringActorBody.transform.rotation.eulerAngles.z, Vector3.forward) * PawnUtility.GroinOffsetAt(anchoringActor.bodyType, bodyFacing).FlipAxes(); break;
|
||||
case "left breast": anchor = bodyPos + Quaternion.AngleAxis(anchoringActorBody.transform.rotation.eulerAngles.z, Vector3.forward) * PawnUtility.BreastLeftOffsetAt(anchoringActor.bodyType, bodyFacing).FlipAxes(); break;
|
||||
case "right breast": anchor = bodyPos + Quaternion.AngleAxis(anchoringActorBody.transform.rotation.eulerAngles.z, Vector3.forward) * PawnUtility.BreastRightOffsetAt(anchoringActor.bodyType, bodyFacing).FlipAxes(); break;
|
||||
default: anchor = new Vector3(); break;
|
||||
}
|
||||
|
||||
transform.position = new Vector3(mousePosition.x, mousePosition.y, 0f);
|
||||
|
||||
addonKeyframe.posX = transform.position.x - anchor.x;
|
||||
addonKeyframe.posZ = transform.position.y - anchor.y;
|
||||
|
||||
ActorKeyframeCard.Instance.transform.GetComponentsInChildren<ActorAddonCard>()?.FirstOrDefault(x => x.addonName == addonName)?.OnKeyframeValueChanged();
|
||||
}
|
||||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
|
||||
{
|
||||
float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
addonKeyframe.rotation = angle;
|
||||
}
|
||||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
|
||||
{
|
||||
//float angle = Vector2.SignedAngle(Vector2.up, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
//int facing = -Mathf.RoundToInt(angle / 90f);
|
||||
//facing = facing < 0 ? facing + 4 : facing;
|
||||
|
||||
//keyframe.headFacing = facing;
|
||||
}
|
||||
}
|
||||
|
||||
else if (isHead)
|
||||
{
|
||||
if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void Pop()
|
||||
{
|
||||
Initialize();
|
||||
gameObject.SetActive(gameObject.activeSelf == false);
|
||||
}
|
||||
|
||||
|
|
215
Assets/Scripts/GUI/DialogBoxes/SelectActorAddonsDialog.cs
Normal file
215
Assets/Scripts/GUI/DialogBoxes/SelectActorAddonsDialog.cs
Normal file
|
@ -0,0 +1,215 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class SelectActorAddonsDialog : DialogBox
|
||||
{
|
||||
public Toggle handLeftToggle;
|
||||
public Toggle handRightToggle;
|
||||
public Toggle sexToyToggle;
|
||||
|
||||
public Dropdown handLeftAnchor;
|
||||
public Dropdown handRightAnchor;
|
||||
public Dropdown sexToyAnchor;
|
||||
|
||||
public InputField handLeftAnchoringPawn;
|
||||
public InputField handRightAnchoringPawn;
|
||||
public InputField sexToyAnchoringPawn;
|
||||
|
||||
public Dropdown handLeftLayer;
|
||||
public Dropdown handRightLayer;
|
||||
public Dropdown sexToyLayer;
|
||||
|
||||
public GameObject handLeftControls;
|
||||
public GameObject handRightControls;
|
||||
public GameObject sexToyControls;
|
||||
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
switch (clip.GetActorAddon("left hand").anchorName)
|
||||
{
|
||||
case "torso": handLeftAnchor.value = 1; break;
|
||||
case "head": handLeftAnchor.value = 2; break;
|
||||
case "groin": handLeftAnchor.value = 3; break;
|
||||
case "left breast": handLeftAnchor.value = 4; break;
|
||||
case "right breast": handLeftAnchor.value = 5; break;
|
||||
default: handLeftAnchor.value = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("right hand") != null)
|
||||
{
|
||||
switch (clip.GetActorAddon("right hand").anchorName)
|
||||
{
|
||||
case "torso": handRightAnchor.value = 1; break;
|
||||
case "head": handRightAnchor.value = 2; break;
|
||||
case "groin": handRightAnchor.value = 3; break;
|
||||
case "left breast": handRightAnchor.value = 4; break;
|
||||
case "right breast": handRightAnchor.value = 5; break;
|
||||
default: handRightAnchor.value = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{
|
||||
switch (clip.GetActorAddon("dildo").anchorName)
|
||||
{
|
||||
case "torso": sexToyAnchor.value = 1; break;
|
||||
case "head": sexToyAnchor.value = 2; break;
|
||||
case "groin": sexToyAnchor.value = 3; break;
|
||||
case "left breast": sexToyAnchor.value = 4; break;
|
||||
case "right breast": sexToyAnchor.value = 5; break;
|
||||
default: sexToyAnchor.value = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
handLeftLayer.value = handLeftLayer.options.IndexOf(handLeftLayer.options.First(x => x.text == clip.GetActorAddon("left hand").layer));
|
||||
handLeftAnchoringPawn.text = clip.GetActorAddon("left hand").anchoringActor.ToString();
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("right hand") != null)
|
||||
{
|
||||
handRightLayer.value = handRightLayer.options.IndexOf(handRightLayer.options.First(x => x.text == clip.GetActorAddon("right hand").layer));
|
||||
handRightAnchoringPawn.text = clip.GetActorAddon("right hand").anchoringActor.ToString();
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{
|
||||
sexToyLayer.value = sexToyLayer.options.IndexOf(sexToyLayer.options.First(x => x.text == clip.GetActorAddon("dildo").layer));
|
||||
sexToyAnchoringPawn.text = clip.GetActorAddon("dildo").anchoringActor.ToString();
|
||||
}
|
||||
|
||||
handLeftToggle.isOn = clip.IsActorAddonVisible("left hand");
|
||||
handRightToggle.isOn = clip.IsActorAddonVisible("right hand");
|
||||
sexToyToggle.isOn = clip.IsActorAddonVisible("dildo");
|
||||
|
||||
//handLeftControls.SetActive(handLeftToggle.isOn);
|
||||
//handRightControls.SetActive(handRightToggle.isOn);
|
||||
//sexToyControls.SetActive(sexToyToggle.isOn);
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
|
||||
|
||||
clip.ShowOrHideActorAddon("left hand", handLeftToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("right hand", handRightToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("dildo", sexToyToggle.isOn);
|
||||
|
||||
//Initialize();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
switch (handLeftAnchor.value)
|
||||
{
|
||||
case 1: clip.GetActorAddon("left hand").anchorName = "torso"; break;
|
||||
case 2: clip.GetActorAddon("left hand").anchorName = "head"; break;
|
||||
case 3: clip.GetActorAddon("left hand").anchorName = "groin"; break;
|
||||
case 4: clip.GetActorAddon("left hand").anchorName = "left breast"; break;
|
||||
case 5: clip.GetActorAddon("left hand").anchorName = "right breast"; break;
|
||||
default: clip.GetActorAddon("left hand").anchorName = null; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("right hand") != null)
|
||||
{
|
||||
switch (handRightAnchor.value)
|
||||
{
|
||||
case 1: clip.GetActorAddon("right hand").anchorName = "torso"; break;
|
||||
case 2: clip.GetActorAddon("right hand").anchorName = "head"; break;
|
||||
case 3: clip.GetActorAddon("right hand").anchorName = "groin"; break;
|
||||
case 4: clip.GetActorAddon("right hand").anchorName = "left breast"; break;
|
||||
case 5: clip.GetActorAddon("right hand").anchorName = "right breast"; break;
|
||||
default: clip.GetActorAddon("right hand").anchorName = null; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{
|
||||
switch (sexToyAnchor.value)
|
||||
{
|
||||
case 1: clip.GetActorAddon("dildo").anchorName = "torso"; break;
|
||||
case 2: clip.GetActorAddon("dildo").anchorName = "head"; break;
|
||||
case 3: clip.GetActorAddon("dildo").anchorName = "groin"; break;
|
||||
case 4: clip.GetActorAddon("dildo").anchorName = "left breast"; break;
|
||||
case 5: clip.GetActorAddon("dildo").anchorName = "right breast"; break;
|
||||
default: clip.GetActorAddon("dildo").anchorName = null; break;
|
||||
}
|
||||
}
|
||||
|
||||
//Initialize();
|
||||
}
|
||||
|
||||
public void OnLayerChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{ clip.GetActorAddon("left hand").layer = handLeftLayer.options[handLeftLayer.value].text; }
|
||||
|
||||
if (clip?.GetActorAddon("right hand") != null)
|
||||
{ clip.GetActorAddon("right hand").layer = handRightLayer.options[handRightLayer.value].text; }
|
||||
|
||||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{ clip.GetActorAddon("dildo").layer = sexToyLayer.options[sexToyLayer.value].text; }
|
||||
|
||||
//Initialize();
|
||||
}
|
||||
|
||||
public void OnAnchoringPawnChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
int i = int.Parse(handLeftAnchoringPawn.text);
|
||||
|
||||
if (i < 0) { i = clip.GetOwningActorID(); }
|
||||
i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
|
||||
|
||||
clip.GetActorAddon("left hand").anchoringActor = i;
|
||||
handLeftAnchoringPawn.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("right hand") != null)
|
||||
{
|
||||
int i = int.Parse(handRightAnchoringPawn.text);
|
||||
|
||||
if (i < 0) { i = clip.GetOwningActorID(); }
|
||||
i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
|
||||
|
||||
clip.GetActorAddon("right hand").anchoringActor = i;
|
||||
handRightAnchoringPawn.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
|
||||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{
|
||||
int i = int.Parse(sexToyAnchoringPawn.text);
|
||||
|
||||
if (i < 0) { i = clip.GetOwningActorID(); }
|
||||
i = Mathf.Clamp(i, 0, Workspace.animationDef.actors.Count - 1);
|
||||
|
||||
clip.GetActorAddon("dildo").anchoringActor = i;
|
||||
sexToyAnchoringPawn.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 869b2cd91a545c142b38856695c4257a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -64,7 +64,7 @@ namespace RimWorldAnimationStudio
|
|||
GameObject obj = Instantiate(linearScaleTickPrefab, transform);
|
||||
obj.GetComponentInChildren<Text>().text = division.ToString();
|
||||
|
||||
float xOffset = ((float)(division - 1) / (Workspace.StageWindowSize - 1)) * transform.parent.GetComponent<RectTransform>().rect.width;
|
||||
float xOffset = ((float)(division - Constants.minTick) / (Workspace.StageWindowSize - Constants.minTick)) * transform.parent.GetComponent<RectTransform>().rect.width;
|
||||
obj.GetComponent<RectTransform>().localPosition = new Vector3(xOffset, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue