Start adding tests
This commit is contained in:
parent
4ebb162531
commit
50040ed440
BIN
TrueCraft.Core.Test/Files/TestChunk.nbt
Normal file
BIN
TrueCraft.Core.Test/Files/TestChunk.nbt
Normal file
Binary file not shown.
BIN
TrueCraft.Core.Test/Files/manifest.nbt
Normal file
BIN
TrueCraft.Core.Test/Files/manifest.nbt
Normal file
Binary file not shown.
BIN
TrueCraft.Core.Test/Files/r.-1.-1.mca
Normal file
BIN
TrueCraft.Core.Test/Files/r.-1.-1.mca
Normal file
Binary file not shown.
BIN
TrueCraft.Core.Test/Files/r.-1.0.mca
Normal file
BIN
TrueCraft.Core.Test/Files/r.-1.0.mca
Normal file
Binary file not shown.
BIN
TrueCraft.Core.Test/Files/r.0.-1.mca
Normal file
BIN
TrueCraft.Core.Test/Files/r.0.-1.mca
Normal file
Binary file not shown.
BIN
TrueCraft.Core.Test/Files/r.0.0.mca
Normal file
BIN
TrueCraft.Core.Test/Files/r.0.0.mca
Normal file
Binary file not shown.
59
TrueCraft.Core.Test/MathHelperTest.cs
Normal file
59
TrueCraft.Core.Test/MathHelperTest.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.API;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class MathHelperTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestCreateRotationByte()
|
||||||
|
{
|
||||||
|
byte a = (byte)MathHelper.CreateRotationByte(0);
|
||||||
|
byte b = (byte)MathHelper.CreateRotationByte(180);
|
||||||
|
byte c = (byte)MathHelper.CreateRotationByte(359);
|
||||||
|
byte d = (byte)MathHelper.CreateRotationByte(360);
|
||||||
|
Assert.AreEqual(0, a);
|
||||||
|
Assert.AreEqual(128, b);
|
||||||
|
Assert.AreEqual(255, c);
|
||||||
|
Assert.AreEqual(0, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetCollisionPoint()
|
||||||
|
{
|
||||||
|
var inputs = new[]
|
||||||
|
{
|
||||||
|
Vector3.Down,
|
||||||
|
Vector3.Up,
|
||||||
|
Vector3.Left,
|
||||||
|
Vector3.Right,
|
||||||
|
Vector3.Forwards,
|
||||||
|
Vector3.Backwards
|
||||||
|
};
|
||||||
|
var results = new[]
|
||||||
|
{
|
||||||
|
MathHelper.GetCollisionPoint(inputs[0]),
|
||||||
|
MathHelper.GetCollisionPoint(inputs[1]),
|
||||||
|
MathHelper.GetCollisionPoint(inputs[2]),
|
||||||
|
MathHelper.GetCollisionPoint(inputs[3]),
|
||||||
|
MathHelper.GetCollisionPoint(inputs[4]),
|
||||||
|
MathHelper.GetCollisionPoint(inputs[5])
|
||||||
|
};
|
||||||
|
var expected = new[]
|
||||||
|
{
|
||||||
|
CollisionPoint.NegativeY,
|
||||||
|
CollisionPoint.PositiveY,
|
||||||
|
CollisionPoint.NegativeX,
|
||||||
|
CollisionPoint.PositiveX,
|
||||||
|
CollisionPoint.PositiveZ,
|
||||||
|
CollisionPoint.NegativeZ
|
||||||
|
};
|
||||||
|
for (int i = 0; i < expected.Length; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(expected[i], results[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
91
TrueCraft.Core.Test/TrueCraft.Core.Test.csproj
Normal file
91
TrueCraft.Core.Test/TrueCraft.Core.Test.csproj
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{BCFDCD93-C23E-49E6-9767-A887B3C2A709}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>TrueCraft.Core.Test</RootNamespace>
|
||||||
|
<AssemblyName>TrueCraft.Core.Test</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="nunit.framework">
|
||||||
|
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Moq">
|
||||||
|
<HintPath>..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="Files\r.0.0.mca">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Files\TestChunk.nbt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Files\manifest.nbt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Files\r.-1.-1.mca">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Files\r.-1.0.mca">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Files\r.0.-1.mca">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TrueCraft.API\TrueCraft.API.csproj">
|
||||||
|
<Project>{FEE55B54-91B0-4325-A2C3-D576C0B7A81F}</Project>
|
||||||
|
<Name>TrueCraft.API</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\TrueCraft.Core\TrueCraft.Core.csproj">
|
||||||
|
<Project>{FA4BE9A3-DBF0-4380-BA2B-FFAA71C4706D}</Project>
|
||||||
|
<Name>TrueCraft.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\externals\fNbt\fNbt\fNbt.csproj">
|
||||||
|
<Project>{4488498D-976D-4DA3-BF72-109531AF0488}</Project>
|
||||||
|
<Name>fNbt</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="MathHelperTest.cs" />
|
||||||
|
<Compile Include="World\ChunkTest.cs" />
|
||||||
|
<Compile Include="World\RegionTest.cs" />
|
||||||
|
<Compile Include="World\WorldTest.cs" />
|
||||||
|
<Compile Include="Windows\WindowAreaTest.cs" />
|
||||||
|
<Compile Include="Windows\CraftingWindowAreaTest.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="World\" />
|
||||||
|
<Folder Include="Files\" />
|
||||||
|
<Folder Include="Windows\" />
|
||||||
|
<Folder Include="Logic\" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
27
TrueCraft.Core.Test/Windows/CraftingWindowAreaTest.cs
Normal file
27
TrueCraft.Core.Test/Windows/CraftingWindowAreaTest.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using TrueCraft.API.Logic;
|
||||||
|
using TrueCraft.API.Windows;
|
||||||
|
using TrueCraft.API;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.Core.Windows;
|
||||||
|
using Moq;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test.Windows
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CraftingWindowAreaTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestCraftingWindowArea()
|
||||||
|
{
|
||||||
|
var recipe = new Mock<ICraftingRecipe>();
|
||||||
|
recipe.Setup(r => r.Output).Returns(new ItemStack(10));
|
||||||
|
var repository = new Mock<ICraftingRepository>();
|
||||||
|
repository.Setup(r => r.GetRecipe(It.IsAny<IWindowArea>())).Returns(recipe.Object);
|
||||||
|
|
||||||
|
var area = new CraftingWindowArea(repository.Object, 0);
|
||||||
|
area[0] = new ItemStack(11);
|
||||||
|
Assert.AreEqual(new ItemStack(10), area[CraftingWindowArea.CraftingOutput]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
TrueCraft.Core.Test/Windows/WindowAreaTest.cs
Normal file
40
TrueCraft.Core.Test/Windows/WindowAreaTest.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.Core.Windows;
|
||||||
|
using TrueCraft.API;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test.Windows
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class WindowAreaTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestIndexing()
|
||||||
|
{
|
||||||
|
var area = new WindowArea(0, 10, 10, 1);
|
||||||
|
area[0] = new ItemStack(10);
|
||||||
|
Assert.AreEqual(new ItemStack(10), area[0]);
|
||||||
|
area[1] = new ItemStack(20);
|
||||||
|
Assert.AreEqual(new ItemStack(20), area[1]);
|
||||||
|
bool called = false;
|
||||||
|
area.WindowChange += (sender, e) => called = true;
|
||||||
|
area[0] = ItemStack.EmptyStack;
|
||||||
|
Assert.IsTrue(called);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCopyTo()
|
||||||
|
{
|
||||||
|
var area1 = new WindowArea(0, 10, 10, 1);
|
||||||
|
var area2 = new WindowArea(0, 10, 10, 1);
|
||||||
|
area1[0] = new ItemStack(10);
|
||||||
|
area1[1] = new ItemStack(20);
|
||||||
|
area1[2] = new ItemStack(30);
|
||||||
|
area1.CopyTo(area2);
|
||||||
|
Assert.AreEqual(area1[0], area2[0]);
|
||||||
|
Assert.AreEqual(area1[1], area2[1]);
|
||||||
|
Assert.AreEqual(area1[2], area2[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
59
TrueCraft.Core.Test/World/ChunkTest.cs
Normal file
59
TrueCraft.Core.Test/World/ChunkTest.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.Core.World;
|
||||||
|
using TrueCraft.API;
|
||||||
|
using fNbt;
|
||||||
|
using TrueCraft.Core.Logic.Blocks;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test.World
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ChunkTest
|
||||||
|
{
|
||||||
|
public Chunk Chunk { get; set; }
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
var file = new NbtFile("Files/TestChunk.nbt");
|
||||||
|
Chunk = Chunk.FromNbt(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetBlockID()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(BedrockBlock.BlockID, Chunk.GetBlockID(Coordinates3D.Zero));
|
||||||
|
Chunk.SetBlockID(Coordinates3D.Zero, 12);
|
||||||
|
Assert.AreEqual(12, Chunk.GetBlockID(Coordinates3D.Zero));
|
||||||
|
Chunk.SetBlockID(Coordinates3D.Zero, BedrockBlock.BlockID);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetBlockLight()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, Chunk.GetBlockLight(Coordinates3D.Zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetSkyLight()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, Chunk.GetBlockLight(Coordinates3D.Zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetMetadata()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, Chunk.GetBlockLight(Coordinates3D.Zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHeightMap()
|
||||||
|
{
|
||||||
|
Chunk.UpdateHeightMap();
|
||||||
|
Assert.AreEqual(59, Chunk.GetHeight(0, 0));
|
||||||
|
Assert.AreEqual(58, Chunk.GetHeight(1, 0));
|
||||||
|
Chunk.SetBlockID(new Coordinates3D(1, 80, 0), 1);
|
||||||
|
Assert.AreEqual(80, Chunk.GetHeight(1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
TrueCraft.Core.Test/World/RegionTest.cs
Normal file
45
TrueCraft.Core.Test/World/RegionTest.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.Core.World;
|
||||||
|
using TrueCraft.API;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test.World
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class RegionTest
|
||||||
|
{
|
||||||
|
public Region Region { get; set; }
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
var world = new TrueCraft.Core.World.World();
|
||||||
|
Region = new Region(Coordinates2D.Zero, world, "Files/r.0.0.mca");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetChunk()
|
||||||
|
{
|
||||||
|
var chunk = Region.GetChunk(Coordinates2D.Zero);
|
||||||
|
Assert.AreEqual(Coordinates2D.Zero, chunk.Coordinates);
|
||||||
|
Assert.Throws(typeof(ArgumentException), () =>
|
||||||
|
Region.GetChunk(new Coordinates2D(31, 31)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUnloadChunk()
|
||||||
|
{
|
||||||
|
var chunk = Region.GetChunk(Coordinates2D.Zero);
|
||||||
|
Assert.AreEqual(Coordinates2D.Zero, chunk.Coordinates);
|
||||||
|
Assert.IsTrue(Region.Chunks.ContainsKey(Coordinates2D.Zero));
|
||||||
|
Region.UnloadChunk(Coordinates2D.Zero);
|
||||||
|
Assert.IsFalse(Region.Chunks.ContainsKey(Coordinates2D.Zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetRegionFileName()
|
||||||
|
{
|
||||||
|
Assert.AreEqual("r.0.0.mca", Region.GetRegionFileName(Region.Position));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
TrueCraft.Core.Test/World/WorldTest.cs
Normal file
55
TrueCraft.Core.Test/World/WorldTest.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using TrueCraft.Core.World;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TrueCraft.API;
|
||||||
|
using TrueCraft.Core.TerrainGen;
|
||||||
|
using TrueCraft.API.World;
|
||||||
|
|
||||||
|
namespace TrueCraft.Core.Test.World
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class WorldTest
|
||||||
|
{
|
||||||
|
public TrueCraft.Core.World.World World { get; set; }
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
World = TrueCraft.Core.World.World.LoadWorld("Files");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMetadataLoaded()
|
||||||
|
{
|
||||||
|
// Constants from manifest.nbt
|
||||||
|
Assert.AreEqual(new Coordinates3D(0, 60, 0), World.SpawnPoint);
|
||||||
|
Assert.AreEqual(1168393583, World.Seed);
|
||||||
|
Assert.IsInstanceOf<StandardGenerator>(World.ChunkProvider);
|
||||||
|
Assert.AreEqual("default", World.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFindChunk()
|
||||||
|
{
|
||||||
|
var a = World.FindChunk(new Coordinates3D(0, 0, 0));
|
||||||
|
var b = World.FindChunk(new Coordinates3D(-1, 0, 0));
|
||||||
|
var c = World.FindChunk(new Coordinates3D(-1, 0, -1));
|
||||||
|
var d = World.FindChunk(new Coordinates3D(16, 0, 0));
|
||||||
|
Assert.AreEqual(new Coordinates2D(0, 0), a.Coordinates);
|
||||||
|
Assert.AreEqual(new Coordinates2D(-1, 0), b.Coordinates);
|
||||||
|
Assert.AreEqual(new Coordinates2D(-1, -1), c.Coordinates);
|
||||||
|
Assert.AreEqual(new Coordinates2D(1, 0), d.Coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetChunk()
|
||||||
|
{
|
||||||
|
var a = World.GetChunk(new Coordinates2D(0, 0));
|
||||||
|
var b = World.GetChunk(new Coordinates2D(1, 0));
|
||||||
|
var c = World.GetChunk(new Coordinates2D(-1, 0));
|
||||||
|
Assert.AreEqual(new Coordinates2D(0, 0), a.Coordinates);
|
||||||
|
Assert.AreEqual(new Coordinates2D(1, 0), b.Coordinates);
|
||||||
|
Assert.AreEqual(new Coordinates2D(-1, 0), c.Coordinates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
TrueCraft.Core.Test/packages.config
Normal file
5
TrueCraft.Core.Test/packages.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
|
||||||
|
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||||
|
</packages>
|
@ -22,10 +22,17 @@ namespace TrueCraft.Core.TerrainGen
|
|||||||
{
|
{
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
foreach (var type in assembly.GetTypes().Where(t => typeof(IBiomeProvider).IsAssignableFrom(t) && !t.IsAbstract))
|
try
|
||||||
{
|
{
|
||||||
var instance = (IBiomeProvider)Activator.CreateInstance(type);
|
foreach (var type in assembly.GetTypes().Where(t => typeof(IBiomeProvider).IsAssignableFrom(t) && !t.IsAbstract))
|
||||||
RegisterBiomeProvider(instance);
|
{
|
||||||
|
var instance = (IBiomeProvider)Activator.CreateInstance(type);
|
||||||
|
RegisterBiomeProvider(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// There are some bugs with loading mscorlib during a unit test like this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,14 +200,14 @@ namespace TrueCraft.Core.World
|
|||||||
public int GetHeight(byte x, byte z)
|
public int GetHeight(byte x, byte z)
|
||||||
{
|
{
|
||||||
LastAccessed = DateTime.Now;
|
LastAccessed = DateTime.Now;
|
||||||
return HeightMap[(byte)(x * Width) + z];
|
return HeightMap[(x * Width) + z];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetHeight(byte x, byte z, int value)
|
private void SetHeight(byte x, byte z, int value)
|
||||||
{
|
{
|
||||||
LastAccessed = DateTime.Now;
|
LastAccessed = DateTime.Now;
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
HeightMap[(byte)(x * Width) + z] = value;
|
HeightMap[(x * Width) + z] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateHeightMap()
|
public void UpdateHeightMap()
|
||||||
@ -308,7 +308,7 @@ namespace TrueCraft.Core.World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Tile entities, entities
|
// TODO: Entities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ namespace TrueCraft.Core.World
|
|||||||
public Region(Coordinates2D position, World world, string file) : this(position, world)
|
public Region(Coordinates2D position, World world, string file) : this(position, world)
|
||||||
{
|
{
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
regionFile = File.Open(file, FileMode.OpenOrCreate);
|
regionFile = File.Open(file, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionFile = File.Open(file, FileMode.OpenOrCreate);
|
regionFile = File.Open(file, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||||
CreateRegionHeader();
|
CreateRegionHeader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueCraft.Client", "TrueCra
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueCraft.Launcher", "TrueCraft.Launcher\TrueCraft.Launcher.csproj", "{6604F17A-552E-405D-B327-37C8B1648C86}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueCraft.Launcher", "TrueCraft.Launcher\TrueCraft.Launcher.csproj", "{6604F17A-552E-405D-B327-37C8B1648C86}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{6756B61E-5856-4CA7-90B5-6053763FE7BA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueCraft.Core.Test", "TrueCraft.Core.Test\TrueCraft.Core.Test.csproj", "{BCFDCD93-C23E-49E6-9767-A887B3C2A709}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
@ -45,6 +49,14 @@ Global
|
|||||||
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x64.Build.0 = Release|x86
|
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x64.Build.0 = Release|x86
|
||||||
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x86.ActiveCfg = Release|x86
|
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x86.ActiveCfg = Release|x86
|
||||||
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x86.Build.0 = Release|x86
|
{A6516869-A2FB-4E31-85C8-2285490CB32C}.Release|x86.Build.0 = Release|x86
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x64.ActiveCfg = Debug|x86
|
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x64.ActiveCfg = Debug|x86
|
||||||
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x64.Build.0 = Debug|x86
|
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x64.Build.0 = Debug|x86
|
||||||
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x86.ActiveCfg = Debug|x86
|
{C1C47EF5-2D8A-4231-AAA8-F651F52F480E}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
@ -70,6 +82,9 @@ Global
|
|||||||
{FEE55B54-91B0-4325-A2C3-D576C0B7A81F}.Release|x86.ActiveCfg = Release|Any CPU
|
{FEE55B54-91B0-4325-A2C3-D576C0B7A81F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{FEE55B54-91B0-4325-A2C3-D576C0B7A81F}.Release|x86.Build.0 = Release|Any CPU
|
{FEE55B54-91B0-4325-A2C3-D576C0B7A81F}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{BCFDCD93-C23E-49E6-9767-A887B3C2A709} = {6756B61E-5856-4CA7-90B5-6053763FE7BA}
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
Policies = $0
|
Policies = $0
|
||||||
$0.TextStylePolicy = $1
|
$0.TextStylePolicy = $1
|
||||||
|
Reference in New Issue
Block a user