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,29 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// A set of globally accessible Editor utilities.
///
/// </summary>
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Pixelplacement
{
public class EditorUtilities : Editor
{
//Public Methods:
/// <summary>
/// Global error for the Editor.
/// </summary>
/// <param name="errorMessage">Error message.</param>
public static void Error (string errorMessage)
{
EditorUtility.DisplayDialog ("Framework Error", errorMessage, "OK");
}
}
}
#endif

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 5b0c21dc5573a4c0d9d49d3fa220604f
timeCreated: 1448507758
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/Utilities/EditorUtilities.cs
uploadId: 467433

View File

@@ -0,0 +1,94 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Utilizes script execution order to run before anything else to avoid order of operation failures so accessing things like singletons at any stage of application startup will never fail.
///
/// </summary>
using UnityEngine;
using System.Collections;
using System;
using System.Reflection;
namespace Pixelplacement
{
public class Initialization : MonoBehaviour
{
//Private Variables:
StateMachine _stateMachine;
DisplayObject _displayObject;
//Init:
void Awake()
{
//singleton initialization:
InitializeSingleton();
//values:
_stateMachine = GetComponent<StateMachine>();
_displayObject = GetComponent<DisplayObject>();
//display object initialization:
if (_displayObject != null) _displayObject.Register();
//state machine initialization:
if (_stateMachine != null) _stateMachine.Initialize();
}
void Start()
{
//state machine start:
if (_stateMachine != null) _stateMachine.StartMachine();
}
//Deinit:
void OnDisable()
{
if (_stateMachine != null)
{
if (!_stateMachine.returnToDefaultOnDisable || _stateMachine.defaultState == null) return;
if (_stateMachine.currentState == null)
{
_stateMachine.ChangeState(_stateMachine.defaultState);
return;
}
if (_stateMachine.currentState != _stateMachine.defaultState)
{
_stateMachine.ChangeState(_stateMachine.defaultState);
}
}
}
//Private Methods:
void InitializeSingleton()
{
foreach (Component item in GetComponents<Component>())
{
string baseType;
#if NETFX_CORE
baseType = item.GetType ().GetTypeInfo ().BaseType.ToString ();
#else
baseType = item.GetType().BaseType.ToString();
#endif
if (baseType.Contains("Singleton") && baseType.Contains("Pixelplacement"))
{
MethodInfo m;
#if NETFX_CORE
m = item.GetType ().GetTypeInfo ().BaseType.GetMethod ("Initialize", BindingFlags.NonPublic | BindingFlags.Instance);
#else
m = item.GetType().BaseType.GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance);
#endif
m.Invoke(item, new Component[] { item });
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 55938fb1577dd4ad3af7e994048c86f6
timeCreated: 1492745978
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: -9999
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Utilities/Initialization.cs
uploadId: 467433

View File

@@ -0,0 +1,56 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Helpers for layermasls: http://www.pixelplacement.com/site/2012/01/31/layermasks-simplified/
///
/// </summary>
using UnityEngine;
namespace Pixelplacement
{
public class LayerMaskHelper
{
public static int OnlyIncluding(params int[] layers)
{
return MakeMask(layers);
}
public static int Everything()
{
return -1;
}
public static int Default()
{
return 1;
}
public static int Nothing()
{
return 0;
}
public static int EverythingBut(params int[] layers)
{
return ~MakeMask(layers);
}
public static bool ContainsLayer(LayerMask layerMask, int layer)
{
return (layerMask.value & 1 << layer) != 0;
}
static int MakeMask(params int[] layers)
{
int mask = 0;
foreach (int item in layers)
{
mask |= 1 << item;
}
return mask;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 74999a540f5f2437b91951b7f06965c6
MonoImporter:
externalObjects: {}
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/Utilities/LayerMaskHelper.cs
uploadId: 467433

View File

@@ -0,0 +1,95 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Math. Math. Math.
///
/// </summary>
using UnityEngine;
namespace Pixelplacement
{
public static class CoreMath
{
//interpolation:
/// <summary>
/// Linear interpolation.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
public static float LinearInterpolate (float from, float to, float percentage)
{
return (to - from) * percentage + from;
}
/// <summary>
/// Linear interpolation.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
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.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
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.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
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.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
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.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <param name="percentage">Percentage.</param>
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));
}
//animation curves:
/// <summary>
/// Evaluates the curve.
/// </summary>
/// <returns>The value evaluated at the percentage of the clip.</returns>
/// <param name="curve">Curve.</param>
/// <param name="percentage">Percentage.</param>
public static float EvaluateCurve (AnimationCurve curve, float percentage)
{
return curve.Evaluate ((curve [curve.length - 1].time) * percentage);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 17115f1ce14df4c0bacca4be282bbbc6
timeCreated: 1445539293
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/Utilities/Math.cs
uploadId: 467433