Tile changes
This commit is contained in:
@@ -28,7 +28,6 @@ public class EditModel : AdminPageModel
|
||||
|
||||
public async Task OnGetAsync(int? id)
|
||||
{
|
||||
//CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com";
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
CdnImages = await _db.ClientAssets
|
||||
.Where(a => a.AssetType == ClientAssetType.Texture && a.IsEnabled)
|
||||
@@ -70,7 +69,6 @@ public class EditModel : AdminPageModel
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
//CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com";
|
||||
CdnBaseUrl = NormalizeCdnBaseUrl(_config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com");
|
||||
try
|
||||
{
|
||||
@@ -127,7 +125,25 @@ public class EditModel : AdminPageModel
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSaveTileAsync(int sheetId, int frameIndex, string? name, int type, string? tags, bool isWalkable, bool blocksProjectiles, bool blocksLineOfSight, int renderLayer)
|
||||
public async Task<IActionResult> OnPostSaveTileAsync(
|
||||
int sheetId,
|
||||
int frameIndex,
|
||||
string? name,
|
||||
int type,
|
||||
string? tags,
|
||||
bool isWalkable,
|
||||
bool blocksProjectiles,
|
||||
bool blocksLineOfSight,
|
||||
int renderLayer,
|
||||
// Socket fields
|
||||
int socketN,
|
||||
int socketE,
|
||||
int socketS,
|
||||
int socketW,
|
||||
string? socketNCustom,
|
||||
string? socketECustom,
|
||||
string? socketSCustom,
|
||||
string? socketWCustom)
|
||||
{
|
||||
var existing = await _db.TileDefinitions
|
||||
.FirstOrDefaultAsync(t => t.TileMapSheetId == sheetId && t.FrameIndex == frameIndex);
|
||||
@@ -141,6 +157,15 @@ public class EditModel : AdminPageModel
|
||||
existing.BlocksProjectiles = blocksProjectiles;
|
||||
existing.BlocksLineOfSight = blocksLineOfSight;
|
||||
existing.RenderLayer = renderLayer;
|
||||
// Socket fields
|
||||
existing.SocketN = (SocketType)socketN;
|
||||
existing.SocketE = (SocketType)socketE;
|
||||
existing.SocketS = (SocketType)socketS;
|
||||
existing.SocketW = (SocketType)socketW;
|
||||
existing.SocketNCustom = socketN == 2 ? socketNCustom : null;
|
||||
existing.SocketECustom = socketE == 2 ? socketECustom : null;
|
||||
existing.SocketSCustom = socketS == 2 ? socketSCustom : null;
|
||||
existing.SocketWCustom = socketW == 2 ? socketWCustom : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -155,7 +180,16 @@ public class EditModel : AdminPageModel
|
||||
BlocksProjectiles = blocksProjectiles,
|
||||
BlocksLineOfSight = blocksLineOfSight,
|
||||
RenderLayer = renderLayer,
|
||||
IsEnabled = true
|
||||
IsEnabled = true,
|
||||
// Socket fields
|
||||
SocketN = (SocketType)socketN,
|
||||
SocketE = (SocketType)socketE,
|
||||
SocketS = (SocketType)socketS,
|
||||
SocketW = (SocketType)socketW,
|
||||
SocketNCustom = socketN == 2 ? socketNCustom : null,
|
||||
SocketECustom = socketE == 2 ? socketECustom : null,
|
||||
SocketSCustom = socketS == 2 ? socketSCustom : null,
|
||||
SocketWCustom = socketW == 2 ? socketWCustom : null
|
||||
});
|
||||
}
|
||||
|
||||
@@ -190,20 +224,65 @@ public class EditModel : AdminPageModel
|
||||
{
|
||||
if (!existingFrames.Contains(i))
|
||||
{
|
||||
_db.TileDefinitions.Add(new TileDefinition
|
||||
var tile = new TileDefinition
|
||||
{
|
||||
TileMapSheetId = sheetId,
|
||||
FrameIndex = i,
|
||||
Type = (TileType)defaultType,
|
||||
IsWalkable = defaultType == 0, // Floor is walkable
|
||||
IsEnabled = true
|
||||
});
|
||||
};
|
||||
|
||||
// Auto-configure sockets based on type
|
||||
tile.AutoConfigureSockets();
|
||||
|
||||
_db.TileDefinitions.Add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
return RedirectToPage(new { id = sheetId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auto-configure sockets for all tiles based on their type
|
||||
/// </summary>
|
||||
public async Task<IActionResult> OnPostAutoConfigureSocketsAsync(int sheetId)
|
||||
{
|
||||
var tiles = await _db.TileDefinitions
|
||||
.Where(t => t.TileMapSheetId == sheetId)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var tile in tiles)
|
||||
{
|
||||
tile.AutoConfigureSockets();
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
Message = $"Auto-configured sockets for {tiles.Count} tiles.";
|
||||
return RedirectToPage(new { id = sheetId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulk set all tile sockets to a specific type
|
||||
/// </summary>
|
||||
public async Task<IActionResult> OnPostBulkSetSocketsAsync(int sheetId, int socketType)
|
||||
{
|
||||
var tiles = await _db.TileDefinitions
|
||||
.Where(t => t.TileMapSheetId == sheetId)
|
||||
.ToListAsync();
|
||||
|
||||
var type = (SocketType)socketType;
|
||||
foreach (var tile in tiles)
|
||||
{
|
||||
tile.SetAllSockets(type);
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
Message = $"Set all sockets to {type} for {tiles.Count} tiles.";
|
||||
return RedirectToPage(new { id = sheetId });
|
||||
}
|
||||
|
||||
private string NormalizeCdnBaseUrl(string? baseUrl)
|
||||
{
|
||||
baseUrl = string.IsNullOrWhiteSpace(baseUrl)
|
||||
|
||||
Reference in New Issue
Block a user