1
0
Fork 0
polaris-task-force/src/collections/logistics/Vehicles.ts

408 lines
10 KiB
TypeScript

import { CollectionConfig } from "payload";
import { isDeveloper } from "@/utils/access-control/isRole";
export const Vehicles: CollectionConfig = {
slug: "vehicles",
admin: {
useAsTitle: "name",
group: "Logistics",
},
fields: [
{
label: "Identity",
type: "group",
fields: [
{
name: "name",
type: "text",
required: true,
},
{
name: "classname",
type: "text",
admin: {
description:
"If not provided, this vehicle will ONLY be available as a virtual asset (i.e., cannot be used in Arma.)",
},
},
{
name: "approvalStatus",
type: "select",
label: "Approval Status",
options: [
{ label: "In Progress", value: "in_progress" },
{ label: "Ready for Review", value: "ready_for_review" },
{ label: "Approved", value: "approved" },
{ label: "Rejected", value: "rejected" },
{ label: "Revision Requested", value: "revision_requested" },
],
defaultValue: "in_progress",
filterOptions: ({ options, data, req }) => {
return !isDeveloper({ req })
? options.filter((option) =>
typeof option === "string"
? options
: ["in_progress", "ready_for_review"].includes(option.value),
)
: options;
},
required: true,
admin: {
description:
"Mark whether this vehicle is ready for developer approval and implementation into the live environment.",
},
},
{
name: "description",
type: "richText",
admin: {
description:
"A detailed description of the vehicle, including details like tactical usage, mechanical details, and/or world lore regarding this vehicle.",
},
},
{
name: "image",
type: "upload",
relationTo: "media",
},
{
name: "category",
type: "select",
hasMany: true,
options: [
{
label: "Civilian",
value: "civilian",
},
{
label: "Utility",
value: "utility",
},
{
label: "Transport",
value: "transport",
},
{
label: "Weaponized",
value: "weaponized",
},
{
label: "Military",
value: "military",
},
],
},
{
name: "fuel",
type: "group",
admin: {
description:
"Fuel configuration for this vehicle. Defines what fuel type it uses, how much it can hold, and how fast it consumes fuel.",
},
fields: [
{
name: "fuelType",
type: "relationship",
relationTo: "resources",
required: true,
admin: {
description:
"The type of fuel this vehicle consumes (e.g., gasoline, diesel, jet fuel).",
},
},
{
name: "fuelCapacity",
type: "number",
required: true,
admin: {
description: "Maximum fuel units this vehicle's tank can hold.",
},
},
{
name: "fuelConsumptionRate",
type: "number",
required: true,
defaultValue: 1,
admin: {
description: "Fuel consumed per unit of distance traveled.",
},
},
],
},
],
},
{
label: "Construction",
type: "group",
fields: [
{
name: "materials",
type: "array",
fields: [
{
name: "resource",
type: "relationship",
required: true,
relationTo: "resources",
},
{
name: "amount",
type: "number",
},
],
},
{
name: "constructionTime",
type: "number",
admin: {
description: "The number of ticks it takes to complete construction of this vehicle.",
},
},
{
name: "requiredTech",
type: "relationship",
relationTo: "technologies",
hasMany: true,
label: "Required Technologies",
admin: {
description: "What research must be done before this can be built.",
},
},
{
name: "requiredStructure",
type: "join",
collection: "structures",
on: "canProduce",
},
],
},
{
label: "Scrapping & Maintenance",
type: "group",
fields: [
{
name: "scrapReturns",
type: "array",
label: "Materials Returned when Scrapped",
fields: [
{
name: "resource",
type: "relationship",
required: true,
relationTo: "resources",
},
{
name: "amount",
type: "number",
defaultValue: 1,
},
{
name: "chance",
type: "number",
min: 0,
max: 100,
defaultValue: 100,
admin: {
description:
"An optional percent (%) chance to recover this specific resource (between 0 and 100).",
},
},
],
},
{
name: "upkeepCosts",
type: "array",
admin: {
description: "Recurring costs to keep this vehicle operational.",
},
fields: [
{
name: "resource",
type: "relationship",
required: true,
relationTo: "resources",
},
{
name: "amount",
type: "number",
defaultValue: 1,
admin: {
description: "How much of this resource is consumed per tick.",
},
},
],
},
],
},
{
label: "Logistics & Grid Storage",
type: "group",
fields: [
{
label: "Storage Grid Dimensions",
type: "group",
fields: [
{
name: "width",
type: "number",
},
{
name: "height",
type: "number",
},
],
},
{
label: "Cargo Capacity",
type: "group",
fields: [
{
name: "maxMass",
label: "Max Weight (kg.)",
type: "number",
},
{
name: "aceCargoSlots",
type: "number",
label: "ACE Cargo Slots",
admin: {
description: "The number of ACE cargo slots this vehicle has by default.",
},
},
{
name: "allowedVirtualCargo",
type: "array",
admin: {
description:
"The cargo this vehicle is permitted to carry if used virtually (e.g., during deliveries, moving troops, etc.)",
},
fields: [
{
name: "item",
type: "relationship",
relationTo: ["assets", "vehicles", "resources"],
required: true,
},
{
name: "amount",
type: "number",
defaultValue: 1,
},
],
},
],
},
],
},
{
label: "Combat & Performance",
type: "group",
fields: [
{
label: "Durability",
type: "group",
admin: {
description:
"These attributes only apply to the virtual vehicle and are not required nor expected to match the in-game version's actual attributes.",
},
fields: [
{
name: "maxHealth",
type: "number",
},
{
name: "armorRating",
type: "select",
options: [
{
label: "None",
value: "none",
},
{
label: "Light",
value: "light",
},
{
label: "Medium",
value: "medium",
},
{
label: "Heavy",
value: "heavy",
},
{
label: "Composite",
value: "composite",
},
],
},
],
},
{
label: "Speed & Agility",
type: "group",
fields: [
{
name: "maxSpeedOnRoad",
type: "number",
},
{
name: "maxSpeedOffRoad",
type: "number",
},
{
name: "maxAirspeed",
type: "number",
},
{
name: "maxKnots",
type: "number",
},
],
},
{
name: "pylons",
label: "Pylons & Mounted Weapons",
type: "array",
fields: [
{
name: "pylonName",
type: "text",
required: true,
},
{
name: "pylonType",
type: "select",
required: true,
defaultValue: "mountedWeapon",
options: [
{
label: "Mounted Weapon",
value: "mountedWeapon",
},
{
label: "Pylon",
value: "pylon",
},
],
},
{
name: "amount",
type: "number",
defaultValue: 1,
},
{
name: "ammoType",
type: "relationship",
relationTo: "assets",
},
],
},
],
},
],
};