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
a55ba7b95b
commit
5ca7e486f8
243 changed files with 1065 additions and 625 deletions
|
@ -10,6 +10,28 @@ 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;
|
||||
|
@ -30,92 +52,70 @@ namespace RimWorldAnimationStudio
|
|||
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;
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
Debug.Log("Actor: " + clip.GetOwningActorID());
|
||||
|
||||
foreach (AddonDef addonDef in addonDefs)
|
||||
{
|
||||
switch (clip.GetActorAddon("left hand").AnchorName)
|
||||
if (clip?.GetActorAddon(addonDef.addonName) != null)
|
||||
{
|
||||
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;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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.GetCurrentPawnAnimationClip();
|
||||
|
||||
clip.ShowOrHideActorAddon("left hand", handLeftToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("right hand", handRightToggle.isOn);
|
||||
clip.ShowOrHideActorAddon("dildo", sexToyToggle.isOn);
|
||||
|
||||
//Initialize();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
switch (handLeftAnchor.value)
|
||||
|
@ -155,13 +155,11 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
//Initialize();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnLayerChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{ clip.GetActorAddon("left hand").Layer = handLeftLayer.options[handLeftLayer.value].text; }
|
||||
|
||||
|
@ -171,13 +169,11 @@ namespace RimWorldAnimationStudio
|
|||
if (clip?.GetActorAddon("dildo") != null)
|
||||
{ clip.GetActorAddon("dildo").Layer = sexToyLayer.options[sexToyLayer.value].text; }
|
||||
|
||||
//Initialize();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchoringPawnChanged()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip?.GetActorAddon("left hand") != null)
|
||||
{
|
||||
int i = int.Parse(handLeftAnchoringPawn.text);
|
||||
|
@ -210,6 +206,8 @@ namespace RimWorldAnimationStudio
|
|||
clip.GetActorAddon("dildo").AnchoringActor = i;
|
||||
sexToyAnchoringPawn.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue