XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

feat: articula customizations (#2636)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2636 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

62881aaa
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

6 个文件 +101 -25
Modified src/controllers/api/setPlacedDecoInfoController.ts +5 -9
@@ -1,23 +1,19 @@
1 1 import { getAccountIdForRequest } from "@/src/services/loginService";
2 import { IPictureFrameInfo, ISetPlacedDecoInfoRequest } from "@/src/types/personalRoomsTypes";
2 import { ISetPlacedDecoInfoRequest } from "@/src/types/personalRoomsTypes";
3 3 import { RequestHandler } from "express";
4 4 import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";
5 5
6 6 export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
7 7 const accountId = await getAccountIdForRequest(req);
8 8 const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
9 //console.log(JSON.stringify(payload, null, 2));
9 10 await handleSetPlacedDecoInfo(accountId, payload);
10 11 res.json({
11 DecoId: payload.DecoId,
12 IsPicture: true,
13 PictureFrameInfo: payload.PictureFrameInfo,
14 BootLocation: payload.BootLocation
12 ...payload,
13 IsPicture: !!payload.PictureFrameInfo
15 14 } satisfies ISetPlacedDecoInfoResponse);
16 15 };
17 16
18 interface ISetPlacedDecoInfoResponse {
19 DecoId: string;
17 interface ISetPlacedDecoInfoResponse extends ISetPlacedDecoInfoRequest {
20 18 IsPicture: boolean;
21 PictureFrameInfo?: IPictureFrameInfo;
22 BootLocation?: string;
23 19 }
Modified src/models/inventoryModels/loadoutModel.ts +1 -1
@@ -25,7 +25,7 @@ export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
25 25 }
26 26 );
27 27
28 const loadoutConfigSchema = new Schema<ILoadoutConfigDatabase>(
28 export const loadoutConfigSchema = new Schema<ILoadoutConfigDatabase>(
29 29 {
30 30 FocusSchool: String,
31 31 PresetIcon: String,
Modified src/models/personalRoomsModel.ts +21 -4
@@ -1,6 +1,7 @@
1 1 import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
2 2 import {
3 3 IApartmentDatabase,
4 ICustomizationInfoDatabase,
4 5 IFavouriteLoadoutDatabase,
5 6 IGardeningDatabase,
6 7 IOrbiterClient,
@@ -11,12 +12,13 @@ import {
11 12 IPlantClient,
12 13 IPlantDatabase,
13 14 IPlanterDatabase,
14 IRoom,
15 IRoomDatabase,
15 16 ITailorShopDatabase,
16 17 PersonalRoomsModelType
17 18 } from "@/src/types/personalRoomsTypes";
18 19 import { Schema, Types, model } from "mongoose";
19 20 import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
21 import { loadoutConfigSchema } from "@/src/models/inventoryModels/loadoutModel";
20 22
21 23 export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
22 24 {
@@ -34,7 +36,20 @@ export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
34 36 TextColorB: Number,
35 37 TextOrientation: Number
36 38 },
37 { id: false, _id: false }
39 { _id: false }
40 );
41
42 export const customizationInfoSchema = new Schema<ICustomizationInfoDatabase>(
43 {
44 Anim: String,
45 AnimPose: Number,
46 LoadOutPreset: loadoutConfigSchema,
47 VehiclePreset: loadoutConfigSchema,
48 EquippedWeapon: String,
49 AvatarType: String,
50 LoadOutType: String
51 },
52 { _id: false }
38 53 );
39 54
40 55 const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
@@ -44,7 +59,9 @@ const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
44 59 Rot: [Number],
45 60 Scale: Number,
46 61 Sockets: Number,
47 PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined }
62 PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined },
63 CustomizationInfo: { type: customizationInfoSchema, default: undefined },
64 AnimPoseItem: String
48 65 },
49 66 { id: false }
50 67 );
@@ -60,7 +77,7 @@ placedDecosSchema.set("toJSON", {
60 77 }
61 78 });
62 79
63 const roomSchema = new Schema<IRoom>(
80 const roomSchema = new Schema<IRoomDatabase>(
64 81 {
65 82 Name: String,
66 83 MaxCapacity: Number,
Modified src/services/importService.ts +33 -0
@@ -47,16 +47,22 @@ import {
47 47 import {
48 48 IApartmentClient,
49 49 IApartmentDatabase,
50 ICustomizationInfoClient,
51 ICustomizationInfoDatabase,
50 52 IFavouriteLoadout,
51 53 IFavouriteLoadoutDatabase,
52 54 IGetShipResponse,
53 55 IOrbiterClient,
54 56 IOrbiterDatabase,
55 57 IPersonalRoomsDatabase,
58 IPlacedDecosClient,
59 IPlacedDecosDatabase,
56 60 IPlantClient,
57 61 IPlantDatabase,
58 62 IPlanterClient,
59 63 IPlanterDatabase,
64 IRoomClient,
65 IRoomDatabase,
60 66 ITailorShop,
61 67 ITailorShopDatabase
62 68 } from "@/src/types/personalRoomsTypes";
@@ -446,6 +452,30 @@ export const importLoadOutPresets = (db: ILoadoutDatabase, client: ILoadOutPrese
446 452 db.DRIFTER = client.DRIFTER.map(convertLoadOutConfig);
447 453 };
448 454
455 export const convertCustomizationInfo = (client: ICustomizationInfoClient): ICustomizationInfoDatabase => {
456 return {
457 ...client,
458 LoadOutPreset: client.LoadOutPreset ? convertLoadOutConfig(client.LoadOutPreset) : undefined,
459 VehiclePreset: client.VehiclePreset ? convertLoadOutConfig(client.VehiclePreset) : undefined
460 };
461 };
462
463 const convertDeco = (client: IPlacedDecosClient): IPlacedDecosDatabase => {
464 const { id, ...rest } = client;
465 return {
466 ...rest,
467 CustomizationInfo: client.CustomizationInfo ? convertCustomizationInfo(client.CustomizationInfo) : undefined,
468 _id: new Types.ObjectId(id.$oid)
469 };
470 };
471
472 const convertRoom = (client: IRoomClient): IRoomDatabase => {
473 return {
474 ...client,
475 PlacedDecos: client.PlacedDecos ? client.PlacedDecos.map(convertDeco) : []
476 };
477 };
478
449 479 const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
450 480 return {
451 481 ...client,
@@ -453,6 +483,7 @@ const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
453 483 ...client.ShipInterior,
454 484 Colors: Array.isArray(client.ShipInterior.Colors) ? {} : client.ShipInterior.Colors
455 485 },
486 Rooms: client.Rooms.map(convertRoom),
456 487 FavouriteLoadoutId: client.FavouriteLoadoutId ? new Types.ObjectId(client.FavouriteLoadoutId.$oid) : undefined
457 488 };
458 489 };
@@ -481,6 +512,7 @@ const convertFavouriteLoadout = (client: IFavouriteLoadout): IFavouriteLoadoutDa
481 512 const convertApartment = (client: IApartmentClient): IApartmentDatabase => {
482 513 return {
483 514 ...client,
515 Rooms: client.Rooms.map(convertRoom),
484 516 Gardening: { Planters: client.Gardening.Planters.map(convertPlanter) },
485 517 FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
486 518 };
@@ -489,6 +521,7 @@ const convertApartment = (client: IApartmentClient): IApartmentDatabase => {
489 521 const convertTailorShop = (client: ITailorShop): ITailorShopDatabase => {
490 522 return {
491 523 ...client,
524 Rooms: client.Rooms.map(convertRoom),
492 525 Colors: Array.isArray(client.Colors) ? {} : client.Colors,
493 526 FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
494 527 };
Modified src/services/shipCustomizationsService.ts +3 -0
@@ -19,6 +19,7 @@ import { Guild } from "@/src/models/guildModel";
19 19 import { hasGuildPermission } from "@/src/services/guildService";
20 20 import { GuildPermission } from "@/src/types/guildTypes";
21 21 import { ExportResources } from "warframe-public-export-plus";
22 import { convertCustomizationInfo } from "@/src/services/importService";
22 23
23 24 export const setShipCustomizations = async (
24 25 accountId: string,
@@ -269,6 +270,8 @@ export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlaced
269 270 }
270 271
271 272 placedDeco.PictureFrameInfo = req.PictureFrameInfo;
273 placedDeco.CustomizationInfo = req.CustomizationInfo ? convertCustomizationInfo(req.CustomizationInfo) : undefined;
274 placedDeco.AnimPoseItem = req.AnimPoseItem;
272 275
273 276 await personalRooms.save();
274 277 };
Modified src/types/personalRoomsTypes.ts +38 -11
@@ -1,6 +1,6 @@
1 1 import { IColor, IShipAttachments, IShipCustomization } from "@/src/types/inventoryTypes/commonInventoryTypes";
2 2 import { Document, Model, Types } from "mongoose";
3 import { ILoadoutClient } from "@/src/types/saveLoadoutTypes";
3 import { ILoadoutClient, ILoadoutConfigClient, ILoadoutConfigDatabase } from "@/src/types/saveLoadoutTypes";
4 4 import { IMongoDate, IOid } from "@/src/types/commonTypes";
5 5
6 6 export interface IGetShipResponse {
@@ -17,7 +17,7 @@ export interface IOrbiterClient {
17 17 Features: string[];
18 18 ShipId: IOid;
19 19 ShipInterior: IShipCustomization;
20 Rooms: IRoom[];
20 Rooms: IRoomClient[];
21 21 VignetteFish?: string[];
22 22 FavouriteLoadoutId?: IOid;
23 23 Wallpaper?: string;
@@ -28,7 +28,7 @@ export interface IOrbiterClient {
28 28
29 29 export interface IOrbiterDatabase {
30 30 Features: string[];
31 Rooms: IRoom[];
31 Rooms: IRoomDatabase[];
32 32 ShipInterior?: IShipCustomization;
33 33 VignetteFish?: string[];
34 34 FavouriteLoadoutId?: Types.ObjectId;
@@ -53,12 +53,18 @@ export interface IPersonalRoomsDatabase {
53 53 TailorShop: ITailorShopDatabase;
54 54 }
55 55
56 export interface IRoom {
56 export interface IRoomDatabase {
57 57 Name: string;
58 58 MaxCapacity: number;
59 59 PlacedDecos?: IPlacedDecosDatabase[];
60 60 }
61 61
62 export interface IRoomClient {
63 Name: string;
64 MaxCapacity: number;
65 PlacedDecos?: IPlacedDecosClient[];
66 }
67
62 68 export interface IPlantClient {
63 69 PlantType: string;
64 70 EndTime: IMongoDate;
@@ -89,7 +95,7 @@ export interface IGardeningDatabase {
89 95
90 96 export interface IApartmentClient {
91 97 Gardening: IGardeningClient;
92 Rooms: IRoom[];
98 Rooms: IRoomClient[];
93 99 FavouriteLoadouts?: IFavouriteLoadout[];
94 100 VideoWallBackdrop?: string;
95 101 Soundscape?: string;
@@ -97,7 +103,7 @@ export interface IApartmentClient {
97 103
98 104 export interface IApartmentDatabase {
99 105 Gardening: IGardeningDatabase;
100 Rooms: IRoom[];
106 Rooms: IRoomDatabase[];
101 107 FavouriteLoadouts: IFavouriteLoadoutDatabase[];
102 108 VideoWallBackdrop?: string;
103 109 Soundscape?: string;
@@ -110,11 +116,14 @@ export interface IPlacedDecosDatabase {
110 116 Scale?: number;
111 117 Sockets?: number;
112 118 PictureFrameInfo?: IPictureFrameInfo;
119 CustomizationInfo?: ICustomizationInfoDatabase;
120 AnimPoseItem?: string;
113 121 _id: Types.ObjectId;
114 122 }
115 123
116 export interface IPlacedDecosClient extends Omit<IPlacedDecosDatabase, "_id"> {
124 export interface IPlacedDecosClient extends Omit<IPlacedDecosDatabase, "_id" | "CustomizationInfo"> {
117 125 id: IOid;
126 CustomizationInfo?: ICustomizationInfoClient;
118 127 }
119 128
120 129 export interface ISetShipCustomizationsRequest {
@@ -166,11 +175,13 @@ export interface IResetShipDecorationsResponse {
166 175 }
167 176
168 177 export interface ISetPlacedDecoInfoRequest {
169 DecoType: string;
178 DecoType?: string;
170 179 DecoId: string;
171 180 Room: string;
172 PictureFrameInfo: IPictureFrameInfo;
181 PictureFrameInfo: IPictureFrameInfo; // IsPicture
182 CustomizationInfo?: ICustomizationInfoClient; // !IsPicture
173 183 BootLocation?: TBootLocation;
184 AnimPoseItem?: string; // !IsPicture
174 185 ComponentId?: string;
175 186 GuildId?: string;
176 187 }
@@ -191,6 +202,21 @@ export interface IPictureFrameInfo {
191 202 TextOrientation: number;
192 203 }
193 204
205 export interface ICustomizationInfoClient {
206 Anim?: string;
207 AnimPose?: number;
208 LoadOutPreset?: ILoadoutConfigClient;
209 VehiclePreset?: ILoadoutConfigClient;
210 EquippedWeapon?: "SUIT_SLOT" | "LONG_GUN_SLOT" | "PISTOL_SLOT";
211 AvatarType?: string;
212 LoadOutType?: string; // "LOT_NORMAL"
213 }
214
215 export interface ICustomizationInfoDatabase extends Omit<ICustomizationInfoClient, "LoadOutPreset" | "VehiclePreset"> {
216 LoadOutPreset?: ILoadoutConfigDatabase;
217 VehiclePreset?: ILoadoutConfigDatabase;
218 }
219
194 220 export interface IFavouriteLoadout {
195 221 Tag: string;
196 222 LoadoutId: IOid;
@@ -206,10 +232,11 @@ export interface ITailorShopDatabase {
206 232 Colors?: IColor;
207 233 CustomJson?: string;
208 234 LevelDecosVisible?: boolean;
209 Rooms: IRoom[];
235 Rooms: IRoomDatabase[];
210 236 }
211 237
212 export interface ITailorShop extends Omit<ITailorShopDatabase, "FavouriteLoadouts"> {
238 export interface ITailorShop extends Omit<ITailorShopDatabase, "Rooms" | "FavouriteLoadouts"> {
239 Rooms: IRoomClient[];
213 240 FavouriteLoadouts?: IFavouriteLoadout[];
214 241 }
215 242