Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 9 additions & 85 deletions Turbo.Rooms/Grains/RoomGrain.Furni.Floor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Turbo.Primitives.Action;
using Turbo.Primitives.Furniture.Snapshots.WiredData;
using Turbo.Primitives.Inventory.Snapshots;
Expand All @@ -18,19 +19,7 @@ public sealed partial class RoomGrain
{
public async Task<bool> AddFloorItemAsync(IRoomFloorItem item, CancellationToken ct)
{
try
{
if (!await _actionModule.AddFloorItemAsync(item, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.AddFloorItemAsync(item, ct).ConfigureAwait(false);
}

public async Task<bool> PlaceFloorItemAsync(
Expand All @@ -42,19 +31,7 @@ public async Task<bool> PlaceFloorItemAsync(
CancellationToken ct
)
{
try
{
if (!await _actionModule.PlaceFloorItemAsync(ctx, item, x, y, rot, ct))
return false;

return true;
}
catch (Exception)
{
// TODO handle exceptions

return false;
}
return await _actionModule.PlaceFloorItemAsync(ctx, item, x, y, rot, ct).ConfigureAwait(false);
}

public async Task<bool> MoveFloorItemByIdAsync(
Expand All @@ -66,19 +43,7 @@ public async Task<bool> MoveFloorItemByIdAsync(
CancellationToken ct
)
{
try
{
if (!await _actionModule.MoveFloorItemByIdAsync(ctx, itemId, x, y, rot, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.MoveFloorItemByIdAsync(ctx, itemId, x, y, rot, ct).ConfigureAwait(false);
}

public async Task<bool> RemoveFloorItemByIdAsync(
Expand All @@ -87,19 +52,7 @@ public async Task<bool> RemoveFloorItemByIdAsync(
CancellationToken ct
)
{
try
{
if (!await _actionModule.RemoveFloorItemByIdAsync(ctx, itemId, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.RemoveFloorItemByIdAsync(ctx, itemId, ct).ConfigureAwait(false);
}

public async Task<bool> UseFloorItemByIdAsync(
Expand All @@ -109,19 +62,7 @@ public async Task<bool> UseFloorItemByIdAsync(
int param = -1
)
{
try
{
if (!await _actionModule.UseFloorItemByIdAsync(ctx, itemId, ct, param))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.UseFloorItemByIdAsync(ctx, itemId, ct, param).ConfigureAwait(false);
}

public async Task<bool> ClickFloorItemByIdAsync(
Expand All @@ -131,19 +72,7 @@ public async Task<bool> ClickFloorItemByIdAsync(
int param = -1
)
{
try
{
if (!await _actionModule.ClickFloorItemByIdAsync(ctx, itemId, ct, param))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.ClickFloorItemByIdAsync(ctx, itemId, ct, param).ConfigureAwait(false);
}

public async Task<bool> ApplyWiredUpdateAsync(
Expand All @@ -155,16 +84,11 @@ CancellationToken ct
{
try
{
if (!await _actionModule.ApplyWiredUpdateAsync(ctx, itemId, update, ct))
return false;

return true;
return await _actionModule.ApplyWiredUpdateAsync(ctx, itemId, update, ct).ConfigureAwait(false);
}
catch (Exception ex)
{
Console.WriteLine(ex);
// TODO handle exceptions

_logger.LogError(ex, "Failed to apply wired update for item {ItemId} in room {RoomId}", itemId, _roomId);
return false;
}
}
Expand Down
104 changes: 15 additions & 89 deletions Turbo.Rooms/Grains/RoomGrain.Furni.Wall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,7 @@ public sealed partial class RoomGrain
{
public async Task<bool> AddWallItemAsync(IRoomWallItem item, CancellationToken ct)
{
try
{
if (!await _actionModule.AddWallItemAsync(item, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.AddWallItemAsync(item, ct).ConfigureAwait(false);
}

public async Task<bool> PlaceWallItemAsync(
Expand All @@ -40,19 +28,7 @@ public async Task<bool> PlaceWallItemAsync(
CancellationToken ct
)
{
try
{
if (!await _actionModule.PlaceWallItemAsync(ctx, item, x, y, z, wallOffset, rot, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.PlaceWallItemAsync(ctx, item, x, y, z, wallOffset, rot, ct).ConfigureAwait(false);
}

public async Task<bool> MoveWallItemByIdAsync(
Expand All @@ -66,30 +42,16 @@ public async Task<bool> MoveWallItemByIdAsync(
CancellationToken ct
)
{
try
{
if (
!await _actionModule.MoveWallItemByIdAsync(
ctx,
itemId,
newX,
newY,
newZ,
wallOffset,
newRot,
ct
)
)
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.MoveWallItemByIdAsync(
ctx,
itemId,
newX,
newY,
newZ,
wallOffset,
newRot,
ct
).ConfigureAwait(false);
}

public async Task<bool> RemoveWallItemByIdAsync(
Expand All @@ -98,19 +60,7 @@ public async Task<bool> RemoveWallItemByIdAsync(
CancellationToken ct
)
{
try
{
if (!await _actionModule.RemoveWallItemByIdAsync(ctx, itemId, ct))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.RemoveWallItemByIdAsync(ctx, itemId, ct).ConfigureAwait(false);
}

public async Task<bool> UseWallItemByIdAsync(
Expand All @@ -120,19 +70,7 @@ public async Task<bool> UseWallItemByIdAsync(
int param = -1
)
{
try
{
if (!await _actionModule.UseWallItemByIdAsync(ctx, itemId, ct, param))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.UseWallItemByIdAsync(ctx, itemId, ct, param).ConfigureAwait(false);
}

public async Task<bool> ClickWallItemByIdAsync(
Expand All @@ -142,19 +80,7 @@ public async Task<bool> ClickWallItemByIdAsync(
int param = -1
)
{
try
{
if (!await _actionModule.ClickWallItemByIdAsync(ctx, itemId, ct, param))
return false;

return true;
}
catch
{
// TODO handle exceptions

return false;
}
return await _actionModule.ClickWallItemByIdAsync(ctx, itemId, ct, param).ConfigureAwait(false);
}

public Task<RoomWallItemSnapshot?> GetWallItemSnapshotByIdAsync(
Expand Down
4 changes: 0 additions & 4 deletions Turbo.Rooms/Grains/RoomGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ await dbCtx.Rooms.AsNoTracking().SingleOrDefaultAsync(e => e.Id == (int)_roomId,
LastUpdatedUtc = DateTime.UtcNow,
};
}
catch (Exception)
{
throw;
}
finally
{
await dbCtx.DisposeAsync();
Expand Down
Loading