-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
231 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Client\Client.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using CentrED; | ||
using CentrED.Client; | ||
using CentrED.Network; | ||
|
||
var start = DateTime.Now; | ||
|
||
Dictionary<ushort, ushort> treeToLeaves = new Dictionary<ushort, ushort> | ||
{ | ||
{0x0CCD, 0x0CCE}, {0x0CD0, 0x0CD1}, {0x0CD3, 0x0CD4} | ||
}; | ||
ushort x1 = 0; | ||
ushort y1 = 0; | ||
ushort x2 = 100; | ||
ushort y2 = 100; | ||
|
||
CentrEDClient client = new CentrEDClient(); | ||
client.Connect("127.0.0.1", 2597, "user", "password"); | ||
|
||
client.LoadBlocks(new AreaInfo(x1, y1, x2, y2)); | ||
for (var x = x1; x < x2; x++) | ||
{ | ||
for (var y = y1; y < y2; y++) | ||
{ | ||
StaticTile tree = null; | ||
StaticTile leaves = null; | ||
foreach (var tile in client.GetStaticTiles(x, y)) | ||
{ | ||
if (treeToLeaves.ContainsKey(tile.Id)) | ||
{ | ||
tree = tile; | ||
}else if (treeToLeaves.Values.Contains(tile.Id)) | ||
{ | ||
leaves = tile; | ||
} | ||
} | ||
if (tree != null && leaves == null) | ||
{ | ||
client.Add(new StaticTile(treeToLeaves[tree.Id], tree.X, tree.Y, tree.Z, 0)); | ||
} | ||
client.Update(); | ||
} | ||
} | ||
client.Disconnect(); | ||
|
||
Console.WriteLine($"Elapsed: {(DateTime.Now - start).TotalMilliseconds}ms"); |
14 changes: 14 additions & 0 deletions
14
examples/Example.DeduplicateTiles/Example.DeduplicateTiles.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Client\Client.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using CentrED.Client; | ||
using CentrED.Network; | ||
|
||
var start = DateTime.Now; | ||
|
||
ushort[] duplicatedTiles = [0x1CD9, 0x1CDA, 0x1CDB, 0x1CDC]; | ||
ushort x1 = 0; | ||
ushort y1 = 0; | ||
ushort x2 = 100; | ||
ushort y2 = 100; | ||
|
||
CentrEDClient client = new CentrEDClient(); | ||
client.Connect("127.0.0.1", 2597, "user", "password"); | ||
|
||
client.LoadBlocks(new AreaInfo(x1, y1, x2, y2)); | ||
for (var x = x1; x < x2; x++) | ||
{ | ||
for (var y = y1; y < y2; y++) | ||
{ | ||
if(client.TryGetStaticTiles(x,y, out var statics)) | ||
{ | ||
var filtered = statics.Where(tile => duplicatedTiles.Contains(tile.Id)).ToArray(); | ||
for (var i = 1; i < filtered.Length; i++) | ||
{ | ||
client.Remove(filtered[i]); | ||
} | ||
} | ||
client.Update(); | ||
} | ||
} | ||
client.Disconnect(); | ||
|
||
Console.WriteLine($"Elapsed: {(DateTime.Now - start).TotalMilliseconds}ms"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Client\Client.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using CentrED.Client; | ||
using CentrED.Network; | ||
|
||
var start = DateTime.Now; | ||
|
||
ushort[] grassTiles = [0x3, 0x4, 0x5, 0x6]; | ||
ushort x1 = 0; | ||
ushort y1 = 0; | ||
ushort x2 = 100; | ||
ushort y2 = 100; | ||
|
||
CentrEDClient client = new CentrEDClient(); | ||
client.Connect("127.0.0.1", 2597, "user", "password"); | ||
|
||
client.LoadBlocks(new AreaInfo(x1, y1, x2, y2)); | ||
for (var x = x1; x < x2; x++) | ||
{ | ||
for (var y = y1; y < y2; y++) | ||
{ | ||
if(client.TryGetLandTile(x,y, out var landTile)) | ||
{ | ||
landTile.Id = grassTiles[Random.Shared.Next(grassTiles.Length)]; | ||
} | ||
client.Update(); | ||
} | ||
} | ||
client.Disconnect(); | ||
|
||
Console.WriteLine($"Elapsed: {(DateTime.Now - start).TotalMilliseconds}ms"); |