(Re)load blueprints from file, t3 shields

Blueprints can be loaded and reloaded from a file in the game's directory except in a release version
This commit is contained in:
Norbi Peti 2020-09-20 23:23:33 +02:00
parent 5bc0351bd1
commit ab169fb87c
3 changed files with 20 additions and 4 deletions

View file

@ -14,11 +14,18 @@ namespace Pixi.Common
StreamReader bluemap = new StreamReader(File.OpenRead(name)); StreamReader bluemap = new StreamReader(File.OpenRead(name));
return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd()); return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd());
} }
public static Dictionary<string, BlockJsonInfo[]> ParseBlueprintResource(string name) public static Dictionary<string, BlockJsonInfo[]> ParseBlueprintResource(string name)
{ {
StreamReader bluemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(name)); StreamReader bluemap;
return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd()); #if DEBUG
if (File.Exists(name))
bluemap = File.OpenText(name);
else
#endif
bluemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(name));
using (bluemap)
return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd());
} }
public static ProcessedVoxelObjectNotation[][] ProcessAndExpandBlocks(string name, BlockJsonInfo[] blocks, BlueprintProvider blueprints) public static ProcessedVoxelObjectNotation[][] ProcessAndExpandBlocks(string name, BlockJsonInfo[] blocks, BlueprintProvider blueprints)

View file

@ -47,12 +47,14 @@ namespace Pixi
root.Inject(new ImageTextBlockImporter()); root.Inject(new ImageTextBlockImporter());
root.Inject(new ImageCommandImporter()); root.Inject(new ImageCommandImporter());
// Robot functionality // Robot functionality
root.Inject(new RobotInternetImporter()); var robot = new RobotInternetImporter();
root.Inject(robot);
//RobotCommands.CreateRobotCRFCommand(); //RobotCommands.CreateRobotCRFCommand();
//RobotCommands.CreateRobotFileCommand(); //RobotCommands.CreateRobotFileCommand();
#if DEBUG #if DEBUG
// Development functionality // Development functionality
RobotCommands.CreatePartDumpCommand(); RobotCommands.CreatePartDumpCommand();
((RobotBlueprintProvider) robot.BlueprintProvider).AddReloadCommand();
#endif #endif
} }
} }

View file

@ -6,6 +6,7 @@ using Unity.Mathematics;
using UnityEngine; using UnityEngine;
using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Utility;
using Pixi.Common; using Pixi.Common;
@ -96,5 +97,11 @@ namespace Pixi.Robots
} }
return adjustedBlueprint; return adjustedBlueprint;
} }
public void AddReloadCommand()
{
CommandBuilder.Builder("PixiReload", "Reloads the robot blueprints")
.Action(() => botprints = null).Build();
}
} }
} }