8000 Rename animation component events by nuskey8 · Pull Request #183 · annulusgames/LitMotion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rename animation component events #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override MotionHandle Play()
.RunWithoutBinding();
}

public override void Stop() { }
public override void OnStop() { }
}

[Serializable]
Expand All @@ -33,7 +33,7 @@ public override MotionHandle Play()
return LMotion.Create(0f, 1f, 0f).RunWithoutBinding();
}

public override void Stop()
public override void OnStop()
{
onStop.Invoke();
}
Expand All @@ -56,7 +56,17 @@ public override MotionHandle Play()
});
}

public override void Stop()
public override void OnResume()
{
target.Play();
}

public override void OnPause()
{
target.Pause();
}

public override void OnStop()
{
target.Stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override MotionHandle Play()
});
}

public override void Stop() { }
public override void OnStop() { }
}

[Serializable]
Expand Down Expand Up @@ -75,6 +75,6 @@ public override MotionHandle Play()
});
}

public override void Stop() { }
public override void OnStop() { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void Play()
{
handle.PlaybackSpeed = 1f;
isPlaying = true;

component.OnResume();
}
}

Expand Down Expand Up @@ -122,7 +124,11 @@ public void Pause()
foreach (var component in playingComponents.AsSpan())
{
var handle = component.TrackedHandle;
if (handle.IsActive()) handle.PlaybackSpeed = 0f;
if (handle.IsActive())
{
handle.PlaybackSpeed = 0f;
component.OnPause();
}
}
}

Expand All @@ -134,7 +140,7 @@ public void Stop()
{
var handle = component.TrackedHandle;
handle.TryCancel();
component.Stop();
component.OnStop();
component.TrackedHandle = handle;
}

Expand Down Expand Up @@ -173,7 +179,7 @@ public bool IsPlaying
foreach (var component in playingComponents.AsSpan())
{
var handle = component.TrackedHandle;
if (handle.IsPlaying() && handle.PlaybackSpeed != 0f) return true;
if (handle.IsPlaying()) return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public LitMotionAnimationComponent()
public string DisplayName => displayName;

public abstract MotionHandle Play();
public abstract void Stop();

public virtual void OnResume() { }
public virtual void OnPause() { }
public virtual void OnStop() { }

public MotionHandle TrackedHandle { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@ public abstract class PropertyAnimationComponent<TObject, TValue, TOptions, TAda

TValue startValue;

public sealed override void Stop()
public override void OnStop()
{
if (target == null) return;
SetValue(target, startValue);
OnRevert(target);
}

protected virtual void OnBeforePlay(TObject target) { }
protected virtual void OnAfterPlay(TObject target) { }
protected virtual void OnRevert(TObject target) { }

public override MotionHandle Play()
{
startValue = GetValue(target);

OnBeforePlay(target);

MotionHandle handle;

if (relative)
Expand All @@ -53,8 +46,6 @@ public override MotionHandle Play()
});
}

OnAfterPlay(target);

return handle;
}

Expand Down
0