something
This commit is contained in:
@@ -23,7 +23,7 @@ namespace RebootKitEditor.PropertyDrawers {
|
||||
}
|
||||
|
||||
public string BuildGuidString(SerializedProperty[] parts) {
|
||||
StringBuilder sb = new();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("{0:X8}", parts[0].uintValue);
|
||||
sb.AppendFormat("{0:X8}", parts[1].uintValue);
|
||||
sb.AppendFormat("{0:X8}", parts[2].uintValue);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
ScrollView scrollView = new() {
|
||||
ScrollView scrollView = new ScrollView {
|
||||
style = {
|
||||
flexGrow = 1
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
ConfigVarsContainer.Init();
|
||||
|
||||
foreach (ConfigVar cvar in ConfigVarsContainer.All()) {
|
||||
VisualElement varContainer = new() {
|
||||
VisualElement varContainer = new VisualElement {
|
||||
style = {
|
||||
marginBottom = 8,
|
||||
paddingBottom = 8,
|
||||
@@ -28,14 +28,14 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
|
||||
VisualElement valueContainer = new() {
|
||||
VisualElement valueContainer = new VisualElement {
|
||||
style = {
|
||||
flexDirection = FlexDirection.Row
|
||||
}
|
||||
};
|
||||
varContainer.Add(valueContainer);
|
||||
|
||||
Label nameLabel = new(cvar.name) {
|
||||
Label nameLabel = new Label(cvar.name) {
|
||||
style = {
|
||||
color = new Color(0.7f, 0.9f, 0.9f),
|
||||
unityFontStyleAndWeight = FontStyle.Bold
|
||||
@@ -43,7 +43,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
valueContainer.Add(nameLabel);
|
||||
|
||||
Label valueLabel = new(cvar.ToString()) {
|
||||
Label valueLabel = new Label(cvar.ToString()) {
|
||||
style = {
|
||||
color = RTheme.s_FirstColor
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
valueContainer.Add(CreateFlagLabel("ReadOnly", new Color(0.13f, 0.07f, 0.47f)));
|
||||
}
|
||||
|
||||
Label descLabel = new(cvar.description) {
|
||||
Label descLabel = new Label(cvar.description) {
|
||||
style = {
|
||||
fontSize = 10,
|
||||
color = new Color(0.7f, 0.7f, 0.7f)
|
||||
@@ -81,7 +81,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
VisualElement CreateFlagLabel(string text, Color color) {
|
||||
Label label = new(text) {
|
||||
Label label = new Label(text) {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.7f, 0.7f, 0.7f),
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
public class GameServicesView : IView {
|
||||
VisualElement m_RootElement;
|
||||
|
||||
readonly List<Editor> m_ServiceEditors = new();
|
||||
readonly List<Editor> m_ServiceEditors = new List<Editor>();
|
||||
|
||||
[Inject] EngineConfigAsset m_EngineConfigAsset;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
VisualElement CreateServicesView<T>(ServiceAsset<T> serviceAsset) where T : class, IService {
|
||||
VisualElement root = new() {
|
||||
VisualElement root = new VisualElement {
|
||||
style = {
|
||||
paddingBottom = 4,
|
||||
paddingTop = 4,
|
||||
@@ -60,7 +60,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
|
||||
VisualElement header = new() {
|
||||
VisualElement header = new VisualElement {
|
||||
style = {
|
||||
backgroundColor = new Color(0.2f, 0.2f, 0.2f),
|
||||
paddingLeft = 8,
|
||||
@@ -73,7 +73,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
root.Add(header);
|
||||
|
||||
Label nameLabel = new(serviceAsset.name) {
|
||||
Label nameLabel = new Label(serviceAsset.name) {
|
||||
style = {
|
||||
color = new Color(0.7f, 0.9f, 0.9f),
|
||||
unityFontStyleAndWeight = FontStyle.Bold
|
||||
@@ -81,7 +81,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
header.Add(nameLabel);
|
||||
|
||||
VisualElement editorView = new() {
|
||||
VisualElement editorView = new VisualElement {
|
||||
style = {
|
||||
backgroundColor = new Color(0.3f, 0.3f, 0.3f),
|
||||
paddingLeft = 10,
|
||||
@@ -96,7 +96,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
Editor editor = Editor.CreateEditor(serviceAsset);
|
||||
m_ServiceEditors.Add(editor);
|
||||
|
||||
InspectorElement inspectorElement = new(editor);
|
||||
InspectorElement inspectorElement = new InspectorElement(editor);
|
||||
editorView.Add(inspectorElement);
|
||||
|
||||
return root;
|
||||
|
||||
@@ -11,14 +11,14 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
VisualElement rootContainer = new() {
|
||||
VisualElement rootContainer = new VisualElement {
|
||||
style = {
|
||||
flexGrow = 1,
|
||||
fontSize = 14
|
||||
}
|
||||
};
|
||||
|
||||
Label label = new($"{Application.productName} {Application.version}") {
|
||||
Label label = new Label($"{Application.productName} {Application.version}") {
|
||||
style = {
|
||||
fontSize = 18,
|
||||
unityFontStyleAndWeight = FontStyle.Bold
|
||||
@@ -26,7 +26,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
rootContainer.Add(label);
|
||||
|
||||
VisualElement persistentPathContainer = new() {
|
||||
VisualElement persistentPathContainer = new VisualElement {
|
||||
style = {
|
||||
marginTop = 8,
|
||||
marginBottom = 8,
|
||||
@@ -40,7 +40,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
|
||||
Label persistentPathLabel = new($"Persistent Path: {Application.persistentDataPath}") {
|
||||
Label persistentPathLabel = new Label($"Persistent Path: {Application.persistentDataPath}") {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.7f, 0.9f, 0.9f)
|
||||
@@ -48,7 +48,9 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
persistentPathContainer.Add(persistentPathLabel);
|
||||
|
||||
Button openPersistentPathButton = new(() => { Application.OpenURL(Application.persistentDataPath); }) {
|
||||
Button openPersistentPathButton = new Button(() => {
|
||||
Application.OpenURL(Application.persistentDataPath);
|
||||
}) {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
width = 48
|
||||
@@ -59,7 +61,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
|
||||
rootContainer.Add(persistentPathContainer);
|
||||
|
||||
Label onGameRunScriptLabel = new("On Game Run Script (User):") {
|
||||
Label onGameRunScriptLabel = new Label("On Game Run Script (User):") {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.7f, 0.9f, 0.9f)
|
||||
@@ -67,7 +69,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
rootContainer.Add(onGameRunScriptLabel);
|
||||
|
||||
TextField onGameRunScriptTextField = new() {
|
||||
TextField onGameRunScriptTextField = new TextField {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
},
|
||||
@@ -80,7 +82,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
});
|
||||
rootContainer.Add(onGameRunScriptTextField);
|
||||
|
||||
Label consoleCommandsLabel = new("Console Commands:") {
|
||||
Label consoleCommandsLabel = new Label("Console Commands:") {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.7f, 0.9f, 0.9f)
|
||||
@@ -90,7 +92,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
|
||||
ConsoleService.ConsoleCommand[] consoleCommands = ConsoleService.GenerateCommandsToRegister();
|
||||
foreach (ConsoleService.ConsoleCommand consoleCommand in consoleCommands) {
|
||||
VisualElement commandContainer = new() {
|
||||
VisualElement commandContainer = new VisualElement {
|
||||
style = {
|
||||
flexDirection = FlexDirection.Row,
|
||||
marginTop = 4,
|
||||
@@ -101,7 +103,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
paddingBottom = 4,
|
||||
}
|
||||
};
|
||||
Label commandLabel = new(consoleCommand.name) {
|
||||
Label commandLabel = new Label(consoleCommand.name) {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.7f, 0.9f, 0.9f)
|
||||
@@ -109,7 +111,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
commandContainer.Add(commandLabel);
|
||||
|
||||
Label descriptionLabel = new(consoleCommand.description) {
|
||||
Label descriptionLabel = new Label(consoleCommand.description) {
|
||||
style = {
|
||||
fontSize = 12,
|
||||
color = new Color(0.5f, 0.7f, 0.7f)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
public class RebootEditorWindow : EditorWindow {
|
||||
static readonly Logger s_logger = new(nameof(RebootEditorWindow));
|
||||
static readonly Logger s_logger = new Logger(nameof(RebootEditorWindow));
|
||||
|
||||
EngineConfigAsset m_EngineConfigAsset;
|
||||
DIContext m_DIContext;
|
||||
|
||||
@@ -12,16 +12,16 @@ namespace RebootKitEditor.RebootWindow {
|
||||
public VisualElement container;
|
||||
}
|
||||
|
||||
readonly List<Tab> m_Tabs = new();
|
||||
readonly List<VisualElement> m_TabContents = new();
|
||||
readonly List<Button> m_TabButtons = new();
|
||||
readonly List<Tab> m_Tabs = new List<Tab>();
|
||||
readonly List<VisualElement> m_TabContents = new List<VisualElement>();
|
||||
readonly List<Button> m_TabButtons = new List<Button>();
|
||||
int m_CurrentTabIndex = -1;
|
||||
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
VisualElement rootContainer = new() {
|
||||
VisualElement rootContainer = new VisualElement {
|
||||
style = {
|
||||
flexDirection = FlexDirection.Row,
|
||||
flexGrow = 1,
|
||||
@@ -31,7 +31,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
|
||||
VisualElement tabContainer = new() {
|
||||
VisualElement tabContainer = new VisualElement {
|
||||
style = {
|
||||
flexDirection = FlexDirection.Row,
|
||||
width = new StyleLength(new Length(100, LengthUnit.Percent)),
|
||||
@@ -39,7 +39,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
rootContainer.Add(tabContainer);
|
||||
|
||||
VisualElement tabButtonsContainer = new() {
|
||||
VisualElement tabButtonsContainer = new VisualElement {
|
||||
style = {
|
||||
flexDirection = FlexDirection.Column,
|
||||
borderRightWidth = 1,
|
||||
@@ -51,7 +51,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
tabContainer.Add(tabButtonsContainer);
|
||||
|
||||
VisualElement contentContainer = new() {
|
||||
VisualElement contentContainer = new VisualElement {
|
||||
style = {
|
||||
flexGrow = 1,
|
||||
paddingLeft = 4,
|
||||
@@ -66,7 +66,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
Tab tab = m_Tabs[i];
|
||||
int index = i;
|
||||
|
||||
Button button = new(() => SetActiveTab(index)) {
|
||||
Button button = new Button(() => SetActiveTab(index)) {
|
||||
text = tab.name,
|
||||
style = {
|
||||
paddingLeft = 8,
|
||||
@@ -94,7 +94,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
public void AddTab(string name, IView view) {
|
||||
VisualElement tabContainer = new() {
|
||||
VisualElement tabContainer = new VisualElement {
|
||||
name = "rr_tab__container",
|
||||
style = {
|
||||
flexGrow = 1
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
VisualElement root = new() {
|
||||
VisualElement root = new VisualElement {
|
||||
style = {
|
||||
paddingBottom = 4,
|
||||
paddingTop = 4,
|
||||
@@ -33,7 +33,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
|
||||
VisualElement CreateWorldView(WorldConfigAsset worldConfigAsset) {
|
||||
VisualElement root = new() {
|
||||
VisualElement root = new VisualElement {
|
||||
style = {
|
||||
backgroundColor = new Color(0.1f, 0.1f, 0.1f),
|
||||
paddingBottom = 4,
|
||||
@@ -45,7 +45,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
|
||||
Label label = new(worldConfigAsset.name) {
|
||||
Label label = new Label(worldConfigAsset.name) {
|
||||
style = {
|
||||
color = new Color(0.7f, 0.9f, 0.9f),
|
||||
unityFontStyleAndWeight = FontStyle.Bold
|
||||
@@ -53,7 +53,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
};
|
||||
root.Add(label);
|
||||
|
||||
Button openButton = new(() => OpenWorldScenes(worldConfigAsset)) {
|
||||
Button openButton = new Button(() => OpenWorldScenes(worldConfigAsset)) {
|
||||
text = "Open",
|
||||
style = {
|
||||
backgroundColor = new Color(0.2f, 0.2f, 0.2f),
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace RebootKitEditor.Utils {
|
||||
const string k_CVarDefaultValueStringValueProperty = "stringValue";
|
||||
|
||||
public static CVarSerializedProperties Find(SerializedProperty cvar) {
|
||||
CVarSerializedProperties properties = new();
|
||||
CVarSerializedProperties properties = new CVarSerializedProperties();
|
||||
properties.flags = cvar.FindPropertyRelative(k_CVarFlagsProperty);
|
||||
properties.name = cvar.FindPropertyRelative(k_CVarNameProperty);
|
||||
properties.description = cvar.FindPropertyRelative(k_CVarDescriptionProperty);
|
||||
|
||||
@@ -29,13 +29,13 @@ namespace SzafaKitEditor.VisualElements {
|
||||
}
|
||||
|
||||
void CreateInlineField() {
|
||||
VisualElement box = new() {
|
||||
VisualElement box = new VisualElement {
|
||||
style = {
|
||||
height = 48
|
||||
}
|
||||
};
|
||||
|
||||
Label nameLabel = new("NAME") {
|
||||
Label nameLabel = new Label("NAME") {
|
||||
style = {
|
||||
unityFontStyleAndWeight = FontStyle.Bold,
|
||||
backgroundColor = new Color(0.1f, 0.1f, 0.1f, 1.0f)
|
||||
@@ -43,7 +43,7 @@ namespace SzafaKitEditor.VisualElements {
|
||||
};
|
||||
box.Add(nameLabel);
|
||||
|
||||
Button button = new(ToggleDetails) {
|
||||
Button button = new Button(ToggleDetails) {
|
||||
text = "...",
|
||||
style = {
|
||||
width = new StyleLength(new Length(64.0f, LengthUnit.Pixel)),
|
||||
@@ -62,10 +62,10 @@ namespace SzafaKitEditor.VisualElements {
|
||||
}
|
||||
|
||||
void CreateDetailsBox() {
|
||||
PropertyField nameField = new(_nameProperty);
|
||||
PropertyField defaultValueKindField = new(_defaultValueKindProperty);
|
||||
PropertyField numberField = new(_defaultValueNumberProperty);
|
||||
PropertyField stringField = new(_defaultValueStringProperty);
|
||||
PropertyField nameField = new PropertyField(_nameProperty);
|
||||
PropertyField defaultValueKindField = new PropertyField(_defaultValueKindProperty);
|
||||
PropertyField numberField = new PropertyField(_defaultValueNumberProperty);
|
||||
PropertyField stringField = new PropertyField(_defaultValueStringProperty);
|
||||
|
||||
_details = new VisualElement {
|
||||
style = {
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace RebootKit.Engine.Foundation {
|
||||
}
|
||||
|
||||
public static class ConfigVarsContainer {
|
||||
static readonly Logger s_logger = new(nameof(ConfigVarsContainer));
|
||||
static readonly Logger s_logger = new Logger(nameof(ConfigVarsContainer));
|
||||
|
||||
static readonly List<ConfigVar> s_configVars = new();
|
||||
static readonly List<ConfigVar> s_configVars = new List<ConfigVar>();
|
||||
|
||||
public static void Register(ConfigVar cvar) {
|
||||
if (s_configVars.AsValueEnumerable().Any(c => c.name.Equals(cvar.name, StringComparison.Ordinal))) {
|
||||
@@ -106,7 +106,7 @@ namespace RebootKit.Engine.Foundation {
|
||||
|
||||
s_logger.Info("Saving cvars to file: " + path);
|
||||
|
||||
StringBuilder sb = new();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (ConfigVar cvar in All()) {
|
||||
if (!cvar.flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace RebootKit.Engine.Foundation {
|
||||
const BindingFlags k_fieldsBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
const BindingFlags k_methodsBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
|
||||
static readonly Logger s_logger = new(nameof(DIContext));
|
||||
static readonly Logger s_logger = new Logger(nameof(DIContext));
|
||||
|
||||
readonly Dictionary<Type, object> m_BindingsMaps = new();
|
||||
readonly List<IFieldInjector> m_FieldInjectors = new();
|
||||
readonly Dictionary<Type, object> m_BindingsMaps = new Dictionary<Type, object>();
|
||||
readonly List<IFieldInjector> m_FieldInjectors = new List<IFieldInjector>();
|
||||
|
||||
public DIContext() {
|
||||
Bind(this);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace RebootKit.Engine.Foundation {
|
||||
|
||||
public class ControllersManager<TController> : IDisposable where TController : IController {
|
||||
readonly CancellationToken _cancellationToken;
|
||||
readonly List<TController> _controllers = new();
|
||||
readonly List<TController> _controllers = new List<TController>();
|
||||
bool _isRunning;
|
||||
|
||||
public ControllersManager(CancellationToken cancellationToken) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace RebootKit.Engine.Foundation {
|
||||
|
||||
[DefaultExecutionOrder(-1000)]
|
||||
public class SceneContext : MonoBehaviour {
|
||||
static readonly Logger s_logger = new(nameof(SceneContext));
|
||||
static readonly Logger s_logger = new Logger(nameof(SceneContext));
|
||||
|
||||
[SerializeField] SceneDependencyInstaller[] m_Installers;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
namespace RebootKit.Engine.Foundation {
|
||||
[Serializable]
|
||||
public struct SerializableGuid : IEquatable<SerializableGuid> {
|
||||
public static SerializableGuid Zero = new(0, 0, 0, 0);
|
||||
public static SerializableGuid Zero = new SerializableGuid(0, 0, 0, 0);
|
||||
|
||||
[SerializeField, HideInInspector] public uint A;
|
||||
[SerializeField, HideInInspector] public uint B;
|
||||
|
||||
7
Runtime/Engine/Code/Graphics/MainCameraService.cs → Runtime/Engine/Code/Graphics/MainCameraSetter.cs
Executable file → Normal file
7
Runtime/Engine/Code/Graphics/MainCameraService.cs → Runtime/Engine/Code/Graphics/MainCameraSetter.cs
Executable file → Normal file
@@ -1,12 +1,13 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Graphics {
|
||||
public class MainCameraService : ServiceMonoBehaviour {
|
||||
public class MainCameraSetter : MonoBehaviour {
|
||||
[field: SerializeField]
|
||||
public Camera Camera { get; private set; }
|
||||
|
||||
public override void Dispose() {
|
||||
void Awake() {
|
||||
RR.MainCamera = Camera;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
Runtime/Engine/Code/Graphics/MainCameraService.cs.meta → Runtime/Engine/Code/Graphics/MainCameraSetter.cs.meta
Executable file → Normal file
0
Runtime/Engine/Code/Graphics/MainCameraService.cs.meta → Runtime/Engine/Code/Graphics/MainCameraSetter.cs.meta
Executable file → Normal file
@@ -7,7 +7,7 @@ using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.Main {
|
||||
public static class EntryPoint {
|
||||
static readonly Logger s_logger = new(nameof(EntryPoint));
|
||||
static readonly Logger s_logger = new Logger(nameof(EntryPoint));
|
||||
|
||||
static CancellationTokenSource s_cancellationTokenSource;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace RebootKit.Engine.Main {
|
||||
}
|
||||
|
||||
public static class RR {
|
||||
static readonly Logger s_logger = new("RR");
|
||||
static readonly Logger s_Logger = new Logger("RR");
|
||||
|
||||
[ConfigVar("con.write_log", 1, "Enables writing game log to console output")]
|
||||
static ConfigVar s_writeLogToConsole;
|
||||
@@ -48,6 +48,8 @@ namespace RebootKit.Engine.Main {
|
||||
public static WorldService World => s_worldService;
|
||||
public static GameModesService GameModes => s_gameModesService;
|
||||
|
||||
public static Camera MainCamera { get; internal set; }
|
||||
|
||||
static IGame s_game;
|
||||
|
||||
public static async UniTask InitAsync(EngineConfigAsset configAsset, CancellationToken cancellationToken) {
|
||||
@@ -56,11 +58,11 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
s_engineConfigAsset = configAsset;
|
||||
|
||||
s_logger.Info("Initializing");
|
||||
s_Logger.Info("Initializing");
|
||||
s_servicesBag = new DisposableBag();
|
||||
s_disposableBag = new DisposableBag();
|
||||
|
||||
s_logger.Debug("Registering core services");
|
||||
s_Logger.Debug("Registering core services");
|
||||
s_consoleService = CreateService(s_engineConfigAsset.coreServices.consoleService);
|
||||
s_inputService = CreateService(s_engineConfigAsset.coreServices.inputService);
|
||||
s_worldService = CreateService(s_engineConfigAsset.coreServices.worldService);
|
||||
@@ -68,14 +70,14 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
await InitializeAssetsAsync(cancellationToken);
|
||||
|
||||
s_logger.Debug("Creating game");
|
||||
s_Logger.Debug("Creating game");
|
||||
s_game = s_engineConfigAsset.gameAsset.CreateGame();
|
||||
|
||||
await s_game.InitAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public static void Shutdown() {
|
||||
s_logger.Info("Shutting down");
|
||||
s_Logger.Info("Shutting down");
|
||||
s_servicesBag.Dispose();
|
||||
s_disposableBag.Dispose();
|
||||
}
|
||||
@@ -85,11 +87,11 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
#if UNITY_EDITOR
|
||||
string scriptContent = UnityEditor.EditorPrefs.GetString("RebootKitEditor.OnGameRunScriptContent", "");
|
||||
s_logger.Info($"Executing script: {scriptContent}");
|
||||
s_Logger.Info($"Executing script: {scriptContent}");
|
||||
|
||||
if (!string.IsNullOrEmpty(scriptContent)) {
|
||||
foreach (string cmd in scriptContent.Split('\n')) {
|
||||
s_logger.Info($"Executing command: {cmd}");
|
||||
s_Logger.Info($"Executing command: {cmd}");
|
||||
Console.Execute(cmd);
|
||||
}
|
||||
}
|
||||
@@ -97,8 +99,8 @@ namespace RebootKit.Engine.Main {
|
||||
}
|
||||
|
||||
// Assets API
|
||||
static readonly List<GameModeAsset> s_gameModesAssets = new();
|
||||
static readonly List<WorldConfigAsset> s_worldConfigsAssets = new();
|
||||
static readonly List<GameModeAsset> s_gameModesAssets = new List<GameModeAsset>();
|
||||
static readonly List<WorldConfigAsset> s_worldConfigsAssets = new List<WorldConfigAsset>();
|
||||
|
||||
public static IReadOnlyList<GameModeAsset> GameModesAssets => s_gameModesAssets;
|
||||
public static IReadOnlyList<WorldConfigAsset> WorldConfigsAssets => s_worldConfigsAssets;
|
||||
@@ -107,10 +109,10 @@ namespace RebootKit.Engine.Main {
|
||||
s_gameModesAssets.Clear();
|
||||
s_worldConfigsAssets.Clear();
|
||||
|
||||
s_logger.Info("Loading game assets");
|
||||
s_Logger.Info("Loading game assets");
|
||||
|
||||
await Addressables.LoadAssetsAsync<GameModeAsset>("game_mode", asset => { s_gameModesAssets.Add(asset); }).ToUniTask(cancellationToken: cancellationToken);
|
||||
s_logger.Info($"Loaded {s_gameModesAssets.Count} game modes");
|
||||
s_Logger.Info($"Loaded {s_gameModesAssets.Count} game modes");
|
||||
|
||||
await Addressables.LoadAssetsAsync<WorldConfigAsset>("world", asset => { s_worldConfigsAssets.Add(asset); }).ToUniTask(cancellationToken: cancellationToken);
|
||||
}
|
||||
@@ -121,7 +123,7 @@ namespace RebootKit.Engine.Main {
|
||||
throw new ArgumentNullException(nameof(gameMode));
|
||||
}
|
||||
|
||||
s_logger.Info($"Starting game mode: {gameMode.name} in world: {world.name}");
|
||||
s_Logger.Info($"Starting game mode: {gameMode.name} in world: {world.name}");
|
||||
s_gameModesService.Start(gameMode, world);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
}
|
||||
|
||||
public class ConsoleService : IService {
|
||||
static readonly Logger s_logger = new(nameof(ConsoleService));
|
||||
static readonly Logger s_logger = new Logger(nameof(ConsoleService));
|
||||
|
||||
public struct ConsoleCommand {
|
||||
public string name;
|
||||
@@ -30,7 +30,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
public Action<string[]> action;
|
||||
}
|
||||
|
||||
readonly List<ConsoleCommand> m_ConsoleCommands = new();
|
||||
readonly List<ConsoleCommand> m_ConsoleCommands = new List<ConsoleCommand>();
|
||||
|
||||
FileStream m_LogFileStream;
|
||||
TextWriter m_LogFileWriter;
|
||||
@@ -149,7 +149,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
.SelectMany(type => type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
|
||||
.Where(method => method.GetCustomAttributes(typeof(RCCMD), false).Length > 0);
|
||||
|
||||
List<ConsoleCommand> commands = new();
|
||||
List<ConsoleCommand> commands = new List<ConsoleCommand>();
|
||||
foreach (MethodInfo method in methods) {
|
||||
RCCMD attribute = (RCCMD)method.GetCustomAttributes(typeof(RCCMD), false)[0];
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
|
||||
[RCCMD("help", "Prints help message with all commands and cvars")]
|
||||
public static void PrintHelpCommand(string[] args) {
|
||||
StringBuilder message = new();
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
message.AppendLine("Available commands:");
|
||||
foreach (ConsoleCommand command in RR.Console.m_ConsoleCommands) {
|
||||
@@ -224,7 +224,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
|
||||
[RCCMD("cvars", "Prints all cvars")]
|
||||
public static void PrintCVars(string[] args) {
|
||||
StringBuilder message = new();
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
foreach (ConfigVar cvar in ConfigVarsContainer.All()) {
|
||||
message.AppendLine($"{cvar.name} - {cvar}");
|
||||
@@ -238,7 +238,7 @@ namespace RebootKit.Engine.Services.Console {
|
||||
|
||||
s_logger.Info("Saving cvars to file: " + path);
|
||||
|
||||
StringBuilder sb = new();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (ConfigVar cvar in ConfigVarsContainer.All()) {
|
||||
if (!cvar.flags.HasFlag(CVarFlags.ReadOnly)) {
|
||||
|
||||
@@ -5,10 +5,10 @@ using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
namespace RebootKit.Engine.Services.Console {
|
||||
[CreateAssetMenu(menuName = RConsts.k_ServiceAssetMenu + "Console")]
|
||||
public class ConsoleServiceAsset : ServiceAsset<ConsoleService> {
|
||||
static readonly Logger s_logger = new(nameof(ConsoleServiceAsset));
|
||||
static readonly Logger s_logger = new Logger(nameof(ConsoleServiceAsset));
|
||||
|
||||
public override ConsoleService Create() {
|
||||
ConsoleService service = new();
|
||||
ConsoleService service = new ConsoleService();
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.Services.ConsoleUI {
|
||||
public class ConsoleUIService : ServiceMonoBehaviour {
|
||||
static readonly Logger s_logger = new(nameof(ConsoleUIService));
|
||||
static readonly Logger s_logger = new Logger(nameof(ConsoleUIService));
|
||||
|
||||
[SerializeField] ConsoleVC m_ConsoleVC;
|
||||
[SerializeField] ScriptableInputAction m_ToggleAction;
|
||||
|
||||
readonly StringBuilder m_Content = new();
|
||||
readonly StringBuilder m_Content = new StringBuilder();
|
||||
|
||||
public bool IsVisible => m_ConsoleVC.gameObject.activeSelf;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.Services.ConsoleUI {
|
||||
public class ConsoleVC : MonoBehaviour {
|
||||
static readonly Logger s_logger = new(nameof(ConsoleVC));
|
||||
static readonly Logger s_logger = new Logger(nameof(ConsoleVC));
|
||||
|
||||
[SerializeField] UIDocument m_Document;
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ using RebootKit.Engine.Services.Simulation;
|
||||
|
||||
namespace RebootKit.Engine.Services.GameMode {
|
||||
public class GameModesService : IService {
|
||||
static readonly Logger s_logger = new(nameof(GameModesService));
|
||||
static readonly Logger s_logger = new Logger(nameof(GameModesService));
|
||||
|
||||
[Inject] DIContext m_DIContext;
|
||||
|
||||
GameModeAsset m_GameModeAsset;
|
||||
|
||||
readonly CancellationTokenSource m_DestroyCancellationTokenSource = new();
|
||||
readonly CancellationTokenSource m_DestroyCancellationTokenSource = new CancellationTokenSource();
|
||||
DisposableBag m_ActiveGameModeDisposableBag;
|
||||
readonly ReactiveProperty<IGameMode> m_ActiveGameMode = new(null);
|
||||
readonly ReactiveProperty<IGameMode> m_ActiveGameMode = new ReactiveProperty<IGameMode>(null);
|
||||
|
||||
public ReadOnlyReactiveProperty<IGameMode> ActiveGameMode => m_ActiveGameMode;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace RebootKit.Engine.Services.Input {
|
||||
[SerializeField] InputService.Config m_Config;
|
||||
|
||||
public override InputService Create() {
|
||||
InputService instance = new(m_Config);
|
||||
InputService instance = new InputService(m_Config);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace RebootKit.Engine.Services.Simulation.Interactors {
|
||||
}
|
||||
|
||||
public class GroupInteractor<TInteractable> : IInteractor<TInteractable> {
|
||||
readonly List<IInteractor<TInteractable>> m_Interactors = new();
|
||||
readonly List<IInteractor<TInteractable>> m_Interactors = new List<IInteractor<TInteractable>>();
|
||||
|
||||
public void Interact(TInteractable target) {
|
||||
foreach (IInteractor<TInteractable> interactor in m_Interactors) interactor.Interact(target);
|
||||
|
||||
@@ -5,14 +5,18 @@ using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation {
|
||||
public interface IWorldContext {
|
||||
}
|
||||
|
||||
public class WorldService : IService {
|
||||
static readonly Logger s_logger = new(nameof(WorldService));
|
||||
static readonly Logger s_Logger = new Logger(nameof(WorldService));
|
||||
|
||||
enum WorldState {
|
||||
Unloaded,
|
||||
@@ -23,8 +27,10 @@ namespace RebootKit.Engine.Services.Simulation {
|
||||
WorldState m_WorldState = WorldState.Unloaded;
|
||||
WorldConfig m_Config;
|
||||
AsyncOperationHandle<SceneInstance> m_SceneInstance;
|
||||
|
||||
public IWorldContext Context { get; private set; }
|
||||
|
||||
readonly List<Actor> m_Actors = new();
|
||||
readonly List<Actor> m_Actors = new List<Actor>();
|
||||
|
||||
public void Dispose() {
|
||||
Unload();
|
||||
@@ -45,6 +51,11 @@ namespace RebootKit.Engine.Services.Simulation {
|
||||
SceneManager.SetActiveScene(m_SceneInstance.Result.Scene);
|
||||
|
||||
foreach (GameObject root in m_SceneInstance.Result.Scene.GetRootGameObjects()) {
|
||||
if (root.TryGetComponent(out IWorldContext worldContext)) {
|
||||
Assert.IsNull(Context, "WorldContext is already set. There should be only one WorldContext in the scene.");
|
||||
Context = worldContext;
|
||||
}
|
||||
|
||||
foreach (Actor actor in root.GetComponentsInChildren<Actor>()) {
|
||||
RegisterActor(actor);
|
||||
}
|
||||
@@ -58,7 +69,7 @@ namespace RebootKit.Engine.Services.Simulation {
|
||||
|
||||
TRequiredActor actor = m_Actors.FirstOrDefault(t => t is TRequiredActor) as TRequiredActor;
|
||||
if (actor is null) {
|
||||
s_logger.Error($"Actor of type {typeof(TRequiredActor)} not found in the scene");
|
||||
s_Logger.Error($"Actor of type {typeof(TRequiredActor)} not found in the scene");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -74,6 +85,7 @@ namespace RebootKit.Engine.Services.Simulation {
|
||||
}
|
||||
|
||||
m_WorldState = WorldState.Unloaded;
|
||||
Context = null;
|
||||
}
|
||||
|
||||
public async UniTask<TActor> SpawnActor<TActor>(AssetReferenceT<GameObject> asset, CancellationToken cancellationToken) where TActor : Actor {
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace RebootKit.Engine.UI {
|
||||
}
|
||||
|
||||
public class VisualElementBuilder : IVisualElementBuilder {
|
||||
readonly List<string> m_ClassNames = new();
|
||||
readonly List<string> m_ClassNames = new List<string>();
|
||||
|
||||
Color? m_BackgroundColor;
|
||||
float2? m_Size;
|
||||
@@ -47,7 +47,7 @@ namespace RebootKit.Engine.UI {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
VisualElement element = new();
|
||||
VisualElement element = new VisualElement();
|
||||
element.AddToClassList(Classes.k_Base);
|
||||
|
||||
foreach (string className in m_ClassNames) {
|
||||
@@ -79,12 +79,12 @@ namespace RebootKit.Engine.UI {
|
||||
}
|
||||
|
||||
public VisualElement Build() {
|
||||
Label label = new(m_Text);
|
||||
Label label = new Label(m_Text);
|
||||
label.AddToClassList(Classes.k_Base);
|
||||
label.AddToClassList(Classes.k_Label);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static LabelBuilder New(string text) => new(text);
|
||||
public static LabelBuilder New(string text) => new LabelBuilder(text);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.UI {
|
||||
public abstract class UIDocumentView : MonoBehaviour, IView, IVisualElementBuilder {
|
||||
static readonly Logger s_logger = new(nameof(UIDocumentView));
|
||||
static readonly Logger s_logger = new Logger(nameof(UIDocumentView));
|
||||
|
||||
[SerializeField] UIDocument m_Document;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Tests.Runtime.Engine {
|
||||
public class DIContextTests {
|
||||
[Test]
|
||||
public void Single_Bind_And_Resolve() {
|
||||
DIContext context = new();
|
||||
DIContext context = new DIContext();
|
||||
context.Bind<ITestService>(new TestServiceA());
|
||||
|
||||
ITestService testService = context.Resolve<ITestService>();
|
||||
@@ -36,10 +36,10 @@ namespace Tests.Runtime.Engine {
|
||||
|
||||
[Test]
|
||||
public void Single_Bind_And_Field_Inject() {
|
||||
DIContext context = new();
|
||||
DIContext context = new DIContext();
|
||||
context.Bind<ITestService>(new TestServiceB());
|
||||
|
||||
TestObject obj = new();
|
||||
TestObject obj = new TestObject();
|
||||
context.Inject(obj);
|
||||
|
||||
Assert.IsNotNull(obj.Service, "obj.Service != null");
|
||||
@@ -48,10 +48,10 @@ namespace Tests.Runtime.Engine {
|
||||
|
||||
[Test]
|
||||
public void Single_Bind_And_Method_Inject() {
|
||||
DIContext context = new();
|
||||
DIContext context = new DIContext();
|
||||
context.Bind<ITestService>(new TestServiceA());
|
||||
|
||||
TestObjectMethod obj = new();
|
||||
TestObjectMethod obj = new TestObjectMethod();
|
||||
context.Inject(obj);
|
||||
|
||||
Assert.IsNotNull(obj.Service, "obj.Service != null");
|
||||
|
||||
Reference in New Issue
Block a user