first
This commit is contained in:
3
Runtime/Engine/Code/Services/Console.meta
Normal file
3
Runtime/Engine/Code/Services/Console.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d059b7f04b524c6fbd39c7b14af4a299
|
||||
timeCreated: 1740779746
|
||||
169
Runtime/Engine/Code/Services/Console/CVar.cs
Normal file
169
Runtime/Engine/Code/Services/Console/CVar.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
public enum CVarValueKind {
|
||||
Number, String
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct CVarValue {
|
||||
public CVarValueKind Kind;
|
||||
|
||||
public double NumberValue;
|
||||
public string StringValue;
|
||||
|
||||
public CVarValue(int value) {
|
||||
Kind = CVarValueKind.Number;
|
||||
NumberValue = value;
|
||||
StringValue = null;
|
||||
}
|
||||
|
||||
public CVarValue(float value) {
|
||||
Kind = CVarValueKind.Number;
|
||||
NumberValue = value;
|
||||
StringValue = null;
|
||||
}
|
||||
|
||||
public CVarValue(double value) {
|
||||
Kind = CVarValueKind.Number;
|
||||
NumberValue = value;
|
||||
StringValue = null;
|
||||
}
|
||||
|
||||
public CVarValue(string value) {
|
||||
Kind = CVarValueKind.String;
|
||||
NumberValue = 0;
|
||||
StringValue = value;
|
||||
}
|
||||
|
||||
public void CopyFrom(CVarValue value) {
|
||||
Kind = value.Kind;
|
||||
NumberValue = value.NumberValue;
|
||||
StringValue = value.StringValue;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Kind switch {
|
||||
CVarValueKind.Number => NumberValue.ToString(),
|
||||
CVarValueKind.String => $"\"{StringValue}\"",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CVarFlags {
|
||||
None, Persistent, ReadOnly
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CVar {
|
||||
public CVarFlags Flags;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public CVarValue DefaultValue;
|
||||
public CVarValue Value { get; private set; }
|
||||
|
||||
public int IndexValue => (int) Value.NumberValue;
|
||||
public float FloatValue => (float) Value.NumberValue;
|
||||
public double NumberValue => Value.NumberValue;
|
||||
public string StringValue => Value.StringValue;
|
||||
|
||||
public event Action OnChanged = delegate { };
|
||||
|
||||
public CVar(CVar other) {
|
||||
Flags = other.Flags;
|
||||
Name = other.Name;
|
||||
Description = other.Description;
|
||||
DefaultValue = other.DefaultValue;
|
||||
Value = other.Value;
|
||||
}
|
||||
|
||||
public CVar(string name, CVarValue value, string description = "") {
|
||||
Name = name;
|
||||
Description = description;
|
||||
DefaultValue = value;
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public CVar(string name, int value, string description = "") {
|
||||
Name = name;
|
||||
Description = description;
|
||||
DefaultValue = new CVarValue(value);
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public CVar(string name, float value, string description = "") {
|
||||
Name = name;
|
||||
Description = description;
|
||||
DefaultValue = new CVarValue(value);
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public CVar(string name, double value, string description = "") {
|
||||
Name = name;
|
||||
Description = description;
|
||||
DefaultValue = new CVarValue(value);
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public CVar(string name, string value, string description = "") {
|
||||
Name = name;
|
||||
Description = description;
|
||||
DefaultValue = new CVarValue(value);
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public void Set(int value) {
|
||||
if (Flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Value = new CVarValue(value);
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Set(float value) {
|
||||
if (Flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Value = new CVarValue(value);
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Set(string value) {
|
||||
if (Flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Value = new CVarValue(value);
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void ParseFromString(string str) {
|
||||
if (Flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (float.TryParse(str, out float f)) {
|
||||
Set(f);
|
||||
} else {
|
||||
Set(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
if (Flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Value = DefaultValue;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Services/Console/CVar.cs.meta
Normal file
3
Runtime/Engine/Code/Services/Console/CVar.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f560b25a893456c90fac62ad278c02b
|
||||
timeCreated: 1740779755
|
||||
19
Runtime/Engine/Code/Services/Console/CVarAsset.cs
Normal file
19
Runtime/Engine/Code/Services/Console/CVarAsset.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
[CreateAssetMenu(fileName = RConsts.AssetMenu + "cvar")]
|
||||
public class CVarAsset : ScriptableObject {
|
||||
[SerializeField]
|
||||
private CVar _cvar;
|
||||
|
||||
public CVar Create(string name = null) {
|
||||
CVar cvar = new CVar(_cvar);
|
||||
|
||||
if (name != null) {
|
||||
cvar.Name = name;
|
||||
}
|
||||
|
||||
return cvar;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Services/Console/CVarAsset.cs.meta
Normal file
3
Runtime/Engine/Code/Services/Console/CVarAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 443a66c3a441450d96d222872a567df0
|
||||
timeCreated: 1741639598
|
||||
193
Runtime/Engine/Code/Services/Console/ConsoleService.cs
Normal file
193
Runtime/Engine/Code/Services/Console/ConsoleService.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Services.Input;
|
||||
using UnityEngine.InputSystem;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
public interface IConsoleCommand {
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
void Execute(string[] args);
|
||||
}
|
||||
|
||||
public class HelpCommand : IConsoleCommand {
|
||||
public string Name { get; } = "help";
|
||||
public string Description { get; } = "Prints available commands/cvars and their descriptions.";
|
||||
|
||||
public void Execute(string[] args) {
|
||||
RR.Console().PrintHelp();
|
||||
}
|
||||
}
|
||||
|
||||
public class ConsoleService : IService {
|
||||
private static readonly Logger _logger = new(nameof(ConsoleService));
|
||||
|
||||
[Serializable]
|
||||
public class Config {
|
||||
public ConsoleUI ConsoleUIPrefab;
|
||||
public ScriptableInputAction ToggleAction;
|
||||
}
|
||||
|
||||
private ConsoleUI _ui;
|
||||
private Config _config;
|
||||
|
||||
private List<IConsoleCommand> _commands = new();
|
||||
private List<CVar> _cvars = new();
|
||||
|
||||
public bool IsVisible => _ui.IsVisible;
|
||||
|
||||
public ConsoleService(Config config) {
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
_logger.Info("Waking up");
|
||||
|
||||
_ui = UnityEngine.Object.Instantiate(_config.ConsoleUIPrefab);
|
||||
UnityEngine.Object.DontDestroyOnLoad(_ui.gameObject);
|
||||
await UniTask.Yield(cancellationToken);
|
||||
|
||||
_config.ToggleAction.Action.Enable();
|
||||
_config.ToggleAction.Action.performed += OnToggleAction;
|
||||
|
||||
RegisterCommand(new HelpCommand());
|
||||
|
||||
_ui.SetVisibility(false);
|
||||
_ui.Clear();
|
||||
_ui.Write("Hello shelf\n");
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (_ui != null) {
|
||||
UnityEngine.Object.Destroy(_ui);
|
||||
_ui = null;
|
||||
}
|
||||
|
||||
_config.ToggleAction.Action.performed -= OnToggleAction;
|
||||
}
|
||||
|
||||
public CVar GetCVar(string name) {
|
||||
foreach (CVar cvar in _cvars) {
|
||||
if (cvar.Name.Equals(name)) {
|
||||
return cvar;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CVar ReplaceOrDefault(CVar cvar) {
|
||||
CVar foundCVar = GetCVar(cvar.Name);
|
||||
if (foundCVar != null) {
|
||||
return foundCVar;
|
||||
}
|
||||
|
||||
_cvars.Add(cvar);
|
||||
return cvar;
|
||||
}
|
||||
|
||||
public void Replace(CVar cvar) {
|
||||
CVar foundCVar = GetCVar(cvar.Name);
|
||||
if (foundCVar != null) {
|
||||
_cvars.Remove(foundCVar);
|
||||
}
|
||||
|
||||
_cvars.Add(cvar);
|
||||
}
|
||||
|
||||
private string[] ParseCommandInputArguments(string text) {
|
||||
if (text.Length == 0) {
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
return new string[] {text};
|
||||
}
|
||||
|
||||
public void Execute(string input) {
|
||||
if (input.Length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
string commandName = input;
|
||||
if (input.IndexOf(' ') != -1) {
|
||||
commandName = input.Substring(0, input.IndexOf(' '));
|
||||
}
|
||||
|
||||
string[] arguments = ParseCommandInputArguments(input.Substring(commandName.Length));
|
||||
|
||||
foreach (IConsoleCommand command in _commands) {
|
||||
if (command.Name.Equals(commandName)) {
|
||||
command.Execute(arguments);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CVar cvar in _cvars) {
|
||||
if (cvar.Name.Equals(commandName)) {
|
||||
if (arguments.Length == 1) {
|
||||
cvar.ParseFromString(arguments[0]);
|
||||
}
|
||||
|
||||
_ui.Write($"<b>{cvar.Name}</b> - {cvar.ToString()}\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_ui.Write($"ERROR: Command/CVar `{commandName}` not found.");
|
||||
}
|
||||
|
||||
public void ToggleVisibility() {
|
||||
_ui.SetVisibility(!_ui.IsVisible);
|
||||
|
||||
if (_ui.IsVisible) {
|
||||
// RR.Input().DisableControls();
|
||||
} else {
|
||||
RR.Input().EnableControls();
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCommand(IConsoleCommand command) {
|
||||
if (_commands.Any(t => t.Name.Equals(command.Name))) {
|
||||
_logger.Error($"`{command.Name}` command is already registered");
|
||||
return;
|
||||
}
|
||||
|
||||
_commands.Add(command);
|
||||
_logger.Info($"Registered command: {command.Name}");
|
||||
}
|
||||
|
||||
public void PrintHelp() {
|
||||
StringBuilder message = new();
|
||||
|
||||
message.AppendLine("Available commands:");
|
||||
foreach (IConsoleCommand command in _commands) {
|
||||
message.Append(" ");
|
||||
message.Append(command.Name);
|
||||
message.Append(" - ");
|
||||
message.Append(command.Description);
|
||||
message.AppendLine();
|
||||
}
|
||||
|
||||
message.AppendLine("Available cvars:");
|
||||
foreach (CVar cvar in _cvars) {
|
||||
message.Append(" ");
|
||||
message.Append(cvar.Name);
|
||||
message.Append(" - ");
|
||||
message.Append(cvar.Description);
|
||||
message.AppendLine();
|
||||
}
|
||||
|
||||
_ui.Write(message.ToString());
|
||||
}
|
||||
|
||||
private void OnToggleAction(InputAction.CallbackContext obj) {
|
||||
ToggleVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b841238f225048e88d8d8d89cfeafaa7
|
||||
timeCreated: 1740884588
|
||||
34
Runtime/Engine/Code/Services/Console/ConsoleServiceAsset.cs
Normal file
34
Runtime/Engine/Code/Services/Console/ConsoleServiceAsset.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
[CreateAssetMenu(menuName = RConsts.ServiceAssetMenu + "Console")]
|
||||
public class ConsoleServiceAsset : ServiceAsset<ConsoleService> {
|
||||
[SerializeField]
|
||||
private ConsoleService.Config _config;
|
||||
|
||||
[SerializeField]
|
||||
private CVar[] _initialCVars;
|
||||
|
||||
[SerializeField]
|
||||
private bool _loadCVarsFromResources = true;
|
||||
|
||||
public override ConsoleService Create() {
|
||||
ConsoleService service = new(_config);
|
||||
foreach (CVar cvar in _initialCVars) {
|
||||
service.Replace(cvar);
|
||||
cvar.Reset();
|
||||
}
|
||||
|
||||
if (_loadCVarsFromResources) {
|
||||
CVarAsset[] cvarsAssets = Resources.LoadAll<CVarAsset>("cvar");
|
||||
foreach (CVarAsset cvarAsset in cvarsAssets) {
|
||||
CVar cvar = cvarAsset.Create();
|
||||
service.Replace(cvar);
|
||||
}
|
||||
}
|
||||
|
||||
return new ConsoleService(_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 577b018c25510774aaccba06137e264d
|
||||
52
Runtime/Engine/Code/Services/Console/ConsoleUI.cs
Normal file
52
Runtime/Engine/Code/Services/Console/ConsoleUI.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
public class ConsoleUI : MonoBehaviour {
|
||||
private StringBuilder _content = new();
|
||||
|
||||
[SerializeField]
|
||||
private UIDocument _document;
|
||||
|
||||
private TextField _textField;
|
||||
private Button _submitButton;
|
||||
|
||||
public bool IsVisible { get; private set; }
|
||||
|
||||
private void Awake() {
|
||||
|
||||
VisualElement root = _document.rootVisualElement;
|
||||
return;
|
||||
// _textField = root.Q<TextField>("console-text-field");
|
||||
// _submitButton = root.Q<Button>("console-btn-submit");
|
||||
// _submitButton.clicked += OnSubmitButtonClicked;
|
||||
}
|
||||
|
||||
private void OnSubmit(string input) {
|
||||
RR.Console().Execute(input);
|
||||
_textField.value = input;
|
||||
}
|
||||
|
||||
public void SetVisibility(bool visible) {
|
||||
_document.enabled = visible;
|
||||
}
|
||||
|
||||
public void Write(string message) {
|
||||
_content.Append(message);
|
||||
//_textField.value = _content.ToString();
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_content.Clear();
|
||||
|
||||
if (_textField != null) {
|
||||
_textField.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSubmitButtonClicked() {
|
||||
OnSubmit(_textField.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Services/Console/ConsoleUI.cs.meta
Normal file
3
Runtime/Engine/Code/Services/Console/ConsoleUI.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca844a0157054677b2f129fdbf6ddc45
|
||||
timeCreated: 1740780314
|
||||
8
Runtime/Engine/Code/Services/Game.meta
Normal file
8
Runtime/Engine/Code/Services/Game.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1177ea3903bdba5419ad3347250cb3b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
68
Runtime/Engine/Code/Services/Game/GameMode.cs
Normal file
68
Runtime/Engine/Code/Services/Game/GameMode.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Game {
|
||||
[Serializable]
|
||||
public class GameModeConfig {
|
||||
public ControllerAsset[] Controllers;
|
||||
}
|
||||
|
||||
public abstract class GameModeAsset : ScriptableObject {
|
||||
[field: SerializeField]
|
||||
public GameModeConfig GameModeConfig { get; private set; }
|
||||
|
||||
public GameMode Create() {
|
||||
GameMode gameMode = new GameMode(GameModeConfig);
|
||||
ConfigureGameMode(gameMode);
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
public abstract void ConfigureGameMode(GameMode gameMode);
|
||||
}
|
||||
|
||||
public class GameMode : IDisposable {
|
||||
private readonly GameModeConfig _config;
|
||||
private readonly ControllersManager _controllersManager;
|
||||
|
||||
private CancellationTokenSource _destroyCancellationTokenSource;
|
||||
|
||||
private bool _isRunning;
|
||||
|
||||
public GameMode(GameModeConfig config) {
|
||||
_config = config;
|
||||
_isRunning = false;
|
||||
|
||||
_destroyCancellationTokenSource = new CancellationTokenSource();
|
||||
_controllersManager = new ControllersManager(_destroyCancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
_destroyCancellationTokenSource.Cancel();
|
||||
_controllersManager.Dispose();
|
||||
}
|
||||
|
||||
public async Awaitable<bool> Start(CancellationToken cancellationToken) {
|
||||
_controllersManager.Add(_config.Controllers);
|
||||
await _controllersManager.Start(cancellationToken);
|
||||
|
||||
_isRunning = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Stop() {
|
||||
_isRunning = false;
|
||||
|
||||
_controllersManager.Stop();
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
_controllersManager.Tick();
|
||||
}
|
||||
|
||||
public void AddController(IController controller) {
|
||||
_controllersManager.Add(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Engine/Code/Services/Game/GameMode.cs.meta
Normal file
2
Runtime/Engine/Code/Services/Game/GameMode.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73f15dc489209cc4a9ff6963e0fbd2c6
|
||||
42
Runtime/Engine/Code/Services/Game/GameService.cs
Normal file
42
Runtime/Engine/Code/Services/Game/GameService.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
|
||||
namespace RebootKit.Engine.Services.Game {
|
||||
public class GameService : IService {
|
||||
private static readonly Logger _logger = new(nameof(GameService));
|
||||
|
||||
private GameModeAsset _gameModeAsset;
|
||||
private GameMode _gameMode;
|
||||
private bool _running;
|
||||
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
_running = false;
|
||||
_gameMode.Dispose();
|
||||
}
|
||||
|
||||
public async UniTask Start(GameModeAsset asset, CancellationToken cancellationToken) {
|
||||
_gameMode = asset.Create();
|
||||
await _gameMode.Start(cancellationToken);
|
||||
|
||||
Run(cancellationToken).Forget();
|
||||
}
|
||||
|
||||
private async UniTask Run(CancellationToken cancellationToken) {
|
||||
if (_gameMode == null) {
|
||||
_logger.Error("Trying to run game without game mode");
|
||||
return;
|
||||
}
|
||||
|
||||
_running = true;
|
||||
while (_running) {
|
||||
await UniTask.Yield(PlayerLoopTiming.Update, cancellationToken);
|
||||
_gameMode.Tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Engine/Code/Services/Game/GameService.cs.meta
Normal file
2
Runtime/Engine/Code/Services/Game/GameService.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82082a4d082be274bbec52347d25b836
|
||||
11
Runtime/Engine/Code/Services/Game/GameServiceAsset.cs
Normal file
11
Runtime/Engine/Code/Services/Game/GameServiceAsset.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Game {
|
||||
[CreateAssetMenu(menuName = RConsts.ServiceAssetMenu + "Game")]
|
||||
public class GameServiceAsset : ServiceAsset<GameService> {
|
||||
public override GameService Create() {
|
||||
return new GameService();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51f134b6c2abcd34fa8e376b3afc757d
|
||||
3
Runtime/Engine/Code/Services/Input.meta
Normal file
3
Runtime/Engine/Code/Services/Input.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b0c063e9b7a4190894f338b2fdef3b4
|
||||
timeCreated: 1740768141
|
||||
50
Runtime/Engine/Code/Services/Input/InputService.cs
Normal file
50
Runtime/Engine/Code/Services/Input/InputService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
public class InputService : IService {
|
||||
[Serializable]
|
||||
public class Config {
|
||||
public InputActionAsset InputAsset;
|
||||
}
|
||||
|
||||
private Config _config;
|
||||
|
||||
public InputService(Config config) {
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public void EnableControls() {
|
||||
_config.InputAsset.Enable();
|
||||
}
|
||||
|
||||
public void DisableControls() {
|
||||
_config.InputAsset.Disable();
|
||||
}
|
||||
|
||||
public InputAction FindInputAction(string path) {
|
||||
return _config.InputAsset.FindAction(path);
|
||||
}
|
||||
|
||||
public void LockCursor() {
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
public void UnlockCursor() {
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Services/Input/InputService.cs.meta
Normal file
3
Runtime/Engine/Code/Services/Input/InputService.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6ee7382dba74afe84aaf53259b1cf8a
|
||||
timeCreated: 1740769896
|
||||
14
Runtime/Engine/Code/Services/Input/InputServiceAsset.cs
Normal file
14
Runtime/Engine/Code/Services/Input/InputServiceAsset.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
[CreateAssetMenu(menuName = RConsts.ServiceAssetMenu + "Input")]
|
||||
public class InputServiceAsset : ServiceAsset<InputService> {
|
||||
[SerializeField]
|
||||
private InputService.Config _config;
|
||||
|
||||
public override InputService Create() {
|
||||
return new InputService(_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fcf71fe79ef1ed4cbfdefde09e708d9
|
||||
12
Runtime/Engine/Code/Services/Input/ScriptableInputAction.cs
Normal file
12
Runtime/Engine/Code/Services/Input/ScriptableInputAction.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input
|
||||
{
|
||||
[CreateAssetMenu(menuName = RConsts.AssetMenu + "Input Action", fileName = "Input Action")]
|
||||
public class ScriptableInputAction : ScriptableObject
|
||||
{
|
||||
[field: SerializeField]
|
||||
public InputAction Action { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8d574cf0e024ec7bc4363a675dbb2c9
|
||||
timeCreated: 1740768148
|
||||
3
Runtime/Engine/Code/Services/LoadigScreen.meta
Normal file
3
Runtime/Engine/Code/Services/LoadigScreen.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5fb2de6697247618aa0dc36a659ddcc
|
||||
timeCreated: 1741791621
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace RebootKit.Engine.Services.LoadigScreen
|
||||
{
|
||||
public class LoadingScreenService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a45f8f7ea6f45198713694a39790614
|
||||
timeCreated: 1740671052
|
||||
3
Runtime/Engine/Code/Services/Persistance.meta
Normal file
3
Runtime/Engine/Code/Services/Persistance.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 663488f6dc6f4f23a2fb88ab0b2a8daa
|
||||
timeCreated: 1741043532
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace RebootKit.Engine.Services.Persistance {
|
||||
|
||||
[Serializable]
|
||||
public class SaveData {
|
||||
public string ProfileName;
|
||||
}
|
||||
|
||||
public class SaveSystemService {
|
||||
public void Save() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fd19386b9584594bac09c3f43489a1a
|
||||
timeCreated: 1741043540
|
||||
3
Runtime/Engine/Code/Services/Simulation.meta
Normal file
3
Runtime/Engine/Code/Services/Simulation.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fda1b5a08e44d878d326cd3b7692e42
|
||||
timeCreated: 1740766816
|
||||
6
Runtime/Engine/Code/Services/Simulation/Actor.cs
Normal file
6
Runtime/Engine/Code/Services/Simulation/Actor.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
public class Actor : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
2
Runtime/Engine/Code/Services/Simulation/Actor.cs.meta
Normal file
2
Runtime/Engine/Code/Services/Simulation/Actor.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db64eadf8c93c8e47b954139078cb3bc
|
||||
3
Runtime/Engine/Code/Services/Simulation/Characters.meta
Normal file
3
Runtime/Engine/Code/Services/Simulation/Characters.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf2d5c590c224ae6a7acbdbfa0b79b57
|
||||
timeCreated: 1740770300
|
||||
@@ -0,0 +1,160 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Characters
|
||||
{
|
||||
public class CharacterLocomotion : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private CharacterController _characterController;
|
||||
|
||||
public float MaxMovementSpeed = 4.0f;
|
||||
public float MaxSprintSpeed = 15.0f;
|
||||
public float JumpHeight = 1.0f;
|
||||
public float Gravity = 10f;
|
||||
public float MaxFallSpeed = 20f;
|
||||
public float Damping = 20.0f;
|
||||
|
||||
private Vector3 _pendingInputValue;
|
||||
private Vector3 _currentVelocity;
|
||||
|
||||
private bool _isSprinting;
|
||||
private bool _jumpRequested;
|
||||
private bool _isFalling;
|
||||
|
||||
public bool IsGrounded => _characterController.isGrounded;
|
||||
|
||||
public Vector3 Velocity => _currentVelocity;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ConsumePendingInput();
|
||||
UpdateVerticalVelocity();
|
||||
|
||||
_characterController.Move(_currentVelocity * Time.deltaTime);
|
||||
|
||||
ApplyFriction();
|
||||
DetectFall();
|
||||
}
|
||||
|
||||
private void DetectFall()
|
||||
{
|
||||
if (_isFalling && _characterController.isGrounded)
|
||||
{
|
||||
_isFalling = false;
|
||||
}
|
||||
else if (!_characterController.isGrounded)
|
||||
{
|
||||
_isFalling = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConsumePendingInput()
|
||||
{
|
||||
if (!IsGrounded)
|
||||
{
|
||||
_pendingInputValue = Vector3.zero;
|
||||
return;
|
||||
}
|
||||
|
||||
_pendingInputValue.y = 0.0f;
|
||||
|
||||
float pendingInputMagnitude = _pendingInputValue.magnitude;
|
||||
Vector3 direction = Vector3.zero;
|
||||
|
||||
if (pendingInputMagnitude > 0.0f)
|
||||
{
|
||||
// normalize vector, reusing magnitude to avoid multiple sqrt calls
|
||||
direction = _pendingInputValue / pendingInputMagnitude;
|
||||
}
|
||||
|
||||
float movementSpeed = _isSprinting ? MaxSprintSpeed : MaxMovementSpeed;
|
||||
Vector3 movementVelocity = _currentVelocity;
|
||||
movementVelocity.y = 0.0f;
|
||||
movementVelocity += direction * (movementSpeed * pendingInputMagnitude);
|
||||
movementVelocity.y = 0.0f;
|
||||
|
||||
// Clamp speed
|
||||
float movementVelocityMagnitude = movementVelocity.magnitude;
|
||||
Vector3 movementVelocityDirection = movementVelocityMagnitude > 0.0f ? movementVelocity / movementVelocityMagnitude : Vector3.zero;
|
||||
|
||||
if (movementVelocityMagnitude > movementSpeed)
|
||||
{
|
||||
movementVelocityMagnitude = movementSpeed;
|
||||
}
|
||||
|
||||
movementVelocity = movementVelocityDirection * movementVelocityMagnitude;
|
||||
|
||||
_currentVelocity.x = movementVelocity.x;
|
||||
_currentVelocity.z = movementVelocity.z;
|
||||
|
||||
_pendingInputValue = Vector3.zero;
|
||||
}
|
||||
|
||||
private void UpdateVerticalVelocity()
|
||||
{
|
||||
if (_characterController.isGrounded)
|
||||
{
|
||||
if (_jumpRequested)
|
||||
{
|
||||
_currentVelocity.y = Mathf.Sqrt(2.0f * Gravity * JumpHeight);
|
||||
_jumpRequested = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentVelocity.y = -1f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentVelocity.y -= Gravity * Time.deltaTime;
|
||||
_currentVelocity.y = Mathf.Max(_currentVelocity.y, -MaxFallSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyFriction()
|
||||
{
|
||||
if (!IsGrounded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 movementVelocity = _currentVelocity;
|
||||
movementVelocity.y = 0.0f;
|
||||
|
||||
movementVelocity = Vector3.MoveTowards(movementVelocity, Vector3.zero, Damping * Time.deltaTime);
|
||||
|
||||
_currentVelocity.x = movementVelocity.x;
|
||||
_currentVelocity.z = movementVelocity.z;
|
||||
}
|
||||
|
||||
public void AddVelocity(Vector3 velocity)
|
||||
{
|
||||
_currentVelocity += velocity;
|
||||
}
|
||||
|
||||
public void AddMovementInput(Vector3 input, float scale)
|
||||
{
|
||||
_pendingInputValue += input * scale;
|
||||
}
|
||||
|
||||
public void Jump()
|
||||
{
|
||||
if (!_characterController.isGrounded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_jumpRequested = true;
|
||||
}
|
||||
|
||||
public void StartSprint()
|
||||
{
|
||||
_isSprinting = true;
|
||||
}
|
||||
|
||||
public void StopSprint()
|
||||
{
|
||||
_isSprinting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e909888e8f2465fb2f032b66bbd20a4
|
||||
timeCreated: 1740766822
|
||||
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Characters {
|
||||
public class GameCharacter : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4dd42e93f8a469685be596f305ed985
|
||||
timeCreated: 1741791931
|
||||
3
Runtime/Engine/Code/Services/Simulation/Interactors.meta
Normal file
3
Runtime/Engine/Code/Services/Simulation/Interactors.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89332296442a469281fddf681dcf176e
|
||||
timeCreated: 1740881642
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Interactors {
|
||||
public interface IInteractorAsync<in TInteractable> {
|
||||
UniTask Interact(TInteractable target, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public interface IInteractor<in TInteractable> {
|
||||
public static Type InteractableType() => typeof(TInteractable);
|
||||
|
||||
void Interact(TInteractable target);
|
||||
}
|
||||
|
||||
public class GroupInteractor<TInteractable> : IInteractor<TInteractable> {
|
||||
private readonly List<IInteractor<TInteractable>> _interactors = new();
|
||||
|
||||
public void Add(IInteractor<TInteractable> interactor) => _interactors.Add(interactor);
|
||||
public void Remove(IInteractor<TInteractable> interactor) => _interactors.Remove(interactor);
|
||||
public void RemoveAll() => _interactors.Clear();
|
||||
|
||||
public void Interact(TInteractable target) {
|
||||
foreach (IInteractor<TInteractable> interactor in _interactors) {
|
||||
interactor.Interact(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbb4d95dfc6a479caeeaa9078c45f5b8
|
||||
timeCreated: 1740881665
|
||||
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
public class PhysicsObjectDragger : MonoBehaviour {
|
||||
[field: SerializeField]
|
||||
public float DampingFactor { get; private set; } = 1.0f;
|
||||
|
||||
[field: SerializeField]
|
||||
public float AngularSlowdown { get; private set; } = 90.0f;
|
||||
|
||||
[field: SerializeField]
|
||||
public float DragForce { get; private set; } = 10.0f;
|
||||
|
||||
public Rigidbody Current { get; private set; }
|
||||
|
||||
public Vector3 TargetWorldPosition { get; set; }
|
||||
|
||||
public bool IsDragging => Current != null;
|
||||
|
||||
public void Grab(Rigidbody physicsObject) {
|
||||
Current = physicsObject;
|
||||
Current.linearDamping = 5.0f;
|
||||
}
|
||||
|
||||
public void Drop() {
|
||||
if (Current == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Current.linearDamping = 0.0f;
|
||||
Current = null;
|
||||
}
|
||||
|
||||
public void FixedUpdate() {
|
||||
if (Current == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 direction = (TargetWorldPosition - Current.position).normalized;
|
||||
float distance = Vector3.Distance(TargetWorldPosition, Current.position);
|
||||
|
||||
Vector3 damping = Current.linearVelocity * DampingFactor;
|
||||
|
||||
Vector3 force = direction * Mathf.Clamp(distance * DragForce, 0, DragForce) - damping;
|
||||
Current.AddForce(force, ForceMode.Force);
|
||||
|
||||
Current.angularVelocity = Vector3.MoveTowards(Current.angularVelocity, Vector3.zero, Time.fixedDeltaTime * AngularSlowdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8498955cf5ff17145aa4bbd96edd8ca6
|
||||
3
Runtime/Engine/Code/Services/Simulation/Sensors.meta
Normal file
3
Runtime/Engine/Code/Services/Simulation/Sensors.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5e9be517bad4d0ea6d175fd19cc9e98
|
||||
timeCreated: 1740880682
|
||||
@@ -0,0 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
||||
public interface ISensor {
|
||||
GameObject Sense();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a25d318166444cdea14df9c89554436d
|
||||
timeCreated: 1740880690
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
||||
public class RaycastSensor : ISensor {
|
||||
public Ray Ray;
|
||||
public LayerMask LayerMask;
|
||||
public float MaxDistance;
|
||||
|
||||
public bool HasHit { get; private set; }
|
||||
public RaycastHit Hit { get; private set; }
|
||||
|
||||
public void Clear() {
|
||||
HasHit = false;
|
||||
Hit = default;
|
||||
}
|
||||
|
||||
public GameObject Sense() {
|
||||
HasHit = Physics.Raycast(Ray, out RaycastHit hit, MaxDistance, LayerMask);
|
||||
|
||||
if (HasHit) {
|
||||
Hit = hit;
|
||||
return Hit.transform.gameObject;
|
||||
}
|
||||
|
||||
Hit = default;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b56194d1060a4b4da3e8a2acf7453a2f
|
||||
timeCreated: 1740880749
|
||||
22
Runtime/Engine/Code/Services/Simulation/WorldConfigAsset.cs
Normal file
22
Runtime/Engine/Code/Services/Simulation/WorldConfigAsset.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
[Serializable]
|
||||
public struct WorldConfig {
|
||||
public string Name;
|
||||
|
||||
// @NOTE: stays loaded during world lifetime
|
||||
public AssetReference MainScene;
|
||||
}
|
||||
|
||||
[CreateAssetMenu(menuName = RConsts.WorldAssetMenu + "World")]
|
||||
public class WorldConfigAsset : ScriptableObject {
|
||||
|
||||
[SerializeField]
|
||||
private WorldConfig _config;
|
||||
|
||||
public WorldConfig Config => _config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dff210be181a0cd408f6b35eff2f38af
|
||||
64
Runtime/Engine/Code/Services/Simulation/WorldService.cs
Normal file
64
Runtime/Engine/Code/Services/Simulation/WorldService.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
public class WorldService : IService {
|
||||
private WorldConfig _config;
|
||||
private List<Actor> _actors = new();
|
||||
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
KillAllActors();
|
||||
}
|
||||
|
||||
public async UniTask Load(WorldConfig worldConfig) {
|
||||
_config = worldConfig;
|
||||
|
||||
AsyncOperationHandle<SceneInstance> handle = worldConfig.MainScene.LoadSceneAsync(LoadSceneMode.Additive);
|
||||
await handle.ToUniTask();
|
||||
SceneManager.SetActiveScene(handle.Result.Scene);
|
||||
}
|
||||
|
||||
public async UniTask<TActor> SpawnActor<TActor>(AssetReferenceT<GameObject> asset, CancellationToken cancellationToken) where TActor : Actor {
|
||||
GameObject gameObject = await Addressables.InstantiateAsync(asset);
|
||||
if (cancellationToken.IsCancellationRequested) {
|
||||
asset.ReleaseInstance(gameObject);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (gameObject.TryGetComponent(out TActor actor)) {
|
||||
return actor;
|
||||
}
|
||||
|
||||
asset.ReleaseInstance(gameObject);
|
||||
return null;
|
||||
}
|
||||
|
||||
public async UniTask RegisterActor(Actor actor) {
|
||||
_actors.Add(actor);
|
||||
await UniTask.Yield();
|
||||
}
|
||||
|
||||
public void KillActor(Actor actor) {
|
||||
Addressables.ReleaseInstance(actor.gameObject);
|
||||
}
|
||||
|
||||
public void KillAllActors() {
|
||||
foreach (Actor actor in _actors) {
|
||||
Addressables.ReleaseInstance(actor.gameObject);
|
||||
}
|
||||
|
||||
_actors.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e5e78f7ea7dacc42b9a0ea9a4bb1c00
|
||||
11
Runtime/Engine/Code/Services/Simulation/WorldServiceAsset.cs
Normal file
11
Runtime/Engine/Code/Services/Simulation/WorldServiceAsset.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
[CreateAssetMenu(menuName = RConsts.ServiceAssetMenu + "World")]
|
||||
public class WorldServiceAsset : ServiceAsset<WorldService> {
|
||||
public override WorldService Create() {
|
||||
return new WorldService();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f449396a11e05e41990dbddfb992815
|
||||
17
Runtime/Engine/Code/Services/UpdateLoopService.cs
Normal file
17
Runtime/Engine/Code/Services/UpdateLoopService.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
|
||||
namespace RebootKit.Engine.Services {
|
||||
public class UpdateLoopService : IService {
|
||||
public async UniTask OnInit(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
public void Add(PlayerLoopTiming playerLoopTiming) {
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Engine/Code/Services/UpdateLoopService.cs.meta
Normal file
2
Runtime/Engine/Code/Services/UpdateLoopService.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f0892c234a3a3a40a7f2516fa4dd1e0
|
||||
Reference in New Issue
Block a user