{"version":3,"file":"set.luau","names":[],"sources":["..\\..\\..\\src\\centurion\\commands\\set.ts"],"sourcesContent":["import { store } from \"@lisachandra/core/store\";\nimport { getItemFromGUID } from \"@lisachandra/matter/utils/item/state\";\nimport type { CommandContext } from \"@rbxts/centurion\";\nimport { CenturionType, Command, Guard, Register } from \"@rbxts/centurion\";\n\nimport { adminOrDeveloper } from \"../guards\";\n\n@Register()\n/**\n * Admin command that sets property values on an ECS item identified by its GUID.\n *\n * @remarks\n *   Properties are parsed from a comma-separated `key:value` string. Supported value types are\n *   `string` and `number`.\n */\nexport class SetCommand {\n\t@Command({\n\t\targuments: [\n\t\t\t{\n\t\t\t\ttype: CenturionType.String,\n\t\t\t\tdescription: \"The GUID of the item you want to modify.\",\n\t\t\t\tname: \"itemGuid\",\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: CenturionType.String,\n\t\t\t\tdescription:\n\t\t\t\t\t\"The properties and values for the item you want to modify.\\nFormat: key:value\",\n\t\t\t\tname: \"properties\",\n\t\t\t},\n\t\t],\n\t\tdescription: \"Set new values to an item's properties.\",\n\t\tname: \"set\",\n\t})\n\t@Guard(adminOrDeveloper)\n\t/**\n\t * Applies key-value property updates to the item matching the given GUID.\n\t *\n\t * @param _ - The command context (unused).\n\t * @param guid - The GUID of the ECS item to modify.\n\t * @param propertiesStr - Comma-separated `key:value` pairs (e.g. `health:100,speed:16`).\n\t */\n\tpublic set(_: CommandContext, guid: string, propertiesStr: string): void {\n\t\tconst item = getItemFromGUID(store.world, guid);\n\t\tif (!item) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst properties = propertiesStr.split(\",\").map((str) => str.gsub(\"%s\", \"\")[0].split(\":\"));\n\t\tfor (const [key, value] of properties) {\n\t\t\tif (!typeIs(key, \"string\") || !(key in item.data)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (typeIs(item.data[key as never], \"string\")) {\n\t\t\t\titem.data[key as never] = value as never;\n\t\t\t} else if (typeIs(item.data[key as never], \"number\")) {\n\t\t\t\titem.data[key as never] = (tonumber(value) as never) ?? item.data[key as never];\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;AAAA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAEA;AAEA;AAAA;;;;;;;;;;;;;;AAmCE;AACA;AACC;AACD;AAEA;AAAA;AAAA;AAAA;;;AAAA;;AAA0F;AAA1F;AAAA;AACA;;;AACC;AACC;AACD;AAEA;AAAA;AACC;;;;AAEA;;AACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAFF","ignoreList":[]}