diff --git a/.gitignore b/.gitignore index 7fb0d0527..0524e8cb8 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,8 @@ crashlytics-build.properties *.blend1 Packages/packages-lock.json -GameData/PlayerSettings.msgpack +GameData/run.cc +GameData/player.cc Vault/Aetheria/.obsidian/plugins/copilot/data.json # Agent scratch, sandboxed toolchain caches, and throwaway checkouts. These had diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 985be5881..ca078459d 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -55,23 +55,6 @@ public class ActionGameManager : MonoBehaviour } } - private static PlayerSettings _playerSettings; - public static PlayerSettings PlayerSettings - { - get - { - return _playerSettings ??= File.Exists(_playerSettingsFilePath) - ? MessagePackSerializer.Deserialize(File.ReadAllBytes(_playerSettingsFilePath), CultDocumentMessagePackSerialization.OptionsFor(typeof(PlayerSettings).Assembly)) - : GetDefaultPlayerSettings(); - } - } - - private static string _playerSettingsFilePath => Path.Combine(GameDataDirectory.FullName, "PlayerSettings.msgpack"); - public static void SavePlayerSettings() - { - File.WriteAllBytes(_playerSettingsFilePath, MessagePackSerializer.Serialize(_playerSettings, CultDocumentMessagePackSerialization.OptionsFor(typeof(PlayerSettings).Assembly))); - } - private static PlayerSettings GetDefaultPlayerSettings() { var settings = new PlayerSettings(); @@ -161,7 +144,6 @@ public class ActionGameManager : MonoBehaviour // private CinemachineFramingTransposer _transposer; // private CinemachineComposer _composer; - private DirectoryInfo _loadoutPath; private bool _paused; private float _time; private int _zoomLevelIndex; @@ -205,7 +187,6 @@ public class ActionGameManager : MonoBehaviour public ItemManager ItemManager { get; private set; } public Zone Zone { get; private set; } - public List Loadouts { get; } = new List(); private readonly (float2 direction, string name)[] _directions = { (float2(0, 1), "Front"), @@ -224,24 +205,6 @@ public class ActionGameManager : MonoBehaviour get => MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(Settings.GameplaySettings.DefaultEntitySettings)); } - public void SaveLoadout(EntityPack pack) - { - File.WriteAllBytes(Path.Combine(_loadoutPath.FullName, $"{pack.Name}.loadout"), MessagePackSerializer.Serialize(pack)); - } - - private void OnApplicationQuit() => SaveState(); - - public void SaveState() - { - PlayerSettings.SavedRun = CurrentGalaxy == null ? null : new SavedGame(CultCache, CurrentGalaxy, Zone, DockedEntity ?? CurrentEntity); - if(PlayerSettings.SavedRun != null) - { - PlayerSettings.SavedRun.IsTutorial = IsTutorial; - PlayerSettings.SavedRun.ActionBarBindings = _actionBarSlots.Select(slot => slot.Save()).ToArray(); - } - SavePlayerSettings(); - } - private void OnDisable() { Input.Dispose(); @@ -264,10 +227,6 @@ public class ActionGameManager : MonoBehaviour // TODO: Process Stories - // _loadoutPath = GameDataDirectory.CreateSubdirectory("Loadouts"); - // Loadouts.AddRange(_loadoutPath.EnumerateFiles("*.loadout") - // .Select(fi => MessagePackSerializer.Deserialize(File.ReadAllBytes(fi.FullName)))); - #region Input Handling Input = new AetheriaInput(); @@ -1084,9 +1043,6 @@ public class ActionGameManager : MonoBehaviour }); } - public void SaveZone(string name) => File.WriteAllBytes( - Path.Combine(_gameDataDirectory.FullName, $"{name}.zone"), MessagePackSerializer.Serialize(Zone.PackZone())); - // public void ToggleEditMode() // { // _editMode = !_editMode; diff --git a/Assets/Scripts/ServerShared/PlayerSettings.cs b/Assets/Scripts/ServerShared/PlayerSettings.cs index ad9a8b3e6..e52f785e6 100644 --- a/Assets/Scripts/ServerShared/PlayerSettings.cs +++ b/Assets/Scripts/ServerShared/PlayerSettings.cs @@ -8,7 +8,6 @@ using MessagePack; public class PlayerSettings { [Key(0)] public string Name = "Anonymous"; - [Key(1)] public SavedGame SavedRun; [Key(2)] public bool TutorialPassed; [Key(3)] public Dictionary HashedStoryFiles = new Dictionary(); [Key(4)] public PlayerGameplaySettings GameplaySettings = new PlayerGameplaySettings(); diff --git a/Assets/Scripts/ServerShared/SavedGame.cs b/Assets/Scripts/ServerShared/SavedGame.cs index 4cd91e52c..94c1659d9 100644 --- a/Assets/Scripts/ServerShared/SavedGame.cs +++ b/Assets/Scripts/ServerShared/SavedGame.cs @@ -48,40 +48,6 @@ public class SavedGame [Key(12)] public FactionRelationship[] Relationships; - public SavedGame() { } - - // Writes a SavedZone record for every galaxy zone through the cache. - public SavedGame(CultCache cache, Galaxy galaxy, Zone currentZone, Entity currentEntity) - { - DiscoveredZones = galaxy.DiscoveredZones.Select(dz => Array.IndexOf(galaxy.Zones, dz)).ToArray(); - Background = galaxy.Background; - var factions = galaxy.HomeZones.Keys.ToArray(); - Factions = factions.Select(f => cache.RefOf(f)).ToArray(); - Relationships = galaxy.Factions.Select(f => galaxy.FactionRelationships[f]).ToArray(); - - HomeZones = galaxy.HomeZones.ToDictionary( - x => Array.IndexOf(factions, x.Key), - x => Array.IndexOf(galaxy.Zones, x.Value)); - BossZones = galaxy.BossZones.ToDictionary( - x => Array.IndexOf(factions, x.Key), - x => Array.IndexOf(galaxy.Zones, x.Value)); - - Zones = galaxy.Zones.Select(zone => cache.Upsert(new SavedZone - { - Name = zone.Name, - Position = zone.Position, - AdjacentZones = zone.AdjacentZones.Select(az=> Array.IndexOf(galaxy.Zones, az)).ToArray(), - Factions = zone.Factions.Select(f=> Array.IndexOf(factions, f)).ToArray(), - Contents = zone.Contents?.PackZone(), - Owner = zone.Owner == null ? -1 : Array.IndexOf(factions, zone.Owner) - })).ToArray(); - - CurrentZone = Array.FindIndex(galaxy.Zones, zone => zone.Contents == currentZone); - CurrentZoneEntity = currentZone.Entities.IndexOf(currentEntity); - - Entrance = Array.IndexOf(galaxy.Zones, galaxy.Entrance); - Exit = Array.IndexOf(galaxy.Zones, galaxy.Exit); - } } [CultDocument("aetheria.savedzone", "1"), MessagePackObject] diff --git a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs index d1a87c4a4..5c727996a 100644 --- a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs +++ b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs @@ -1,11 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; -using MessagePack; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using TMPro; using UniRx; using UnityEngine; @@ -85,11 +81,6 @@ public class InputDisplayLayout : MonoBehaviour void Start() { _canvas = transform.root.GetComponent(); - var path = Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.msgpack"); - // _inputLayout = ParseJson(LayoutFile.text); - _inputLayout = MessagePackSerializer.Deserialize(File.ReadAllBytes(path)); - // _inputLayout = JsonConvert.DeserializeObject(File.ReadAllText(path)); - // SaveLayout(); DisplayLayout(_inputLayout); _buttonMappings.Add(MapMouseButton(MouseLeft, "/leftButton")); @@ -147,8 +138,6 @@ public class InputDisplayLayout : MonoBehaviour RegisterMouseCallbacks(); }); - - //StartCoroutine(AssociateInputKeys(_inputLayout)); } private ButtonMapping MapMouseButton(InputDisplayButton button, string path) @@ -383,121 +372,6 @@ public class InputDisplayLayout : MonoBehaviour } } - public InputLayout ParseJson(string layout) - { - var rows = new List(); - var nextWidth = 1f; - var nextHeight = 1; - var reader = new JsonTextReader(new StringReader(layout)); - - reader.Read(); - if (reader.TokenType != JsonToken.StartArray) - throw new JsonReaderException($"Unexpected JSON format in line {reader.LineNumber}:{reader.LinePosition}, expected: StartArray, received: {Enum.GetName(typeof(JsonToken), reader.TokenType)}"); - - while(reader.Read() && reader.TokenType != JsonToken.EndArray) - { - if (reader.TokenType != JsonToken.StartArray) - throw new JsonReaderException($"Unexpected JSON format in line {reader.LineNumber}:{reader.LinePosition}, expected: StartArray, received: {Enum.GetName(typeof(JsonToken), reader.TokenType)}"); - - var row = new InputLayoutKeyRow(); - var columns = new List(); - - while (reader.Read() && reader.TokenType != JsonToken.EndArray) - { - switch (reader.TokenType) - { - case JsonToken.StartObject: - while(reader.Read() && reader.TokenType != JsonToken.EndObject) - { - switch (reader.Value.ToString()) - { - case "a": break; - case "w": - nextWidth = (float) (reader.ReadAsDouble() ?? 1.0); - break; - case "h": - nextHeight = reader.ReadAsInt32() ?? 1; - break; - case "y": - rows.Add(new InputLayoutRowSpacer{Height = (float) (reader.ReadAsDouble() ?? 0.0)}); - break; - case "x": - columns.Add(new InputLayoutColumnSpacer{Width = (float) (reader.ReadAsDouble() ?? 0.0)}); - break; - } - } - break; - case JsonToken.String: - InputLayoutKey key; - var v = reader.Value.ToString().Trim(); - if (!string.IsNullOrEmpty(v)) - { - var labels = v.Split('\n'); - key = nextHeight != 1 ? new InputLayoutMultiRowKey {Height = nextHeight} : new InputLayoutBindableKey(); - nextHeight = 1; - ((InputLayoutBindableKey) key).MainLabel = labels.Length == 2 ? labels[1] : v; - ((InputLayoutBindableKey) key).AltLabel = labels.Length == 2 ? labels[0] : ""; - } - else - key = new InputLayoutKey(); - - key.Width = nextWidth; - columns.Add(key); - nextWidth = 1f; - break; - default: - throw new JsonReaderException($"Unexpected JSON format in line {reader.LineNumber}:{reader.LinePosition}"); - } - } - - row.Columns = columns.ToArray(); - rows.Add(row); - } - - return new InputLayout {Rows = rows.ToArray()}; - } - - private IEnumerator AssociateInputKeys() - { - var path = ""; - var keyPress = new InputAction(binding: "//