56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
public class StageCardManager : Singleton<StageCardManager>
|
|
{
|
|
public StageCard stageCardPrefab;
|
|
|
|
public void Initialize()
|
|
{
|
|
foreach(AnimationStage stage in Workspace.animationDef.animationStages)
|
|
{ MakeStageCard(stage.stageName); }
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
foreach(StageCard stageCard in GetComponentsInChildren<StageCard>())
|
|
{ Destroy(stageCard.gameObject); }
|
|
}
|
|
|
|
public StageCard MakeStageCard(string stageName = null)
|
|
{
|
|
StageCard stageCard = Instantiate(stageCardPrefab, transform);
|
|
|
|
if (stageName != null)
|
|
{ stageCard.Initialize(stageName); }
|
|
|
|
return stageCard;
|
|
}
|
|
|
|
public void OnNewStage()
|
|
{
|
|
if (AnimationController.Instance.AddAnimationStage())
|
|
{ MakeStageCard("NewStage"); }
|
|
}
|
|
|
|
public void OnCloneStage()
|
|
{
|
|
if (AnimationController.Instance.CloneAnimationStage())
|
|
{
|
|
StageCard stageCard = MakeStageCard(Workspace.animationDef.animationStages[Workspace.stageID + 1].stageName);
|
|
stageCard.transform.SetSiblingIndex(Workspace.stageID + 1);
|
|
}
|
|
}
|
|
|
|
public void OnDeleteStage()
|
|
{
|
|
if (AnimationController.Instance.RemoveAnimationStage())
|
|
{ Destroy(transform.GetChild(Workspace.stageID).gameObject); }
|
|
}
|
|
}
|
|
}
|