Add support for moving levels with decoration tool (#440)

Co-authored-by: Jayden <jvyden@jvyden.xyz>
This commit is contained in:
Josh 2022-08-19 17:43:12 -05:00 committed by GitHub
parent 9d877f9eef
commit f06fcc4847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 1 deletions

View file

@ -3,10 +3,10 @@ using System.Text.Json;
using System.Xml.Serialization;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Levels;
using LBPUnion.ProjectLighthouse.PlayerData;
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@ -122,6 +122,27 @@ public class UserController : ControllerBase
if (update.MehHash != null) user.MehHash = update.MehHash;
if (update.BooHash != null) user.BooHash = update.BooHash;
if (update.Slots != null)
{
foreach (UserUpdateSlot? updateSlot in update.Slots)
{
// ReSharper disable once MergeIntoNegatedPattern
if (updateSlot.Type != SlotType.User || updateSlot.Location == null || updateSlot.SlotId == 0) continue;
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == updateSlot.SlotId);
if (slot == null) continue;
if (slot.CreatorId != gameToken.UserId) continue;
Location? loc = await this.database.Locations.FirstOrDefaultAsync(l => l.Id == slot.LocationId);
if (loc == null) throw new ArgumentNullException();
loc.X = updateSlot.Location.X;
loc.Y = updateSlot.Location.Y;
}
}
if (update.PlanetHash != null)
{

View file

@ -1,4 +1,5 @@
#nullable enable
using System.Collections.Generic;
using System.Xml.Serialization;
namespace LBPUnion.ProjectLighthouse.PlayerData.Profiles;
@ -17,6 +18,10 @@ public class UserUpdate
[XmlElement("planets")]
public string? PlanetHash { get; set; }
[XmlArray("slots")]
[XmlArrayItem("slot")]
public List<UserUpdateSlot>? Slots { get; set; }
[XmlElement("yay2")]
public string? YayHash { get; set; }

View file

@ -0,0 +1,20 @@
#nullable enable
using System.Xml.Serialization;
using LBPUnion.ProjectLighthouse.Levels;
namespace LBPUnion.ProjectLighthouse.PlayerData.Profiles;
[XmlRoot("slot")]
public class UserUpdateSlot
{
[XmlElement("type")]
public SlotType? Type { get; set; }
[XmlElement("id")]
public int? SlotId { get; set; }
[XmlElement("location")]
public Location? Location { get; set; }
}