Working Developer Settings

This commit is contained in:
2025-09-24 13:31:15 +02:00
parent 8b96a5d0c3
commit 783541a776
24 changed files with 965 additions and 754 deletions

View File

@@ -1,5 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using System;
namespace AppleHills.Core.Settings
{
@@ -38,8 +40,8 @@ namespace AppleHills.Core.Settings
// Dictionary to cache loaded settings
private Dictionary<System.Type, BaseDeveloperSettings> _settingsCache = new Dictionary<System.Type, BaseDeveloperSettings>();
// Default developer settings stored in the Resources folder
[SerializeField] private string _resourcesPath = "Settings/Developer";
// Path prefix for addressable developer settings
[SerializeField] private string _addressablePath = "Settings/Developer";
private void Awake()
{
@@ -71,16 +73,35 @@ namespace AppleHills.Core.Settings
return cachedSettings as T;
}
// Load from Resources if not cached
T settings = Resources.Load<T>($"{_resourcesPath}/{type.Name}");
// Load from Addressables if not cached
string key = $"{_addressablePath}/{type.Name}";
if (settings != null)
try
{
_settingsCache[type] = settings;
return settings;
T settings = Addressables.LoadAssetAsync<T>(key).WaitForCompletion();
if (settings != null)
{
_settingsCache[type] = settings;
return settings;
}
}
catch (Exception e)
{
Debug.LogError($"Failed to load developer settings at '{key}': {e.Message}");
}
Debug.LogWarning($"Developer settings of type {type.Name} not found at addressable path '{key}'");
// Fallback to Resources for backward compatibility
T resourcesSettings = Resources.Load<T>($"{_addressablePath}/{type.Name}");
if (resourcesSettings != null)
{
Debug.Log($"Found developer settings in Resources instead of Addressables at '{_addressablePath}/{type.Name}'");
_settingsCache[type] = resourcesSettings;
return resourcesSettings;
}
Debug.LogWarning($"Developer settings of type {type.Name} not found in Resources/{_resourcesPath}");
return null;
}

View File

@@ -54,11 +54,9 @@ namespace AppleHills.Core.Settings
[Header("Obstacle System")]
[Tooltip("Layer for obstacles to be placed on")]
[Layer]
[SerializeField] private int obstacleLayer = 9;
[Tooltip("Layer mask for tile collision detection during obstacle spawn validation")]
[SerializeField] private LayerMask obstacleTileLayerMask = -1;
[Tooltip("Whether to use object pooling for obstacles")]
[SerializeField] private bool obstacleUseObjectPooling = true;
@@ -67,7 +65,73 @@ namespace AppleHills.Core.Settings
[Tooltip("Total maximum size of obstacle pool across all prefab types")]
[SerializeField] private int obstacleTotalMaxPoolSize = 15;
[Header("Trench Tile System")]
[Tooltip("Layer for trench tiles to be placed on")]
[Layer]
[SerializeField] private int trenchTileLayer = 13; // QuarryTrenchTile layer
[Tooltip("Whether to use object pooling for trench tiles")]
[SerializeField] private bool trenchTileUseObjectPooling = true;
[Tooltip("Maximum objects per prefab type in trench tile pool")]
[SerializeField] private int trenchTileMaxPerPrefabPoolSize = 2;
[Tooltip("Total maximum size of trench tile pool across all prefab types")]
[SerializeField] private int trenchTileTotalMaxPoolSize = 10;
[Header("Player Blink Behavior")]
[Tooltip("Color to blink to when taking damage (typically red for damage indication)")]
[SerializeField] private Color playerBlinkDamageColor = Color.red;
[Tooltip("How fast to blink between normal and damage colors (seconds between color changes)")]
[SerializeField] private float playerBlinkRate = 0.15f;
[Tooltip("Alpha value for the damage color (0 = transparent, 1 = opaque)")]
[Range(0f, 1f)]
[SerializeField] private float playerDamageColorAlpha = 0.7f;
[Header("Player Wobble Behavior")]
[Tooltip("Frequency of wobble (higher = faster rocking)")]
[SerializeField] private float playerWobbleFrequency = 1.5f;
[Tooltip("Base wobble amplitude in degrees from horizontal")]
[SerializeField] private float playerBaseWobbleAmplitude = 8f;
[Tooltip("How much speed affects amplitude")]
[SerializeField] private float playerSpeedToAmplitude = 2f;
[Tooltip("Maximum allowed rotation in degrees")]
[SerializeField] private float playerMaxRotationLimit = 45f;
[Tooltip("Frequency of vertical bobbing")]
[SerializeField] private float playerVerticalFrequency = 0.5f;
[Tooltip("How far the object moves up/down")]
[SerializeField] private float playerVerticalAmplitude = 0.5f;
[Tooltip("How quickly velocity changes are smoothed")]
[SerializeField] private float playerVelocitySmoothing = 10f;
[Tooltip("How quickly rotation is smoothed")]
[SerializeField] private float playerRotationSmoothing = 10f;
[Header("Collision Settings")]
[Tooltip("Layer mask for obstacle detection - configure which layers contain obstacles")]
[LayerMask]
[SerializeField] private LayerMask playerObstacleLayerMask = -1;
[Tooltip("Whether to block player input during damage immunity period")]
[SerializeField] private bool blockInputDuringImmunity = true;
[Tooltip("Type of bump response: 0=Impulse, 1=SmoothToCenter")]
[SerializeField] private int bumpMode = 0;
[Tooltip("Animation curve controlling bump movement over time")]
[SerializeField] private AnimationCurve bumpCurve = new AnimationCurve(
new Keyframe(0f, 0f, 0f, 2f),
new Keyframe(1f, 1f, 0f, 0f));
// Bubble properties access
public bool BubbleUseObjectPooling => bubbleUseObjectPooling;
public int BubbleInitialPoolSize => bubbleInitialPoolSize;
@@ -86,10 +150,36 @@ namespace AppleHills.Core.Settings
// Obstacle properties access
public int ObstacleLayer => obstacleLayer;
public LayerMask ObstacleTileLayerMask => obstacleTileLayerMask;
public bool ObstacleUseObjectPooling => obstacleUseObjectPooling;
public int ObstacleMaxPerPrefabPoolSize => obstacleMaxPerPrefabPoolSize;
public int ObstacleTotalMaxPoolSize => obstacleTotalMaxPoolSize;
// Trench Tile System properties
public int TrenchTileLayer => trenchTileLayer;
public bool TrenchTileUseObjectPooling => trenchTileUseObjectPooling;
public int TrenchTileMaxPerPrefabPoolSize => trenchTileMaxPerPrefabPoolSize;
public int TrenchTileTotalMaxPoolSize => trenchTileTotalMaxPoolSize;
// Player Blink Behavior properties
public Color PlayerBlinkDamageColor => playerBlinkDamageColor;
public float PlayerBlinkRate => playerBlinkRate;
public float PlayerDamageColorAlpha => playerDamageColorAlpha;
// Player Wobble Behavior properties
public float PlayerWobbleFrequency => playerWobbleFrequency;
public float PlayerBaseWobbleAmplitude => playerBaseWobbleAmplitude;
public float PlayerSpeedToAmplitude => playerSpeedToAmplitude;
public float PlayerMaxRotationLimit => playerMaxRotationLimit;
public float PlayerVerticalFrequency => playerVerticalFrequency;
public float PlayerVerticalAmplitude => playerVerticalAmplitude;
public float PlayerVelocitySmoothing => playerVelocitySmoothing;
public float PlayerRotationSmoothing => playerRotationSmoothing;
// Collision Settings properties
public LayerMask PlayerObstacleLayerMask => playerObstacleLayerMask;
public bool BlockInputDuringImmunity => blockInputDuringImmunity;
public int BumpMode => bumpMode;
public AnimationCurve BumpCurve => bumpCurve;
public override void OnValidate()
{
@@ -122,6 +212,26 @@ namespace AppleHills.Core.Settings
// Validate obstacle settings
obstacleMaxPerPrefabPoolSize = Mathf.Max(1, obstacleMaxPerPrefabPoolSize);
obstacleTotalMaxPoolSize = Mathf.Max(obstacleMaxPerPrefabPoolSize, obstacleTotalMaxPoolSize);
// Validate Trench Tile settings
trenchTileMaxPerPrefabPoolSize = Mathf.Max(1, trenchTileMaxPerPrefabPoolSize);
trenchTileTotalMaxPoolSize = Mathf.Max(trenchTileMaxPerPrefabPoolSize, trenchTileTotalMaxPoolSize);
// Validate Player Blink settings
playerBlinkRate = Mathf.Max(0.01f, playerBlinkRate);
playerDamageColorAlpha = Mathf.Clamp01(playerDamageColorAlpha);
// Validate Player Wobble settings
playerWobbleFrequency = Mathf.Max(0.01f, playerWobbleFrequency);
playerBaseWobbleAmplitude = Mathf.Max(0f, playerBaseWobbleAmplitude);
playerMaxRotationLimit = Mathf.Max(0f, playerMaxRotationLimit);
playerVerticalFrequency = Mathf.Max(0.01f, playerVerticalFrequency);
playerVerticalAmplitude = Mathf.Max(0f, playerVerticalAmplitude);
playerVelocitySmoothing = Mathf.Max(0.1f, playerVelocitySmoothing);
playerRotationSmoothing = Mathf.Max(0.1f, playerRotationSmoothing);
// Validate Collision settings
bumpMode = Mathf.Clamp(bumpMode, 0, 1);
}
}
}

View File

@@ -105,6 +105,19 @@ namespace AppleHills.Core.Settings
[Tooltip("Maximum movement speed for spawned obstacles")]
[SerializeField] private float endlessDescenderObstacleMaxMoveSpeed = 4f;
[Header("Endless Descender - Collision Handling")]
[Tooltip("Duration in seconds of damage immunity after being hit")]
[SerializeField] private float endlessDescenderDamageImmunityDuration = 1.0f;
[Tooltip("Force strength for impulse bumps - higher values push further toward center")]
[SerializeField] private float endlessDescenderBumpForce = 5.0f;
[Tooltip("Speed for smooth movement to center (units per second)")]
[SerializeField] private float endlessDescenderSmoothMoveSpeed = 8.0f;
[Tooltip("Whether to block player input during bump movement")]
[SerializeField] private bool endlessDescenderBlockInputDuringBump = true;
// IMinigameSettings implementation - Basic Movement
public float EndlessDescenderLerpSpeed => endlessDescenderLerpSpeed;
public float EndlessDescenderMaxOffset => endlessDescenderMaxOffset;
@@ -149,6 +162,12 @@ namespace AppleHills.Core.Settings
public float EndlessDescenderObstacleMinMoveSpeed => endlessDescenderObstacleMinMoveSpeed;
public float EndlessDescenderObstacleMaxMoveSpeed => endlessDescenderObstacleMaxMoveSpeed;
// IMinigameSettings implementation - Collision Handling
public float EndlessDescenderDamageImmunityDuration => endlessDescenderDamageImmunityDuration;
public float EndlessDescenderBumpForce => endlessDescenderBumpForce;
public float EndlessDescenderSmoothMoveSpeed => endlessDescenderSmoothMoveSpeed;
public bool EndlessDescenderBlockInputDuringBump => endlessDescenderBlockInputDuringBump;
public override void OnValidate()
{
base.OnValidate();
@@ -205,6 +224,11 @@ namespace AppleHills.Core.Settings
endlessDescenderObstacleSpawnCollisionRadius = Mathf.Max(0.1f, endlessDescenderObstacleSpawnCollisionRadius);
endlessDescenderObstacleMinMoveSpeed = Mathf.Max(0.1f, endlessDescenderObstacleMinMoveSpeed);
endlessDescenderObstacleMaxMoveSpeed = Mathf.Max(endlessDescenderObstacleMinMoveSpeed, endlessDescenderObstacleMaxMoveSpeed);
// Validate collision settings
endlessDescenderDamageImmunityDuration = Mathf.Max(0.1f, endlessDescenderDamageImmunityDuration);
endlessDescenderBumpForce = Mathf.Max(0.1f, endlessDescenderBumpForce);
endlessDescenderSmoothMoveSpeed = Mathf.Max(0.1f, endlessDescenderSmoothMoveSpeed);
}
}
}

View File

@@ -0,0 +1,20 @@
using UnityEngine;
namespace AppleHills.Core.Settings
{
/// <summary>
/// Attribute to indicate a field should be drawn using the layer selector dropdown
/// </summary>
public class LayerAttribute : PropertyAttribute
{
// No properties needed - this is a marker attribute
}
/// <summary>
/// Attribute to indicate a field should be drawn using the layer mask selector dropdown
/// </summary>
public class LayerMaskAttribute : PropertyAttribute
{
// No properties needed - this is a marker attribute
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7c64dbd728524f23bda766b57a388207
timeCreated: 1758711688

View File

@@ -88,5 +88,11 @@ namespace AppleHills.Core.Settings
float EndlessDescenderObstacleSpawnCollisionRadius { get; }
float EndlessDescenderObstacleMinMoveSpeed { get; }
float EndlessDescenderObstacleMaxMoveSpeed { get; }
// Endless Descender - Collision Handling
float EndlessDescenderDamageImmunityDuration { get; }
float EndlessDescenderBumpForce { get; }
float EndlessDescenderSmoothMoveSpeed { get; }
bool EndlessDescenderBlockInputDuringBump { get; }
}
}