Bug fix to support nested groups within switches

This commit is contained in:
Robbie Cargill 2024-01-07 16:32:21 +00:00
parent 2189cfc787
commit 3a7faa930f
3 changed files with 57 additions and 6 deletions

View File

@ -47,7 +47,30 @@ namespace R0bbie.Timeline
else
attachedController.StepCompleted();
}
}
/// <summary>
/// When a child step is played using GoToStep, if that step was nested within multiple step groups and/or switches, this function may be called by a child step group to tell this switch that a step within it somewhere is active
/// </summary>
public void SetActiveOnGoToChild(Step _childStep)
{
// If group wasn't already active, we'll set it active now
if (!isActive)
{
isActive = true;
}
// Set the active option
activeStepOption = _childStep;
// Then set any other parent step groups active too (all the way up the hierarchy, till we make it to the timeline, then till timeline to mark highest level group as active)
if (parentStepGroup)
parentStepGroup.SetActiveOnGoToChild(this);
if (parentStepSwitch)
parentStepSwitch.SetActiveOnGoToChild(this);
else
attachedStepTimeline.SetSpecifiedHighestStepActive(this);
}

View File

@ -244,12 +244,12 @@ namespace R0bbie.Timeline
/// <summary>
/// Called via a child step group when a deeper child step group has been activated via GoToStep
/// Called via a child step group or switch when a deeper child step group has been activated via GoToStep
/// </summary>
public void SetSpecifiedHighestStepGroupActive(StepGroup _group)
public void SetSpecifiedHighestStepActive(Step _step)
{
// Set the index in the timeline to that of new step's highest parent group
activeStepIndex = steps.IndexOf(_group);
activeStepIndex = steps.IndexOf(_step);
SetActiveStep(activeStepIndex);
}

View File

@ -170,7 +170,7 @@ namespace R0bbie.Timeline
if (parentStepGroup)
parentStepGroup.SetActiveOnGoToChild(this);
else
attachedStepTimeline.SetSpecifiedHighestStepGroupActive(this);
attachedStepTimeline.SetSpecifiedHighestStepActive(this);
// Set the index to the newly requested step
activeChildStepIndex = childSteps.IndexOf(_step);
@ -184,7 +184,7 @@ namespace R0bbie.Timeline
/// <summary>
/// When a child step is played using GoToStep, if that step was nested within multiple step groups, this function may be called by a child step group to tell this step group that it's now active
/// </summary>
private void SetActiveOnGoToChild(StepGroup _childStepGroup)
public void SetActiveOnGoToChild(StepGroup _childStepGroup)
{
// If group wasn't already active, we'll set it active now
if (!isActive)
@ -200,8 +200,36 @@ namespace R0bbie.Timeline
// Then set any other parent step groups active too (all the way up the hierarchy, till we make it to the timeline, then till timeline to mark highest level group as active)
if (parentStepGroup)
parentStepGroup.SetActiveOnGoToChild(this);
if (parentStepSwitch)
parentStepSwitch.SetActiveOnGoToChild(this);
else
attachedStepTimeline.SetSpecifiedHighestStepGroupActive(this);
attachedStepTimeline.SetSpecifiedHighestStepActive(this);
}
/// <summary>
/// When a child step is played using GoToStep, allow for a child switch
/// </summary>
public void SetActiveOnGoToChild(StepSwitch _childStepSwitch)
{
// If group wasn't already active, we'll set it active now
if (!isActive)
{
isActive = true;
onGroupPlayEvent?.Invoke();
}
// Set the index and active step on this group
activeChildStepIndex = childSteps.IndexOf(_childStepSwitch);
activeChildStep = childSteps[activeChildStepIndex];
// Then set any other parent step groups active too (all the way up the hierarchy, till we make it to the timeline, then till timeline to mark highest level group as active)
if (parentStepGroup)
parentStepGroup.SetActiveOnGoToChild(this);
if (parentStepSwitch)
parentStepSwitch.SetActiveOnGoToChild(this);
else
attachedStepTimeline.SetSpecifiedHighestStepActive(this);
}