Installed Surge, fixed compile errors, moved a bunch of external stuff into folder

This commit is contained in:
2025-09-10 10:53:04 +02:00
parent a3649c65b0
commit 52bd7ef585
433 changed files with 10589 additions and 4 deletions

View File

@@ -0,0 +1,273 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Base class for tweens.
///
/// </summary>
using UnityEngine;
using System;
using Pixelplacement;
#pragma warning disable 0168
namespace Pixelplacement.TweenSystem
{
public abstract class TweenBase
{
//Public Variables:
public int targetInstanceID;
public Tween.TweenType tweenType;
//Public Properties:
public Tween.TweenStatus Status {get; private set;}
public float Duration {get; private set;}
public AnimationCurve Curve {get; private set;}
public Keyframe[] CurveKeys { get; private set; }
public bool ObeyTimescale {get; private set;}
public Action StartCallback {get; private set;}
public Action CompleteCallback {get; private set;}
public float Delay {get; private set;}
public Tween.LoopType LoopType {get; private set;}
public float Percentage {get; private set; }
//Protected Variables:
protected float elapsedTime = 0.0f;
//Public Methods:
/// <summary>
/// Stop/pauses the tween.
/// </summary>
public void Stop ()
{
Status = Tween.TweenStatus.Stopped;
Tick ();
}
/// <summary>
/// Starts or restarts a tween - interrupts a delay and allows a canceled or finished tween to restart.
/// </summary>
public void Start ()
{
elapsedTime = 0.0f;
if (Status == Tween.TweenStatus.Canceled || Status == Tween.TweenStatus.Finished || Status == Tween.TweenStatus.Stopped)
{
Status = Tween.TweenStatus.Running;
Operation (0);
Tween.Instance.ExecuteTween (this);
}
}
/// <summary>
/// Resumes a stopped/paused tween.
/// </summary>
public void Resume()
{
if (Status != Tween.TweenStatus.Stopped) return;
if (Status == Tween.TweenStatus.Stopped)
{
Status = Tween.TweenStatus.Running;
Tween.Instance.ExecuteTween(this);
}
}
/// <summary>
/// Rewind the tween.
/// </summary>
public void Rewind ()
{
Cancel ();
Operation (0);
}
/// <summary>
/// Rewind the tween and stop.
/// </summary>
public void Cancel ()
{
Status = Tween.TweenStatus.Canceled;
Tick ();
}
/// <summary>
/// Fast forward the tween and stop.
/// </summary>
public void Finish ()
{
Status = Tween.TweenStatus.Finished;
Tick ();
}
/// <summary>
/// Used internally to update the tween and report status to the main system.
/// </summary>
public void Tick ()
{
//stop where we are:
if (Status == Tween.TweenStatus.Stopped)
{
CleanUp();
return;
}
//rewind operation and stop:
if (Status == Tween.TweenStatus.Canceled)
{
Operation (0);
Percentage = 0;
CleanUp();
return;
}
//fast forward operation and stop:
if (Status == Tween.TweenStatus.Finished)
{
Operation (1);
Percentage = 1;
if (CompleteCallback != null) CompleteCallback ();
CleanUp();
return;
}
float progress = 0.0f;
//calculate:
if (ObeyTimescale)
{
elapsedTime += Time.deltaTime;
}else{
elapsedTime += Time.unscaledDeltaTime;
}
progress = Math.Max(elapsedTime, 0f);
//percentage:
float percentage = Mathf.Min(progress / Duration, 1);
//delayed?
if (percentage == 0 && Status != Tween.TweenStatus.Delayed) Status = Tween.TweenStatus.Delayed;
//running?
if (percentage > 0 && Status == Tween.TweenStatus.Delayed)
{
if (SetStartValue ())
{
if (StartCallback != null) StartCallback ();
Status = Tween.TweenStatus.Running;
}else{
CleanUp();
return;
}
}
//evaluate:
float curveValue = percentage;
//using a curve?
if (Curve != null && CurveKeys.Length > 0) curveValue = TweenUtilities.EvaluateCurve (Curve, percentage);
//perform operation with minimal overhead of a try/catch to account for anything that has been destroyed while tweening:
if (Status == Tween.TweenStatus.Running)
{
try {
Operation (curveValue);
Percentage = curveValue;
} catch (Exception ex) {
CleanUp();
return;
}
}
//tween complete:
if (percentage == 1)
{
if (CompleteCallback != null)
{
CompleteCallback();
}
switch (LoopType)
{
case Tween.LoopType.Loop:
Loop ();
break;
case Tween.LoopType.PingPong:
PingPong ();
break;
default:
Status = Tween.TweenStatus.Finished;
CleanUp();
return;
}
}
}
//Private Methods:
private void CleanUp()
{
if (Tween.activeTweens.Contains(this))
{
Tween.activeTweens.Remove(this);
}
}
//Protected Methods:
/// <summary>
/// Resets the start time.
/// </summary>
protected void ResetStartTime ()
{
elapsedTime = -Delay;
}
/// <summary>
/// Sets the essential properties that all tweens need and should be called from their constructor. If targetInstanceID is -1 then this tween won't interrupt tweens of the same type on the same target.
/// </summary>
protected void SetEssentials (Tween.TweenType tweenType, int targetInstanceID, float duration, float delay, bool obeyTimeScale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
{
this.tweenType = tweenType;
this.targetInstanceID = targetInstanceID;
if (delay > 0)
Status = Tween.TweenStatus.Delayed;
Duration = duration;
Delay = delay;
Curve = curve;
CurveKeys = curve == null ? null : curve.keys;
StartCallback = startCallback;
CompleteCallback = completeCallback;
LoopType = loop;
ObeyTimescale = obeyTimeScale;
ResetStartTime ();
}
//Abstract Methods:
/// <summary>
/// Override this method to carry out the initialization required for the tween.
/// </summary>
protected abstract bool SetStartValue ();
/// <summary>
/// Override this method to carry out the processing required for the tween.
/// </summary>
protected abstract void Operation (float percentage);
/// <summary>
/// Override this method to carry out a standard loop.
/// </summary>
public abstract void Loop ();
/// <summary>
/// Override this method to carry out a ping pong loop.
/// </summary>
public abstract void PingPong ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0cc92aa32653c5c49961cb6ef1a155f4
timeCreated: 1550029582
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Tween/Helpers/TweenBase.cs
uploadId: 467433

View File

@@ -0,0 +1,39 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Used internally by the tween system to run all tween calculations.
///
/// </summary>
using UnityEngine;
using System.Collections;
using Pixelplacement;
namespace Pixelplacement.TweenSystem
{
public class TweenEngine : MonoBehaviour
{
public void ExecuteTween(TweenBase tween)
{
Tween.activeTweens.Add(tween);
}
private void Update()
{
foreach (var tween in Tween.activeTweens.ToArray())
{
tween.Tick();
}
// for (int i = Tween.activeTweens.Count - 1; i >= 0; i--)
// {
// if (!Tween.activeTweens[i].Tick())
// {
// Tween.activeTweens.RemoveAt(i);
// }
// }
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6b13dfb4f9630436a8a99ed556dd04da
timeCreated: 1462246277
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Tween/Helpers/TweenEngine.cs
uploadId: 467433

View File

@@ -0,0 +1,123 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Math helpers for interpolation and curve evaluation.
///
/// </summary>
using UnityEngine;
using Pixelplacement;
namespace Pixelplacement.TweenSystem
{
public class TweenUtilities : MonoBehaviour
{
//Public Methods:
/// <summary>
/// Generates the code to contain an Animation Curve in a property for use in storing ease curves within the Tween engine class.
/// </summary>
public static void GenerateAnimationCurvePropertyCode (AnimationCurve curve)
{
string code = "get { return new AnimationCurve (";
for (int i = 0; i < curve.keys.Length; i++)
{
Keyframe currentFrame = curve.keys [i];
code += "new Keyframe (" + currentFrame.time + "f, " + currentFrame.value + "f, " + currentFrame.inTangent + "f, " + currentFrame.outTangent + "f)";
if (i < curve.keys.Length - 1) code += ", ";
}
code += "); }";
Debug.Log (code);
}
/// <summary>
/// Linear interpolation for float.
/// </summary>
public static float LinearInterpolate (float from, float to, float percentage)
{
return (to - from) * percentage + from; //this approach is needed instead of a simple Mathf.Lerp to accommodate ease cuves that overshoot
}
/// <summary>
/// Linear interpolation for Vector2.
/// </summary>
public static Vector2 LinearInterpolate (Vector2 from, Vector2 to, float percentage)
{
return new Vector2 (LinearInterpolate (from.x, to.x, percentage), LinearInterpolate (from.y, to.y, percentage));
}
/// <summary>
/// Linear interpolation for Vector3.
/// </summary>
public static Vector3 LinearInterpolate (Vector3 from, Vector3 to, float percentage)
{
return new Vector3 (LinearInterpolate (from.x, to.x, percentage), LinearInterpolate (from.y, to.y, percentage), LinearInterpolate (from.z, to.z, percentage));
}
/// <summary>
/// Linear interpolation for Rotations.
/// </summary>
public static Vector3 LinearInterpolateRotational (Vector3 from, Vector3 to, float percentage)
{
return new Vector3 (CylindricalLerp (from.x, to.x, percentage), CylindricalLerp (from.y, to.y, percentage), CylindricalLerp (from.z, to.z, percentage));
}
/// <summary>
/// Linear interpolation for Vector4.
/// </summary>
public static Vector4 LinearInterpolate (Vector4 from, Vector4 to, float percentage)
{
return new Vector4 (LinearInterpolate (from.x, to.x, percentage), LinearInterpolate (from.y, to.y, percentage), LinearInterpolate (from.z, to.z, percentage), LinearInterpolate (from.w, to.w, percentage));
}
/// <summary>
/// Linear interpolation for Rect.
/// </summary>
public static Rect LinearInterpolate (Rect from, Rect to, float percentage)
{
return new Rect (LinearInterpolate (from.x, to.x, percentage), LinearInterpolate (from.y, to.y, percentage), LinearInterpolate (from.width, to.width, percentage), LinearInterpolate (from.height, to.height, percentage));
}
/// <summary>
/// Linear interpolation for Color.
/// </summary>
public static Color LinearInterpolate (Color from, Color to, float percentage)
{
return new Color (LinearInterpolate (from.r, to.r, percentage), LinearInterpolate (from.g, to.g, percentage), LinearInterpolate (from.b, to.b, percentage), LinearInterpolate (from.a, to.a, percentage));
}
/// <summary>
/// Evaluates a curve at a percentage.
/// </summary>
public static float EvaluateCurve (AnimationCurve curve, float percentage)
{
return curve.Evaluate ((curve [curve.length - 1].time) * percentage);
}
//Private Methods:
//use to handle rotational lerping so values that wrap around 360 don't spin in the wrong direction:
static float CylindricalLerp (float from, float to, float percentage)
{
float min = 0f;
float max = 360f;
float half = Mathf.Abs ((max - min) * .5f);
float calculation = 0f;
float difference = 0f;
if ((to - from) < -half)
{
difference = ((max - from) + to) * percentage;
calculation = from + difference;
}else if ((to - from) > half){
difference = -((max - to) + from) * percentage;
calculation = from + difference;
}else{
calculation = from + (to - from) * percentage;
}
return calculation;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 04a591ac6904e4a5b851e2a29c607e76
timeCreated: 1460088213
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Tween/Helpers/TweenUtilities.cs
uploadId: 467433