2024-02-18 13:58:43 +01:00
|
|
|
import { toOid } from "@/src/helpers/inventoryHelpers";
|
2024-12-23 09:15:41 +01:00
|
|
|
import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
|
2024-12-23 06:21:48 +01:00
|
|
|
import { IOrbiter, IPersonalRoomsDatabase, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
|
2024-12-22 20:32:19 +01:00
|
|
|
import {
|
|
|
|
IApartment,
|
|
|
|
IFavouriteLoadoutDatabase,
|
|
|
|
IGardening,
|
|
|
|
IPlacedDecosDatabase,
|
|
|
|
IPictureFrameInfo,
|
|
|
|
IRoom,
|
|
|
|
ITailorShopDatabase
|
|
|
|
} from "@/src/types/shipTypes";
|
2024-02-18 13:58:43 +01:00
|
|
|
import { Schema, model } from "mongoose";
|
|
|
|
|
2024-10-18 16:54:49 +02:00
|
|
|
const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
|
|
|
{
|
|
|
|
Image: String,
|
|
|
|
Filter: String,
|
|
|
|
XOffset: Number,
|
|
|
|
YOffset: Number,
|
|
|
|
Scale: Number,
|
|
|
|
InvertX: Boolean,
|
|
|
|
InvertY: Boolean,
|
|
|
|
ColorCorrection: Number,
|
|
|
|
Text: String,
|
|
|
|
TextScale: Number,
|
|
|
|
TextColorA: Number,
|
|
|
|
TextColorB: Number,
|
|
|
|
TextOrientation: Number
|
|
|
|
},
|
|
|
|
{ id: false, _id: false }
|
|
|
|
);
|
|
|
|
|
2024-02-18 13:58:43 +01:00
|
|
|
const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
|
|
|
|
{
|
|
|
|
Type: String,
|
|
|
|
Pos: [Number],
|
2024-06-15 17:39:13 +02:00
|
|
|
Rot: [Number],
|
2024-10-18 16:54:49 +02:00
|
|
|
Scale: Number,
|
|
|
|
PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined }
|
2024-02-18 13:58:43 +01:00
|
|
|
},
|
|
|
|
{ id: false }
|
|
|
|
);
|
|
|
|
|
|
|
|
placedDecosSchema.virtual("id").get(function (this: IPlacedDecosDatabase) {
|
|
|
|
return toOid(this._id);
|
|
|
|
});
|
|
|
|
|
|
|
|
placedDecosSchema.set("toJSON", {
|
|
|
|
virtuals: true,
|
|
|
|
transform(_document, returnedObject) {
|
|
|
|
delete returnedObject._id;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-12-22 20:32:19 +01:00
|
|
|
const roomSchema = new Schema<IRoom>(
|
2024-02-18 13:58:43 +01:00
|
|
|
{
|
|
|
|
Name: String,
|
|
|
|
MaxCapacity: Number,
|
2024-12-23 06:21:48 +01:00
|
|
|
PlacedDecos: { type: [placedDecosSchema], default: undefined }
|
2024-02-18 13:58:43 +01:00
|
|
|
},
|
|
|
|
{ _id: false }
|
|
|
|
);
|
|
|
|
|
|
|
|
const gardeningSchema = new Schema<IGardening>({
|
|
|
|
Planters: [Schema.Types.Mixed] //TODO: add when implementing gardening
|
|
|
|
});
|
|
|
|
|
|
|
|
const apartmentSchema = new Schema<IApartment>(
|
|
|
|
{
|
|
|
|
Rooms: [roomSchema],
|
|
|
|
FavouriteLoadouts: [Schema.Types.Mixed],
|
2025-01-24 14:13:21 +01:00
|
|
|
Gardening: gardeningSchema // TODO: ensure this is correct
|
2024-02-18 13:58:43 +01:00
|
|
|
},
|
|
|
|
{ _id: false }
|
|
|
|
);
|
2025-01-20 18:25:50 +01:00
|
|
|
const apartmentDefault: IApartment = {
|
|
|
|
Rooms: [
|
|
|
|
{ Name: "ElevatorLanding", MaxCapacity: 1600 },
|
|
|
|
{ Name: "ApartmentRoomA", MaxCapacity: 1000 },
|
|
|
|
{ Name: "ApartmentRoomB", MaxCapacity: 1600 },
|
|
|
|
{ Name: "ApartmentRoomC", MaxCapacity: 1600 },
|
|
|
|
{ Name: "DuviriHallway", MaxCapacity: 1600 }
|
|
|
|
],
|
|
|
|
FavouriteLoadouts: [],
|
|
|
|
Gardening: {}
|
|
|
|
};
|
2024-02-18 13:58:43 +01:00
|
|
|
|
|
|
|
const orbiterSchema = new Schema<IOrbiter>(
|
2024-05-06 15:39:27 +02:00
|
|
|
{
|
|
|
|
Features: [String],
|
|
|
|
Rooms: [roomSchema],
|
2025-01-20 18:25:50 +01:00
|
|
|
ContentUrlSignature: { type: String, required: false },
|
2024-05-06 15:39:27 +02:00
|
|
|
BootLocation: String
|
|
|
|
},
|
2024-02-18 13:58:43 +01:00
|
|
|
{ _id: false }
|
|
|
|
);
|
2025-01-20 18:25:50 +01:00
|
|
|
const orbiterDefault: IOrbiter = {
|
2025-01-24 14:13:21 +01:00
|
|
|
Features: ["/Lotus/Types/Items/ShipFeatureItems/EarthNavigationFeatureItem"], //TODO: potentially remove after missionstarting gear
|
2025-01-20 18:25:50 +01:00
|
|
|
Rooms: [
|
|
|
|
{ Name: "AlchemyRoom", MaxCapacity: 1600 },
|
|
|
|
{ Name: "BridgeRoom", MaxCapacity: 1600 },
|
|
|
|
{ Name: "LisetRoom", MaxCapacity: 1000 },
|
|
|
|
{ Name: "OperatorChamberRoom", MaxCapacity: 1600 },
|
|
|
|
{ Name: "OutsideRoom", MaxCapacity: 1600 },
|
|
|
|
{ Name: "PersonalQuartersRoom", MaxCapacity: 1600 }
|
|
|
|
]
|
|
|
|
};
|
2024-02-18 13:58:43 +01:00
|
|
|
|
2024-12-22 20:32:19 +01:00
|
|
|
const favouriteLoadoutSchema = new Schema<IFavouriteLoadoutDatabase>(
|
|
|
|
{
|
|
|
|
Tag: String,
|
|
|
|
LoadoutId: Schema.Types.ObjectId
|
|
|
|
},
|
|
|
|
{ _id: false }
|
|
|
|
);
|
|
|
|
favouriteLoadoutSchema.set("toJSON", {
|
|
|
|
virtuals: true,
|
|
|
|
transform(_document, returnedObject) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
|
|
returnedObject.LoadoutId = toOid(returnedObject.LoadoutId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const tailorShopSchema = new Schema<ITailorShopDatabase>(
|
|
|
|
{
|
|
|
|
FavouriteLoadouts: [favouriteLoadoutSchema],
|
2025-02-08 17:41:33 -08:00
|
|
|
Colors: { type: colorSchema, required: false },
|
2024-12-22 20:32:19 +01:00
|
|
|
CustomJson: String,
|
|
|
|
LevelDecosVisible: Boolean,
|
|
|
|
Rooms: [roomSchema]
|
|
|
|
},
|
|
|
|
{ _id: false }
|
|
|
|
);
|
|
|
|
const tailorShopDefault: ITailorShopDatabase = {
|
|
|
|
FavouriteLoadouts: [],
|
|
|
|
CustomJson: "{}",
|
|
|
|
LevelDecosVisible: true,
|
|
|
|
Rooms: [
|
2025-01-20 18:25:50 +01:00
|
|
|
{ Name: "LabRoom", MaxCapacity: 4000 },
|
|
|
|
{ Name: "LivingQuartersRoom", MaxCapacity: 3000 },
|
|
|
|
{ Name: "HelminthRoom", MaxCapacity: 2000 }
|
2024-12-22 20:32:19 +01:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2024-12-23 06:21:48 +01:00
|
|
|
export const personalRoomsSchema = new Schema<IPersonalRoomsDatabase>({
|
2024-02-18 13:58:43 +01:00
|
|
|
personalRoomsOwnerId: Schema.Types.ObjectId,
|
|
|
|
activeShipId: Schema.Types.ObjectId,
|
2024-12-23 09:15:41 +01:00
|
|
|
ShipInteriorColors: colorSchema,
|
2025-01-20 18:25:50 +01:00
|
|
|
Ship: { type: orbiterSchema, default: orbiterDefault },
|
|
|
|
Apartment: { type: apartmentSchema, default: apartmentDefault },
|
2024-12-23 06:21:48 +01:00
|
|
|
TailorShop: { type: tailorShopSchema, default: tailorShopDefault }
|
2024-02-18 13:58:43 +01:00
|
|
|
});
|
|
|
|
|
2025-03-16 08:46:02 -07:00
|
|
|
personalRoomsSchema.index({ personalRoomsOwnerId: 1 }, { unique: true });
|
|
|
|
|
2024-12-23 06:21:48 +01:00
|
|
|
export const PersonalRooms = model<IPersonalRoomsDatabase, PersonalRoomsModelType>(
|
|
|
|
"PersonalRooms",
|
|
|
|
personalRoomsSchema
|
|
|
|
);
|