-
Notifications
You must be signed in to change notification settings - Fork 83
Feat: UGC Blueprints #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat: UGC Blueprints #239
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a94c3f0
Feat: UGC Blueprints
AngeloTadeucci 8145205
suggestions
AngeloTadeucci 7d5c608
fix packet
AngeloTadeucci 3bbb04b
fix exception
AngeloTadeucci f2c185d
Update GameStorage.User.cs
AngeloTadeucci b78fa9a
suggestion
AngeloTadeucci c786892
move StagedItemBlueprint to HousingManager
AngeloTadeucci 5b19c20
fix migrations
AngeloTadeucci 7d52b0f
fix: layouts duping cubes
AngeloTadeucci d34c06f
.
AngeloTadeucci 6d76c60
Merge branch 'master' into home_layouts
AngeloTadeucci c3af809
Merge branch 'master' into home_layouts
AngeloTadeucci f6e4ee8
suggestions
AngeloTadeucci 442168d
save home properties & load when its blueprint
AngeloTadeucci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Maple2.Model.Enum; | ||
| using Maple2.Model.Game; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
|
||
| namespace Maple2.Database.Model; | ||
|
|
||
| internal class HomeLayout { | ||
| public long Uid { get; set; } | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } | ||
| public byte Area { get; set; } | ||
| public byte Height { get; set; } | ||
| public HomeBackground Background { get; set; } | ||
| public HomeLighting Lighting { get; set; } | ||
| public HomeCamera Camera { get; set; } | ||
| public DateTimeOffset Timestamp { get; set; } | ||
| public List<HomeLayoutCube> Cubes { get; set; } = null!; | ||
|
AngeloTadeucci marked this conversation as resolved.
|
||
|
|
||
| [return: NotNullIfNotNull(nameof(other))] | ||
| public static implicit operator HomeLayout?(Maple2.Model.Game.HomeLayout? other) { | ||
| return other == null ? null : new HomeLayout { | ||
| Uid = other.Uid, | ||
| Id = other.Id, | ||
| Name = other.Name, | ||
| Area = other.Area, | ||
| Height = other.Height, | ||
| Timestamp = other.Timestamp, | ||
| Cubes = other.Cubes.ConvertAll(cube => (HomeLayoutCube) cube), | ||
|
AngeloTadeucci marked this conversation as resolved.
|
||
| Background = other.Background, | ||
| Lighting = other.Lighting, | ||
| Camera = other.Camera, | ||
| }; | ||
| } | ||
|
|
||
| [return: NotNullIfNotNull(nameof(other))] | ||
| public static implicit operator Maple2.Model.Game.HomeLayout?(HomeLayout? other) { | ||
| if (other == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return new Maple2.Model.Game.HomeLayout(other.Uid, other.Id, other.Name, other.Area, other.Height, other.Timestamp, other.Cubes.ConvertAll(cube => (PlotCube) cube)) { | ||
| Background = other.Background, | ||
| Lighting = other.Lighting, | ||
| Camera = other.Camera, | ||
| }; | ||
| } | ||
|
|
||
| public static void Configure(EntityTypeBuilder<HomeLayout> builder) { | ||
| builder.ToTable("home-layout"); | ||
| builder.HasKey(layout => layout.Uid); | ||
| } | ||
|
AngeloTadeucci marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Maple2.Database.Extensions; | ||
| using Maple2.Model.Common; | ||
| using Maple2.Model.Game; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
|
||
| namespace Maple2.Database.Model; | ||
|
|
||
| internal class HomeLayoutCube { | ||
| public long Id { get; set; } | ||
| public long HomeLayoutId { get; set; } | ||
| public sbyte X { get; set; } | ||
| public sbyte Y { get; set; } | ||
| public sbyte Z { get; set; } | ||
|
AngeloTadeucci marked this conversation as resolved.
|
||
| public float Rotation { get; set; } | ||
|
|
||
| public int ItemId { get; set; } | ||
| public UgcItemLook? Template { get; set; } | ||
|
|
||
| [return: NotNullIfNotNull(nameof(other))] | ||
| public static implicit operator PlotCube?(HomeLayoutCube? other) { | ||
| return other == null ? null : new PlotCube(other.ItemId, other.Id, other.Template) { | ||
| Position = new Vector3B(other.X, other.Y, other.Z), | ||
| Rotation = other.Rotation, | ||
| }; | ||
| } | ||
|
|
||
| [return: NotNullIfNotNull(nameof(other))] | ||
| public static implicit operator HomeLayoutCube?(PlotCube? other) { | ||
| return other == null ? null : new HomeLayoutCube { | ||
| X = other.Position.X, | ||
| Y = other.Position.Y, | ||
| Z = other.Position.Z, | ||
| Rotation = other.Rotation, | ||
| ItemId = other.ItemId, | ||
| Template = other.Template, | ||
| }; | ||
| } | ||
|
AngeloTadeucci marked this conversation as resolved.
AngeloTadeucci marked this conversation as resolved.
|
||
|
|
||
| public static void Configure(EntityTypeBuilder<HomeLayoutCube> builder) { | ||
| builder.ToTable("home-layout-cube"); | ||
| builder.HasKey(cube => cube.Id); | ||
|
|
||
| builder.HasOne<HomeLayout>() | ||
| .WithMany(ugcMap => ugcMap.Cubes) | ||
| .HasForeignKey(cube => cube.HomeLayoutId); | ||
|
|
||
| builder.Property(cube => cube.Template).HasJsonConversion(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using Maple2.Database.Extensions; | ||
| using Maple2.Database.Model; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using HomeLayout = Maple2.Model.Game.HomeLayout; | ||
|
|
||
| namespace Maple2.Database.Storage; | ||
|
|
||
| public partial class GameStorage { | ||
| public partial class Request { | ||
| public HomeLayout? SaveHomeLayout(HomeLayout layout) { | ||
| Model.HomeLayout homeLayout = layout; | ||
| Context.HomeLayout.Add(homeLayout); | ||
| foreach (HomeLayoutCube cubes in homeLayout.Cubes) { | ||
| Context.UgcCubeLayout.Add(cubes); | ||
| } | ||
| bool success = Context.TrySaveChanges(); | ||
|
|
||
| return success ? homeLayout : null; | ||
| } | ||
|
|
||
| public void RemoveHomeLayout(HomeLayout layout) { | ||
| Model.HomeLayout homeLayout = layout; | ||
| Context.HomeLayout.Remove(homeLayout); | ||
| Context.TrySaveChanges(); | ||
| } | ||
|
|
||
| public HomeLayout? GetHomeLayout(long layoutUid) { | ||
| HomeLayout? layout = Context.HomeLayout | ||
| .Where(homeLayout => homeLayout.Uid == layoutUid) | ||
| .Include(homeLayout => homeLayout.Cubes) | ||
| .FirstOrDefault(); | ||
|
|
||
| return layout; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.