import { writeFileSync } from 'node:fs'; // 카드 전투용 자기등록 마커 codeblock(CombatMonster) 생성. // BeginPlay 시 /common 컨트롤러에 자기등록해 인카운터를 구성한다. // 맵 부착 값(EnemyId/Group)은 gen-map-encounters.mjs가 인스턴스에 직접 기록한다. function prop(Type, Name, DefaultValue = 'nil') { return { Type, DefaultValue, SyncDirection: 0, Attributes: [], Name }; } function method(Name, Code, Arguments = [], ExecSpace = 6) { return { Return: { Type: 'void', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: null }, Arguments, Code, Scope: 2, ExecSpace, Attributes: [], Name, }; } function writeCodeblock() { const cb = { Id: '', GameId: '', EntryKey: 'codeblock://combatmonster', ContentType: 'x-mod/codeblock', Content: '', Usage: 0, UsePublish: 1, UseService: 0, CoreVersion: '26.5.0.0', StudioVersion: '', DynamicLoading: 0, ContentProto: { Use: 'Json', Json: { CoreVersion: { Major: 0, Minor: 2 }, ScriptVersion: { Major: 1, Minor: 0 }, Description: '', Id: 'CombatMonster', Language: 1, Name: 'CombatMonster', Type: 1, Source: 0, Target: null, Properties: [prop('string', 'EnemyId', '""'), prop('string', 'Group', '"combat"'), prop('number', 'RegTries', '0')], Methods: [ method('OnBeginPlay', `self.RegTries = 0 local eventId = 0 local function reg() self.RegTries = self.RegTries + 1 local c = _EntityService:GetEntityByPath("/common") if c ~= nil and c.SlayDeckController ~= nil then local mapName = "" if self.Entity.CurrentMapName ~= nil then mapName = self.Entity.CurrentMapName end c.SlayDeckController:RegisterMonster(self.Entity, self.EnemyId, self.Group, mapName) _TimerService:ClearTimer(eventId) elseif self.RegTries > 50 then _TimerService:ClearTimer(eventId) end end eventId = _TimerService:SetTimerRepeat(reg, 0.1)`), ], EntityEventHandlers: [], } }, }; writeFileSync('RootDesk/MyDesk/CombatMonster.codeblock', JSON.stringify(cb, null, 2) + '\n', 'utf8'); } writeCodeblock(); console.log('CombatMonster codeblock written.');