mirror of
https://github.com/kwsch/NHSE.git
synced 2026-03-29 13:04:39 -05:00
Code now compiles, but will need to test and bugfix extensively. Need to pre-fill the pixel buffers with sea first unless the acre fill actually works (maybe?) Items need to be relative'd to apply 1 row lower, and skip the bottom row. Need to check that terrain is the same as well. Note to self: For Map - probably better to get a starting x,y,width and iterate off that, fetching tile from relative, converting to absolute... idk. For View - need to check if tile is in layer.
41 lines
2.0 KiB
C#
41 lines
2.0 KiB
C#
namespace NHSE.Core;
|
|
|
|
public static class MapTileManagerUtil
|
|
{
|
|
/// <summary>
|
|
/// Retrieves a <see cref="MapTileManager"/> from the provided <see cref="MainSave"/>.
|
|
/// </summary>
|
|
public static MapTileManager FromSaveFile(MainSave sav) => new()
|
|
{
|
|
ConfigTerrain = LayerPositionConfig.Create(7, 6, 16, 1),
|
|
ConfigBuildings = LayerPositionConfig.Create(5, 4, 16, 2),
|
|
ConfigItems = LayerPositionConfig.Create(sav.FieldItemAcreWidth, sav.FieldItemAcreHeight, 32, 1),
|
|
|
|
LayerTerrain = new LayerTerrain(sav.GetTerrainTiles(), sav.GetAcreBytes()),
|
|
LayerBuildings = new LayerBuilding { Buildings = sav.Buildings },
|
|
FieldItems = new LayerFieldItemSet
|
|
{
|
|
Layer0 = new LayerFieldItem(sav.GetFieldItemLayer0(), sav.FieldItemAcreWidth, sav.FieldItemAcreHeight),
|
|
Layer1 = new LayerFieldItem(sav.GetFieldItemLayer1(), sav.FieldItemAcreWidth, sav.FieldItemAcreHeight),
|
|
},
|
|
LayerItemFlag0 = new LayerFieldItemFlag(sav.FieldItemFlag0Data, sav.FieldItemAcreWidth, sav.FieldItemAcreHeight),
|
|
LayerItemFlag1 = new LayerFieldItemFlag(sav.FieldItemFlag1Data, sav.FieldItemAcreWidth, sav.FieldItemAcreHeight),
|
|
Plaza = new MapStatePlaza { X = sav.EventPlazaLeftUpX, Z = sav.EventPlazaLeftUpZ },
|
|
};
|
|
|
|
/// <summary>
|
|
/// Sets the values from the provided <see cref="MapTileManager"/> into the provided <see cref="MainSave"/>.
|
|
/// </summary>
|
|
public static void SetManager(this MapTileManager mgr, MainSave sav)
|
|
{
|
|
sav.Buildings = mgr.LayerBuildings.Buildings;
|
|
sav.SetTerrainTiles(mgr.LayerTerrain.Tiles);
|
|
sav.SetFieldItemLayer0(mgr.FieldItems.Layer0.Tiles);
|
|
sav.SetFieldItemLayer1(mgr.FieldItems.Layer1.Tiles);
|
|
mgr.LayerItemFlag0.Save(sav.FieldItemFlag0Data.Span);
|
|
mgr.LayerItemFlag1.Save(sav.FieldItemFlag1Data.Span);
|
|
sav.SetAcreBytes(mgr.LayerTerrain.BaseAcres.Span);
|
|
sav.EventPlazaLeftUpX = mgr.Plaza.X;
|
|
sav.EventPlazaLeftUpZ = mgr.Plaza.Z;
|
|
}
|
|
} |