First commit

This commit is contained in:
mrtoine 2025-10-08 19:14:10 +02:00
commit f502f6b578
126 changed files with 10202 additions and 0 deletions

View file

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

View file

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

View file

@ -0,0 +1,138 @@
using System.Collections.Generic;
using Core.Runtime.Interfaces;
using UnityEngine;
namespace Core.Runtime
{
public class BaseMonobehaviour : MonoBehaviour
{
#region Publics
[Header("Debug")]
[SerializeField] protected bool m_isVerbose;
public enum FactPersistence
{
Normal,
Persistent,
}
public GameObject GameObject => _gameObject ? _gameObject : _gameObject = gameObject;
public Rigidbody Rigidbody => _rigidbody ? _rigidbody : _rigidbody = GetComponent<Rigidbody>();
public Transform Transform => _transform ? _transform : _transform = GetComponent<Transform>();
#endregion
#region Fact Dictionnary
protected bool FactExists<T>(string key, out T value)
{
GameFacts.FactExists<T>(key, out value);
return value != null;
}
protected T GetFact<T>(string key)
{
return GameFacts.GetFact<T>(key);
}
protected Dictionary<string, IFact> GetAllFacts()
{
return GameFacts.GetAllFacts();
}
protected void SetFact<T>(string key, T value, FactPersistence persistence = FactPersistence.Normal)
{
GameFacts.SetFact<T>(key, value, persistence);
}
protected void RemoveFact<T>(string key)
{
GameFacts.RemoveFact<T>(key);
}
#endregion
#region Save System
protected List<string> GetAllSaves()
{
return GameFacts.GetAllSaves();
}
protected void SaveFacts(string slotName = "")
{
string slot = GameManager.Instance.Profile;
if (slotName != "")
{
slot = slotName;
}
if (GameFacts.SaveFacts(slot))
{
Info("Données sauvegardées avec succès dans le fichier save.json");
}
else
{
Error("Failed to save facts");
}
}
protected void LoadFacts(string slotName = "")
{
string slot = GameManager.Instance.Profile;
if (slotName != "")
{
slot = slotName;
}
if (GameFacts.LoadFacts(slot))
{
Info("Données chargées avec succès");
}
else
{
Error("Failed to load facts");
}
}
protected void DeleteSaveFile()
{
GameFacts.DeleteSaveFile(GameManager.Instance.Profile);
}
#endregion
#region DEBUG
protected void Info(string message)
{
if (!m_isVerbose) return;
Debug.Log(message, this);
}
protected void Error(string message)
{
if (!m_isVerbose) return;
Debug.LogError(message, this);
}
protected void Warning(string message)
{
if (!m_isVerbose) return;
Debug.LogWarning(message, this);
}
#endregion
#region GETTERS
private GameObject _gameObject;
private Rigidbody _rigidbody;
private Transform _transform;
protected FactDictionnary GameFacts => GameManager.m_gameFacts;
#endregion
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5a0991893b6c24954afe021de03614ad

View file

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

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2ca720bbf8aa349608caa5ce4acaa603
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50fff7e431d747439539a559d25219d3
timeCreated: 1752140467

View file

@ -0,0 +1,43 @@
using System;
using Core.Runtime.Interfaces;
using Unity.Plastic.Newtonsoft.Json;
using UnityEngine;
namespace Core.Runtime
{
public class Fact<T> : IFact
{
#region Publics
public T Value;
public Fact(object value, bool isPersistent)
{
Value = (T) value;
IsPersistent = isPersistent;
}
public Type ValueType => typeof(T);
[JsonIgnore]
public object GetObjectValue => Value;
public void SetObjectValue(object value)
{
if (value is T cast)
{
Value = cast;
}
else
{
throw new InvalidCastException("Cannot asign a value to a fact");
}
}
public bool IsPersistent { get; set; }
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dbdaad04e901476ebafb6f2c0d22a257
timeCreated: 1752132457

View file

@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.IO;
using Codice.Client.BaseCommands.Merge.Xml;
using Core.Runtime.Interfaces;
using Unity.Plastic.Newtonsoft.Json;
using UnityEngine;
namespace Core.Runtime
{
public class FactDictionnary
{
#region Publics
public Dictionary<string, IFact> AllFacts => _facts;
#endregion
#region Main Methods
public bool FactExists<T>(string key, out T value)
{
if (_facts.TryGetValue(key, out var fact) && fact is Fact<T> typedFact)
{
value = typedFact.Value;
return true;
}
value = default;
return false;
}
public void SetFact<T>(string key, T value, BaseMonobehaviour.FactPersistence persistence)
{
if (_facts.TryGetValue(key, out var existingFact))
{
if (existingFact is Fact<T> typedFact)
{
typedFact.Value = value;
typedFact.IsPersistent = persistence == BaseMonobehaviour.FactPersistence.Persistent;
}
else
{
throw new InvalidCastException("Fact exists but is a wrong type");
}
}
else
{
bool isPersistent = persistence == BaseMonobehaviour.FactPersistence.Persistent;
_facts[key] = new Fact<T>(value, isPersistent);
}
}
public T GetFact<T>(string key)
{
if (!_facts.TryGetValue(key, out var fact))
{
throw new InvalidCastException($"Fact {key} does not exist");
}
if (_facts[key] is not Fact<T> typedFact)
{
throw new InvalidCastException($"Fact {key} is not of type {typeof(T)}");
}
return typedFact.Value;
}
public Dictionary<string, IFact> GetAllFacts()
{
return AllFacts;
}
public void RemoveFact<T>(string key)
{
_facts.Remove(key);
}
public List<string> GetAllSaves()
{
foreach (var slot in Directory.GetFiles(Application.persistentDataPath))
{
if (slot.Contains("_save.json") && !slot.Contains("GeneralSettings"))
{
string fileName = Path.GetFileNameWithoutExtension(slot);
if (fileName.EndsWith("_save"))
{
string slotName = fileName.Substring(0, fileName.Length - "_save".Length); // "Rom1"
_saves.Add(slotName);
}
}
}
return _saves;
}
public bool SaveFileExists(string slotName= "")
{
if (slotName != "")
{
string filename = Path.Combine(Application.persistentDataPath, $"{slotName}_save.json");
return File.Exists(filename);
}
int nbFiles = Directory.GetFiles(Application.persistentDataPath, "*.json").Length;
string fileSettings = Path.Combine(Application.persistentDataPath, "GeneralSettings_save.json");
if (File.Exists(fileSettings)) nbFiles--; // On retire le fichier nommé GeneralSettings_save.json
Debug.Log($"NbFiles => {nbFiles}");
if(nbFiles <= 0) return false;
return true;
}
public bool SaveFacts(string slotName)
{
Dictionary<string, IFact> persistentsFacts = GetPersistentsFacts();
JsonSerializerSettings settings = new JsonSerializerSettings
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
DateFormatHandling = DateFormatHandling.IsoDateFormat,
TypeNameHandling = TypeNameHandling.None
};
string json = JsonConvert.SerializeObject(persistentsFacts, settings);
string filename = Path.Combine(Application.persistentDataPath, $"{slotName}_save.json");
Debug.Log($"Saving to {filename}");
try
{
File.WriteAllText(filename, json);
_saves.Add(slotName);
return true;
}
catch (Exception e)
{
return false;
}
}
public bool LoadFacts(string slotName)
{
string file = Path.Combine(Application.persistentDataPath, $"{slotName}_save.json");
if (File.Exists(file))
{
JsonSerializerSettings settings = new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.All
};
string json = File.ReadAllText(file);
Dictionary<string, IFact> facts = JsonConvert.DeserializeObject<Dictionary<string, IFact>>(json, settings);
foreach (var fact in facts)
{
_facts[fact.Key] = fact.Value;
}
return true;
}
return false;
}
public void DeleteSaveFile(string slotName)
{
string file = Path.Combine(Application.persistentDataPath, $"{slotName}_save.json");
File.Delete(file);
}
#endregion
#region Utils
private Dictionary<string, IFact> GetPersistentsFacts()
{
Dictionary<string, IFact> persistentsFacts = new();
foreach (var fact in _facts)
{
if (fact.Value.IsPersistent)
{
persistentsFacts.Add(fact.Key, fact.Value);
}
}
return persistentsFacts;
}
#endregion
#region private
private Dictionary<string, IFact> _facts = new();
private List<string> _saves = new List<string>();
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bb7f99aca4b5495aaecca229e21225ef
timeCreated: 1752132416

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using PlasticGui;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Core.Runtime
{
public class GameManager: BaseMonobehaviour
{
#region Privates and Protected
bool isOnPause = false;
SceneLoader _sceneLoader;
FactDictionnary _fact;
bool _canPause;
string _profile;
string _currentLanguage = "en";
Dictionary<string, string> _localTexts;
#endregion
#region Publics
public static GameManager Instance { get; private set; }
public static FactDictionnary m_gameFacts;
public bool IsOnPause
{
get => isOnPause;
set => isOnPause = value;
}
public FactDictionnary Fact
{
get
{
return _fact;
}
set
{
_fact = value;
}
}
public String Profile
{
get
{
return _profile;
}
set
{
_profile = value;
}
}
public bool SaveFileExist => m_gameFacts.SaveFileExists();
public bool CanPause
{
get => _canPause;
set => _canPause = value;
}
public string CurrentLanguage
{
get
{
return _currentLanguage;
}
set
{
_currentLanguage = value;
}
}
public Dictionary<string, string> GetLocalTexts
{
get
{
return _localTexts;
}
set
{
_localTexts = value;
}
}
#endregion
#region Unity API
private void Awake()
{
_sceneLoader = GetComponent<SceneLoader>();
// Si une instance existe déjà et que ce nest pas celle-ci, détruire ce GameObject
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
// Sinon, cette instance devient linstance unique
Instance = this;
DontDestroyOnLoad(gameObject);
m_gameFacts = new FactDictionnary();
_localTexts = new Dictionary<string, string>();
if(!FactExists<GeneralSettings>("GeneralSettings", out var _))
{
Profile = "GeneralSettings";
GeneralSettings settings = new GeneralSettings();
settings.Language = "en";
SetFact<GeneralSettings>("GeneralSettings", settings, FactPersistence.Persistent);
SaveFacts();
}
CurrentLanguage = GetFact<GeneralSettings>("GeneralSettings").Language;
LocalizationSystem.Instance.LoadLanguage();
}
#endregion
#region Main Methods
public void CreateObject(GameObject prefab, Vector3 position)
{
Instantiate(prefab, position, Quaternion.identity);
}
public void ReloadScene()
{
string sceneName = SceneManager.GetActiveScene().name;
_sceneLoader.LoadScene(sceneName);
}
#endregion
#region Utils
/* Fonctions privées utiles */
#endregion
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3664fb5e6bffa4a6cbfc8fce31b53be3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 11
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
namespace Core.Runtime
{
public class GeneralSettings
{
#region Attributes
string _language;
#endregion
#region Getters and Setters
public string Language
{
get => _language;
set => _language = value;
}
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c9de6ca1160646fcb66e8e896ab4998a
timeCreated: 1759940361

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c2c2153ca77294f16adf4ecf6b122114
timeCreated: 1751010258

View file

@ -0,0 +1,12 @@
using System;
namespace Core.Runtime.Interfaces
{
public interface IFact
{
Type ValueType { get; }
object GetObjectValue { get; }
void SetObjectValue(object value);
bool IsPersistent { get; }
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 28d823c3a267436eaf00bf170c9669f9
timeCreated: 1752132484

View file

@ -0,0 +1,89 @@
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace Core.Runtime
{
public class LocalizationSystem : BaseMonobehaviour
{
#region Publics
public static LocalizationSystem Instance { get; private set; }
#endregion
#region Unity API
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
}
#endregion
#region Main Methods
public string GetLocalizedText(string key)
{
if (GameManager.Instance.GetLocalTexts.TryGetValue(key, out var value))
return value;
return $"{key}";
}
public void SaveLanguage(string newLanguage)
{
//
}
public void LoadLanguage()
{
string lang = GetLanguage();
GameManager.Instance.CurrentLanguage = lang;
string langFile = GetLanguageFile();
if (!string.IsNullOrEmpty(langFile))
{
GameManager.Instance.GetLocalTexts = XmlLoader.LoadDictionary(GetLanguageFile());
}
else
{
Error($"[ERROR] Language file not found : {lang} <{langFile}>");
}
}
#endregion
#region Utils
private string GetLanguage()
{
string file = GetLanguageFile();
return file.Split('/')[file.Split('/').Length - 1].Split('.')[0];
}
private string GetLanguageFile()
{
string filename = Application.dataPath + "/_/Database/Localization/" + GetFact<GeneralSettings>("GeneralSettings").Language + ".xml";
if (File.Exists(filename))
{
return filename;
}
return "";
}
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02c5410883674e91875167d2ef34abe5
timeCreated: 1752475493

View file

@ -0,0 +1,101 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
namespace Core.Runtime
{
public class SceneLoader : BaseMonobehaviour
{
#region Publics
public static event Action<Scene> OnSceneLoaded;
public static string CurrentSceneName => SceneManager.GetActiveScene().name;
public static SceneLoader Instance { get; private set; }
#endregion
#region Unity API
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
SceneManager.sceneLoaded += HandleSceneLoaded;
}
void OnDestroy()
{
SceneManager.sceneLoaded -= HandleSceneLoaded;
}
#endregion
#region Main Methods
public void LoadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
public void FakeLoading(string nextSceneName)
{
Info("On vérifie que la scene Loading est disponible");
if (SceneExists("Loading"))
{
LoadScene("Loading");
Info($"level suivant {nextSceneName}");
StartCoroutine(WaitingLoading(nextSceneName));
}
}
#endregion
#region Utils
private IEnumerator WaitingLoading(string nextSceneName)
{
int time = Random.Range(3, 6);
Info($"On attend {time} secondes et on charge la scene {nextSceneName}");
yield return new WaitForSeconds(time);
LoadScene(nextSceneName);
}
private void HandleSceneLoaded(Scene scene, LoadSceneMode mode)
{
OnSceneLoaded?.Invoke(scene);
}
private bool SceneExists(string sceneName)
{
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
{
string path = SceneUtility.GetScenePathByBuildIndex(i);
string name = System.IO.Path.GetFileNameWithoutExtension(path);
if (name == sceneName)
return true;
}
return false;
}
#endregion
#region Privates and Protected
//
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9a4bd386e20d414fb3e91c510e890143
timeCreated: 1751130958

View file

@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using UnityEngine;
namespace Core.Runtime
{
public class XmlLoader
{
public static Dictionary<string, string> LoadDictionary(string filepath)
{
XDocument xmlDoc = XDocument.Load(filepath);
return xmlDoc.Root
.Elements()
.ToDictionary(
e => e.Name.LocalName,
e => e.Value
);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f0170f390842426a826731a88149968e
timeCreated: 1752483882

View file

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

View file

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

View file

@ -0,0 +1,458 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.14.2
// from Assets/ActionMap.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
namespace Player.Runtime
{
/// <summary>
/// Provides programmatic access to <see cref="InputActionAsset" />, <see cref="InputActionMap" />, <see cref="InputAction" /> and <see cref="InputControlScheme" /> instances defined in asset "Assets/ActionMap.inputactions".
/// </summary>
/// <remarks>
/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
/// </remarks>
/// <example>
/// <code>
/// using namespace UnityEngine;
/// using UnityEngine.InputSystem;
///
/// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
/// public class Example : MonoBehaviour, MyActions.IPlayerActions
/// {
/// private MyActions_Actions m_Actions; // Source code representation of asset.
/// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
///
/// void Awake()
/// {
/// m_Actions = new MyActions_Actions(); // Create asset object.
/// m_Player = m_Actions.Player; // Extract action map object.
/// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
/// }
///
/// void OnDestroy()
/// {
/// m_Actions.Dispose(); // Destroy asset object.
/// }
///
/// void OnEnable()
/// {
/// m_Player.Enable(); // Enable all actions within map.
/// }
///
/// void OnDisable()
/// {
/// m_Player.Disable(); // Disable all actions within map.
/// }
///
/// #region Interface implementation of MyActions.IPlayerActions
///
/// // Invoked when "Move" action is either started, performed or canceled.
/// public void OnMove(InputAction.CallbackContext context)
/// {
/// Debug.Log($"OnMove: {context.ReadValue&lt;Vector2&gt;()}");
/// }
///
/// // Invoked when "Attack" action is either started, performed or canceled.
/// public void OnAttack(InputAction.CallbackContext context)
/// {
/// Debug.Log($"OnAttack: {context.ReadValue&lt;float&gt;()}");
/// }
///
/// #endregion
/// }
/// </code>
/// </example>
public partial class @ActionMap: IInputActionCollection2, IDisposable
{
/// <summary>
/// Provides access to the underlying asset instance.
/// </summary>
public InputActionAsset asset { get; }
/// <summary>
/// Constructs a new instance.
/// </summary>
public @ActionMap()
{
asset = InputActionAsset.FromJson(@"{
""version"": 1,
""name"": ""ActionMap"",
""maps"": [
{
""name"": ""Player"",
""id"": ""7908f49f-ca02-4f4e-9488-95f850f8e533"",
""actions"": [
{
""name"": ""Move"",
""type"": ""Value"",
""id"": ""ce45504d-0efe-4f16-a510-dddc773d7c45"",
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
}
],
""bindings"": [
{
""name"": """",
""id"": ""92b4140c-574b-47c8-99c0-3c4d060a7e5a"",
""path"": """",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
{
""name"": ""UI"",
""id"": ""296fd1da-9e6c-44c7-a23e-fcaa10e9e89e"",
""actions"": [
{
""name"": ""New action"",
""type"": ""Button"",
""id"": ""f1bdc171-6695-41e3-bdb0-7a0ba14c84af"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": """",
""id"": ""4d9b405b-6cd4-4305-890f-1bf83975e509"",
""path"": """",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""New action"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
}");
// Player
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Move = m_Player.FindAction("Move", throwIfNotFound: true);
// UI
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
m_UI_Newaction = m_UI.FindAction("New action", throwIfNotFound: true);
}
~@ActionMap()
{
UnityEngine.Debug.Assert(!m_Player.enabled, "This will cause a leak and performance issues, ActionMap.Player.Disable() has not been called.");
UnityEngine.Debug.Assert(!m_UI.enabled, "This will cause a leak and performance issues, ActionMap.UI.Disable() has not been called.");
}
/// <summary>
/// Destroys this asset and all associated <see cref="InputAction"/> instances.
/// </summary>
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindingMask" />
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.devices" />
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.controlSchemes" />
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Contains(InputAction)" />
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.GetEnumerator()" />
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Enable()" />
public void Enable()
{
asset.Enable();
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Disable()" />
public void Disable()
{
asset.Disable();
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindings" />
public IEnumerable<InputBinding> bindings => asset.bindings;
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindAction(string, bool)" />
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindBinding(InputBinding, out InputAction)" />
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
}
// Player
private readonly InputActionMap m_Player;
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
private readonly InputAction m_Player_Move;
/// <summary>
/// Provides access to input actions defined in input action map "Player".
/// </summary>
public struct PlayerActions
{
private @ActionMap m_Wrapper;
/// <summary>
/// Construct a new instance of the input action map wrapper class.
/// </summary>
public PlayerActions(@ActionMap wrapper) { m_Wrapper = wrapper; }
/// <summary>
/// Provides access to the underlying input action "Player/Move".
/// </summary>
public InputAction @Move => m_Wrapper.m_Player_Move;
/// <summary>
/// Provides access to the underlying input action map instance.
/// </summary>
public InputActionMap Get() { return m_Wrapper.m_Player; }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
public void Enable() { Get().Enable(); }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
public void Disable() { Get().Disable(); }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
public bool enabled => Get().enabled;
/// <summary>
/// Implicitly converts an <see ref="PlayerActions" /> to an <see ref="InputActionMap" /> instance.
/// </summary>
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
/// <summary>
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
/// </summary>
/// <param name="instance">Callback instance.</param>
/// <remarks>
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
/// </remarks>
/// <seealso cref="PlayerActions" />
public void AddCallbacks(IPlayerActions instance)
{
if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_PlayerActionsCallbackInterfaces.Add(instance);
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
}
/// <summary>
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
/// </summary>
/// <remarks>
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
/// </remarks>
/// <seealso cref="PlayerActions" />
private void UnregisterCallbacks(IPlayerActions instance)
{
@Move.started -= instance.OnMove;
@Move.performed -= instance.OnMove;
@Move.canceled -= instance.OnMove;
}
/// <summary>
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />.
/// </summary>
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
public void RemoveCallbacks(IPlayerActions instance)
{
if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
/// <summary>
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
/// </summary>
/// <remarks>
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
/// </remarks>
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
public void SetCallbacks(IPlayerActions instance)
{
foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_PlayerActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
/// <summary>
/// Provides a new <see cref="PlayerActions" /> instance referencing this action map.
/// </summary>
public PlayerActions @Player => new PlayerActions(this);
// UI
private readonly InputActionMap m_UI;
private List<IUIActions> m_UIActionsCallbackInterfaces = new List<IUIActions>();
private readonly InputAction m_UI_Newaction;
/// <summary>
/// Provides access to input actions defined in input action map "UI".
/// </summary>
public struct UIActions
{
private @ActionMap m_Wrapper;
/// <summary>
/// Construct a new instance of the input action map wrapper class.
/// </summary>
public UIActions(@ActionMap wrapper) { m_Wrapper = wrapper; }
/// <summary>
/// Provides access to the underlying input action "UI/Newaction".
/// </summary>
public InputAction @Newaction => m_Wrapper.m_UI_Newaction;
/// <summary>
/// Provides access to the underlying input action map instance.
/// </summary>
public InputActionMap Get() { return m_Wrapper.m_UI; }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
public void Enable() { Get().Enable(); }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
public void Disable() { Get().Disable(); }
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
public bool enabled => Get().enabled;
/// <summary>
/// Implicitly converts an <see ref="UIActions" /> to an <see ref="InputActionMap" /> instance.
/// </summary>
public static implicit operator InputActionMap(UIActions set) { return set.Get(); }
/// <summary>
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
/// </summary>
/// <param name="instance">Callback instance.</param>
/// <remarks>
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
/// </remarks>
/// <seealso cref="UIActions" />
public void AddCallbacks(IUIActions instance)
{
if (instance == null || m_Wrapper.m_UIActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_UIActionsCallbackInterfaces.Add(instance);
@Newaction.started += instance.OnNewaction;
@Newaction.performed += instance.OnNewaction;
@Newaction.canceled += instance.OnNewaction;
}
/// <summary>
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
/// </summary>
/// <remarks>
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
/// </remarks>
/// <seealso cref="UIActions" />
private void UnregisterCallbacks(IUIActions instance)
{
@Newaction.started -= instance.OnNewaction;
@Newaction.performed -= instance.OnNewaction;
@Newaction.canceled -= instance.OnNewaction;
}
/// <summary>
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="UIActions.UnregisterCallbacks(IUIActions)" />.
/// </summary>
/// <seealso cref="UIActions.UnregisterCallbacks(IUIActions)" />
public void RemoveCallbacks(IUIActions instance)
{
if (m_Wrapper.m_UIActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
/// <summary>
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
/// </summary>
/// <remarks>
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
/// </remarks>
/// <seealso cref="UIActions.AddCallbacks(IUIActions)" />
/// <seealso cref="UIActions.RemoveCallbacks(IUIActions)" />
/// <seealso cref="UIActions.UnregisterCallbacks(IUIActions)" />
public void SetCallbacks(IUIActions instance)
{
foreach (var item in m_Wrapper.m_UIActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_UIActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
/// <summary>
/// Provides a new <see cref="UIActions" /> instance referencing this action map.
/// </summary>
public UIActions @UI => new UIActions(this);
/// <summary>
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Player" which allows adding and removing callbacks.
/// </summary>
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
public interface IPlayerActions
{
/// <summary>
/// Method invoked when associated input action "Move" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnMove(InputAction.CallbackContext context);
}
/// <summary>
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks.
/// </summary>
/// <seealso cref="UIActions.AddCallbacks(IUIActions)" />
/// <seealso cref="UIActions.RemoveCallbacks(IUIActions)" />
public interface IUIActions
{
/// <summary>
/// Method invoked when associated input action "New action" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnNewaction(InputAction.CallbackContext context);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f47401f297b144ffa669ca25b7a4eb4

View file

@ -0,0 +1,17 @@
{
"name": "Player.Runtime",
"rootNamespace": "Player.Runtime",
"references": [
"GUID:2ca720bbf8aa349608caa5ce4acaa603",
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f739b7e42809c4432b49bb1410219d06
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: