mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-20 03:24:51 +00:00
Add support for moving levels with decoration tool (#440)
Co-authored-by: Jayden <jvyden@jvyden.xyz>
This commit is contained in:
parent
9d877f9eef
commit
f06fcc4847
3 changed files with 47 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
20
ProjectLighthouse/PlayerData/Profiles/UserUpdateSlot.cs
Normal file
20
ProjectLighthouse/PlayerData/Profiles/UserUpdateSlot.cs
Normal 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; }
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue