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
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue