From 3dfce70fdc801a76ff052162d4189c25484d6aa1 Mon Sep 17 00:00:00 2001 From: Acruid Date: Tue, 6 Feb 2018 19:34:36 -0800 Subject: [PATCH] Map Blueprint Save/Loading (#32) * Change entry point to new system. * Map saving/loading works. * Cleans up old code. * Saving and Loading of blueprints works. * Saving and Loading of blueprints works. * Updated the nuget 'YamlDotNet' package to 4.3.0. * Submodules are trash --- .gitmodules | 2 +- BuildChecker/BuildChecker.csproj | 11 ++++- Content.Client/Content.Client.csproj | 12 ++++-- Content.Client/Prototypes/DiscoBall.cs | 20 +++++---- Content.Client/app.config | 11 +++++ Content.Client/packages.config | 6 +-- Content.Server/Content.Server.csproj | 11 +++-- Content.Server/EntryPoint.cs | 58 ++++++++------------------ Content.Server/app.config | 11 +++++ Content.Server/packages.config | 6 +-- Content.Shared/Content.Shared.csproj | 12 ++++-- Content.Shared/app.config | 11 +++++ Content.Shared/packages.config | 6 +-- SpaceStation14Content.sln | 19 +++++---- engine | 2 +- 15 files changed, 116 insertions(+), 82 deletions(-) create mode 100644 Content.Client/app.config create mode 100644 Content.Server/app.config create mode 100644 Content.Shared/app.config diff --git a/.gitmodules b/.gitmodules index 03081a0dd7..086894f330 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "engine"] path = engine url = https://github.com/space-wizards/space-station-14.git - branch = 56508df91937fd456bc5411008575169d93b262b \ No newline at end of file + branch = a8c302eadb516f919df1f751af8a5d2993458b2e \ No newline at end of file diff --git a/BuildChecker/BuildChecker.csproj b/BuildChecker/BuildChecker.csproj index ff45440554..5384696457 100644 --- a/BuildChecker/BuildChecker.csproj +++ b/BuildChecker/BuildChecker.csproj @@ -16,12 +16,19 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild python3 py -3 + {C899FCA4-7037-4E49-ABC2-44DE72487110} + + + Library + + + - + - + \ No newline at end of file diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index d73805adbb..78f4483cf9 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -51,12 +51,12 @@ - - $(SolutionDir)packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll - $(SolutionDir)packages\OpenTK.3.0.0-pre\lib\net20\OpenTK.dll + + $(SolutionDir)packages\YamlDotNet.4.3.0\lib\net45\YamlDotNet.dll + @@ -99,4 +99,8 @@ - + + + + + \ No newline at end of file diff --git a/Content.Client/Prototypes/DiscoBall.cs b/Content.Client/Prototypes/DiscoBall.cs index b184437c3f..68efa81968 100644 --- a/Content.Client/Prototypes/DiscoBall.cs +++ b/Content.Client/Prototypes/DiscoBall.cs @@ -4,32 +4,36 @@ using SS14.Shared.Maths; namespace Content.Client.Prototypes { + // Instantiated through reflection by the prototype system. public class DiscoBall : Entity { - private PointLightComponent LightComponent; - private float Hue; + private PointLightComponent _lightComponent; + private float _hue; + /// public override void Initialize() { base.Initialize(); - LightComponent = GetComponent(); + _lightComponent = GetComponent(); } + /// public override void Shutdown() { base.Shutdown(); - LightComponent = null; + _lightComponent = null; } + /// public override void Update(float frameTime) { - Hue += frameTime / 10; - if (Hue > 1) + _hue += frameTime / 10; + if (_hue > 1) { - Hue -= 1; + _hue -= 1; } - LightComponent.Color = Color4.FromHsl(new Vector4(Hue, 1, 0.5f, 0.5f)); + _lightComponent.Color = Color4.FromHsl(new Vector4(_hue, 1, 0.5f, 0.5f)); } } } diff --git a/Content.Client/app.config b/Content.Client/app.config new file mode 100644 index 0000000000..b1e9c47917 --- /dev/null +++ b/Content.Client/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Content.Client/packages.config b/Content.Client/packages.config index 45c455cb90..0072b14da4 100644 --- a/Content.Client/packages.config +++ b/Content.Client/packages.config @@ -1,6 +1,6 @@ - + - - + + \ No newline at end of file diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index 6c291fde4c..2d4a2dccbc 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -47,12 +47,12 @@ - - $(SolutionDir)packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll - $(SolutionDir)packages\OpenTK.3.0.0-pre\lib\net20\OpenTK.dll + + $(SolutionDir)packages\YamlDotNet.4.3.0\lib\net45\YamlDotNet.dll + @@ -115,5 +115,8 @@ - + + + + \ No newline at end of file diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index 926ec0c334..554ae3b68d 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -1,5 +1,4 @@ - -using Content.Server.GameObjects; +using Content.Server.GameObjects; using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Interactable.Tools; using Content.Server.Interfaces.GameObjects; @@ -19,7 +18,7 @@ using SS14.Shared.IoC; using SS14.Shared.Log; using SS14.Shared.Map; using SS14.Shared.Timers; -using System.Diagnostics; +using SS14.Shared.Interfaces.Timing; namespace Content.Server { @@ -84,13 +83,26 @@ namespace Content.Server base.Dispose(); } - private void HandleRunLevelChanged(object sender, RunLevelChangedEventArgs args) + private static void HandleRunLevelChanged(object sender, RunLevelChangedEventArgs args) { switch (args.NewLevel) { case ServerRunLevel.PreGame: - IoCManager.Resolve().FallbackSpawnPoint = new LocalCoordinates(0, 0, GridId.DefaultGrid, new MapId(1)); - NewDemoGrid(new GridId(1), new MapId(1)); + var timing = IoCManager.Resolve(); + + IoCManager.Resolve().FallbackSpawnPoint = new LocalCoordinates(0, 0, GridId.DefaultGrid, new MapId(2)); + + var mapLoader = IoCManager.Resolve(); + var mapMan = IoCManager.Resolve(); + + var startTime = timing.RealTime; + { + var newMap = mapMan.CreateMap(new MapId(2)); + + mapLoader.LoadBlueprint(newMap, new GridId(4), "Maps/Demo/DemoGrid.yaml"); + } + var timeSpan = timing.RealTime - startTime; + Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms."); IoCManager.Resolve().DispatchMessage(ChatChannel.Server, "Gamemode: Round loaded!"); break; @@ -152,39 +164,5 @@ namespace Content.Server break; } } - - //TODO: This whole method should be removed once file loading/saving works, and replaced with a 'Demo' map. - /// - /// Generates 'Demo' grid and inserts it into the map manager. - /// - private void NewDemoGrid(GridId gridId, MapId mapId) - { - var mapManager = IoCManager.Resolve(); - var defManager = IoCManager.Resolve(); - - mapManager.SuppressOnTileChanged = true; - - Logger.Log("Cannot find map. Generating blank map.", LogLevel.Warning); - var floor = defManager["Floor"].TileId; - - Debug.Assert(floor > 0); - - var map = mapManager.CreateMap(mapId); - var grid = map.CreateGrid(gridId); - - for (var y = -32; y <= 32; ++y) - { - for (var x = -32; x <= 32; ++x) - { - grid.SetTile(new LocalCoordinates(x, y, gridId, mapId), new Tile(floor)); - } - } - - // load entities - IoCManager.Resolve().Load(_server.MapName, map); - - mapManager.SuppressOnTileChanged = false; - } - } } diff --git a/Content.Server/app.config b/Content.Server/app.config new file mode 100644 index 0000000000..b1e9c47917 --- /dev/null +++ b/Content.Server/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Content.Server/packages.config b/Content.Server/packages.config index 45c455cb90..0072b14da4 100644 --- a/Content.Server/packages.config +++ b/Content.Server/packages.config @@ -1,6 +1,6 @@ - + - - + + \ No newline at end of file diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index 20f38254d5..b26d1f0b4a 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -46,12 +46,12 @@ - - $(SolutionDir)packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll - $(SolutionDir)packages\OpenTK.3.0.0-pre\lib\net20\OpenTK.dll + + $(SolutionDir)packages\YamlDotNet.4.3.0\lib\net45\YamlDotNet.dll + @@ -94,10 +94,14 @@ Prototypes\Content\ + + + + - + \ No newline at end of file diff --git a/Content.Shared/app.config b/Content.Shared/app.config new file mode 100644 index 0000000000..b1e9c47917 --- /dev/null +++ b/Content.Shared/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Content.Shared/packages.config b/Content.Shared/packages.config index 45c455cb90..0072b14da4 100644 --- a/Content.Shared/packages.config +++ b/Content.Shared/packages.config @@ -1,6 +1,6 @@ - + - - + + \ No newline at end of file diff --git a/SpaceStation14Content.sln b/SpaceStation14Content.sln index 71d0c58e43..27e96154e2 100644 --- a/SpaceStation14Content.sln +++ b/SpaceStation14Content.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +VisualStudioVersion = 15.0.27130.2026 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Shared", "Content.Shared\Content.Shared.csproj", "{26AEEBB3-DDE7-443A-9F43-7BC7F4ACF6B5}" ProjectSection(ProjectDependencies) = postProject @@ -129,14 +129,12 @@ Global {59250BAF-0000-0000-0000-000000000000}.Release|x64.Build.0 = Release|x64 {59250BAF-0000-0000-0000-000000000000}.Release|x86.ActiveCfg = Release|x86 {59250BAF-0000-0000-0000-000000000000}.Release|x86.Build.0 = Release|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.ActiveCfg = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.Build.0 = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x86.ActiveCfg = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x86.Build.0 = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x64.ActiveCfg = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x64.Build.0 = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x86.ActiveCfg = Debug|x86 - {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x86.Build.0 = Debug|x86 + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.ActiveCfg = Debug|Any CPU + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.Build.0 = Debug|Any CPU + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x86.ActiveCfg = Debug|Any CPU + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x64.ActiveCfg = Debug|Any CPU + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x64.Build.0 = Debug|Any CPU + {C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|x86.ActiveCfg = Debug|Any CPU {31D24303-F6A9-4D53-BB03-A73EDCB3186D}.Debug|x64.ActiveCfg = Debug|x64 {31D24303-F6A9-4D53-BB03-A73EDCB3186D}.Debug|x64.Build.0 = Debug|x64 {31D24303-F6A9-4D53-BB03-A73EDCB3186D}.Debug|x86.ActiveCfg = Debug|x86 @@ -178,4 +176,7 @@ Global {D17DE83D-A592-461F-8AF2-53F9E22E1D0F} = {1780DA39-F1EC-4100-8C58-ECD756C68033} {1780DA39-F1EC-4100-8C58-ECD756C68033} = {B01693E5-CF08-4DB7-8920-407F8D6603A1} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A} + EndGlobalSection EndGlobal diff --git a/engine b/engine index 56508df919..a8c302eadb 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 56508df91937fd456bc5411008575169d93b262b +Subproject commit a8c302eadb516f919df1f751af8a5d2993458b2e