493 lines
13 KiB
C#
493 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.TextCore.Text;
|
|
|
|
namespace DanieleMarotta.RiversongCodeShowcase
|
|
{
|
|
[CreateAssetMenu(fileName = "GameConfig", menuName = "Riversong Code Showcase/Game Config")]
|
|
[Searchable]
|
|
public class GameConfig : ScriptableObject
|
|
{
|
|
[FoldoutGroup("General Settings")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public GeneralSettingsConfig GeneralSettings;
|
|
|
|
[FoldoutGroup("Audio")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public AudioConfig Audio;
|
|
|
|
[FoldoutGroup("Camera")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public CameraConfig Camera;
|
|
|
|
[FoldoutGroup("World Generation")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public WorldGenConfig WorldGen;
|
|
|
|
[FoldoutGroup("Time")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public TimeConfig Time;
|
|
|
|
[FoldoutGroup("Terrain")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public TerrainConfig Terrain;
|
|
|
|
[FoldoutGroup("Buildings")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public BuildingsConfig Buildings;
|
|
|
|
[FoldoutGroup("Roads")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public RoadsConfig Roads;
|
|
|
|
[FoldoutGroup("Agents")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public AgentsConfig Agents;
|
|
|
|
[FoldoutGroup("Population")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public PopulationConfig Population;
|
|
|
|
[FoldoutGroup("Economy")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public EconomyConfig Economy;
|
|
|
|
[FoldoutGroup("Onboarding")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public OnboardingConfig Onboarding;
|
|
|
|
[FoldoutGroup("UI")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public UIConfig UI;
|
|
|
|
[FoldoutGroup("VFX")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public VfxConfig Vfx;
|
|
|
|
[Serializable]
|
|
public class GeneralSettingsConfig
|
|
{
|
|
public float TileSize = 1;
|
|
|
|
public int BaseElevation = 2;
|
|
|
|
[TitleGroup("Demo Only")]
|
|
public int PopulationGoal = 50;
|
|
|
|
[Range(0, 1)]
|
|
public float HappinessGoal = 1;
|
|
}
|
|
|
|
[Serializable]
|
|
public class AudioConfig
|
|
{
|
|
public AssetReferenceT<AudioClip> MainThemeClip;
|
|
|
|
[Range(0, 1)]
|
|
public float MainThemeVolume = 1;
|
|
|
|
public AssetReferenceT<AudioClip> GameplayClip;
|
|
|
|
[Range(0, 1)]
|
|
public float GameplayVolume = 1;
|
|
|
|
public AssetReferenceT<SystemSoundLibrary> SystemSoundLibrary;
|
|
|
|
public AssetReferenceGameObject AudioSourcePrefab;
|
|
|
|
[TitleGroup("Spatial Audio")]
|
|
[LabelText("Horizontal Distance Range")]
|
|
public Vector2 SpatialAudioHorizontalDistanceRange = new(10, 20);
|
|
|
|
[LabelText("Zoom Range")]
|
|
public Vector2 SpatialAudioZoomRange = new(0, 0.3f);
|
|
}
|
|
|
|
[Serializable]
|
|
public class CameraConfig
|
|
{
|
|
[TitleGroup("Movement")]
|
|
public Vector2 MoveSpeed = new(10, 30);
|
|
|
|
[TitleGroup("Rotation")]
|
|
public Vector2 MouseRotationSpeed = new(70, 70);
|
|
|
|
public Vector2 KeyboardRotationSpeed = new(70, 70);
|
|
|
|
public Vector2 PitchRange = new(30, 70);
|
|
|
|
[TitleGroup("Zoom")]
|
|
public float ZoomSensitivity = 10;
|
|
|
|
public float ZoomSpeed = 40;
|
|
|
|
public Vector2 ZoomRange = new(10, 150);
|
|
}
|
|
|
|
[Serializable]
|
|
public class WorldGenConfig
|
|
{
|
|
public int ChunkSize = 16;
|
|
|
|
public int ChunkGenerationBatchCount = 16;
|
|
|
|
public int ChunksPerThread = 16;
|
|
|
|
public List<AssetReferenceT<Texture2D>> MapTextures = new();
|
|
|
|
public TreesConfig Trees = new();
|
|
|
|
public StoneConfig Stone = new();
|
|
|
|
public GrassConfig Grass = new();
|
|
|
|
public GrassConfig Crops = new();
|
|
|
|
public ProductStacksConfig ProductStacks = new();
|
|
|
|
[Serializable]
|
|
public class TreesConfig
|
|
{
|
|
public AssetReferenceT<ResourceNodeDefinition> TreeDefinition;
|
|
|
|
public float NoiseScale = 0.05f;
|
|
|
|
[Range(0, 1)]
|
|
public float Coverage = 0.3f;
|
|
|
|
public float Spacing = 2.5f;
|
|
|
|
public Vector2 OffsetRange = new(0, 0.25f);
|
|
|
|
[Range(0, 1)]
|
|
public float RandomTreeChance = 0.03f;
|
|
}
|
|
|
|
[Serializable]
|
|
public class StoneConfig
|
|
{
|
|
public AssetReferenceT<ResourceNodeDefinition> StoneDefinition;
|
|
|
|
public Vector2Int Count = new(3, 5);
|
|
|
|
public int Spacing = 10;
|
|
}
|
|
|
|
[Serializable]
|
|
public class GrassConfig
|
|
{
|
|
public float NoiseScale = 0.1f;
|
|
|
|
public float NoiseDiscardThreshold = 0.1f;
|
|
|
|
public float BladeWidth = 0.05f;
|
|
|
|
public float2 BladeHeightRange = new(0.3f, 1);
|
|
}
|
|
|
|
[Serializable]
|
|
public class ProductStacksConfig
|
|
{
|
|
public List<AssetReferenceT<ProductDefinition>> EligibleProducts;
|
|
|
|
[Range(0, 1)]
|
|
public float Chance = 0.05f;
|
|
|
|
public int ProductAmount = 1;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class TimeConfig
|
|
{
|
|
public float WeekDuration = 15;
|
|
|
|
[TitleGroup("Day Night Cycle")]
|
|
public float DayDuration = 120;
|
|
|
|
public float NightDuration = 30;
|
|
|
|
public float DayToNightDuration = 5;
|
|
|
|
public float NightToDayDuration = 5;
|
|
|
|
public DayNightLightingConfig DayLighting;
|
|
|
|
public DayNightLightingConfig NightLighting;
|
|
|
|
[MinMaxSlider(0, 1, true)]
|
|
public Vector2 WarmTintRampUp;
|
|
|
|
[MinMaxSlider(0, 1, true)]
|
|
public Vector2 WarmTintRampDown;
|
|
|
|
[Serializable]
|
|
public class DayNightLightingConfig
|
|
{
|
|
public Color AmbientColor = Color.black;
|
|
|
|
[Range(0, 1)]
|
|
public float ShadowStrength = 1;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class TerrainConfig
|
|
{
|
|
[TitleGroup("Materials")]
|
|
public Material GroundMaterial;
|
|
|
|
public Material CliffMaterial;
|
|
|
|
public Material GrassMaterial;
|
|
|
|
public Material CropsMaterial;
|
|
|
|
[TitleGroup("Grass and Crops")]
|
|
[LabelText("Growth Rate")]
|
|
public float GrassGrowthRate = 0.2f;
|
|
|
|
[LabelText("Grass LODs")]
|
|
public GrassLOD[] GrassLODs;
|
|
|
|
[LabelText("Crops LODs")]
|
|
public GrassLOD[] CropsLODs;
|
|
|
|
public float FertilityRegenarationRate = 0.05f;
|
|
|
|
[TitleGroup("Wind")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public WindConfig Wind;
|
|
|
|
[Serializable]
|
|
public class GrassLOD
|
|
{
|
|
public float Threshold = 1000;
|
|
|
|
public int Density = 16;
|
|
}
|
|
|
|
[Serializable]
|
|
public class WindConfig
|
|
{
|
|
public AssetReferenceT<Texture2D> Map;
|
|
|
|
public Vector3 BendDirection = Vector3.right;
|
|
|
|
public float MapScale = 0.1f;
|
|
|
|
public float Speed = 1;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class BuildingsConfig
|
|
{
|
|
public Material ConstructionSiteMaterial;
|
|
|
|
public int WeeksWithNeedsMetToUpgrade = 2;
|
|
}
|
|
|
|
[Serializable]
|
|
public class RoadsConfig
|
|
{
|
|
public float PlaceTileInterval = 0.2f;
|
|
|
|
public List<AssetReferenceT<GameObject>> Tiles;
|
|
|
|
public AssetReferenceT<GameObject> PlacementVfxPrefab;
|
|
}
|
|
|
|
[Serializable]
|
|
public class AgentsConfig
|
|
{
|
|
public AssetReferenceT<AgentDefinition> GenericAgent;
|
|
|
|
public AssetReferenceT<AgentDefinition> HunterAgent;
|
|
|
|
public AssetReferenceT<AgentDefinition> FarmerAgent;
|
|
|
|
public float MoveSpeed = 5;
|
|
|
|
public float RotationSpeed = 180;
|
|
}
|
|
|
|
[Serializable]
|
|
public class PopulationConfig
|
|
{
|
|
public AssetReferenceT<BuildingDefinition> TentBuilding;
|
|
|
|
[TitleGroup("Grace Period")]
|
|
[LabelText("Number of Weeks")]
|
|
public int GraceWeekCount = 3;
|
|
|
|
[LabelText("Min Happiness during Grace")]
|
|
[Range(0, 1)]
|
|
public float GraceMinHappiness = 0.8f;
|
|
|
|
[TitleGroup("Overall Happiness")]
|
|
[LabelText("Initial Value")]
|
|
[Range(0, 1)]
|
|
public float InitialeOverallHappiness = 0.8f;
|
|
|
|
[LabelText("Change Rate")]
|
|
public float OverallHappinessChangeRate = 0.5f;
|
|
|
|
[TitleGroup("Houses Happiness")]
|
|
[LabelText("Initial Value")]
|
|
[Range(0, 1)]
|
|
public float InitialHouseHappiness = 0.8f;
|
|
|
|
[LabelText("Weight Ramp Up (Weeks)")]
|
|
public int HouseWeightRampUpWeekCount = 3;
|
|
|
|
[TitleGroup("Growth Rate")]
|
|
[LabelText("Peak")]
|
|
public float GrowthRatePeakValue = 1;
|
|
|
|
[LabelText("Curve")]
|
|
public AnimationCurve GrowthRateCurve = AnimationCurve.Linear(0, -1, 1, 1);
|
|
}
|
|
|
|
[Serializable]
|
|
public class EconomyConfig
|
|
{
|
|
public float ProductionTickInterval = 0.1f;
|
|
|
|
public float RestedWorkersEfficiencyModifier = 0.5f;
|
|
|
|
public int RestedWorkersHouseMaxStepCount = 10;
|
|
|
|
public float PopulationToLaborFactor = 1;
|
|
|
|
public int PopulationPerMinLaborTierStep = 8;
|
|
|
|
public List<LaborTierConfig> LaborTiers = new()
|
|
{
|
|
new LaborTierConfig
|
|
{
|
|
Threshold = 0,
|
|
EfficiencyModifier = -0.3f
|
|
},
|
|
new LaborTierConfig
|
|
{
|
|
Threshold = 0.6f,
|
|
EfficiencyModifier = -0.15f
|
|
},
|
|
new LaborTierConfig
|
|
{
|
|
Threshold = 0.85f,
|
|
EfficiencyModifier = -0.05f
|
|
},
|
|
new LaborTierConfig
|
|
{
|
|
Threshold = 1,
|
|
EfficiencyModifier = 0
|
|
}
|
|
};
|
|
}
|
|
|
|
[Serializable]
|
|
public class LaborTierConfig
|
|
{
|
|
[Range(0, 1)]
|
|
public float Threshold;
|
|
|
|
public float EfficiencyModifier;
|
|
}
|
|
|
|
[Serializable]
|
|
public class OnboardingConfig
|
|
{
|
|
public int PopulationMilestone = 20;
|
|
|
|
public float MessageDuration = 30;
|
|
|
|
public OnboardingMessages Messages;
|
|
}
|
|
|
|
[Serializable]
|
|
public class UIConfig
|
|
{
|
|
public AssetReferenceT<GameObject> RootPrefab;
|
|
|
|
public AssetReferenceT<UITemplateLibrary> TemplateLibrary;
|
|
|
|
public DayNightUITheme Theme;
|
|
|
|
public AssetReferenceT<FontAsset> DebugFont;
|
|
|
|
public Material HighlightedGameObjectsMaterial;
|
|
|
|
public Material DeletedGameObjectsMaterial;
|
|
|
|
[TitleGroup("Tile Highlight")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public TileHighlightConfig TileHighlight;
|
|
|
|
[TitleGroup("Build Tool")]
|
|
[InlineProperty]
|
|
[HideLabel]
|
|
public BuildToolConfig BuildTool;
|
|
|
|
[Serializable]
|
|
public class TileHighlightConfig
|
|
{
|
|
public AssetReferenceT<GameObject> Prefab;
|
|
|
|
public Color ValidColor = Color.cyan;
|
|
|
|
public Color InvalidColor = Color.red;
|
|
|
|
public Color DeletePreviewColor = Color.red;
|
|
}
|
|
|
|
[Serializable]
|
|
public class BuildToolConfig
|
|
{
|
|
public float Height = 5;
|
|
|
|
public float LerpFactor = 10;
|
|
|
|
public float ImpulseScale = 1;
|
|
|
|
public float MaxTilt = 5;
|
|
|
|
public float MaxTiltAngle = 30;
|
|
|
|
public float Elasticity = 25;
|
|
|
|
[Range(0, 1)]
|
|
public float Damping = 0.9f;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class VfxConfig
|
|
{
|
|
[LabelText("AoE Material")]
|
|
public Material AoEMaterial;
|
|
}
|
|
}
|
|
}
|