Started working on XP and leveling/stats system

This commit is contained in:
caleb
2025-10-09 08:49:20 +01:00
parent a22eefd770
commit 7745d73d06
219 changed files with 82809 additions and 538 deletions

View File

@@ -0,0 +1,14 @@
{
"name": "OccaSoftware.SuperSimpleSkybox.Runtime",
"rootNamespace": "OccaSoftware.SuperSimpleSkybox.Runtime",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: ee54ccb0344ed264090ebfc168b827b0
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/OccaSoftware.SuperSimpleSkybox.Runtime.asmdef
uploadId: 612339

View File

@@ -0,0 +1,11 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
internal static class ShaderParams
{
public static int _StarMatrix = Shader.PropertyToID("_MainLightMatrix");
public static int _SunDirection = Shader.PropertyToID("_SunDirection");
public static int _MoonDirection = Shader.PropertyToID("_MoonDirection");
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 76da7a9e64f198f498384450c005c7b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/ShaderParams.cs
uploadId: 612339

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2122deeed008a4b4aa66e27937f81d2f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using System;
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
/// <summary>
/// This component automatically rotates the sun and sets the light intensity from the angle.
/// </summary>
[ExecuteAlways]
[RequireComponent(typeof(Light))]
// We hide this component in the inspector Add Component Menu
// It doesn't do anything on its own and is intended only as a base class
// It is extended by Sun.cs, Moon.cs as base functions for automatic light handling.
[AddComponentMenu("OccaSoftware/Super Simple Skybox/")]
public class DirectionalLight : MonoBehaviour
{
[SerializeField]
[Min(0)]
private float rotationsPerHour = 1f;
/// <summary>
/// The rate of rotation of the directional light. Set as number of rotations per hour.
/// </summary>
public float RotationsPerHour
{
get => rotationsPerHour;
set => rotationsPerHour = value;
}
[SerializeField]
private bool automaticLightIntensity = true;
/// <summary>
/// When enabled, the light intensity will be set automatically based on the maximum intensity and alignment with the zenith.
/// </summary>
public bool AutomaticLightIntensity
{
get => automaticLightIntensity;
set => automaticLightIntensity = value;
}
[SerializeField]
[Min(0)]
private float maximumLightIntensity = 2f;
/// <summary>
/// The light intensity when at the zenith.
/// </summary>
public float MaximumLightIntensity
{
get => maximumLightIntensity;
set => maximumLightIntensity = value;
}
private Light _light = null;
public event Action OnRise = null;
public event Action OnSet = null;
/// <summary>
/// Returns the current state of the light (up or down).
/// </summary>
public LightState State
{
get => state;
}
private LightState state;
private float lightAngle;
private float GetLightAngle()
{
return Vector3.Dot(Vector3.down, transform.forward);
}
protected virtual void OnEnable()
{
_light = GetComponent<Light>();
lightAngle = GetLightAngle();
SetInitialLightState();
}
protected virtual void Update()
{
Rotate();
lightAngle = GetLightAngle();
SetLightState();
SetLightIntensity();
}
private void SetInitialLightState()
{
state = LightState.Up;
if (lightAngle < 0f)
state = LightState.Down;
}
/// <summary>
/// Updates the light state if needed.
/// Triggers the appropriate callback.
/// </summary>
private void SetLightState()
{
if (lightAngle > 0f && state == LightState.Down)
{
state = LightState.Up;
OnRise?.Invoke();
}
if (lightAngle < 0f && state == LightState.Up)
{
state = LightState.Down;
OnSet?.Invoke();
}
}
/// <summary>
/// Rotates the transform based on the rotation speed.
/// </summary>
private void Rotate()
{
if (!Application.isPlaying)
return;
if (rotationsPerHour == 0f)
return;
transform.Rotate(
transform.right * rotationsPerHour * Time.deltaTime * 0.1f,
Space.World
);
}
/// <summary>
/// Sets the light intensity based on the alignment between the light direction and the sky peak.
/// </summary>
private void SetLightIntensity()
{
if (!automaticLightIntensity)
return;
if (state == LightState.Down)
{
_light.intensity = 0;
return;
}
float t = Mathf.Clamp01(lightAngle);
t = 1f - Mathf.Pow(1f - t, 2f);
_light.intensity = t * maximumLightIntensity;
_light.shadowStrength = t;
}
/// <summary>
/// The state of the light object.
/// </summary>
public enum LightState
{
Down,
Up
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0a19356b94217ec4591aeee9efc4feeb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/DirectionalLight.cs
uploadId: 612339

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
[AddComponentMenu("OccaSoftware/Super Simple Skybox/Moon")]
public class Moon : DirectionalLight
{
protected override void Update()
{
base.Update();
Shader.SetGlobalVector(ShaderParams._MoonDirection, -transform.forward);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 162079df74f2f094ab771f7e0e70151b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/Moon.cs
uploadId: 612339

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
[ExecuteAlways]
[AddComponentMenu("OccaSoftware/Super Simple Skybox/Moon (Static)")]
public class MoonStatic : MonoBehaviour
{
private void Update()
{
Shader.SetGlobalVector(ShaderParams._MoonDirection, -transform.forward);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fa88c4cf155f1284db1f41bfbaf3b3f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/MoonStatic.cs
uploadId: 612339

View File

@@ -0,0 +1,27 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
/// <summary>
/// This component uses the local to world matrix of the transform to set the rotation of the stars.
/// Typically, you would set this component on the main directional light in your scene.
/// </summary>
[ExecuteAlways]
[AddComponentMenu("OccaSoftware/Super Simple Skybox/Set Star Rotation")]
public class SetStarRotation : MonoBehaviour
{
void Update()
{
SetMatrix();
}
/// <summary>
/// Sets the main light matrix for the star rotation in the shader.
/// </summary>
private void SetMatrix()
{
Shader.SetGlobalMatrix(ShaderParams._StarMatrix, transform.localToWorldMatrix);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 86f07a9a11c313b48b82d2f4f8ead64a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/SetStarRotation.cs
uploadId: 612339

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
[AddComponentMenu("OccaSoftware/Super Simple Skybox/Sun")]
public class Sun : DirectionalLight
{
protected override void Update()
{
base.Update();
Shader.SetGlobalVector(ShaderParams._SunDirection, -transform.forward);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fd543c84a5b59c541b325244b881a706
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/Sun.cs
uploadId: 612339

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
[ExecuteAlways]
[AddComponentMenu("OccaSoftware/Super Simple Skybox/Sun (Static)")]
public class SunStatic : MonoBehaviour
{
private void Update()
{
Shader.SetGlobalVector(ShaderParams._SunDirection, -transform.forward);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b6bc0f1414c2f9f4cb45eff128907e7f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/SkyObjects/SunStatic.cs
uploadId: 612339

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f9c542e0de9551b4785b11b3ad4ca40a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
using UnityEngine;
namespace OccaSoftware.SuperSimpleSkybox.Runtime
{
/// <summary>
/// This component synchronizes the position of the VR Skybox with the targeted camera component.
/// </summary>
[ExecuteAlways]
[AddComponentMenu("OccaSoftware/Super Simple Skybox/VR-Compatible Skybox")]
public class VRSkybox : MonoBehaviour
{
[SerializeField]
Camera target;
void Start()
{
if (target == null)
return;
transform.position = target.transform.position;
}
int farClipPlaneCached;
void LateUpdate()
{
if (target == null)
return;
transform.position = target.transform.position;
if (farClipPlaneCached != (int)target.farClipPlane)
{
float targetScale = (int)target.farClipPlane - 1;
farClipPlaneCached = (int)target.farClipPlane;
transform.localScale = FloatToV3(targetScale);
}
}
Vector3 FloatToV3(float x)
{
return new Vector3(x, x, x);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 840ced298170c424883a7c2c9735c545
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 210177
packageName: 'Super Simple Skybox: Dynamic Sky / Procedural Skybox (URP & BIRP)'
packageVersion: 4.2.1
assetPath: Packages/com.occasoftware.super-simple-skybox/Runtime/XR/VRSkybox.cs
uploadId: 612339