214 lines
8.4 KiB
C#
214 lines
8.4 KiB
C#
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 class AddonDef
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
}
|