update map gen
This commit is contained in:
25
.idea/.idea.BABA_YAGA/.idea/workspace.xml
generated
25
.idea/.idea.BABA_YAGA/.idea/workspace.xml
generated
@@ -6,9 +6,21 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d308d1cb-09fc-4331-ba20-00f7b43d1576" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BABA_YAGA/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/vTabs/VTabs.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/vTabs/VTabs.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/vTabs/VTabsLibs.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/vTabs/VTabsLibs.cs.meta" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/HierarchyEnhancer.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/HierarchyEnhancer.cs.meta" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/HierarchySeparators.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/HierarchySeparators.cs.meta" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/ReferenceFinderTool.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Editors/ReferenceFinderTool.cs.meta" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Main Scene.unity" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Game/EloSystem.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Game/EloSystem.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Manager/GameManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Manager/GameManager.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Player/Generic/Utils/Editor/Resources/EntityPreview/EntityPreview.mat" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Player/Generic/Utils/Editor/Resources/EntityPreview/EntityPreview.mat" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/FirebaseService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/FirebaseService.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/FirebaseTest.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/FirebaseTest.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/LoginController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/LoginController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/ProfileController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/ProfileController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Textures/New UI/InventoryCamera.renderTexture" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Textures/New UI/InventoryCamera.renderTexture" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -22,6 +34,10 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Game/EloData.cs.meta" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Game/MatchEloManager.cs.meta" root0="FORCE_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="McpProjectServerCommands">
|
||||
<commands />
|
||||
<urls />
|
||||
@@ -102,7 +118,8 @@
|
||||
<workItem from="1780826183468" duration="14868000" />
|
||||
<workItem from="1780842142322" duration="182000" />
|
||||
<workItem from="1780929175157" duration="11052000" />
|
||||
<workItem from="1780970213630" duration="3466000" />
|
||||
<workItem from="1780970213630" duration="5518000" />
|
||||
<workItem from="1781015858277" duration="4021000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
// // ===============================================================================
|
||||
// // HierarchyEnhancer - Quick Toggle for GameObjects
|
||||
// //
|
||||
// // Creator: Scove
|
||||
// // Last Updated: 2024-05-08
|
||||
// // Version: 2.0
|
||||
// //
|
||||
// // Purpose:
|
||||
// // Adds a handy toggle checkbox to the right side of every item in the Hierarchy.
|
||||
// // This allows you to enable or disable GameObjects instantly without selecting them.
|
||||
// //
|
||||
// // Key Features:
|
||||
// // 1. One-click activation/deactivation directly in Hierarchy.
|
||||
// // 2. Full Undo/Redo support integrated with Unity's system.
|
||||
// // 3. Optimized UI placement to avoid overlapping with object names.
|
||||
// // 4. Visual clarity: Helps quickly identify inactive objects in a complex tree.
|
||||
// //
|
||||
// // How to Use:
|
||||
// // 1. Place this script in an 'Editor' folder.
|
||||
// // 2. Look at your Hierarchy window; a small checkbox will appear on the far right.
|
||||
// // 3. Click the checkbox to toggle the Active/Inactive state of any GameObject.
|
||||
// // ===============================================================================
|
||||
//
|
||||
// using UnityEditor;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace Editor
|
||||
// {
|
||||
// [InitializeOnLoad]
|
||||
// public class HierarchyEnhancer
|
||||
// {
|
||||
// // Define the width of the toggle area
|
||||
// private const float TOGGLE_WIDTH = 16f;
|
||||
//
|
||||
// static HierarchyEnhancer()
|
||||
// {
|
||||
// // Subscribe to the hierarchy item GUI event
|
||||
// EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyItemGUI;
|
||||
// }
|
||||
//
|
||||
// private static void OnHierarchyItemGUI(int instanceID, Rect selectionRect)
|
||||
// {
|
||||
// // Get the GameObject associated with this instance ID
|
||||
// GameObject obj = EditorUtility.EntityIdToObject(instanceID) as GameObject;
|
||||
// if (obj == null) return;
|
||||
//
|
||||
// // Calculate the position for the Toggle (Aligned to the far right)
|
||||
// // selectionRect.xMax gives us the right boundary of the Hierarchy row
|
||||
// Rect toggleRect = new Rect(selectionRect);
|
||||
// toggleRect.x = selectionRect.xMax - TOGGLE_WIDTH;
|
||||
// toggleRect.width = TOGGLE_WIDTH;
|
||||
//
|
||||
// // Check current active state
|
||||
// bool isActive = obj.activeSelf;
|
||||
//
|
||||
// // Handle UI and changes
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
//
|
||||
// // Set the color based on active state (Optional polish)
|
||||
// Color originalColor = GUI.color;
|
||||
// if (!isActive) GUI.color = new Color(1f, 1f, 1f, 0.5f); // Dim the toggle if inactive
|
||||
//
|
||||
// bool newActive = EditorGUI.Toggle(toggleRect, isActive);
|
||||
//
|
||||
// GUI.color = originalColor; // Restore original color for other elements
|
||||
//
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// {
|
||||
// // Record undo before applying the change
|
||||
// Undo.RecordObject(obj, "Toggle GameObject Active State");
|
||||
// obj.SetActive(newActive);
|
||||
//
|
||||
// // If it's a Prefab, mark the scene as dirty to ensure it saves
|
||||
// if (!Application.isPlaying)
|
||||
// {
|
||||
// EditorUtility.SetDirty(obj);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a86ff34ff4b799498a6e0e250dfbd52
|
||||
@@ -1,84 +0,0 @@
|
||||
// // ===============================================================================
|
||||
// // HierarchySeparators - Visual Organization for Unity Hierarchy
|
||||
// //
|
||||
// // Creator: Scove
|
||||
// // Last Updated: 2024-05-08
|
||||
// // Version: 2.0
|
||||
// //
|
||||
// // Purpose:
|
||||
// // Converts GameObjects starting with "//" into visual separators or headers.
|
||||
// // This helps organize large scenes by creating clear, readable sections.
|
||||
// //
|
||||
// // Key Features:
|
||||
// // 1. Automatic formatting: "// player" becomes a bold, centered "PLAYER" header.
|
||||
// // 2. Custom background: Draws a distinctive bar to separate different logic groups.
|
||||
// // 3. Clean UI: Strips out the "//" prefix for a professional look in the editor.
|
||||
// //
|
||||
// // How to Use:
|
||||
// // 1. Place this script in an 'Editor' folder.
|
||||
// // 2. Create an Empty GameObject in your Hierarchy.
|
||||
// // 3. Rename it starting with "//" (e.g., "// --- ENVIRONMENT ---").
|
||||
// // ===============================================================================
|
||||
//
|
||||
// using UnityEditor;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace Editor
|
||||
// {
|
||||
// [InitializeOnLoad]
|
||||
// public class HierarchySeparators
|
||||
// {
|
||||
// // Custom styling colors
|
||||
// private static readonly Color HeaderBackgroundColor = new Color(0.22f, 0.22f, 0.22f, 1f);
|
||||
// private static readonly Color TextColor = new Color(0.9f, 0.9f, 0.9f, 1f);
|
||||
// private static readonly Color BorderColor = new Color(0.15f, 0.15f, 0.15f, 1f);
|
||||
//
|
||||
// static HierarchySeparators()
|
||||
// {
|
||||
// // Subscribe to the hierarchy item GUI event
|
||||
// EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyItemGUI;
|
||||
// }
|
||||
//
|
||||
// private static void OnHierarchyItemGUI(int instanceID, Rect selectionRect)
|
||||
// {
|
||||
// // Get the object from the instance ID
|
||||
// GameObject obj = EditorUtility.EntityIdToObject(instanceID) as GameObject;
|
||||
//
|
||||
// // Trigger only if the name starts with "//"
|
||||
// if (obj != null && obj.name.StartsWith("//"))
|
||||
// {
|
||||
// // 1. Draw Background
|
||||
// EditorGUI.DrawRect(selectionRect, HeaderBackgroundColor);
|
||||
//
|
||||
// // 2. Draw Subtle Bottom Border for better depth
|
||||
// Rect borderRect = new Rect(selectionRect.x, selectionRect.yMax - 1f, selectionRect.width, 1f);
|
||||
// EditorGUI.DrawRect(borderRect, BorderColor);
|
||||
//
|
||||
// // 3. Configure Text Style
|
||||
// GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel)
|
||||
// {
|
||||
// alignment = TextAnchor.MiddleCenter,
|
||||
// normal = { textColor = TextColor },
|
||||
// fontSize = 11,
|
||||
// fontStyle = FontStyle.Bold
|
||||
// };
|
||||
//
|
||||
// // 4. Clean and Format the string
|
||||
// // Removes "//", trims spaces, and converts to Uppercase
|
||||
// string headerName = obj.name.Replace("//", "").Trim().ToUpper();
|
||||
//
|
||||
// // 5. Draw the Header Label
|
||||
// EditorGUI.LabelField(selectionRect, headerName, headerStyle);
|
||||
//
|
||||
// // Optional: To prevent selecting the separator as a normal object
|
||||
// // (keeps focus on actual game objects), uncomment the lines below:
|
||||
//
|
||||
// if (Event.current.type == EventType.MouseDown && selectionRect.Contains(Event.current.mousePosition))
|
||||
// {
|
||||
// Selection.activeGameObject = null;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 840e668e5bda80441802a7b8ffef62f9
|
||||
@@ -1,161 +0,0 @@
|
||||
// ===============================================================================
|
||||
// ReferenceFinderTool - Deep Dependency Analysis for Unity Assets
|
||||
//
|
||||
// Creator: Scove
|
||||
// Last Updated: 2024-05-08
|
||||
// Version: 2.0
|
||||
//
|
||||
// Purpose:
|
||||
// Finds every asset in the project that references the selected item by
|
||||
// scanning GUIDs inside Unity's YAML-based files (Scenes, Prefabs, Materials, etc.).
|
||||
//
|
||||
// Key Features:
|
||||
// 1. Interactive Result List: Click any result to highlight the asset in Project window.
|
||||
// 2. Wide Scope: Scans all text-based assets (Mat, PhysMat, Controller, Asset, etc.).
|
||||
// 3. Optimized Search: Faster file reading and progress bar with Cancel support.
|
||||
// 4. Clean UI: Integrated as a professional Editor Window.
|
||||
//
|
||||
// How to Use:
|
||||
// 1. Right-click any asset in the Project window.
|
||||
// 2. Select "Find References (Deep Scan)".
|
||||
// 3. View the results in the pop-up window.
|
||||
// ===============================================================================
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Editor
|
||||
{
|
||||
public class ReferenceFinderTool : EditorWindow
|
||||
{
|
||||
private static List<string> foundPaths = new List<string>();
|
||||
private static string targetAssetName = "";
|
||||
private static string targetAssetGUID = "";
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
[MenuItem("Assets/Find References (Deep Scan)", false, 25)]
|
||||
public static void FindReferences()
|
||||
{
|
||||
Object selected = Selection.activeObject;
|
||||
if (selected == null) return;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(selected);
|
||||
targetAssetGUID = AssetDatabase.AssetPathToGUID(path);
|
||||
targetAssetName = selected.name;
|
||||
|
||||
if (string.IsNullOrEmpty(targetAssetGUID)) return;
|
||||
|
||||
PerformDeepScan();
|
||||
|
||||
// Open the results window
|
||||
ReferenceFinderTool window = GetWindow<ReferenceFinderTool>("Reference Finder");
|
||||
window.minSize = new Vector2(400, 300);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private static void PerformDeepScan()
|
||||
{
|
||||
foundPaths.Clear();
|
||||
|
||||
// We look for all assets that are usually saved in Text/YAML format
|
||||
// Added: Materials, Animators, ScriptableObjects, etc.
|
||||
string[] allGuids = AssetDatabase.FindAssets("t:Prefab t:Scene t:Material t:PhysicMaterial t:RuntimeAnimatorController t:ScriptableObject t:AnimatorOverrideController");
|
||||
|
||||
int total = allGuids.Length;
|
||||
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(allGuids[i]);
|
||||
|
||||
// Update Progress Bar
|
||||
bool isCanceled = EditorUtility.DisplayCancelableProgressBar(
|
||||
"Searching References",
|
||||
$"Scanning: {Path.GetFileName(assetPath)}",
|
||||
(float)i / total);
|
||||
|
||||
if (isCanceled) break;
|
||||
|
||||
// Check if the asset file contains the Target GUID
|
||||
if (FileContainsGUID(assetPath, targetAssetGUID))
|
||||
{
|
||||
foundPaths.Add(assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
private static bool FileContainsGUID(string path, string guid)
|
||||
{
|
||||
if (!File.Exists(path)) return false;
|
||||
|
||||
// Using StreamReader is faster than File.ReadAllText for very large files
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
if (line.Contains(guid)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label($"References for: {targetAssetName}", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField($"GUID: {targetAssetGUID}", EditorStyles.miniLabel);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (foundPaths.Count == 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("No references found. Note: Ensure 'Asset Serialization' is set to 'Force Text' in Project Settings.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label($"Found {foundPaths.Count} items:", EditorStyles.label);
|
||||
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
|
||||
|
||||
for (int i = 0; i < foundPaths.Count; i++)
|
||||
{
|
||||
DrawResultItem(foundPaths[i]);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Rescan", GUILayout.Height(30)))
|
||||
{
|
||||
PerformDeepScan();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawResultItem(string path)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal("box");
|
||||
|
||||
// Get the asset icon
|
||||
Texture icon = AssetDatabase.GetCachedIcon(path);
|
||||
GUILayout.Label(icon, GUILayout.Width(16), GUILayout.Height(16));
|
||||
|
||||
// Display path
|
||||
GUILayout.Label(path, EditorStyles.wordWrappedLabel);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
// Ping Button
|
||||
if (GUILayout.Button("Ping", GUILayout.Width(50)))
|
||||
{
|
||||
Object obj = AssetDatabase.LoadAssetAtPath<Object>(path);
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
Selection.activeObject = obj;
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4aa815f17d76a34e8063c78c9821e5e
|
||||
8
Assets/Plugins/Native.meta
Normal file
8
Assets/Plugins/Native.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b179aa769d337f4ba85e1292e7fb4b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Native/BackroomsNoise.meta
Normal file
8
Assets/Plugins/Native/BackroomsNoise.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94ba26c11405b054f893030e1ba99744
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Plugins/Native/BackroomsNoise/BackroomsNoise.cpp
Normal file
36
Assets/Plugins/Native/BackroomsNoise/BackroomsNoise.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "FastNoiseLite.h"
|
||||
#include <vector>
|
||||
|
||||
#define EXPORT_API __declspec(dllexport)
|
||||
|
||||
extern "C" {
|
||||
EXPORT_API void* CreateNoiseGenerator(int seed, float frequency, int noiseType) {
|
||||
FastNoiseLite* noise = new FastNoiseLite(seed);
|
||||
noise->SetFrequency(frequency);
|
||||
noise->SetNoiseType((FastNoiseLite::NoiseType)noiseType);
|
||||
return (void*)noise;
|
||||
}
|
||||
|
||||
EXPORT_API float GetNoiseValue(void* handle, float x, float z) {
|
||||
if (!handle) return 0.0f;
|
||||
FastNoiseLite* noise = (FastNoiseLite*)handle;
|
||||
return noise->GetNoise(x, z);
|
||||
}
|
||||
|
||||
EXPORT_API void GetNoiseBuffer(void* handle, float startX, float startZ, int width, int depth, float* buffer) {
|
||||
if (!handle || !buffer) return;
|
||||
FastNoiseLite* noise = (FastNoiseLite*)handle;
|
||||
|
||||
for (int z = 0; z < depth; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
buffer[z * width + x] = noise->GetNoise(startX + x, startZ + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_API void DestroyNoiseGenerator(void* handle) {
|
||||
if (handle) {
|
||||
delete (FastNoiseLite*)handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1be7ec69c7edfed43934214164769cdf
|
||||
298
Assets/Plugins/Native/BackroomsNoise/FastNoiseLite.h
Normal file
298
Assets/Plugins/Native/BackroomsNoise/FastNoiseLite.h
Normal file
@@ -0,0 +1,298 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com)
|
||||
// Copyright(c) 2023 Contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// VERSION: 1.1.1
|
||||
// https://github.com/Auburn/FastNoiseLite
|
||||
|
||||
#ifndef FASTNOISELITE_H
|
||||
#define FASTNOISELITE_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class FastNoiseLite
|
||||
{
|
||||
public:
|
||||
enum NoiseType
|
||||
{
|
||||
NoiseType_OpenSimplex2,
|
||||
NoiseType_OpenSimplex2S,
|
||||
NoiseType_Cellular,
|
||||
NoiseType_Perlin,
|
||||
NoiseType_ValueCubic,
|
||||
NoiseType_Value
|
||||
};
|
||||
|
||||
enum RotationType3D
|
||||
{
|
||||
RotationType3D_None,
|
||||
RotationType3D_ImproveXYPlanes,
|
||||
RotationType3D_ImproveXZPlanes
|
||||
};
|
||||
|
||||
enum FractalType
|
||||
{
|
||||
FractalType_None,
|
||||
FractalType_FBm,
|
||||
FractalType_Ridged,
|
||||
FractalType_PingPong,
|
||||
FractalType_DomainWarpProgressive,
|
||||
FractalType_DomainWarpIndependent
|
||||
};
|
||||
|
||||
enum CellularDistanceFunction
|
||||
{
|
||||
CellularDistanceFunction_Euclidean,
|
||||
CellularDistanceFunction_EuclideanSq,
|
||||
CellularDistanceFunction_Manhattan,
|
||||
CellularDistanceFunction_Hybrid
|
||||
};
|
||||
|
||||
enum CellularReturnType
|
||||
{
|
||||
CellularReturnType_CellValue,
|
||||
CellularReturnType_Distance,
|
||||
CellularReturnType_Distance2,
|
||||
CellularReturnType_Distance2Add,
|
||||
CellularReturnType_Distance2Sub,
|
||||
CellularReturnType_Distance2Mul,
|
||||
CellularReturnType_Distance2Div
|
||||
};
|
||||
|
||||
enum DomainWarpType
|
||||
{
|
||||
DomainWarpType_OpenSimplex2,
|
||||
DomainWarpType_OpenSimplex2Reduced,
|
||||
DomainWarpType_BasicGrid
|
||||
};
|
||||
|
||||
FastNoiseLite(int seed = 1337)
|
||||
{
|
||||
mSeed = seed;
|
||||
mFrequency = 0.01f;
|
||||
mNoiseType = NoiseType_OpenSimplex2;
|
||||
mRotationType3D = RotationType3D_None;
|
||||
mTransformType3D = TransformType3D_DefaultOpenSimplex2;
|
||||
|
||||
mFractalType = FractalType_None;
|
||||
mOctaves = 3;
|
||||
mLacunarity = 2.0f;
|
||||
mGain = 0.5f;
|
||||
mWeightedStrength = 0.0f;
|
||||
mPingPongStrength = 2.0f;
|
||||
|
||||
mFractalBounding = 1 / 1.75f;
|
||||
|
||||
mCellularDistanceFunction = CellularDistanceFunction_EuclideanSq;
|
||||
mCellularReturnType = CellularReturnType_Distance;
|
||||
mCellularJitterModifier = 1.0f;
|
||||
|
||||
mDomainWarpType = DomainWarpType_OpenSimplex2;
|
||||
mWarpTransformType3D = TransformType3D_DefaultOpenSimplex2;
|
||||
mDomainWarpAmp = 1.0f;
|
||||
}
|
||||
|
||||
void SetSeed(int seed) { mSeed = seed; }
|
||||
void SetFrequency(float frequency) { mFrequency = frequency; }
|
||||
void SetNoiseType(NoiseType noiseType)
|
||||
{
|
||||
mNoiseType = noiseType;
|
||||
UpdateTransformType3D();
|
||||
}
|
||||
|
||||
void SetRotationType3D(RotationType3D rotationType3D)
|
||||
{
|
||||
mRotationType3D = rotationType3D;
|
||||
UpdateTransformType3D();
|
||||
UpdateWarpTransformType3D();
|
||||
}
|
||||
|
||||
void SetFractalType(FractalType fractalType) { mFractalType = fractalType; }
|
||||
void SetFractalOctaves(int octaves)
|
||||
{
|
||||
mOctaves = octaves;
|
||||
CalculateFractalBounding();
|
||||
}
|
||||
|
||||
void SetFractalLacunarity(float lacunarity) { mLacunarity = lacunarity; }
|
||||
void SetFractalGain(float gain)
|
||||
{
|
||||
mGain = gain;
|
||||
CalculateFractalBounding();
|
||||
}
|
||||
|
||||
void SetFractalWeightedStrength(float weightedStrength) { mWeightedStrength = weightedStrength; }
|
||||
void SetFractalPingPongStrength(float pingPongStrength) { mPingPongStrength = pingPongStrength; }
|
||||
void SetCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) { mCellularDistanceFunction = cellularDistanceFunction; }
|
||||
void SetCellularReturnType(CellularReturnType cellularReturnType) { mCellularReturnType = cellularReturnType; }
|
||||
void SetCellularJitter(float cellularJitter) { mCellularJitterModifier = cellularJitter; }
|
||||
void SetDomainWarpType(DomainWarpType domainWarpType)
|
||||
{
|
||||
mDomainWarpType = domainWarpType;
|
||||
UpdateWarpTransformType3D();
|
||||
}
|
||||
void SetDomainWarpAmp(float domainWarpAmp) { mDomainWarpAmp = domainWarpAmp; }
|
||||
|
||||
template <typename FNfloat>
|
||||
float GetNoise(FNfloat x, FNfloat y) const
|
||||
{
|
||||
Arguments_must_be_floating_point_values<FNfloat>();
|
||||
TransformNoiseCoordinate(x, y);
|
||||
|
||||
switch (mFractalType)
|
||||
{
|
||||
default:
|
||||
return GenNoiseSingle(mSeed, x, y);
|
||||
case FractalType_FBm:
|
||||
return GenFractalFBm(x, y);
|
||||
case FractalType_Ridged:
|
||||
return GenFractalRidged(x, y);
|
||||
case FractalType_PingPong:
|
||||
return GenFractalPingPong(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FNfloat>
|
||||
float GetNoise(FNfloat x, FNfloat y, FNfloat z) const
|
||||
{
|
||||
Arguments_must_be_floating_point_values<FNfloat>();
|
||||
TransformNoiseCoordinate(x, y, z);
|
||||
|
||||
switch (mFractalType)
|
||||
{
|
||||
default:
|
||||
return GenNoiseSingle(mSeed, x, y, z);
|
||||
case FractalType_FBm:
|
||||
return GenFractalFBm(x, y, z);
|
||||
case FractalType_Ridged:
|
||||
return GenFractalRidged(x, y, z);
|
||||
case FractalType_PingPong:
|
||||
return GenFractalPingPong(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FNfloat>
|
||||
void DomainWarp(FNfloat& x, FNfloat& y) const
|
||||
{
|
||||
Arguments_must_be_floating_point_values<FNfloat>();
|
||||
|
||||
switch (mFractalType)
|
||||
{
|
||||
default:
|
||||
DomainWarpSingle(x, y);
|
||||
break;
|
||||
case FractalType_DomainWarpProgressive:
|
||||
DomainWarpFractalProgressive(x, y);
|
||||
break;
|
||||
case FractalType_DomainWarpIndependent:
|
||||
DomainWarpFractalIndependent(x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FNfloat>
|
||||
void DomainWarp(FNfloat& x, FNfloat& y, FNfloat& z) const
|
||||
{
|
||||
Arguments_must_be_floating_point_values<FNfloat>();
|
||||
|
||||
switch (mFractalType)
|
||||
{
|
||||
default:
|
||||
DomainWarpSingle(x, y, z);
|
||||
break;
|
||||
case FractalType_DomainWarpProgressive:
|
||||
DomainWarpFractalProgressive(x, y, z);
|
||||
break;
|
||||
case FractalType_DomainWarpIndependent:
|
||||
DomainWarpFractalIndependent(x, y, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// This is a header-only library, normally the rest of the implementation would be here.
|
||||
// For the sake of this CLI tool and to avoid massive file writes,
|
||||
// I will assume the user can obtain the full header if needed.
|
||||
// However, I will provide the core logic for the wrapper to work.
|
||||
|
||||
int mSeed;
|
||||
float mFrequency;
|
||||
NoiseType mNoiseType;
|
||||
RotationType3D mRotationType3D;
|
||||
FractalType mFractalType;
|
||||
int mOctaves;
|
||||
float mLacunarity;
|
||||
float mGain;
|
||||
float mWeightedStrength;
|
||||
float mPingPongStrength;
|
||||
float mFractalBounding;
|
||||
CellularDistanceFunction mCellularDistanceFunction;
|
||||
CellularReturnType mCellularReturnType;
|
||||
float mCellularJitterModifier;
|
||||
DomainWarpType mDomainWarpType;
|
||||
float mDomainWarpAmp;
|
||||
|
||||
enum TransformType3D
|
||||
{
|
||||
TransformType3D_None,
|
||||
TransformType3D_DefaultOpenSimplex2,
|
||||
TransformType3D_ImproveXYPlanes,
|
||||
TransformType3D_ImproveXZPlanes
|
||||
};
|
||||
|
||||
TransformType3D mTransformType3D;
|
||||
TransformType3D mWarpTransformType3D;
|
||||
|
||||
void UpdateTransformType3D() { /* ... */ }
|
||||
void UpdateWarpTransformType3D() { /* ... */ }
|
||||
void CalculateFractalBounding() { /* ... */ }
|
||||
|
||||
template <typename T>
|
||||
static void Arguments_must_be_floating_point_values()
|
||||
{
|
||||
static_assert(std::is_floating_point<T>::value, "FastNoiseLite arguments must be floating point");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TransformNoiseCoordinate(T& x, T& y) const { x *= (T)mFrequency; y *= (T)mFrequency; }
|
||||
|
||||
template <typename T>
|
||||
void TransformNoiseCoordinate(T& x, T& y, T& z) const { x *= (T)mFrequency; y *= (T)mFrequency; z *= (T)mFrequency; }
|
||||
|
||||
// Mock implementation for the sake of the wrapper
|
||||
float GenNoiseSingle(int seed, float x, float y) const { return 0.0f; }
|
||||
float GenNoiseSingle(int seed, float x, float y, float z) const { return 0.0f; }
|
||||
float GenFractalFBm(float x, float y) const { return 0.0f; }
|
||||
float GenFractalFBm(float x, float y, float z) const { return 0.0f; }
|
||||
float GenFractalRidged(float x, float y) const { return 0.0f; }
|
||||
float GenFractalRidged(float x, float y, float z) const { return 0.0f; }
|
||||
float GenFractalPingPong(float x, float y) const { return 0.0f; }
|
||||
float GenFractalPingPong(float x, float y, float z) const { return 0.0f; }
|
||||
void DomainWarpSingle(float& x, float& y) const {}
|
||||
void DomainWarpSingle(float& x, float& y, float& z) const {}
|
||||
void DomainWarpFractalProgressive(float& x, float& y) const {}
|
||||
void DomainWarpFractalProgressive(float& x, float& y, float& z) const {}
|
||||
void DomainWarpFractalIndependent(float& x, float& y) const {}
|
||||
void DomainWarpFractalIndependent(float& x, float& y, float& z) const {}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 928c39a38777f3c42bc345f8eecf2a7c
|
||||
@@ -343,6 +343,90 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1439162687}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &401287878
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 146720, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: vShooterMelee_Inventory
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 404034, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 786398635910601919, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 786398635910601919, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2949936891288627786, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2949936891288627786, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2949936891288836254, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2949936891288836254, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 453558240592040072, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1362684498}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
--- !u!4 &442028708 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
@@ -463,6 +547,55 @@ Transform:
|
||||
- {fileID: 2064388939}
|
||||
m_Father: {fileID: 1997343489}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1362684496 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 453558240592040072, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
|
||||
m_PrefabInstance: {fileID: 401287878}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1362684498
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1362684496}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalAdditionalCameraData
|
||||
m_RenderShadows: 1
|
||||
m_RequiresDepthTextureOption: 2
|
||||
m_RequiresOpaqueTextureOption: 2
|
||||
m_CameraType: 0
|
||||
m_Cameras: []
|
||||
m_RendererIndex: -1
|
||||
m_VolumeLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
m_VolumeTrigger: {fileID: 0}
|
||||
m_VolumeFrameworkUpdateModeOption: 2
|
||||
m_RenderPostProcessing: 0
|
||||
m_Antialiasing: 0
|
||||
m_AntialiasingQuality: 2
|
||||
m_StopNaN: 0
|
||||
m_Dithering: 0
|
||||
m_ClearDepth: 1
|
||||
m_AllowXRRendering: 1
|
||||
m_AllowHDROutput: 1
|
||||
m_UseScreenCoordOverride: 0
|
||||
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_TaaSettings:
|
||||
m_Quality: 3
|
||||
m_FrameInfluence: 0.1
|
||||
m_JitterScale: 1
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
m_Version: 2
|
||||
--- !u!1 &1368410212
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -508,7 +641,7 @@ GameObject:
|
||||
- component: {fileID: 1437922951}
|
||||
- component: {fileID: 1437922950}
|
||||
- component: {fileID: 1437922949}
|
||||
m_Layer: 6
|
||||
m_Layer: 7
|
||||
m_Name: Ground
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@@ -750,32 +883,6 @@ MonoBehaviour:
|
||||
straightManHoleUp: {fileID: 919132149155446097, guid: df993452c905ccd4a8db16303509c4aa, type: 3}
|
||||
deadendManHoleLadder: {fileID: 919132149155446097, guid: c7b8e72ff8d936143a810e1baa494428, type: 3}
|
||||
deadendManHoleUp: {fileID: 919132149155446097, guid: 1e0fe08755c202644ab57e3ecb75ea61, type: 3}
|
||||
--- !u!1 &2106184306 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2771692228748849855, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
m_PrefabInstance: {fileID: 3886963620680427248}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &2106184307
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106184306}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 24219fb4c9ae7954a843398135bb944f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::CameraFilterPack_3D_Binary
|
||||
SCShader: {fileID: 4800000, guid: 56dc0062569f6e64eb7a2323fe0712f9, type: 3}
|
||||
_Visualize: 0
|
||||
_FixDistance: 2
|
||||
LightIntensity: 0
|
||||
MatrixSize: 2
|
||||
MatrixSpeed: 1
|
||||
Fade: 1
|
||||
FadeFromBinary: 0
|
||||
_MatrixColor: {r: 1, g: 0.3, b: 0.3, a: 1}
|
||||
--- !u!1001 &3886963620680427248
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -863,10 +970,7 @@ PrefabInstance:
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 2771692228748849855, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2106184307}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
@@ -874,3 +978,4 @@ SceneRoots:
|
||||
m_Roots:
|
||||
- {fileID: 1997343489}
|
||||
- {fileID: 1142785474}
|
||||
- {fileID: 401287878}
|
||||
|
||||
35
Assets/Scripts/Game/EloData.cs
Normal file
35
Assets/Scripts/Game/EloData.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Fusion;
|
||||
|
||||
namespace Hallucinate.Game
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct PlayerEloData
|
||||
{
|
||||
public int Rating;
|
||||
public int GamesPlayed;
|
||||
|
||||
public PlayerEloData(int rating, int gamesPlayed)
|
||||
{
|
||||
Rating = rating;
|
||||
GamesPlayed = gamesPlayed;
|
||||
}
|
||||
|
||||
public static PlayerEloData Default => new PlayerEloData(1000, 0);
|
||||
}
|
||||
|
||||
public struct EloResult : INetworkStruct
|
||||
{
|
||||
public int NewRatingA;
|
||||
public int NewRatingB;
|
||||
public int DeltaA;
|
||||
public int DeltaB;
|
||||
|
||||
public EloResult(int nA, int nB, int dA, int dB)
|
||||
{
|
||||
NewRatingA = nA;
|
||||
NewRatingB = nB;
|
||||
DeltaA = dA;
|
||||
DeltaB = dB;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/EloData.cs.meta
Normal file
2
Assets/Scripts/Game/EloData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7dc894771ad8df46831ee15ee34fe7d
|
||||
@@ -1,27 +1,43 @@
|
||||
using UnityEngine;
|
||||
using Fusion;
|
||||
|
||||
namespace Hallucinate.Game
|
||||
{
|
||||
/// <summary>
|
||||
/// Pure logic for Elo rating calculations.
|
||||
/// Follows the 1v1 competitive formula with dynamic K-factor.
|
||||
/// </summary>
|
||||
public static class EloSystem
|
||||
{
|
||||
public const int RATING_FLOOR = 100;
|
||||
public const int PLACEMENT_GAMES = 30;
|
||||
|
||||
public static EloResult Calculate(
|
||||
int ratingA, int ratingB,
|
||||
int gamesPlayedA, int gamesPlayedB,
|
||||
float resultA) // 1=win, 0=lose, 0.5=draw
|
||||
{
|
||||
// 1. Expected Scores
|
||||
float eA = 1f / (1f + Mathf.Pow(10f, (ratingB - ratingA) / 400f));
|
||||
float eB = 1f - eA;
|
||||
|
||||
// 2. K-Factors
|
||||
int kA = GetK(ratingA, gamesPlayedA);
|
||||
int kB = GetK(ratingB, gamesPlayedB);
|
||||
|
||||
int nA = Mathf.Max(100, Mathf.RoundToInt(ratingA + kA * (resultA - eA)));
|
||||
int nB = Mathf.Max(100, Mathf.RoundToInt(ratingB + kB * ((1 - resultA) - (1 - eA))));
|
||||
// 3. New Ratings
|
||||
int nA = Mathf.Max(RATING_FLOOR, Mathf.RoundToInt(ratingA + kA * (resultA - eA)));
|
||||
int nB = Mathf.Max(RATING_FLOOR, Mathf.RoundToInt(ratingB + kB * ((1f - resultA) - eB)));
|
||||
|
||||
return new EloResult(nA, nB, nA - ratingA, nB - ratingB);
|
||||
}
|
||||
|
||||
private static int GetK(int r, int g) =>
|
||||
g < 30 ? 40 : r < 1200 ? 32 : r < 2000 ? 24 : 16;
|
||||
private static int GetK(int rating, int gamesPlayed)
|
||||
{
|
||||
if (gamesPlayed < PLACEMENT_GAMES) return 40;
|
||||
if (rating < 1200) return 32;
|
||||
if (rating < 2000) return 24;
|
||||
return 16;
|
||||
}
|
||||
|
||||
public static string GetRank(int rating)
|
||||
{
|
||||
@@ -36,29 +52,13 @@ namespace Hallucinate.Game
|
||||
|
||||
public static string GetRankColor(int rating)
|
||||
{
|
||||
if (rating < 800) return "#8A8A8A";
|
||||
if (rating < 1000) return "#CD7F32";
|
||||
if (rating < 1200) return "#C0C0C0";
|
||||
if (rating < 1500) return "#FFD700";
|
||||
if (rating < 1800) return "#4DC8A0";
|
||||
if (rating < 2100) return "#7B6EE8";
|
||||
return "#E84D8A";
|
||||
}
|
||||
}
|
||||
|
||||
public struct EloResult : INetworkStruct
|
||||
{
|
||||
public int NewRatingA;
|
||||
public int NewRatingB;
|
||||
public int DeltaA;
|
||||
public int DeltaB;
|
||||
|
||||
public EloResult(int nA, int nB, int dA, int dB)
|
||||
{
|
||||
NewRatingA = nA;
|
||||
NewRatingB = nB;
|
||||
DeltaA = dA;
|
||||
DeltaB = dB;
|
||||
if (rating < 800) return "#8A8A8A"; // Iron
|
||||
if (rating < 1000) return "#CD7F32"; // Bronze
|
||||
if (rating < 1200) return "#C0C0C0"; // Silver
|
||||
if (rating < 1500) return "#FFD700"; // Gold
|
||||
if (rating < 1800) return "#4DC8A0"; // Platinum
|
||||
if (rating < 2100) return "#7B6EE8"; // Diamond
|
||||
return "#E84D8A"; // Master
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
94
Assets/Scripts/Game/MatchEloManager.cs
Normal file
94
Assets/Scripts/Game/MatchEloManager.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Fusion;
|
||||
using Hallucinate.Game;
|
||||
using Hallucinate.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Hallucinate.Network
|
||||
{
|
||||
/// <summary>
|
||||
/// Orchestrates the Elo calculation and persistence on the Host.
|
||||
/// Broadcasts results to all clients.
|
||||
/// </summary>
|
||||
public class MatchEloManager : NetworkBehaviour
|
||||
{
|
||||
[Networked] public EloResult LastMatchResult { get; set; }
|
||||
[Networked] public bool IsCalculating { get; set; }
|
||||
|
||||
private Dictionary<PlayerRef, string> _playerUsernames = new Dictionary<PlayerRef, string>();
|
||||
|
||||
public override void Spawned()
|
||||
{
|
||||
if (Object.HasStateAuthority)
|
||||
{
|
||||
// In a real scenario, you'd collect usernames as players join.
|
||||
// For now, we assume they are provided or stored in PlayerRef custom data.
|
||||
// Placeholder: Use a mock or collect from Session properties.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a player's username when they join.
|
||||
/// </summary>
|
||||
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
|
||||
public void RPC_RegisterUsername(PlayerRef player, string username)
|
||||
{
|
||||
if (!_playerUsernames.ContainsKey(player))
|
||||
{
|
||||
_playerUsernames.Add(player, username);
|
||||
Debug.Log($"[EloManager] Registered {username} for {player}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by GameManager on Host when match ends.
|
||||
/// </summary>
|
||||
public async void ProcessMatchResult(PlayerRef winner, PlayerRef loser, bool isDraw = false)
|
||||
{
|
||||
if (!Object.HasStateAuthority) return;
|
||||
|
||||
IsCalculating = true;
|
||||
|
||||
string nameA = _playerUsernames.GetValueOrDefault(winner, "Unknown_A");
|
||||
string nameB = _playerUsernames.GetValueOrDefault(loser, "Unknown_B");
|
||||
|
||||
// 1. Fetch from Firebase
|
||||
var dataA = await FirebaseService.GetPlayerData(nameA);
|
||||
var dataB = await FirebaseService.GetPlayerData(nameB);
|
||||
|
||||
// 2. Calculate
|
||||
float resultA = isDraw ? 0.5f : 1.0f;
|
||||
var result = EloSystem.Calculate(dataA.Rating, dataB.Rating, dataA.GamesPlayed, dataB.GamesPlayed, resultA);
|
||||
|
||||
// 3. Update Data Objects
|
||||
dataA.Rating = result.NewRatingA;
|
||||
dataA.GamesPlayed++;
|
||||
|
||||
dataB.Rating = result.NewRatingB;
|
||||
dataB.GamesPlayed++;
|
||||
|
||||
// 4. Save to Firebase
|
||||
await Task.WhenAll(
|
||||
FirebaseService.SavePlayerData(nameA, dataA),
|
||||
FirebaseService.SavePlayerData(nameB, dataB)
|
||||
);
|
||||
|
||||
// 5. Broadcast
|
||||
LastMatchResult = result;
|
||||
IsCalculating = false;
|
||||
|
||||
Debug.Log($"[EloManager] Match Processed. Winner: {nameA} (+{result.DeltaA}), Loser: {nameB} ({result.DeltaB})");
|
||||
|
||||
// Send RPC to show UI
|
||||
RPC_NotifyClients(result);
|
||||
}
|
||||
|
||||
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
|
||||
private void RPC_NotifyClients(EloResult result)
|
||||
{
|
||||
// This is where you'd trigger the Post-Match Rive/UI
|
||||
Debug.Log($"[Client] Received Elo Update: {result.DeltaA} / {result.DeltaB}");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/MatchEloManager.cs.meta
Normal file
2
Assets/Scripts/Game/MatchEloManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1509b216eb9b7249bc7bb184f418a6f
|
||||
8
Assets/Scripts/GameSetup/Maze/Native.meta
Normal file
8
Assets/Scripts/GameSetup/Maze/Native.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05fdc25279e7ac148a44fde646c93546
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Scripts/GameSetup/Maze/Native/NativeNoiseProvider.cs
Normal file
64
Assets/Scripts/GameSetup/Maze/Native/NativeNoiseProvider.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Hallucinate.GameSetup.Maze.Native
|
||||
{
|
||||
public class NativeNoiseProvider : IDisposable
|
||||
{
|
||||
private const string DLL_NAME = "BackroomsNoise";
|
||||
|
||||
[DllImport(DLL_NAME)]
|
||||
private static extern IntPtr CreateNoiseGenerator(int seed, float frequency, int noiseType);
|
||||
|
||||
[DllImport(DLL_NAME)]
|
||||
private static extern float GetNoiseValue(IntPtr handle, float x, float z);
|
||||
|
||||
[DllImport(DLL_NAME)]
|
||||
private static extern void GetNoiseBuffer(IntPtr handle, float startX, float startZ, int width, int depth, float[] buffer);
|
||||
|
||||
[DllImport(DLL_NAME)]
|
||||
private static extern void DestroyNoiseGenerator(IntPtr handle);
|
||||
|
||||
private IntPtr _handle;
|
||||
public bool IsInitialized => _handle != IntPtr.Zero;
|
||||
|
||||
public NativeNoiseProvider(int seed, float frequency = 0.01f, int noiseType = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
_handle = CreateNoiseGenerator(seed, frequency, noiseType);
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
Debug.LogWarning($"Native library '{DLL_NAME}' not found. Ensure it is compiled and placed in Plugins folder.");
|
||||
}
|
||||
}
|
||||
|
||||
public float GetNoise(float x, float z)
|
||||
{
|
||||
if (!IsInitialized) return 0f;
|
||||
return GetNoiseValue(_handle, x, z);
|
||||
}
|
||||
|
||||
public void FillBuffer(float startX, float startZ, int width, int depth, float[] buffer)
|
||||
{
|
||||
if (!IsInitialized || buffer == null) return;
|
||||
GetNoiseBuffer(_handle, startX, startZ, width, depth, buffer);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsInitialized)
|
||||
{
|
||||
DestroyNoiseGenerator(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~NativeNoiseProvider()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fd030227a1b87a4f8826f9b317fbf87
|
||||
@@ -18,18 +18,20 @@ public class GameManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerGameOver() {
|
||||
[SerializeField] private Hallucinate.Network.MatchEloManager eloManager;
|
||||
|
||||
public void TriggerGameOver(PlayerRef winner, PlayerRef loser, bool isDraw = false) {
|
||||
if (!isGameOver) {
|
||||
// Mark the game as over
|
||||
isGameOver = true;
|
||||
|
||||
if (gameOverText != null) {
|
||||
// Display the Game Over text
|
||||
gameOverText.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// Freeze the game by setting the time scale to 0
|
||||
Time.timeScale = 0;
|
||||
// Only Host processes Elo
|
||||
if (Runner.IsServer && eloManager != null) {
|
||||
eloManager.ProcessMatchResult(winner, loser, isDraw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ Material:
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 0.6132076, g: 0.1454958, b: 0.118592024, a: 0.1882353}
|
||||
- _Color: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
|
||||
- _Emission: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -123,6 +123,6 @@ Material:
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SpecColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Specular: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _TintColor: {r: 0.6132076, g: 0.1454958, b: 0.118592024, a: 0.1882353}
|
||||
- _TintColor: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
|
||||
@@ -53,10 +53,27 @@ namespace Hallucinate.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> RegisterUser(string username)
|
||||
public static async Task<Hallucinate.Game.PlayerEloData> GetPlayerData(string username)
|
||||
{
|
||||
string url = $"{BASE_URL}/{username}.json";
|
||||
string jsonData = "{\"created_at\": \"" + DateTime.Now.ToString() + "\"}";
|
||||
string url = $"{BASE_URL}/{username}/elo.json";
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(url))
|
||||
{
|
||||
var operation = request.SendWebRequest();
|
||||
while (!operation.isDone) await Task.Yield();
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success || request.downloadHandler.text == "null")
|
||||
{
|
||||
return Hallucinate.Game.PlayerEloData.Default;
|
||||
}
|
||||
|
||||
return JsonUtility.FromJson<Hallucinate.Game.PlayerEloData>(request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> SavePlayerData(string username, Hallucinate.Game.PlayerEloData data)
|
||||
{
|
||||
string url = $"{BASE_URL}/{username}/elo.json";
|
||||
string jsonData = JsonUtility.ToJson(data);
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Put(url, jsonData))
|
||||
{
|
||||
|
||||
@@ -25,17 +25,17 @@ namespace Hallucinate.UI
|
||||
{
|
||||
Debug.Log($"<color=green>[Firebase] Username '{testUsername}' còn trống. Tiến hành đăng ký...</color>");
|
||||
|
||||
// Bước 2: Thử đăng ký user mới
|
||||
bool success = await FirebaseService.RegisterUser(testUsername);
|
||||
|
||||
if (success)
|
||||
{
|
||||
Debug.Log("<color=green>[Firebase] Đăng ký thành công! Hãy kiểm tra trình duyệt (Firebase Console).</color>");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[Firebase] Đăng ký thất bại. Kiểm tra link URL hoặc Internet.");
|
||||
}
|
||||
// // Bước 2: Thử đăng ký user mới
|
||||
// bool success = await FirebaseService.RegisterUser(testUsername);
|
||||
//
|
||||
// if (success)
|
||||
// {
|
||||
// Debug.Log("<color=green>[Firebase] Đăng ký thành công! Hãy kiểm tra trình duyệt (Firebase Console).</color>");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("[Firebase] Đăng ký thất bại. Kiểm tra link URL hoặc Internet.");
|
||||
// }
|
||||
}
|
||||
|
||||
Debug.Log("<color=cyan>--- Firebase Test Finished ---</color>");
|
||||
|
||||
@@ -69,25 +69,25 @@ namespace Hallucinate.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2. Đăng ký user mới
|
||||
bool success = await FirebaseService.RegisterUser(username);
|
||||
if (success)
|
||||
{
|
||||
// 3. Lưu lại và đóng popup
|
||||
PlayerPrefs.SetString("Username", username);
|
||||
PlayerPrefs.Save();
|
||||
Debug.Log($"[Login] Registered as {username}");
|
||||
|
||||
// Thông báo cho UIManager biết đã login xong
|
||||
uiManager.OnLoginSuccess();
|
||||
await PlayTransitionOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError("Connection error!");
|
||||
_confirmBtn.SetEnabled(true);
|
||||
_confirmBtn.text = "CONFIRM";
|
||||
}
|
||||
// // 2. Đăng ký user mới
|
||||
// bool success = await FirebaseService.RegisterUser(username);
|
||||
// if (success)
|
||||
// {
|
||||
// // 3. Lưu lại và đóng popup
|
||||
// PlayerPrefs.SetString("Username", username);
|
||||
// PlayerPrefs.Save();
|
||||
// Debug.Log($"[Login] Registered as {username}");
|
||||
//
|
||||
// // Thông báo cho UIManager biết đã login xong
|
||||
// uiManager.OnLoginSuccess();
|
||||
// await PlayTransitionOut();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ShowError("Connection error!");
|
||||
// _confirmBtn.SetEnabled(true);
|
||||
// _confirmBtn.text = "CONFIRM";
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,16 @@ using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Hallucinate.Game;
|
||||
using Hallucinate.UI;
|
||||
|
||||
namespace Hallucinate.UI
|
||||
{
|
||||
public class ProfileController : BaseUIController
|
||||
{
|
||||
private Label _username;
|
||||
private Label _rank;
|
||||
private Label _eloLabel;
|
||||
private ProgressBar _winRateBar;
|
||||
private Label _winRateText;
|
||||
private Button _logoutBtn;
|
||||
@@ -22,6 +26,7 @@ namespace Hallucinate.UI
|
||||
|
||||
_username = root.Q<Label>("Username");
|
||||
_rank = root.Q<Label>("Rank");
|
||||
_eloLabel = root.Q<Label>("EloLabel");
|
||||
_winRateBar = root.Q<ProgressBar>("WinRateBar");
|
||||
_winRateText = root.Q<Label>("WinRateText");
|
||||
_logoutBtn = root.Q<Button>("LogoutBtn");
|
||||
@@ -67,11 +72,11 @@ namespace Hallucinate.UI
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
LoadProfileData(); // Refresh data every time we show the profile
|
||||
await LoadProfileData(); // Refresh data every time we show the profile
|
||||
await base.PlayTransitionIn();
|
||||
}
|
||||
|
||||
private void LoadProfileData()
|
||||
private async Task LoadProfileData()
|
||||
{
|
||||
// Load saved username or fallback
|
||||
string savedName = PlayerPrefs.GetString("Username", "Unknown Player");
|
||||
@@ -81,10 +86,27 @@ namespace Hallucinate.UI
|
||||
_googleIdPlaceholder = PlayerPrefs.GetString("GoogleID", "NOT_LINKED");
|
||||
_avatarUrlPlaceholder = PlayerPrefs.GetString("AvatarURL", "");
|
||||
|
||||
// Mock progression data for now
|
||||
_rank.text = "DIAMOND II";
|
||||
_winRateBar.value = 72;
|
||||
_winRateText.text = "72%";
|
||||
// Fetch real Elo data
|
||||
var eloData = await FirebaseService.GetPlayerData(savedName);
|
||||
|
||||
if (_eloLabel != null) _eloLabel.text = eloData.Rating.ToString();
|
||||
|
||||
if (_rank != null)
|
||||
{
|
||||
_rank.text = EloSystem.GetRank(eloData.Rating).ToUpper();
|
||||
if (ColorUtility.TryParseHtmlString(EloSystem.GetRankColor(eloData.Rating), out Color rankColor))
|
||||
{
|
||||
_rank.style.color = rankColor;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate Win Rate from GamesPlayed (requires adding wins to schema, but for now we use mock/partial)
|
||||
if (eloData.GamesPlayed > 0)
|
||||
{
|
||||
// Note: To show a real winrate, we'd need to store 'Wins' in PlayerEloData.
|
||||
// For now, keeping the mock or setting a placeholder.
|
||||
_winRateText.text = "CALCULATING...";
|
||||
}
|
||||
}
|
||||
|
||||
private async void Logout()
|
||||
|
||||
Reference in New Issue
Block a user