Skip to content

Commit

Permalink
Improve access modifiers in CoroutineBase
Browse files Browse the repository at this point in the history
Reduce visibility of many methods that control the internal behaviour of coroutines and should not be accessed from the outside
  • Loading branch information
Inspiaaa committed Sep 5, 2024
1 parent 5123e67 commit c058fc7
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/CoroutineBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Init()
/// <summary>
/// Called when the coroutine starts.
/// </summary>
public virtual void OnEnter() { }
protected virtual void OnEnter() { }

/// <summary>
/// Called every frame if the coroutine is playing.
Expand All @@ -73,14 +73,14 @@ public virtual void Update() { }
/// <summary>
/// Called when the coroutine is killed.
/// </summary>
public virtual void OnExit() { }
protected virtual void OnExit() { }

/// <summary>
/// Starts playing this coroutine, meaning that it will receive Update() calls
/// each frame. This is independent of the child coroutines.
/// This method only works if the coroutine is still alive.
/// </summary>
public void ResumeUpdates()
protected void ResumeUpdates()
{
if (!IsAlive)
{
Expand All @@ -95,7 +95,7 @@ public void ResumeUpdates()
/// Stops giving the coroutine Update() calls each frame.
/// This is independent of the child coroutines.
/// </summary>
public void PauseUpdates()
protected void PauseUpdates()
{
IsPlaying = false;
Manager.DeactivateCoroutine(this);
Expand Down Expand Up @@ -147,7 +147,7 @@ public void Kill()
/// <summary>
/// Adds a coroutine as a child.
/// </summary>
protected void AddChild(CoroutineBase coroutine)
private void AddChild(CoroutineBase coroutine)
{
if (firstChild == null)
{
Expand All @@ -165,7 +165,7 @@ protected void AddChild(CoroutineBase coroutine)
/// <summary>
/// Removes a child from the list of child coroutines.
/// </summary>
protected void RemoveChild(CoroutineBase coroutine)
private void RemoveChild(CoroutineBase coroutine)
{
if (coroutine.previousSibling != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Coroutines/AwaitCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AwaitCoroutine(Task<T> task)
this.Task = task;
}

public override void OnEnter()
protected override void OnEnter()
{
// As the CoroutineManager class is not thread safe, ensure that Kill()
// is executed on the main Godot thread.
Expand All @@ -39,7 +39,7 @@ public AwaitCoroutine(Task task)
this.Task = task;
}

public override void OnEnter()
protected override void OnEnter()
{
// As the CoroutineManager class is not thread safe, ensure that Kill()
// is executed on the main Godot thread.
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/Coroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Coroutine(Func<Coroutine, IEnumerator> creator)
this.routine = creator(this);
}

public override void OnEnter()
protected override void OnEnter()
{
if (routine == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/ParallelCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public ParallelCoroutine(params CoroutineBase[] coroutines)
this.coroutines = coroutines;
}

public override void OnEnter()
protected override void OnEnter()
{
if (coroutines.Length == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/RepeatCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public RepeatCoroutine(int repeatTimes, Func<RepeatCoroutine, CoroutineBase> cor
this.coroutineCreator = coroutineCreator;
}

public override void OnEnter()
protected override void OnEnter()
{
if (repeatTimes == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/SequentialCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public SequentialCoroutine(params CoroutineBase[] coroutines)
this.coroutines = coroutines;
}

public override void OnEnter()
protected override void OnEnter()
{
if (coroutines.Length == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Coroutines/TweenCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TweenCoroutine(Func<Tween> createTween)
this.createTween = createTween;
}

public override void OnEnter()
protected override void OnEnter()
{
tween = createTween();

Expand All @@ -30,7 +30,7 @@ public override void OnEnter()
tween.Finished += Kill;
}

public override void OnExit()
protected override void OnExit()
{
tween.Kill();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/WaitDelayCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public WaitDelayCoroutine(float delay)
this.delay = delay;
}

public override void OnEnter()
protected override void OnEnter()
{
Manager.GetTree().CreateTimer(delay).Timeout += Kill;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/WaitForSignalCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public WaitForSignalCoroutine(GodotObject obj, string signal)
this.targetSignal = signal;
}

public override void OnEnter() {
protected override void OnEnter() {
Manager.ToSignal(targetObject, targetSignal).OnCompleted(Kill);
}
}
2 changes: 1 addition & 1 deletion src/Coroutines/WaitUntilCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public WaitUntilCoroutine(Func<Boolean> condition)
this.condition = condition;
}

public override void OnEnter()
protected override void OnEnter()
{
CheckCondition();
if (IsAlive) ResumeUpdates();
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutines/WaitWhileCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public WaitWhileCoroutine(Func<Boolean> condition)
this.condition = condition;
}

public override void OnEnter()
protected override void OnEnter()
{
CheckCondition();
if (IsAlive) ResumeUpdates();
Expand Down

0 comments on commit c058fc7

Please sign in to comment.