mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Code refactor
This commit is contained in:
parent
5ca7e486f8
commit
e14a12f2ab
310 changed files with 4875 additions and 4102 deletions
|
@ -18,6 +18,12 @@ namespace RimWorldAnimationStudio
|
|||
public float? scale;
|
||||
public bool? render;
|
||||
|
||||
// Data serialization control
|
||||
public bool ShouldSerializeanchorName() { return string.IsNullOrEmpty(anchorName) == false && anchorName.ToLower() != "none"; }
|
||||
public bool ShouldSerializeanchoringActor() { return anchoringActor.HasValue; }
|
||||
public bool ShouldSerializescale() { return scale.HasValue; }
|
||||
public bool ShouldSerializerender() { return render == true; }
|
||||
|
||||
// Data helper functions
|
||||
[XmlIgnore] public string AddonName
|
||||
{
|
||||
|
|
15
Assets/Scripts/AnimationComponents/ActorAddonDef.cs
Normal file
15
Assets/Scripts/AnimationComponents/ActorAddonDef.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorAddonDef
|
||||
{
|
||||
public string addonName;
|
||||
public string label;
|
||||
public float scale = 1f;
|
||||
}
|
||||
}
|
11
Assets/Scripts/AnimationComponents/ActorAddonDef.cs.meta
Normal file
11
Assets/Scripts/AnimationComponents/ActorAddonDef.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d836663c2196924eab4a00f4f4ceb3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -13,6 +13,12 @@ namespace RimWorldAnimationStudio
|
|||
public float? posZ;
|
||||
public float? rotation;
|
||||
|
||||
// Data serialization control
|
||||
public bool ShouldSerializeposX() { return posX.HasValue; }
|
||||
public bool ShouldSerializeposZ() { return posZ.HasValue; }
|
||||
public bool ShouldSerializerotation() { return rotation.HasValue; }
|
||||
|
||||
|
||||
// Data helper functions
|
||||
[XmlIgnore] public string AddonName
|
||||
{
|
||||
|
|
|
@ -72,6 +72,10 @@ namespace RimWorldAnimationStudio
|
|||
HeadBob.Clear();
|
||||
GenitalAngle.Clear();
|
||||
|
||||
AddActorAddon("left hand", 0.667f);
|
||||
AddActorAddon("right hand", 0.667f);
|
||||
AddActorAddon("dildo");
|
||||
|
||||
foreach (ActorAddon addon in Addons)
|
||||
{
|
||||
addon.PosX.Clear();
|
||||
|
@ -347,10 +351,6 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
keyframe.OnPostLoad();
|
||||
}
|
||||
|
||||
AddActorAddon("left hand", 0.667f);
|
||||
AddActorAddon("right hand", 0.667f);
|
||||
AddActorAddon("dildo");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,17 @@ namespace RimWorldAnimationStudio
|
|||
public static int minAnimationClipLength = 5;
|
||||
public static int maxAnimationClipLength = 9999;
|
||||
|
||||
// Lists
|
||||
public static Dictionary<string, string> bodyPartAnchorNames = new Dictionary<string, string>()
|
||||
{
|
||||
{ "none", "None" },
|
||||
{ "torso", "Torso"},
|
||||
{ "head", "Head"},
|
||||
{ "groin", "Groin"},
|
||||
{ "left breast", "Breast (left)"},
|
||||
{ "right breast", "Breast (right)"},
|
||||
};
|
||||
|
||||
// Colors used
|
||||
public static Color ColorWhite = new Color(1f, 1f, 1f);
|
||||
public static Color ColorGreen = new Color(0f, 1f, 0f);
|
||||
|
|
30
Assets/Scripts/DefParents/ActorAddonDefs.cs
Normal file
30
Assets/Scripts/DefParents/ActorAddonDefs.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public static class ActorAddonDefs
|
||||
{
|
||||
public static List<ActorAddonDef> allDefs = new List<ActorAddonDef>();
|
||||
|
||||
public static ActorAddonDef GetNamed(string addonName)
|
||||
{
|
||||
return allDefs.FirstOrDefault(x => x.addonName == addonName);
|
||||
}
|
||||
|
||||
public static void AddDef(ActorAddonDef actorAddonDef)
|
||||
{
|
||||
if (allDefs.Any(x => x.addonName == actorAddonDef.addonName)) return;
|
||||
|
||||
allDefs.Add(actorAddonDef);
|
||||
}
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/DefParents/ActorAddonDefs.cs.meta
Normal file
11
Assets/Scripts/DefParents/ActorAddonDefs.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9fc7248e80b340a42a688378a9cc2296
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -99,7 +99,7 @@ namespace RimWorldAnimationStudio
|
|||
dragDelta = Vector3.zero;
|
||||
}
|
||||
|
||||
public ActorBodyPart GetBodyPart(string bodyPart)
|
||||
public ActorBodyPart GetActorBodyPart(string bodyPart)
|
||||
{
|
||||
return GetComponentsInChildren<ActorBodyPart>(true)?.FirstOrDefault(x => x.bodyPart.ToLower() == bodyPart);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
||||
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePosition = new Vector3(mousePosition.x, mousePosition.y, 0f);
|
||||
|
||||
if (dragDelta == Vector3.zero)
|
||||
{ dragDelta = mousePosition - transform.position; }
|
||||
|
@ -114,8 +115,8 @@ namespace RimWorldAnimationStudio
|
|||
if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
|
||||
{
|
||||
ActorBody anchoringActorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.AnchoringActor);
|
||||
Vector3 anchor = PawnUtility.GetBodyPartAnchor(anchoringActorBody, addon.addonName);
|
||||
transform.position = new Vector3(mousePosition.x, mousePosition.y, 0f);
|
||||
Vector3 anchor = PawnUtility.GetBodyPartAnchor(anchoringActorBody, addon.anchorName);
|
||||
transform.position = mousePosition - dragDelta;
|
||||
|
||||
addonKeyframe.PosX = transform.position.x - anchor.x;
|
||||
addonKeyframe.PosZ = transform.position.y - anchor.y;
|
||||
|
|
19
Assets/Scripts/GUI/AddonAnchorDropdown.cs
Normal file
19
Assets/Scripts/GUI/AddonAnchorDropdown.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class AddonAnchorDropdown : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
Dropdown dropdown = GetComponent<Dropdown>();
|
||||
|
||||
dropdown.ClearOptions();
|
||||
dropdown.AddOptions(Constants.bodyPartAnchorNames.Values.ToList());
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/GUI/AddonAnchorDropdown.cs.meta
Normal file
11
Assets/Scripts/GUI/AddonAnchorDropdown.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a0ca236433ad584998f9c7a96dc3af8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -34,6 +34,12 @@ namespace RimWorldAnimationStudio
|
|||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void ClearKeyframeSliders()
|
||||
{
|
||||
foreach (KeyframeSlider slider in GetComponentsInChildren<KeyframeSlider>())
|
||||
{ Destroy(slider.gameObject); }
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
if (actorID < 0) return;
|
||||
|
@ -43,8 +49,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
foreach (KeyframeSlider slider in GetComponentsInChildren<KeyframeSlider>())
|
||||
{ RemovePawnKeyFrame(slider.keyframeID); }
|
||||
ClearKeyframeSliders();
|
||||
|
||||
foreach (PawnKeyframe keyframe in clip.Keyframes)
|
||||
{ AddPawnKeyFrame(keyframe.keyframeID); }
|
||||
|
|
100
Assets/Scripts/GUI/Cards/ActorAddonCard.cs
Normal file
100
Assets/Scripts/GUI/Cards/ActorAddonCard.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
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 Text label;
|
||||
public Toggle toggle;
|
||||
public Dropdown anchorDropdown;
|
||||
public InputField anchoringPawnField;
|
||||
public Dropdown layerDropdown;
|
||||
public ActorAddonKeyframeCard actorAddonKeyframeCard;
|
||||
|
||||
private ActorAddonDef actorAddonDef;
|
||||
|
||||
private PawnAnimationClip clip { get { return Workspace.GetCurrentPawnAnimationClip(); } }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ActorAddonDef actorAddonDef, ActorAddonKeyframeCard actorAddonKeyframeCard)
|
||||
{
|
||||
this.actorAddonDef = actorAddonDef;
|
||||
this.actorAddonKeyframeCard = actorAddonKeyframeCard;
|
||||
|
||||
addonName = actorAddonDef.addonName;
|
||||
label.text = actorAddonDef.label;
|
||||
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
if (Workspace.animationDef == null || string.IsNullOrEmpty(addonName)) return;
|
||||
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{
|
||||
int i = Constants.bodyPartAnchorNames.Keys.ToList().IndexOf(clip.GetActorAddon(addonName).AnchorName);
|
||||
anchorDropdown.SetValueWithoutNotify(i);
|
||||
layerDropdown.SetValueWithoutNotify(layerDropdown.options.IndexOf(layerDropdown.options.First(x => x.text == clip.GetActorAddon(addonName).Layer)));
|
||||
anchoringPawnField.SetTextWithoutNotify(clip.GetActorAddon(addonName).AnchoringActor.ToString());
|
||||
toggle.SetIsOnWithoutNotify(clip.IsActorAddonVisible(addonName));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).render = toggle.isOn; }
|
||||
|
||||
EventsManager.OnPawnKeyframeChanged(null);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchorChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).AnchorName = Constants.bodyPartAnchorNames.Keys.ElementAt(anchorDropdown.value); }
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnLayerChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).Layer = layerDropdown.options[layerDropdown.value].text; }
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchoringPawnChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{
|
||||
int i = int.Parse(anchoringPawnField.text);
|
||||
|
||||
if (i < 0) { i = clip.GetOwningActorID(); }
|
||||
i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
|
||||
|
||||
clip.GetActorAddon(addonName).AnchoringActor = i;
|
||||
anchoringPawnField.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/GUI/Cards/ActorAddonCard.cs.meta
Normal file
11
Assets/Scripts/GUI/Cards/ActorAddonCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 919aed3c4b9671c4e8dc109c7d608683
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -11,16 +11,30 @@ namespace RimWorldAnimationStudio
|
|||
public class ActorAddonKeyframeCard : MonoBehaviour
|
||||
{
|
||||
public string addonName;
|
||||
public Text label;
|
||||
public InputField xOffsetField;
|
||||
public InputField zOffsetField;
|
||||
public InputField rotationField;
|
||||
|
||||
private ActorAddonDef actorAddonDef;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ActorAddonDef actorAddonDef)
|
||||
{
|
||||
this.actorAddonDef = actorAddonDef;
|
||||
this.addonName = actorAddonDef.addonName;
|
||||
|
||||
label.text = actorAddonDef.label + ":";
|
||||
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { Debug.Log("stagetick"); UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onPawnKeyframeChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
xOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
zOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
|
@ -38,17 +52,20 @@ namespace RimWorldAnimationStudio
|
|||
keyframe.GetAddonKeyframe(addonName).Rotation = float.Parse(rotationField.text);
|
||||
|
||||
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
||||
|
||||
Workspace.RecordEvent("Actor addon position / orientation");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
xOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosX.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
|
||||
zOffsetField.SetTextWithoutNotify(clip.GetActorAddon(addonName).PosZ.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
|
||||
rotationField.SetTextWithoutNotify(clip.GetActorAddon(addonName).Rotation.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize).ToString());
|
||||
xOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosX.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
zOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosZ.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
rotationField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).Rotation.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
|
||||
gameObject.SetActive(clip.GetActorAddon(addonName).render == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ using UnityEngine.UI;
|
|||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorKeyframeCard : Singleton<ActorKeyframeCard>
|
||||
{
|
||||
{
|
||||
public InputField positionXField;
|
||||
public InputField positionZField;
|
||||
public InputField rotationField;
|
||||
|
@ -15,6 +15,14 @@ namespace RimWorldAnimationStudio
|
|||
public InputField headRotationField;
|
||||
public InputField appendageRotationField;
|
||||
|
||||
public ActorAddonCard actorAddonCardPrefab;
|
||||
public ActorAddonKeyframeCard actorAddonKeyframeCardPrefab;
|
||||
|
||||
public Transform actorAddonCards;
|
||||
public Transform actorKeyframeCards;
|
||||
|
||||
public SelectActorAddonsDialog selectActorAddonsDialog;
|
||||
|
||||
private Actor actor { get { return Workspace.GetCurrentActor(); } }
|
||||
|
||||
private void Start()
|
||||
|
@ -33,6 +41,17 @@ namespace RimWorldAnimationStudio
|
|||
headRotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
appendageRotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
|
||||
foreach (ActorAddonDef actorAddonDef in ActorAddonDefs.allDefs)
|
||||
{
|
||||
ActorAddonKeyframeCard actorAddonKeyframeCard = Instantiate(actorAddonKeyframeCardPrefab, actorKeyframeCards);
|
||||
actorAddonKeyframeCard.Initialize(actorAddonDef);
|
||||
|
||||
ActorAddonCard actorAddonCard = Instantiate(actorAddonCardPrefab, actorAddonCards);
|
||||
actorAddonCard.Initialize(actorAddonDef, actorAddonKeyframeCard);
|
||||
|
||||
selectActorAddonsDialog.AddActorAddonCard(actorAddonCard);
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public List<GameObject> cloneObjects;
|
||||
|
||||
public void OnEnable()
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,14 @@ namespace RimWorldAnimationStudio
|
|||
public Toggle isHumanoidToggle;
|
||||
public InputField scaleField;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
raceSelectDropdown.ClearOptions();
|
||||
raceSelectDropdown.AddOptions(PawnRaceDefs.allDefs.Select(x => x.defName).ToList());
|
||||
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Reset();
|
||||
|
@ -78,12 +86,12 @@ namespace RimWorldAnimationStudio
|
|||
AddCloneObjectToParent(raceSettingsWindow, 3);
|
||||
}
|
||||
|
||||
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale.ToString());
|
||||
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
RemoveCloneObjectsFromParent(raceSettingsWindow);
|
||||
RemoveCloneObjectsFromParent(raceSettingsWindow);
|
||||
}
|
||||
|
||||
public void SetIsHumanoid()
|
||||
|
@ -134,7 +142,9 @@ namespace RimWorldAnimationStudio
|
|||
if (pawnRaceDef == null) return;
|
||||
|
||||
float scale = float.Parse(scaleField.text);
|
||||
pawnRaceDef.scale = Mathf.Clamp(scale, 0.05f, 100f);
|
||||
pawnRaceDef.scale = Mathf.Clamp(scale, 0.01f, 100f);
|
||||
|
||||
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,204 +10,11 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectActorAddonsDialog : DialogBox
|
||||
{
|
||||
public class AddonDef
|
||||
private List<ActorAddonCard> actorAddonCards = new List<ActorAddonCard>();
|
||||
|
||||
public void AddActorAddonCard(ActorAddonCard actorAddonCard)
|
||||
{
|
||||
public string addonName;
|
||||
public Toggle toggle;
|
||||
public Dropdown anchor;
|
||||
public InputField anchoringPawn;
|
||||
public Dropdown layer;
|
||||
public GameObject controls;
|
||||
|
||||
public AddonDef(string addonName, Toggle toggle, Dropdown anchor, InputField anchoringPawn, Dropdown layer, GameObject controls)
|
||||
{
|
||||
this.addonName = addonName;
|
||||
this.toggle = toggle;
|
||||
this.anchor = anchor;
|
||||
this.anchoringPawn = anchoringPawn;
|
||||
this.layer = layer;
|
||||
this.controls = controls;
|
||||
}
|
||||
}
|
||||
|
||||
private List<AddonDef> addonDefs = new List<AddonDef>();
|
||||
|
||||
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;
|
||||
|
||||
private PawnAnimationClip clip { get { return Workspace.GetCurrentPawnAnimationClip(); } }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
InitializeAddonDefs();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
// temp code
|
||||
public void InitializeAddonDefs()
|
||||
{
|
||||
if (addonDefs.NotNullOrEmpty()) return;
|
||||
|
||||
addonDefs.Add(new AddonDef("left hand", handLeftToggle, handLeftAnchor, handLeftAnchoringPawn, handLeftLayer, handLeftControls));
|
||||
addonDefs.Add(new AddonDef("right hand", handRightToggle, handRightAnchor, handRightAnchoringPawn, handRightLayer, handRightControls));
|
||||
addonDefs.Add(new AddonDef("dildo", sexToyToggle, sexToyAnchor, sexToyAnchoringPawn, sexToyLayer, sexToyControls));
|
||||
}
|
||||
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
InitializeAddonDefs();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Debug.Log("Actor: " + clip.GetOwningActorID());
|
||||
|
||||
foreach (AddonDef addonDef in addonDefs)
|
||||
{
|
||||
if (clip?.GetActorAddon(addonDef.addonName) != null)
|
||||
{
|
||||
switch (clip.GetActorAddon(addonDef.addonName).AnchorName)
|
||||
{
|
||||
case "torso": addonDef.anchor.SetValueWithoutNotify(1); break;
|
||||
case "head": addonDef.anchor.SetValueWithoutNotify(2); break;
|
||||
case "groin": addonDef.anchor.SetValueWithoutNotify(3); break;
|
||||
case "left breast": addonDef.anchor.SetValueWithoutNotify(4); break;
|
||||
case "right breast": addonDef.anchor.SetValueWithoutNotify(5); break;
|
||||
default: addonDef.anchor.SetValueWithoutNotify(0); break;
|
||||
}
|
||||
|
||||
addonDef.layer.SetValueWithoutNotify(addonDef.layer.options.IndexOf(addonDef.layer.options.First(x => x.text == clip.GetActorAddon(addonDef.addonName).Layer)));
|
||||
addonDef.anchoringPawn.SetTextWithoutNotify(clip.GetActorAddon(addonDef.addonName).AnchoringActor.ToString());
|
||||
addonDef.toggle.SetIsOnWithoutNotify(clip.IsActorAddonVisible(addonDef.addonName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
{
|
||||
clip.ShowOrHideActorAddon("left hand", handLeftToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("right hand", handRightToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("dildo", sexToyToggle.isOn);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnLayerChanged()
|
||||
{
|
||||
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; }
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchoringPawnChanged()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
actorAddonCards.Add(actorAddonCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
for (int i = 0; i < Mathf.Max(requiredGhosts, currentGhostCount); i++)
|
||||
{
|
||||
if (clip == null || keyframe == null) continue;
|
||||
|
||||
int targetTick = (int)(i * clip.duration + keyframe.atTick);
|
||||
|
||||
if (ghostSliders.childCount <= i)
|
||||
|
|
|
@ -14,6 +14,10 @@ namespace RimWorldAnimationStudio
|
|||
public SingleGraphic eastGraphic = new SingleGraphic();
|
||||
public SingleGraphic southGraphic = new SingleGraphic();
|
||||
|
||||
public bool ShouldSerializenorthGraphic() { return string.IsNullOrEmpty(northGraphic.path) == false; }
|
||||
public bool ShouldSerializeeastGraphic() { return string.IsNullOrEmpty(eastGraphic.path) == false; }
|
||||
public bool ShouldSerializesouthGraphic() { return string.IsNullOrEmpty(southGraphic.path) == false; }
|
||||
|
||||
public MultiDirectionalGraphic() { }
|
||||
|
||||
public MultiDirectionalGraphic(string bodyType)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
[Serializable]
|
||||
public class SingleGraphic
|
||||
{
|
||||
public string path = "Invalid file path";
|
||||
public string path;
|
||||
[XmlIgnore] public Sprite sprite = null;
|
||||
|
||||
public void SetPath(string path)
|
||||
|
@ -43,7 +43,9 @@ namespace RimWorldAnimationStudio
|
|||
Texture2D texture = new Texture2D(2, 2);
|
||||
texture.LoadImage(pngBytes);
|
||||
|
||||
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 85.0f);
|
||||
float scale = Mathf.Min(texture.width, texture.height) / 128f;
|
||||
|
||||
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 85.0f * scale);
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace RimWorldAnimationStudio
|
|||
actorBody.bodyRenderer.gameObject.SetActive(actorBody.bodyRenderer.sprite != null);
|
||||
|
||||
// Head
|
||||
actorBodypart = actorBody.GetBodyPart("head");
|
||||
actorBodypart = actorBody.GetActorBodyPart("head");
|
||||
|
||||
actorBodypart.transform.localPosition = headPos;
|
||||
actorBodypart.transform.eulerAngles = new Vector3(0, 0, -headAngle);
|
||||
|
@ -156,13 +156,13 @@ namespace RimWorldAnimationStudio
|
|||
actorBodypart.gameObject.SetActive(actorBodypart.bodyPartRenderer.sprite != null);
|
||||
|
||||
// Appendage
|
||||
actorBodypart = actorBody.GetBodyPart("appendage");
|
||||
actorBodypart = actorBody.GetActorBodyPart("appendage");
|
||||
|
||||
actorBodypart.transform.localPosition = new Vector3(appendagePos.x, appendagePos.z, 0f);
|
||||
actorBodypart.transform.eulerAngles = new Vector3(0, 0, -genitalAngle);
|
||||
|
||||
actorBodypart.bodyPartRenderer.sortingLayerName = clip.Layer;
|
||||
actorBodypart.bodyPartRenderer.sprite = requiresGenitals && pawnRaceDef.isHumanoid && bodyFacing != 0 ? Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing) : null;
|
||||
actorBodypart.bodyPartRenderer.sprite = requiresGenitals && pawnRaceDef.isHumanoid ? Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing) : null;
|
||||
//actorBody.appendageRenderer.flipX = bodyFacing == 3;
|
||||
|
||||
actorBodypart.gameObject.SetActive(actorBodypart.bodyPartRenderer.sprite != null);
|
||||
|
@ -170,10 +170,11 @@ namespace RimWorldAnimationStudio
|
|||
// Add-ons
|
||||
foreach (ActorAddon addon in clip.Addons)
|
||||
{
|
||||
actorBodypart = actorBody.GetBodyPart(addon.AddonName);
|
||||
actorBodypart = actorBody.GetActorBodyPart(addon.AddonName);
|
||||
if (actorBodypart == null) continue;
|
||||
|
||||
ActorBody anchoringActorBody = actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.AnchoringActor);
|
||||
Vector3 anchor = PawnUtility.GetBodyPartAnchor(anchoringActorBody, addon.addonName);
|
||||
Vector3 anchor = PawnUtility.GetBodyPartAnchor(anchoringActorBody, addon.anchorName);
|
||||
|
||||
actorBodypart.transform.position = anchor + new Vector3(addon.PosX.Evaluate(clipPercent), addon.PosZ.Evaluate(clipPercent), 0);
|
||||
actorBodypart.transform.eulerAngles = new Vector3(0, 0, -addon.Rotation.Evaluate(clipPercent));
|
||||
|
|
|
@ -16,9 +16,10 @@ namespace RimWorldAnimationStudio
|
|||
public DialogBox newAnimationDialog;
|
||||
public SelectAnimationDialog selectAnimationDialog;
|
||||
|
||||
public void Start()
|
||||
public void Awake()
|
||||
{
|
||||
LoadPawnRaceDefs();
|
||||
LoadActorAddonDefs();
|
||||
LoadCustomArrays();
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@ namespace RimWorldAnimationStudio
|
|||
if (paths == null || paths.Any() == false)
|
||||
{ Debug.LogWarning("Selected file was null or invalid"); return; }
|
||||
|
||||
AnimationDefs defs = null;
|
||||
AnimationDefs defs = XmlUtility.ReadXML<AnimationDefs>(paths[0]);
|
||||
|
||||
try
|
||||
{ defs = XmlUtility.ReadXML<AnimationDefs>(paths[0]); }
|
||||
|
@ -248,10 +249,9 @@ namespace RimWorldAnimationStudio
|
|||
else
|
||||
{ path = Path.Combine(Application.streamingAssetsPath, "pawnRaceDefs.xml"); }
|
||||
|
||||
if (File.Exists(path) == false)
|
||||
{ SavePawnRaceDefs(); return; }
|
||||
|
||||
PawnRaceDefs.allDefs = XmlUtility.ReadXML<List<PawnRaceDef>>(path);
|
||||
SavePawnRaceDefs();
|
||||
|
||||
PawnRaceDefs.OnLoad();
|
||||
}
|
||||
|
||||
|
@ -261,5 +261,26 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
XmlUtility.WriteXML(PawnRaceDefs.allDefs, path);
|
||||
}
|
||||
|
||||
public void LoadActorAddonDefs()
|
||||
{
|
||||
string path;
|
||||
|
||||
if (File.Exists(Path.Combine(Application.persistentDataPath, "actorAddonDefs.xml")))
|
||||
{ path = Path.Combine(Application.persistentDataPath, "actorAddonDefs.xml"); }
|
||||
|
||||
else
|
||||
{ path = Path.Combine(Application.streamingAssetsPath, "actorAddonDefs.xml"); }
|
||||
|
||||
ActorAddonDefs.allDefs = XmlUtility.ReadXML<List<ActorAddonDef>>(path);
|
||||
SaveActorAddonDefs();
|
||||
|
||||
ActorAddonDefs.OnLoad();
|
||||
}
|
||||
|
||||
public void SaveActorAddonDefs()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue