forked from PerpetuumOnline/PerpetuumServer
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new command to copy a zone's groundtype bit array to another zone w/o changing existing plants * a few other enhancements
- Loading branch information
1 parent
572cc1d
commit 10a3ec7
Showing
6 changed files
with
139 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Perpetuum.Host.Requests; | ||
using Perpetuum.Zones; | ||
using System.Threading.Tasks; | ||
|
||
namespace Perpetuum.RequestHandlers | ||
{ | ||
public class ZoneCopyGroundType : IRequestHandler | ||
{ | ||
private readonly IZoneManager _zoneManager; | ||
|
||
public ZoneCopyGroundType(IZoneManager zoneManager) | ||
{ | ||
_zoneManager = zoneManager; | ||
} | ||
|
||
public void HandleRequest(IRequest request) | ||
{ | ||
var sourceZoneId = request.Data.GetOrDefault<int>(k.source); | ||
var targetZoneId = request.Data.GetOrDefault<int>(k.target); | ||
var targetZone = _zoneManager.GetZone(targetZoneId); | ||
var sourceZone = _zoneManager.GetZone(sourceZoneId); | ||
targetZone.IsLayerEditLocked.ThrowIfTrue(ErrorCodes.TileTerraformProtected); | ||
targetZoneId.ThrowIfEqual(sourceZoneId, ErrorCodes.WTFErrorMedicalAttentionSuggested); | ||
targetZone.Size.ThrowIfNotEqual(sourceZone.Size, ErrorCodes.WTFErrorMedicalAttentionSuggested); | ||
|
||
var area = Area.FromRectangle(0, 0, sourceZone.Size.Width, sourceZone.Size.Height); | ||
var altBuffer = new ushort[area.Ground]; | ||
var workAreas = area.Slice(32); | ||
Parallel.ForEach(workAreas, (workArea) => | ||
{ | ||
var target = targetZone.Terrain.Plants.GetArea(workArea); | ||
var source = sourceZone.Terrain.Plants.GetArea(workArea); | ||
for (int i=0; i< target.Length; i++) | ||
{ | ||
target[i].SetGroundType(source[i].groundType); | ||
} | ||
targetZone.Terrain.Plants.SetArea(workArea, target); | ||
}); | ||
|
||
Message.Builder.FromRequest(request).WithOk().Send(); | ||
} | ||
} | ||
} |
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