Browse Source

(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
master
NorbiPeti 4 years ago
parent
commit
ab169fb87c
3 changed files with 20 additions and 4 deletions
  1. +10
    -3
      Pixi/Common/BlueprintUtility.cs
  2. +3
    -1
      Pixi/PixiPlugin.cs
  3. +7
    -0
      Pixi/Robots/RobotBlueprintProvider.cs

+ 10
- 3
Pixi/Common/BlueprintUtility.cs View File

@@ -14,11 +14,18 @@ namespace Pixi.Common
StreamReader bluemap = new StreamReader(File.OpenRead(name));
return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd());
}
public static Dictionary<string, BlockJsonInfo[]> ParseBlueprintResource(string name)
{
StreamReader bluemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(name));
return JsonConvert.DeserializeObject<Dictionary<string, BlockJsonInfo[]>>(bluemap.ReadToEnd());
StreamReader bluemap;
#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)


+ 3
- 1
Pixi/PixiPlugin.cs View File

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

+ 7
- 0
Pixi/Robots/RobotBlueprintProvider.cs View File

@@ -6,6 +6,7 @@ using Unity.Mathematics;
using UnityEngine;

using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
using GamecraftModdingAPI.Utility;
using Pixi.Common;

@@ -96,5 +97,11 @@ namespace Pixi.Robots
}
return adjustedBlueprint;
}

public void AddReloadCommand()
{
CommandBuilder.Builder("PixiReload", "Reloads the robot blueprints")
.Action(() => botprints = null).Build();
}
}
}

Loading…
Cancel
Save