Add support for Cross Controller Planets (#562)

* Add support for Cross Controller Planets

* Clean
This commit is contained in:
Dagg 2022-11-17 20:54:46 -08:00 committed by GitHub
parent 74c70115b8
commit ca317d3afc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 2 deletions

3
.gitignore vendored
View file

@ -16,6 +16,9 @@ ProjectLighthouse/.vscode/launch.json
.editorconfig
launchSettings.json
# macOS Junk
.DS_Store
# Lighthouse junk
riderModule.iml
r/

View file

@ -131,6 +131,8 @@ public class UserController : ControllerBase
}
}
if (update.PlanetHashLBP2CC != null) user.PlanetHashLBP2CC = update.PlanetHashLBP2CC;
if (update.PlanetHash != null)
{
switch (token.GameVersion)

View file

@ -0,0 +1,30 @@
using LBPUnion.ProjectLighthouse;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ProjectLighthouse.Migrations
{
[DbContext(typeof(Database))]
[Migration("20221117165700_AddCrossControlPlanet")]
public partial class AddCrossControlPlanet : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PlanetHashLBP2CC",
table: "Users",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PlanetHashLBP2CC",
table: "Users");
}
}
}

View file

@ -130,6 +130,9 @@ public class User
[JsonIgnore]
public string PlanetHashLBP2 { get; set; } = "";
[JsonIgnore]
public string PlanetHashLBP2CC { get; set; } = "";
[JsonIgnore]
public string PlanetHashLBP3 { get; set; } = "";
@ -227,7 +230,7 @@ public class User
private string serializeEarth(GameVersion gameVersion)
{
return LbpSerializer.StringElement<string>
string planets = LbpSerializer.StringElement<string>
(
"planets",
gameVersion switch
@ -239,6 +242,10 @@ public class User
},
true
);
if (gameVersion == GameVersion.LittleBigPlanet2)
planets += LbpSerializer.StringElement("crossControlPlanet", this.PlanetHashLBP2CC);
return planets;
}
#region Slots

View file

@ -18,6 +18,9 @@ public class UserUpdate
[XmlElement("planets")]
public string? PlanetHash { get; set; }
[XmlElement("crossControlPlanet")]
public string? PlanetHashLBP2CC { get; set; }
[XmlArray("slots")]
[XmlArrayItem("slot")]
public List<UserUpdateSlot>? Slots { get; set; }