Added PurgeEntities example program

This commit is contained in:
Justin Aquadro 2011-04-30 05:18:30 +00:00
parent e215ccd7d5
commit 77438fa1bf
4 changed files with 145 additions and 0 deletions

View file

@ -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

View file

@ -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 <world> <entityID> [<x1> <z1> <x2> <z2>]");
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();
}
}
}
}

View file

@ -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")]

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A64F274A-D5B7-45C2-92BA-4C9A64863DDC}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PurgeEntities</RootNamespace>
<AssemblyName>PurgeEntities</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Substrate, Version=0.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\bin\Release\Substrate.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>