diff --git a/Substrate/SubstrateCS/Examples/Examples.sln b/Substrate/SubstrateCS/Examples/Examples.sln index bff6188..e2937b1 100644 --- a/Substrate/SubstrateCS/Examples/Examples.sln +++ b/Substrate/SubstrateCS/Examples/Examples.sln @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relight", "Relight\Relight. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maze", "Maze\Maze.csproj", "{62D70576-FE3A-4530-B283-889C14B52E9E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PurgeEntities", "PurgeEntities\PurgeEntities.csproj", "{A64F274A-D5B7-45C2-92BA-4C9A64863DDC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {62D70576-FE3A-4530-B283-889C14B52E9E}.Debug|Any CPU.Build.0 = Debug|Any CPU {62D70576-FE3A-4530-B283-889C14B52E9E}.Release|Any CPU.ActiveCfg = Release|Any CPU {62D70576-FE3A-4530-B283-889C14B52E9E}.Release|Any CPU.Build.0 = Release|Any CPU + {A64F274A-D5B7-45C2-92BA-4C9A64863DDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A64F274A-D5B7-45C2-92BA-4C9A64863DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A64F274A-D5B7-45C2-92BA-4C9A64863DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A64F274A-D5B7-45C2-92BA-4C9A64863DDC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Substrate/SubstrateCS/Examples/PurgeEntities/Program.cs b/Substrate/SubstrateCS/Examples/PurgeEntities/Program.cs new file mode 100644 index 0000000..42bba32 --- /dev/null +++ b/Substrate/SubstrateCS/Examples/PurgeEntities/Program.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using Substrate; + +namespace PurgeEntities +{ + class Program + { + static void Main (string[] args) + { + // Process arguments + if (args.Length != 2 && args.Length != 6) { + Console.WriteLine("Usage: PurgeEntities [ ]"); + return; + } + string dest = args[0]; + string eid = args[1]; + + int x1 = BlockManager.MIN_X; + int x2 = BlockManager.MAX_X; + int z1 = BlockManager.MIN_Z; + int z2 = BlockManager.MAX_Z; + + if (args.Length == 6) { + x1 = Convert.ToInt32(args[2]); + z1 = Convert.ToInt32(args[3]); + x2 = Convert.ToInt32(args[4]); + z2 = Convert.ToInt32(args[5]); + } + + // Load world + BetaWorld world = BetaWorld.Open(dest); + ChunkManager cm = world.GetChunkManager(); + + // Remove entities + foreach (ChunkRef chunk in cm) { + // Skip chunks that don't cover our selected area + if (((chunk.X + 1) * chunk.XDim < x1) || + (chunk.X * chunk.XDim >= x2) || + ((chunk.Z + 1) * chunk.ZDim < z1) || + (chunk.Z * chunk.ZDim >= z2)) { + continue; + } + + // Delete the specified entities + chunk.RemoveEntities(eid); + cm.Save(); + } + } + } +} diff --git a/Substrate/SubstrateCS/Examples/PurgeEntities/Properties/AssemblyInfo.cs b/Substrate/SubstrateCS/Examples/PurgeEntities/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6da6ea7 --- /dev/null +++ b/Substrate/SubstrateCS/Examples/PurgeEntities/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PurgeEntities")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("PurgeEntities")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d464b8c1-6bcc-46b9-9ade-ec5d1464dd4d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Substrate/SubstrateCS/Examples/PurgeEntities/PurgeEntities.csproj b/Substrate/SubstrateCS/Examples/PurgeEntities/PurgeEntities.csproj new file mode 100644 index 0000000..ae7ba4a --- /dev/null +++ b/Substrate/SubstrateCS/Examples/PurgeEntities/PurgeEntities.csproj @@ -0,0 +1,52 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {A64F274A-D5B7-45C2-92BA-4C9A64863DDC} + Exe + Properties + PurgeEntities + PurgeEntities + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\bin\Release\Substrate.dll + + + + + + + + + + \ No newline at end of file