@tora-editor/tora 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/** Bounded chat-completions transport. Does not execute tools or log credentials. */
|
|
2
|
-
import {Buffer} from 'node:buffer';
|
|
3
|
-
import {URL} from 'node:url';
|
|
4
|
-
export class PlanError extends Error{constructor(code){super(code);this.code=code;}}
|
|
5
|
-
function secretIn(value,key){if(typeof value==='string')return value.includes(key);if(value&&typeof value==='object')return Object.values(value).some(v=>secretIn(v,key));return false;}
|
|
6
|
-
function reject(code){throw new PlanError(code);}
|
|
7
|
-
async function boundedJson(response,limit,secret){
|
|
8
|
-
if(Number(response.headers.get('content-length'))>limit){await response.body?.cancel();reject('E_MODEL_RESPONSE_LIMIT');}
|
|
9
|
-
const reader=response.body?.getReader();if(!reader)reject('E_MODEL_RESPONSE');let size=0;const chunks=[];
|
|
10
|
-
try{for(;;){const {done,value}=await reader.read();if(done)break;size+=value.length;if(size>limit)reject('E_MODEL_RESPONSE_LIMIT');chunks.push(value);}}
|
|
11
|
-
finally{await reader.cancel().catch(()=>{});reader.releaseLock();}
|
|
12
|
-
let raw;try{raw=new globalThis.TextDecoder('utf-8',{fatal:true}).decode(Buffer.concat(chunks));}catch{reject('E_MODEL_RESPONSE');}
|
|
13
|
-
if(raw.includes(secret))reject('E_MODEL_SECRET_IN_RESPONSE');
|
|
14
|
-
let value;try{value=JSON.parse(raw);}catch{reject('E_MODEL_RESPONSE');}if(secretIn(value,secret))reject('E_MODEL_SECRET_IN_RESPONSE');return value;
|
|
15
|
-
}
|
|
16
|
-
function usageOf(value,config){
|
|
17
|
-
if(!value||typeof value!=='object')return null;
|
|
18
|
-
const input=value.prompt_tokens,output=value.completion_tokens,cacheReported=value.prompt_cache_hit_tokens??value.prompt_tokens_details?.cached_tokens,cached=cacheReported??0;
|
|
19
|
-
if(![input,output,cached].every(x=>Number.isSafeInteger(x)&&x>=0)||cached>input)return null;
|
|
20
|
-
return {inputTokens:input,outputTokens:output,cachedInputTokens:cacheReported===undefined?null:cached,estimatedUsd:((input-cached)*config.inputUsdPerMillion+cached*config.cachedInputUsdPerMillion+output*config.outputUsdPerMillion)/1e6,costBasis:cacheReported===undefined?'cache usage not reported; all input conservatively priced as uncached':config.cachePriceConfigured?'configured-input-cache-output-rates':'configured-input-output-rates; cached input conservatively priced as uncached'};
|
|
21
|
-
}
|
|
22
|
-
const notRetryable=new Set(['E_PLAN_UNSUPPORTED','E_MODEL_TOOLS','E_MODEL_SECRET_IN_RESPONSE','E_MODEL_RESPONSE_LIMIT','E_MODEL_USAGE_LIMIT']);
|
|
23
|
-
async function httpFailure(response,config,call){
|
|
24
|
-
const {status}=response;
|
|
25
|
-
call.httpStatus=status;
|
|
26
|
-
call.retryable=status===429||status>=500;
|
|
27
|
-
if(!config.orcaFreeTier){
|
|
28
|
-
await response.body?.cancel();
|
|
29
|
-
return 'E_MODEL_HTTP';
|
|
30
|
-
}
|
|
31
|
-
if(status===501)call.retryable=false;
|
|
32
|
-
if(status===400||status===429){
|
|
33
|
-
const payload=await boundedJson(response,8192,config.apiKey).catch(()=>undefined);
|
|
34
|
-
const error=payload?.error;
|
|
35
|
-
const details=error?.code==='free_rate_limited'?error.metadata:undefined;
|
|
36
|
-
if(status===400&&details?.reason==='err_free_prompt_cap')return 'E_MODEL_FREE_PROMPT_LIMIT';
|
|
37
|
-
if(status===429&&details?.reason==='err_free_access_denied'){
|
|
38
|
-
call.retryable=false;
|
|
39
|
-
return 'E_MODEL_FREE_ACCESS';
|
|
40
|
-
}
|
|
41
|
-
if(status===429){
|
|
42
|
-
const retryAfter=response.headers.get('Retry-After');
|
|
43
|
-
const seconds=details?.retry_after_seconds??(/^\d+$/.test(retryAfter??'')?Number(retryAfter):undefined);
|
|
44
|
-
if(Number.isSafeInteger(seconds)&&seconds>=0)call.retryAfterSeconds=seconds;
|
|
45
|
-
if(details?.reason==='err_free_rate'&&call.retryAfterSeconds===undefined)return 'E_MODEL_FREE_CAPACITY';
|
|
46
|
-
}
|
|
47
|
-
}else{
|
|
48
|
-
await response.body?.cancel().catch(()=>{});
|
|
49
|
-
}
|
|
50
|
-
if(status===401)return 'E_MODEL_AUTH';
|
|
51
|
-
if(status===403)return 'E_MODEL_FORBIDDEN';
|
|
52
|
-
if(status===402)return 'E_MODEL_QUOTA';
|
|
53
|
-
if(status===404||status===410)return 'E_MODEL_UNAVAILABLE';
|
|
54
|
-
if(status===429)return 'E_MODEL_RATE_LIMIT';
|
|
55
|
-
if(status===408||status===504)return 'E_MODEL_TIMEOUT';
|
|
56
|
-
return status>=500&&status!==501?'E_MODEL_UPSTREAM':'E_MODEL_REQUEST';
|
|
57
|
-
}
|
|
58
|
-
export async function requestChatCompletion({config,request,fetchImpl=globalThis.fetch,call={}}){
|
|
59
|
-
if(secretIn(request,config.apiKey))reject('E_MODEL_SECRET_IN_PROMPT');
|
|
60
|
-
let response;
|
|
61
|
-
try{
|
|
62
|
-
response=await fetchImpl(config.endpoint,{method:'POST',redirect:'error',signal:globalThis.AbortSignal.timeout(config.timeoutMs),
|
|
63
|
-
headers:{'Content-Type':'application/json',Authorization:'Bearer '+config.apiKey},body:JSON.stringify(request)});
|
|
64
|
-
}catch(error){reject(error.name==='TimeoutError'||error.name==='AbortError'?'E_MODEL_TIMEOUT':'E_MODEL_TRANSPORT');}
|
|
65
|
-
if(!response.ok){
|
|
66
|
-
const failure=new PlanError(await httpFailure(response,config,call));
|
|
67
|
-
if(call.retryAfterSeconds!==undefined)failure.retryAfterSeconds=call.retryAfterSeconds;
|
|
68
|
-
throw failure;
|
|
69
|
-
}
|
|
70
|
-
let envelope;
|
|
71
|
-
try{envelope=await boundedJson(response,config.maximumResponseBytes,config.apiKey);}
|
|
72
|
-
catch(error){
|
|
73
|
-
if(error.name==='TimeoutError'||error.name==='AbortError')reject('E_MODEL_TIMEOUT');
|
|
74
|
-
if(error instanceof TypeError)reject('E_MODEL_TRANSPORT');
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
if(!envelope||typeof envelope!=='object'||Array.isArray(envelope))reject('E_MODEL_RESPONSE');
|
|
78
|
-
if(config.orcaFreeTier&&envelope.error)reject('E_MODEL_UPSTREAM');
|
|
79
|
-
return envelope;
|
|
80
|
-
}
|
|
81
|
-
export async function requestCreativePlan({config,messages,projectId,ownedAssetIds=[],telemetry,fetchImpl=globalThis.fetch,validateResponse}){
|
|
82
|
-
if(typeof validateResponse!=='function')reject('E_MODEL_RESPONSE');
|
|
83
|
-
if(config.mode!=='live'||!config.billableCallsEnabled)reject('E_MODEL_NOT_CONFIGURED');
|
|
84
|
-
if(!Number.isInteger(config.maximumAttempts)||config.maximumAttempts<1||config.maximumAttempts>2||!Number.isInteger(config.maximumRetries)||config.maximumRetries<0||config.maximumRetries>1||config.maximumAttempts!==config.maximumRetries+1)reject('E_MODEL_LIMIT_CONFIG');
|
|
85
|
-
for(const [value,min,max]of [[config.maximumInputTokens,8192,131072],[config.maximumOutputTokens,512,8192],[config.maximumResponseBytes,1024,262144],[config.timeoutMs,100,120000]])if(!Number.isInteger(value)||value<min||value>max)reject('E_MODEL_LIMIT_CONFIG');
|
|
86
|
-
for(const value of [config.inputUsdPerMillion,config.outputUsdPerMillion,config.cachedInputUsdPerMillion])if(!Number.isFinite(value)||value<0||value>1000)reject('E_MODEL_LIMIT_CONFIG');
|
|
87
|
-
if(!Number.isFinite(config.maximumSpendUsd)||config.maximumSpendUsd<=0||config.maximumSpendUsd>100)reject('E_MODEL_LIMIT_CONFIG');
|
|
88
|
-
const reserve=(config.maximumInputTokens*config.inputUsdPerMillion+config.maximumOutputTokens*config.outputUsdPerMillion)/1e6;
|
|
89
|
-
telemetry.providerOrigin=new URL(config.endpoint).origin;telemetry.requestedModel=config.model;telemetry.pricing={inputUsdPerMillion:config.inputUsdPerMillion,outputUsdPerMillion:config.outputUsdPerMillion,cachedInputUsdPerMillion:config.cachedInputUsdPerMillion,basis:'Configured rates, not verified provider billing'};telemetry.limits={inputTokens:config.maximumInputTokens,outputTokens:config.maximumOutputTokens,responseBytes:config.maximumResponseBytes,timeoutMs:config.timeoutMs};telemetry.endpointClass=config.endpointClass;telemetry.protocol=config.protocol;telemetry.calls=[];telemetry.maximumSpendUsd=config.maximumSpendUsd;telemetry.maximumRetries=config.maximumRetries;telemetry.reservedUpperBoundUsd=0;telemetry.estimatedReportedUsageUsd=null;
|
|
90
|
-
if(secretIn(messages,config.apiKey))reject('E_MODEL_SECRET_IN_PROMPT');
|
|
91
|
-
const deadline=Date.now()+config.timeoutMs;
|
|
92
|
-
for(let attempt=0;attempt<config.maximumAttempts;attempt++){
|
|
93
|
-
// UTF-8 message bytes upper-bound byte-tokenizers, with 4096 reserved for framing.
|
|
94
|
-
// Provider-hidden/system overhead and configured rates remain provider trust assumptions.
|
|
95
|
-
if(Buffer.byteLength(JSON.stringify(messages),'utf8')+4096>config.maximumInputTokens)reject('E_MODEL_INPUT_LIMIT');
|
|
96
|
-
if(telemetry.reservedUpperBoundUsd+reserve>config.maximumSpendUsd+1e-12)reject('E_MODEL_BUDGET');
|
|
97
|
-
const remaining=deadline-Date.now();if(remaining<=0)reject('E_MODEL_TIMEOUT');
|
|
98
|
-
const started=Date.now(),call={attempt:attempt+1,status:'STARTED',usage:null};telemetry.calls.push(call);telemetry.reservedUpperBoundUsd+=reserve;
|
|
99
|
-
try{
|
|
100
|
-
const request={model:config.model,messages,max_tokens:config.maximumOutputTokens,response_format:{type:'json_object'},stream:false,
|
|
101
|
-
...(config.disableThinking?{thinking:{type:'disabled'}}:{})};
|
|
102
|
-
const envelope=await requestChatCompletion({config:{...config,timeoutMs:remaining},request,fetchImpl,call});
|
|
103
|
-
call.usage=usageOf(envelope.usage,config);if(call.usage)telemetry.estimatedReportedUsageUsd=(telemetry.estimatedReportedUsageUsd??0)+call.usage.estimatedUsd;
|
|
104
|
-
if(call.usage&&(call.usage.inputTokens>config.maximumInputTokens||call.usage.outputTokens>config.maximumOutputTokens))reject('E_MODEL_USAGE_LIMIT');
|
|
105
|
-
if(typeof envelope.model==='string'&&envelope.model.length<=128&&Array.from(envelope.model).every(c=>c.codePointAt(0)>=32&&c.codePointAt(0)!==127))call.reportedModel=envelope.model;
|
|
106
|
-
const choice=envelope.choices?.[0];if(choice?.message?.tool_calls?.length||choice?.finish_reason==='tool_calls')reject('E_MODEL_TOOLS');
|
|
107
|
-
if(choice?.finish_reason!=='stop'||typeof choice?.message?.content!=='string'||!choice.message.content.trim())reject('E_MODEL_INCOMPLETE');
|
|
108
|
-
const plan=validateResponse(choice.message.content,{projectId,ownedAssetIds});if(secretIn(plan,config.apiKey))reject('E_MODEL_SECRET_IN_RESPONSE');call.status='VALIDATED';return plan;
|
|
109
|
-
}catch(error){
|
|
110
|
-
const code=error instanceof PlanError?error.code:error.name==='AbortError'||error.name==='TimeoutError'?'E_MODEL_TIMEOUT':'E_MODEL_RESPONSE';call.status='REJECTED';call.error=code;
|
|
111
|
-
if(attempt+1>=config.maximumAttempts||notRetryable.has(code)||call.retryable===false||Date.now()>=deadline){
|
|
112
|
-
const failure=new PlanError(code);
|
|
113
|
-
if(call.retryAfterSeconds!==undefined)failure.retryAfterSeconds=call.retryAfterSeconds;
|
|
114
|
-
throw failure;
|
|
115
|
-
}
|
|
116
|
-
}finally{call.durationMs=Date.now()-started;}
|
|
117
|
-
}
|
|
118
|
-
reject('E_MODEL_ATTEMPTS');
|
|
119
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import {resolve,dirname} from 'node:path';
|
|
3
|
-
import {fileURLToPath} from 'node:url';
|
|
4
|
-
import {mkdir,writeFile} from 'node:fs/promises';
|
|
5
|
-
import {AssetCatalog} from './asset-catalog.mjs';
|
|
6
|
-
import {emptyProject,applyOperations} from './document.mjs';
|
|
7
|
-
import {compileNative} from './compiler.mjs';
|
|
8
|
-
|
|
9
|
-
async function proofAssets(requests){
|
|
10
|
-
const catalog=new AssetCatalog();await catalog.load();const assets=[],records=[];
|
|
11
|
-
for(const [id,sourceId,name,collection] of requests){
|
|
12
|
-
const entry=[...catalog.entries.values()].find(asset=>asset.sourceId===sourceId&&asset.name===name&&(!collection||asset.tags.includes(collection)));if(!entry)throw Error('Missing proof asset '+sourceId+'/'+name);
|
|
13
|
-
const bytes=await catalog.bytes(entry.id),record={id,hash:entry.sha256,mime:entry.mime,bytes:bytes.length,rights:entry.rights,provenance:JSON.stringify(entry.provenance)};records.push(record);assets.push({...record,data:bytes.toString('base64')});
|
|
14
|
-
}
|
|
15
|
-
return {assets,records};
|
|
16
|
-
}
|
|
17
|
-
const component=(id,contract,parameters={},extra={})=>({kind:'createComponent',component:{id,contract,parameters,...extra}});
|
|
18
|
-
const behavior=(id,componentId,kind,parameters)=>({kind:'putBehavior',behavior:{id,componentId,kind,parameters}});
|
|
19
|
-
const binding=(id,event,actions,condition)=>({kind:'putBinding',binding:{id,event,actions,...(condition?{condition}:{})}});
|
|
20
|
-
const image=(id,assetId,x,y,width=64,height=64,extra={})=>component(id,'native.image.v1',{width,height,fit:'contain',smoothing:false},{transform:[1,0,0,1,x,y],assetSlots:[{slotId:'source',assetId}],...extra});
|
|
21
|
-
const text=(id,value,x,y,width,height,fontSize=24,extra={})=>component(id,'native.text.v1',{text:value,width,height,fontSize,fontFamily:'pixel',color:'#fff0bd',align:'center'}, {transform:[1,0,0,1,x,y],...extra});
|
|
22
|
-
const group=(id,x=0,y=0,width=390,height=700,extra={})=>component(id,'native.group.v1',{width,height},{transform:[1,0,0,1,x,y],...extra});
|
|
23
|
-
const layout=(id,x,y,scaleX=1,scaleY=scaleX,anchor='none')=>behavior(id+'.layout',id,'responsive-layout',{x,y,scaleX,scaleY,anchor,respectSafeArea:false,marginX:16,marginY:16});
|
|
24
|
-
const drag=(id,tag='crop')=>behavior(id+'.drag',id,'drag',{axis:'both',snapBack:true,snapBackSeconds:.16,bringToFront:true,tag});
|
|
25
|
-
const zone=(id,onOccupied='emit',acceptTags=['crop'])=>behavior(id+'.zone',id,'drop-zone',{acceptTags,snapMode:'center',capacity:1,onOccupied,radiusPx:0,highlightColor:'#ffe66d'});
|
|
26
|
-
const emitter=(id,componentId,coverage='local')=>behavior(id,componentId,'emitter',{count:32,color:'#ffe66d',color2:'#95bf48',color3:'#fff0bd',speed:150,lifetime:.8,gravity:220,spread:360,shape:'pixel-confetti',coverage,origin:'center',direction:-90});
|
|
27
|
-
const audio=(id,componentId,role,bus='sfx',loop=false,volume=.3)=>behavior(id,componentId,'audio',{bus,loop,volume,frequency:660,seconds:.15,cooldownMs:45,pitchJitter:0,pitchStep:0,role,allowSynthFallback:false});
|
|
28
|
-
|
|
29
|
-
export async function createFarmMergeProof(){
|
|
30
|
-
const {assets,records}=await proofAssets([
|
|
31
|
-
['farm.crop.1','kenney-tiny-farm','tile_0029.png'],['farm.crop.2','kenney-tiny-farm','tile_0020.png'],['farm.crop.3','kenney-tiny-farm','tile_0030.png'],['farm.crate.art','kenney-tiny-farm','tile_0047.png'],
|
|
32
|
-
['farm.ambient','tarush-singhal-happy-ukelele','ambient.wav','casual'],['farm.match','kenney-interface-sounds','match.wav','casual'],['farm.win','kenney-music-jingles','win.wav','casual'],
|
|
33
|
-
]);
|
|
34
|
-
const ops=[group('farm.hud',0,0),group('farm.board',25,225,340,220),group('farm.end.hero',95,130,200,200,{sceneId:'scene.win'}),group('farm.end.ui',0,370,390,260,{sceneId:'scene.win'}),group('farm.audio',0,0,1,1,{parameters:{width:1,height:1,visible:false}}),
|
|
35
|
-
layout('farm.hud',345,70,.85),layout('farm.board',44,102,.85),layout('farm.end.hero',75,95,1),layout('farm.end.ui',320,95,.82),
|
|
36
|
-
group('farm.background',0,0,390,700,{order:-10}),layout('farm.background',0,0,700/390,390/700),component('farm.background.fill','native.rectangle.v1',{width:390,height:700,fill:'#254b3c',strokeWidth:0},{parentId:'farm.background'}),
|
|
37
|
-
text('farm.title','FARM MERGE',60,52,270,52,32,{parentId:'farm.hud'}),text('farm.prompt','DRAG TO MERGE',75,110,240,34,18,{parentId:'farm.hud'}),text('farm.score','0 / 3',135,152,120,34,20,{parentId:'farm.hud'}),
|
|
38
|
-
group('farm.end.back',0,0,390,700,{sceneId:'scene.win',order:-10}),layout('farm.end.back',0,0,700/390,390/700),component('farm.end.back.fill','native.rectangle.v1',{width:390,height:700,fill:'#254b3c',strokeWidth:0},{sceneId:'scene.win',parentId:'farm.end.back'}),
|
|
39
|
-
image('farm.end.crop','farm.crop.3',0,0,200,200,{parentId:'farm.end.hero',sceneId:'scene.win'}),text('farm.end.title','BUMPER CROP',20,0,350,54,32,{parentId:'farm.end.ui',sceneId:'scene.win'}),
|
|
40
|
-
component('farm.end.cta','native.button.v1',{width:260,height:78,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#3c2933',strokeWidth:4,radius:8,presentation:'shiny-cta'},{parentId:'farm.end.ui',sceneId:'scene.win',transform:[1,0,0,1,65,92]}),
|
|
41
|
-
text('farm.end.cta.label','GROW NOW',10,8,240,58,26,{parentId:'farm.end.cta',sceneId:'scene.win'}),
|
|
42
|
-
behavior('farm.end.cta.float','farm.end.cta','animation',{property:'y',from:92,to:84,seconds:.8,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),
|
|
43
|
-
behavior('farm.end.hero.bob','farm.end.hero','animation',{property:'y',from:130,to:118,seconds:1.1,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),
|
|
44
|
-
binding('farm.end.enter',{kind:'sceneEnter',sceneId:'scene.win'},[{kind:'animate',behaviorId:'farm.end.hero.bob'},{kind:'animate',behaviorId:'farm.end.cta.float'},{kind:'emit',behaviorId:'farm.end.confetti'},{kind:'playAudio',behaviorId:'farm.win.sound'}]),
|
|
45
|
-
binding('farm.end.store',{kind:'click',componentId:'farm.end.cta'},[{kind:'store'}]),emitter('farm.end.confetti','farm.end.hero','screen'),
|
|
46
|
-
];
|
|
47
|
-
ops.push({kind:'createScene',scene:{id:'scene.win',label:'Harvest complete',role:'end-card'}});
|
|
48
|
-
const slots=[];for(let row=0;row<2;row++)for(let column=0;column<3;column++){
|
|
49
|
-
const id=`farm.slot.${row}.${column}`,x=column*120,y=row*120;slots.push(id);ops.push(component(id,'native.rectangle.v1',{width:100,height:100,fill:'#3c5d42',stroke:'#8ba35c',strokeWidth:4,radius:10},{parentId:'farm.board',transform:[1,0,0,1,x,y]}),zone(id,'swap',[]));
|
|
50
|
-
}
|
|
51
|
-
const cropIds=['farm.crop.a','farm.crop.b','farm.crop.c','farm.crop.d'];cropIds.forEach((id,index)=>{const slot=slots[index],slotComponent=ops.find(op=>op.component?.id===slot).component,[x,y]=[slotComponent.transform[4]+18,slotComponent.transform[5]+18];ops.push(image(id,'farm.crop.1',x,y,64,64,{parentId:'farm.board',order:2}),drag(id),zone(id,'emit'),emitter(id+'.burst',id));});
|
|
52
|
-
ops.push(image('farm.crate','farm.crate.art',138,138,64,64,{parentId:'farm.board',order:2}),drag('farm.crate','crate'));
|
|
53
|
-
ops.push(image('farm.tier2','farm.crop.2',0,0,64,64,{prototype:true}),drag('farm.tier2'),zone('farm.tier2','emit'),emitter('farm.tier2.burst','farm.tier2'),image('farm.tier3','farm.crop.3',0,0,64,64,{prototype:true}));
|
|
54
|
-
for(let first=0;first<cropIds.length;first++)for(let second=0;second<cropIds.length;second++){
|
|
55
|
-
if(first===second)continue;
|
|
56
|
-
const a=cropIds[first],b=cropIds[second];ops.push(binding(`farm.merge.${first}.${second}`,{kind:'dragDrop',componentId:a,otherId:b},[{kind:'add',variableId:'farm.merges',value:1},{kind:'spawnAt',prototypeId:'farm.tier2',targetComponentId:a,offsetX:0,offsetY:0,at:'midpoint'},{kind:'setComponent',componentId:a,key:'visible',value:false},{kind:'setComponent',componentId:b,key:'visible',value:false},{kind:'emit',behaviorId:a+'.burst'},{kind:'playAudio',behaviorId:'farm.match.sound'}]));
|
|
57
|
-
}
|
|
58
|
-
ops.push(binding('farm.merge.final',{kind:'dragDrop',componentId:'farm.tier2',otherId:'farm.tier2'},[{kind:'add',variableId:'farm.merges',value:1},{kind:'spawnAt',prototypeId:'farm.tier3',targetComponentId:'farm.tier2',offsetX:0,offsetY:0,at:'midpoint'},{kind:'despawn',target:'both'},{kind:'emit',behaviorId:'farm.tier2.burst'},{kind:'changeScene',sceneId:'scene.win'}]));
|
|
59
|
-
for(const [id,assetId,role,bus,loop,volume] of [['ambient','farm.ambient','ambient','music',true,.12],['match','farm.match','match','sfx',false,.35],['win','farm.win','win','stinger',false,.45]])ops.push(component('farm.audio.'+id,'native.group.v1',{width:1,height:1,visible:false},{parentId:'farm.audio',assetSlots:[{slotId:'source',assetId}]}),audio('farm.'+id+'.sound','farm.audio.'+id,role,bus,loop,volume));
|
|
60
|
-
ops.push({kind:'putVariable',variable:{id:'farm.merges',label:'Merges',type:'number',initial:0}});
|
|
61
|
-
for(const dragId of [...cropIds,'farm.crate'])ops.push(binding('farm.music.'+dragId,{kind:'dragStart',componentId:dragId},[{kind:'playAudio',behaviorId:'farm.ambient.sound'}]));
|
|
62
|
-
const project=applyOperations(emptyProject({id:'farm-merge-proof',name:'Farm Merge',androidUrl:'https://play.google.com/store/apps/details?id=com.tora.farmmerge'}),[...records.map(asset=>({kind:'registerAsset',asset})),...ops]).project;
|
|
63
|
-
project.components.find(c=>c.id==='farm.score').parameters.text='{{farm.merges}} / 3';
|
|
64
|
-
return {project,assets};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function createStarBastionProof(){
|
|
68
|
-
const {assets,records}=await proofAssets([
|
|
69
|
-
['star.background.art','kenney-space-shooter-redux','darkPurple.png'],['star.player.art','kenney-space-shooter-redux','playerShip1_blue.png'],['star.bolt.art','kenney-space-shooter-redux','fire03.png'],['star.enemy.art','kenney-space-shooter-redux','meteorBrown_med1.png'],['star.pickup.art','kenney-space-shooter-redux','powerupYellow_star.png'],
|
|
70
|
-
['star.ambient','3xblast-pop-punk-chiptune','ambient.wav','arcade'],['star.match','kenney-interface-sounds','match.wav','arcade'],['star.win','kenney-music-jingles','win.wav','arcade'],
|
|
71
|
-
]);
|
|
72
|
-
const ops=[group('star.world',0,0),group('star.hud',0,0),group('star.fire.group',0,0),group('star.end.hero',135,120,120,160,{sceneId:'scene.win'}),group('star.end.ui',0,350,390,280,{sceneId:'scene.win'}),group('star.audio',0,0,1,1,{parameters:{width:1,height:1,visible:false}}),
|
|
73
|
-
layout('star.world',25,0,.58),layout('star.hud',400,45,.8),layout('star.fire.group',352,-210,.8),layout('star.end.hero',75,95,1.2),layout('star.end.ui',330,90,.8),
|
|
74
|
-
group('star.background',0,0,390,700,{order:-10}),layout('star.background',0,0,700/390,390/700),
|
|
75
|
-
component('star.background.fill','native.rectangle.v1',{width:390,height:700,fill:'#3a2e3f',strokeWidth:0},{parentId:'star.background',order:-1}),
|
|
76
|
-
image('star.background.image','star.background.art',0,0,390,700,{parentId:'star.background',order:0,parameters:{width:390,height:700,fit:'cover',smoothing:false}}),
|
|
77
|
-
text('star.title','STAR BASTION',65,42,260,52,30,{parentId:'star.hud'}),text('star.prompt','TAP TO FIRE',85,102,220,34,18,{parentId:'star.hud'}),text('star.kills.label','{{star.kills}} / 1',135,142,120,34,20,{parentId:'star.hud'}),
|
|
78
|
-
component('star.fire','native.button.v1',{width:170,height:64,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#241b38',strokeWidth:4,radius:8,presentation:'shiny-cta'},{parentId:'star.fire.group',transform:[1,0,0,1,110,580]}),text('star.fire.label','FIRE',10,8,150,46,24,{parentId:'star.fire'}),
|
|
79
|
-
group('star.spawner',145,235,100,40,{parentId:'star.world',parameters:{width:100,height:40,visible:false}}),image('star.player','star.player.art',145,490,90,90,{parentId:'star.world'}),
|
|
80
|
-
behavior('star.player.state','star.player','instance-state',{hp:1,maxHp:1,value:0,tag:'player',team:'player'}),behavior('star.player.collider','star.player','collider',{shape:'circle'}),
|
|
81
|
-
component('star.input','native.rectangle.v1',{width:350,height:300,fill:'#3a2e3f',strokeWidth:0,opacity:.01},{parentId:'star.world',transform:[1,0,0,1,20,200],order:-1}),behavior('star.world.timer','star.world','timer',{seconds:1.2,repeat:true}),
|
|
82
|
-
image('star.bolt.prototype','star.bolt.art',0,0,28,28,{prototype:true}),behavior('star.bolt.body','star.bolt.prototype','physics-body',{mode:'dynamic',shape:'circle',restitution:0,friction:0,linearDamping:0,gravity:0,maxSpeed:900,restSpeed:1,restDelaySeconds:.1,wallBounce:false,spinToRotation:true}),behavior('star.bolt.collider','star.bolt.prototype','collider',{shape:'circle'}),
|
|
83
|
-
component('star.enemy.prototype','native.group.v1',{width:80,height:80},{prototype:true}),image('star.enemy.image','star.enemy.art',0,0,80,80,{parentId:'star.enemy.prototype'}),component('star.enemy.hp','native.rectangle.v1',{width:80,height:8,fill:'#70e087',strokeWidth:0},{parentId:'star.enemy.prototype',transform:[1,0,0,1,0,-14]}),
|
|
84
|
-
behavior('star.enemy.state','star.enemy.prototype','instance-state',{hp:2,maxHp:2,value:0,tag:'meteor',team:'enemy'}),behavior('star.enemy.meter','star.enemy.hp','value-meter',{instanceField:'hp',min:0,max:1,axis:'x',direction:'positive',smoothingSeconds:.05}),behavior('star.enemy.collider','star.enemy.prototype','collider',{shape:'circle'}),behavior('star.enemy.steer','star.enemy.prototype','steer',{mode:'chase',targetMode:'nearest-team',team:'player',speed:24,turnRateDegPerSec:180,maxRangePx:0,orientToVelocity:false}),
|
|
85
|
-
image('star.pickup.prototype','star.pickup.art',0,0,44,44,{prototype:true}),behavior('star.pickup.state','star.pickup.prototype','instance-state',{hp:1,maxHp:1,value:0,tag:'pickup',team:'pickup'}),behavior('star.pickup.collider','star.pickup.prototype','collider',{shape:'circle'}),behavior('star.pickup.steer','star.pickup.prototype','steer',{mode:'chase',targetMode:'nearest-team',team:'player',speed:170,turnRateDegPerSec:720,maxRangePx:0,orientToVelocity:false}),
|
|
86
|
-
binding('star.opening',{kind:'sceneEnter',sceneId:'scene.play'},[{kind:'spawnAt',prototypeId:'star.enemy.prototype',targetComponentId:'star.spawner',offsetX:0,offsetY:0,count:1,jitterX:45,jitterY:0},{kind:'playAudio',behaviorId:'star.ambient.sound'}]),
|
|
87
|
-
binding('star.auto',{kind:'timer',behaviorId:'star.world.timer'},[{kind:'spawnAt',prototypeId:'star.bolt.prototype',targetComponentId:'star.player',offsetX:0,offsetY:0},{kind:'launchToward',componentId:'star.bolt.prototype',targetMode:'nearest-team',team:'enemy',speed:360}]),
|
|
88
|
-
binding('star.fire.action',{kind:'click',componentId:'star.fire'},[{kind:'spawnAt',prototypeId:'star.bolt.prototype',targetComponentId:'star.player',offsetX:0,offsetY:0},{kind:'launchToward',componentId:'star.bolt.prototype',targetMode:'nearest-team',team:'enemy',speed:420},{kind:'playAudio',behaviorId:'star.match.sound'}]),
|
|
89
|
-
binding('star.pointer.fire',{kind:'click',componentId:'star.input'},[{kind:'spawnAt',prototypeId:'star.bolt.prototype',targetComponentId:'star.player',offsetX:0,offsetY:0},{kind:'launchToward',componentId:'star.bolt.prototype',targetMode:'pointer',speed:420},{kind:'playAudio',behaviorId:'star.match.sound'}]),
|
|
90
|
-
binding('star.hit',{kind:'contactBegin',componentId:'star.bolt.prototype',otherId:'star.enemy.prototype'},[{kind:'modifyInstanceState',target:'other',componentId:'star.enemy.prototype',field:'hp',op:'sub',value:1},{kind:'despawn',target:'self'},{kind:'playAudio',behaviorId:'star.match.sound'}],{instanceTarget:'other',instanceField:'hp',op:'gt',value:0}),
|
|
91
|
-
binding('star.depleted',{kind:'instanceDepleted',componentId:'star.enemy.prototype'},[{kind:'add',variableId:'star.kills',value:1},{kind:'spawnAt',prototypeId:'star.pickup.prototype',targetComponentId:'star.enemy.prototype',offsetX:0,offsetY:0},{kind:'despawn',target:'self'}]),
|
|
92
|
-
binding('star.collect',{kind:'contactBegin',componentId:'star.pickup.prototype',otherId:'star.player'},[{kind:'despawn',target:'self'},{kind:'changeScene',sceneId:'scene.win'}]),
|
|
93
|
-
{kind:'createScene',scene:{id:'scene.win',label:'Sector saved',role:'end-card'}},
|
|
94
|
-
group('star.end.back',0,0,390,700,{sceneId:'scene.win',order:-10}),layout('star.end.back',0,0,700/390,390/700),
|
|
95
|
-
component('star.end.back.fill','native.rectangle.v1',{width:390,height:700,fill:'#3a2e3f',strokeWidth:0},{sceneId:'scene.win',parentId:'star.end.back',order:-1}),
|
|
96
|
-
image('star.end.back.image','star.background.art',0,0,390,700,{sceneId:'scene.win',parentId:'star.end.back',order:0,parameters:{width:390,height:700,fit:'cover',smoothing:false}}),
|
|
97
|
-
image('star.end.ship','star.player.art',0,0,120,120,{parentId:'star.end.hero',sceneId:'scene.win'}),text('star.end.title','SECTOR SAVED',20,0,350,54,30,{parentId:'star.end.ui',sceneId:'scene.win'}),
|
|
98
|
-
component('star.end.cta','native.button.v1',{width:260,height:78,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#241b38',strokeWidth:4,radius:8,presentation:'shiny-cta'},{parentId:'star.end.ui',sceneId:'scene.win',transform:[1,0,0,1,65,92]}),text('star.end.cta.label','LAUNCH NOW',10,8,240,58,24,{parentId:'star.end.cta',sceneId:'scene.win'}),
|
|
99
|
-
behavior('star.end.hero.bob','star.end.hero','animation',{property:'y',from:120,to:105,seconds:1,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),behavior('star.end.cta.float','star.end.cta','animation',{property:'y',from:92,to:84,seconds:.8,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),emitter('star.end.confetti','star.end.hero','screen'),
|
|
100
|
-
binding('star.end.enter',{kind:'sceneEnter',sceneId:'scene.win'},[{kind:'animate',behaviorId:'star.end.hero.bob'},{kind:'animate',behaviorId:'star.end.cta.float'},{kind:'emit',behaviorId:'star.end.confetti'},{kind:'playAudio',behaviorId:'star.win.sound'}]),binding('star.end.store',{kind:'click',componentId:'star.end.cta'},[{kind:'store'}]),
|
|
101
|
-
{kind:'putVariable',variable:{id:'star.kills',label:'Kills',type:'number',initial:0}},
|
|
102
|
-
];
|
|
103
|
-
for(const [id,assetId,role,bus,loop,volume] of [['ambient','star.ambient','ambient','music',true,.12],['match','star.match','match','sfx',false,.35],['win','star.win','win','stinger',false,.45]])ops.push(component('star.audio.'+id,'native.group.v1',{width:1,height:1,visible:false},{parentId:'star.audio',assetSlots:[{slotId:'source',assetId}]}),audio('star.'+id+'.sound','star.audio.'+id,role,bus,loop,volume));
|
|
104
|
-
const project=applyOperations(emptyProject({id:'star-bastion-proof',name:'Star Bastion',androidUrl:'https://play.google.com/store/apps/details?id=com.tora.starbastion'}),[...records.map(asset=>({kind:'registerAsset',asset})),...ops]).project;return {project,assets};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export async function createFrostCleanProof(){
|
|
108
|
-
const {assets,records}=await proofAssets([
|
|
109
|
-
['frost.crop','kenney-tiny-farm','tile_0020.png'],['frost.hero','kenney-tiny-farm','tile_0030.png'],['frost.ambient','tarush-singhal-happy-ukelele','ambient.wav','casual'],['frost.match','kenney-interface-sounds','match.wav','casual'],['frost.win','mintodog-cozy-puzzle-jingle','victory.mp3'],
|
|
110
|
-
]);
|
|
111
|
-
const ops=[group('frost.world',0,0),group('frost.hud',0,0),group('frost.end.hero',95,130,200,200,{sceneId:'scene.win'}),group('frost.end.ui',0,370,390,260,{sceneId:'scene.win'}),group('frost.audio',0,0,1,1,{parameters:{width:1,height:1,visible:false}}),
|
|
112
|
-
layout('frost.world',45,-80,.72),layout('frost.hud',330,75,.85),layout('frost.end.hero',75,95,1),layout('frost.end.ui',320,95,.82),
|
|
113
|
-
group('frost.background',0,0,390,700,{order:-10}),layout('frost.background',0,0,700/390,390/700),component('frost.background.fill','native.rectangle.v1',{width:390,height:700,fill:'#254b3c',strokeWidth:0},{parentId:'frost.background'}),
|
|
114
|
-
text('frost.title','FROST HARVEST',60,42,270,52,30,{parentId:'frost.hud'}),text('frost.prompt','CLEAN THE CROP',75,102,240,34,18,{parentId:'frost.hud'}),
|
|
115
|
-
component('frost.frame','native.rectangle.v1',{width:240,height:240,fill:'#3c5d42',stroke:'#fff0bd',strokeWidth:5,radius:12},{parentId:'frost.world',transform:[1,0,0,1,75,230],order:0}),
|
|
116
|
-
image('frost.crop.image','frost.crop',95,250,200,200,{parentId:'frost.world',order:1}),
|
|
117
|
-
component('frost.cover','native.rectangle.v1',{width:200,height:200,fill:'#d7f2f0',stroke:'#8fc7c5',strokeWidth:4,radius:8},{parentId:'frost.world',transform:[1,0,0,1,95,250],order:2}),behavior('frost.cover.mask','frost.cover','erase-mask',{mode:'erase',brushRadiusPx:36,gridSize:24,targetPercent:65,progressVariableId:'frost.progress',maskColor:'#d7f2f0'}),
|
|
118
|
-
{kind:'putVariable',variable:{id:'frost.progress',label:'Cleaned',type:'number',initial:0}},text('frost.progress.label','{{frost.progress}} / 65',115,490,160,38,22,{parentId:'frost.world'}),
|
|
119
|
-
binding('frost.cleaned',{kind:'maskComplete',componentId:'frost.cover'},[{kind:'playAudio',behaviorId:'frost.match.sound'},{kind:'changeScene',sceneId:'scene.win'}]),
|
|
120
|
-
{kind:'createScene',scene:{id:'scene.win',label:'Frost cleared',role:'end-card'}},
|
|
121
|
-
group('frost.end.back',0,0,390,700,{sceneId:'scene.win',order:-10}),layout('frost.end.back',0,0,700/390,390/700),component('frost.end.back.fill','native.rectangle.v1',{width:390,height:700,fill:'#254b3c',strokeWidth:0},{sceneId:'scene.win',parentId:'frost.end.back'}),
|
|
122
|
-
image('frost.end.crop','frost.hero',0,0,200,200,{parentId:'frost.end.hero',sceneId:'scene.win'}),text('frost.end.title','FRESH PICK',20,0,350,54,32,{parentId:'frost.end.ui',sceneId:'scene.win'}),
|
|
123
|
-
component('frost.end.cta','native.button.v1',{width:260,height:78,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#3c2933',strokeWidth:4,radius:8,presentation:'shiny-cta'},{parentId:'frost.end.ui',sceneId:'scene.win',transform:[1,0,0,1,65,92]}),text('frost.end.cta.label','HARVEST NOW',10,8,240,58,24,{parentId:'frost.end.cta',sceneId:'scene.win'}),
|
|
124
|
-
behavior('frost.end.hero.bob','frost.end.hero','animation',{property:'y',from:130,to:118,seconds:1.1,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),behavior('frost.end.cta.float','frost.end.cta','animation',{property:'y',from:92,to:84,seconds:.8,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),emitter('frost.end.confetti','frost.end.hero','screen'),
|
|
125
|
-
binding('frost.end.enter',{kind:'sceneEnter',sceneId:'scene.win'},[{kind:'animate',behaviorId:'frost.end.hero.bob'},{kind:'animate',behaviorId:'frost.end.cta.float'},{kind:'emit',behaviorId:'frost.end.confetti'},{kind:'playAudio',behaviorId:'frost.win.sound'}]),binding('frost.end.store',{kind:'click',componentId:'frost.end.cta'},[{kind:'store'}]),
|
|
126
|
-
];
|
|
127
|
-
for(const [id,assetId,role,bus,loop,volume] of [['ambient','frost.ambient','ambient','music',true,.12],['match','frost.match','match','sfx',false,.35],['win','frost.win','win','stinger',false,.45]])ops.push(component('frost.audio.'+id,'native.group.v1',{width:1,height:1,visible:false},{parentId:'frost.audio',assetSlots:[{slotId:'source',assetId}]}),audio('frost.'+id+'.sound','frost.audio.'+id,role,bus,loop,volume));
|
|
128
|
-
ops.push(binding('frost.music',{kind:'maskProgress',componentId:'frost.cover'},[{kind:'playAudio',behaviorId:'frost.ambient.sound'}]));
|
|
129
|
-
const project=applyOperations(emptyProject({id:'frost-clean-proof',name:'Frost Harvest',androidUrl:'https://play.google.com/store/apps/details?id=com.tora.frostharvest'}),[...records.map(asset=>({kind:'registerAsset',asset})),...ops]).project;return {project,assets};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export async function createFpsArenaProof(){
|
|
133
|
-
const {assets,records}=await proofAssets([
|
|
134
|
-
['fps.ambient','3xblast-pop-punk-chiptune','ambient.wav','arcade'],['fps.fire.art','kenney-interface-sounds','tap.wav','arcade'],['fps.hit.art','kenney-interface-sounds','match.wav','arcade'],['fps.win.art','kenney-music-jingles','win.wav','arcade'],
|
|
135
|
-
]);
|
|
136
|
-
const mesh=(id,parentId,parameters,extra={})=>component(id,'native.mesh3d.v1',parameters,{parentId,...extra});
|
|
137
|
-
const boxWall=(id,x,z,sx,sy,sz,color='#476085')=>[
|
|
138
|
-
mesh(id,'fps.stage',{primitive:'box',x,y:sy/2,z,sx,sy,sz,color}),
|
|
139
|
-
mesh(id+'.cap','fps.stage',{primitive:'box',x,y:sy+.08,z,sx:sx+.08,sy:.16,sz:sz+.08,color:'#f2b544',unlit:true}),
|
|
140
|
-
behavior(id+'.phys',id,'physics-3d',{mode:'static',radius:.5,hx:sx/2,hz:sz/2,angle:0,friction:1,restitution:.5,maxSpeed:1,boundsX:12,boundsZ:12,ramp:false,restSpeed:.1,restDelaySeconds:.25}),
|
|
141
|
-
];
|
|
142
|
-
const uiText=(id,value,x,y,width,height,fontSize=24,extra={})=>component(id,'native.text.v1',{text:value,width,height,fontSize,fontFamily:'sans-serif',fontWeight:'900',color:'#fff5d6',align:'center'},{transform:[1,0,0,1,x,y],...extra});
|
|
143
|
-
const ops=[
|
|
144
|
-
group('fps.stage.wrap',0,0,390,700,{order:-10}),layout('fps.stage.wrap',0,0,700/390,390/700),
|
|
145
|
-
component('fps.stage','native.stage3d.v1',{width:390,height:700,skyColor:'#182640',hemiSkyColor:'#dbeafe',hemiGroundColor:'#263854',hemiIntensity:1.7,sunColor:'#fff0cf',sunIntensity:2.1,sunX:-7,sunY:16,sunZ:9,cameraX:0,cameraY:1.6,cameraZ:6,cameraFov:80,landscapeCameraX:0,landscapeCameraY:1.6,landscapeCameraZ:6,landscapeCameraFov:52,lookAtX:0,lookAtY:1.5,lookAtZ:-4,introLift:0},{parentId:'fps.stage.wrap'}),
|
|
146
|
-
mesh('fps.floor','fps.stage',{primitive:'box',x:0,y:-.2,z:0,sx:24,sy:.4,sz:24,color:'#2a3c58'}),
|
|
147
|
-
mesh('fps.lane','fps.stage',{primitive:'box',x:0,y:.01,z:-1,sx:2.6,sy:.02,sz:18,color:'#385074',unlit:true}),
|
|
148
|
-
mesh('fps.wall.n','fps.stage',{primitive:'box',x:0,y:2.1,z:-11.8,sx:24,sy:4.2,sz:.6,color:'#20304a'}),
|
|
149
|
-
mesh('fps.wall.s','fps.stage',{primitive:'box',x:0,y:2.1,z:11.8,sx:24,sy:4.2,sz:.6,color:'#20304a'}),
|
|
150
|
-
mesh('fps.wall.w','fps.stage',{primitive:'box',x:-11.8,y:2.1,z:0,sx:.6,sy:4.2,sz:24,color:'#243552'}),
|
|
151
|
-
mesh('fps.wall.e','fps.stage',{primitive:'box',x:11.8,y:2.1,z:0,sx:.6,sy:4.2,sz:24,color:'#243552'}),
|
|
152
|
-
mesh('fps.trim.n','fps.stage',{primitive:'box',x:0,y:3.9,z:-11.45,sx:23,sy:.18,sz:.14,color:'#38bdf8',unlit:true}),
|
|
153
|
-
...boxWall('fps.pillar.nw',-6.0,-2.6,1.5,3.2,1.5),
|
|
154
|
-
...boxWall('fps.pillar.ne',6.0,-2.6,1.5,3.2,1.5),
|
|
155
|
-
...boxWall('fps.pillar.sw',-6.4,2.4,1.5,2.4,1.5),
|
|
156
|
-
...boxWall('fps.pillar.se',6.4,2.4,1.5,2.4,1.5),
|
|
157
|
-
// First-person 3D camera-mounted blaster
|
|
158
|
-
mesh('fps.gun','fps.stage',{primitive:'group',x:.19,y:-.21,z:-.58,rx:.04,ry:-.12,attachToCamera:true}),
|
|
159
|
-
mesh('fps.gun.body','fps.gun',{primitive:'box',x:0,y:0,z:0,sx:.12,sy:.13,sz:.46,color:'#28354a'}),
|
|
160
|
-
mesh('fps.gun.rail','fps.gun',{primitive:'box',x:0,y:.075,z:-.04,sx:.05,sy:.035,sz:.34,color:'#38bdf8',unlit:true}),
|
|
161
|
-
mesh('fps.gun.muzzle','fps.gun',{primitive:'cylinder',x:0,y:.01,z:-.28,rx:1.5708,sx:.16,sy:.14,sz:.16,radiusTop:.22,radiusBottom:.22,color:'#f2b544',unlit:true}),
|
|
162
|
-
// Enemy security drone 3D prototype
|
|
163
|
-
mesh('fps.drone','fps.stage',{primitive:'group',x:0,y:1.55,z:-3},{prototype:true}),
|
|
164
|
-
mesh('fps.drone.core','fps.drone',{primitive:'sphere',x:0,y:0,z:0,sx:1.15,sy:1.15,sz:1.15,radiusTop:.55,color:'#ef5b4c'}),
|
|
165
|
-
mesh('fps.drone.visor','fps.drone',{primitive:'box',x:0,y:.06,z:.46,sx:.68,sy:.24,sz:.22,color:'#172033'}),
|
|
166
|
-
mesh('fps.drone.eye','fps.drone',{primitive:'box',x:0,y:.06,z:.58,sx:.34,sy:.12,sz:.08,color:'#ffe66d',unlit:true}),
|
|
167
|
-
mesh('fps.drone.wing.l','fps.drone',{primitive:'box',x:-.78,y:0,z:0,sx:.36,sy:.16,sz:.64,color:'#3b4e6e'}),
|
|
168
|
-
mesh('fps.drone.wing.r','fps.drone',{primitive:'box',x:.78,y:0,z:0,sx:.36,sy:.16,sz:.64,color:'#3b4e6e'}),
|
|
169
|
-
behavior('fps.drone.state','fps.drone','instance-state',{hp:2,maxHp:2,value:1,tag:'drone',team:'enemy'}),
|
|
170
|
-
behavior('fps.drone.steer','fps.drone','steer-3d',{mode:'chase-camera',speed:.55,stopDistance:4.2,faceCamera:true,boundsX:10.5,boundsZ:10.5}),
|
|
171
|
-
// 2D HUD, crosshair, virtual aim joystick, and FIRE control
|
|
172
|
-
group('fps.hud',0,0,390,150),layout('fps.hud',155,0),
|
|
173
|
-
uiText('fps.title','CYBER ARENA',65,24,260,38,26,{parentId:'fps.hud'}),
|
|
174
|
-
uiText('fps.kills.label','{{fps.kills}} / 3',135,64,120,30,20,{parentId:'fps.hud'}),
|
|
175
|
-
group('fps.reticle',177,332,36,36),layout('fps.reticle',332,177),
|
|
176
|
-
component('fps.reticle.h','native.rectangle.v1',{width:24,height:3,fill:'#ffe66d',strokeWidth:0,radius:2},{parentId:'fps.reticle',transform:[1,0,0,1,6,16.5]}),
|
|
177
|
-
component('fps.reticle.v','native.rectangle.v1',{width:3,height:24,fill:'#ffe66d',strokeWidth:0,radius:2},{parentId:'fps.reticle',transform:[1,0,0,1,16.5,6]}),
|
|
178
|
-
group('fps.joy.wrap',18,504,152,152),layout('fps.joy.wrap',52,212),
|
|
179
|
-
component('fps.joy','native.group.v1',{width:152,height:152},{parentId:'fps.joy.wrap'}),
|
|
180
|
-
behavior('fps.joy.stick','fps.joy','virtual-joystick',{mode:'fixed',radiusPx:54,deadZone:0,drawControl:true,baseColor:'#ffffff38',knobColor:'#ffe66dee'}),
|
|
181
|
-
behavior('fps.controller','fps.stage','fps-controller-3d',{x:0,y:1.6,z:6,yaw:0,pitch:0,minYaw:-.85,maxYaw:.85,minPitch:-.42,maxPitch:.45,moveSpeed:0,lookSensitivity:.0055,playerRadius:.5,boundsX:11,boundsZ:11,aimJoystickBehaviorId:'fps.joy.stick',aimMode:'delta',lookMode:'drag',bobAmplitude:0}),
|
|
182
|
-
group('fps.fire.wrap',228,552,138,68),layout('fps.fire.wrap',520,256),
|
|
183
|
-
component('fps.fire','native.button.v1',{width:138,height:68,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#182640',strokeWidth:4,radius:12,presentation:'shiny-cta'},{parentId:'fps.fire.wrap'}),
|
|
184
|
-
uiText('fps.fire.label','FIRE',8,12,122,44,24,{parentId:'fps.fire'}),
|
|
185
|
-
group('fps.audio',0,0,1,1,{parameters:{width:1,height:1,visible:false}}),
|
|
186
|
-
{kind:'putVariable',variable:{id:'fps.kills',label:'Kills',type:'number',initial:0}},
|
|
187
|
-
binding('fps.start',{kind:'sceneEnter',sceneId:'scene.play'},[
|
|
188
|
-
{kind:'spawnAt3d',prototypeId:'fps.drone',x:0,y:1.6,z:-2.2,count:1},
|
|
189
|
-
{kind:'spawnAt3d',prototypeId:'fps.drone',x:-3.8,y:2.1,z:-3.6,count:1},
|
|
190
|
-
{kind:'spawnAt3d',prototypeId:'fps.drone',x:3.8,y:1.3,z:-3.6,count:1},
|
|
191
|
-
{kind:'playAudio',behaviorId:'fps.ambient.sound'},
|
|
192
|
-
]),
|
|
193
|
-
binding('fps.joy.audio',{kind:'joystickStart',componentId:'fps.joy'},[{kind:'playAudio',behaviorId:'fps.ambient.sound'}]),
|
|
194
|
-
binding('fps.shoot',{kind:'click',componentId:'fps.fire'},[
|
|
195
|
-
{kind:'raycast3d',stageId:'fps.stage',mode:'crosshair',maxDistance:60,targetTeam:'enemy'},
|
|
196
|
-
{kind:'cameraShake',intensity:3,seconds:.09},
|
|
197
|
-
{kind:'screenFlash',color:'#ffe66d',opacity:.12,seconds:.08},
|
|
198
|
-
{kind:'playAudio',behaviorId:'fps.fire.sound'},
|
|
199
|
-
]),
|
|
200
|
-
binding('fps.hit',{kind:'raycastHit3d',componentId:'fps.drone'},[
|
|
201
|
-
{kind:'modifyInstanceState',target:'self',componentId:'fps.drone',field:'hp',op:'sub',value:1},
|
|
202
|
-
{kind:'floatingText',componentId:'fps.drone',text:'HIT!',color:'#ffe66d',fontSize:26,risePx:44,seconds:.45},
|
|
203
|
-
{kind:'playAudio',behaviorId:'fps.hit.sound'},
|
|
204
|
-
]),
|
|
205
|
-
binding('fps.kill',{kind:'instanceDepleted',componentId:'fps.drone'},[
|
|
206
|
-
{kind:'add',variableId:'fps.kills',value:1},
|
|
207
|
-
{kind:'despawn',target:'self'},
|
|
208
|
-
]),
|
|
209
|
-
binding('fps.win',{kind:'variableChange',variableId:'fps.kills'},[{kind:'changeScene',sceneId:'scene.win'}],{variableId:'fps.kills',op:'gte',value:3}),
|
|
210
|
-
// Victory end card with live 3D arena diorama
|
|
211
|
-
{kind:'createScene',scene:{id:'scene.win',label:'Arena cleared',role:'end-card'}},
|
|
212
|
-
group('fps.end.stage.wrap',0,0,390,700,{sceneId:'scene.win',order:-10}),layout('fps.end.stage.wrap',0,0,700/390,390/700),
|
|
213
|
-
component('fps.end.stage','native.stage3d.v1',{width:390,height:700,skyColor:'#182640',hemiSkyColor:'#dbeafe',hemiGroundColor:'#263854',hemiIntensity:1.8,sunColor:'#fff0cf',sunIntensity:2.2,sunX:-6,sunY:14,sunZ:8,cameraX:0,cameraY:3.4,cameraZ:8.4,cameraFov:52,landscapeCameraX:2.2,landscapeCameraY:3.0,landscapeCameraZ:7.8,landscapeCameraFov:38,lookAtX:0,lookAtY:.65,lookAtZ:0,introLift:0},{sceneId:'scene.win',parentId:'fps.end.stage.wrap'}),
|
|
214
|
-
mesh('fps.end.floor','fps.end.stage',{primitive:'box',x:0,y:-.2,z:0,sx:16,sy:.4,sz:16,color:'#2a3c58'},{sceneId:'scene.win'}),
|
|
215
|
-
mesh('fps.end.pedestal','fps.end.stage',{primitive:'cylinder',x:0,y:.35,z:0,sx:1.4,sy:.7,sz:1.4,radiusTop:.9,radiusBottom:1.05,color:'#385074'},{sceneId:'scene.win'}),
|
|
216
|
-
mesh('fps.end.trophy','fps.end.stage',{primitive:'sphere',x:0,y:1.95,z:0,sx:1.3,sy:1.3,sz:1.3,radiusTop:.65,color:'#f2b544'},{sceneId:'scene.win'}),
|
|
217
|
-
mesh('fps.end.visor','fps.end.stage',{primitive:'box',x:0,y:2.02,z:.68,sx:.72,sy:.24,sz:.2,color:'#182640'},{sceneId:'scene.win'}),
|
|
218
|
-
mesh('fps.end.eye','fps.end.stage',{primitive:'box',x:0,y:2.02,z:.80,sx:.36,sy:.12,sz:.08,color:'#38bdf8',unlit:true},{sceneId:'scene.win'}),
|
|
219
|
-
mesh('fps.end.ring','fps.end.stage',{primitive:'ring',x:0,y:.05,z:0,rx:-1.5708,innerRadius:1.4,radiusTop:1.75,color:'#38bdf8',unlit:true,doubleSide:true},{sceneId:'scene.win'}),
|
|
220
|
-
group('fps.end.ui',0,455,390,210,{sceneId:'scene.win'}),layout('fps.end.ui',310,105,.88),
|
|
221
|
-
uiText('fps.end.title','ARENA CLEARED',20,0,350,50,30,{parentId:'fps.end.ui',sceneId:'scene.win'}),
|
|
222
|
-
component('fps.end.cta','native.button.v1',{width:260,height:74,fill:'#f2b544',hoverFill:'#ffe66d',pressedFill:'#d88b32',stroke:'#182640',strokeWidth:4,radius:12,presentation:'shiny-cta'},{parentId:'fps.end.ui',sceneId:'scene.win',transform:[1,0,0,1,65,72]}),
|
|
223
|
-
uiText('fps.end.cta.label','DEPLOY NOW',10,8,240,56,26,{parentId:'fps.end.cta',sceneId:'scene.win'}),
|
|
224
|
-
behavior('fps.end.cta.float','fps.end.cta','animation',{property:'y',from:72,to:64,seconds:.8,loop:true,fromCurrent:false,delay:0,easing:'ease-in-out'}),
|
|
225
|
-
behavior('fps.end.confetti','fps.end.ui','emitter',{count:36,color:'#ffe66d',color2:'#38bdf8',color3:'#ef5b4c',speed:160,lifetime:.9,gravity:220,spread:360,shape:'confetti',coverage:'screen',origin:'center',direction:-90}),
|
|
226
|
-
binding('fps.end.enter',{kind:'sceneEnter',sceneId:'scene.win'},[{kind:'animate',behaviorId:'fps.end.cta.float'},{kind:'emit',behaviorId:'fps.end.confetti'},{kind:'playAudio',behaviorId:'fps.win.sound'}]),
|
|
227
|
-
binding('fps.end.store',{kind:'click',componentId:'fps.end.cta'},[{kind:'store'}]),
|
|
228
|
-
];
|
|
229
|
-
for(const [id,assetId,role,bus,loop,volume] of [['ambient','fps.ambient','ambient','music',true,.12],['fire','fps.fire.art','tap','sfx',false,.3],['hit','fps.hit.art','match','sfx',false,.35],['win','fps.win.art','win','stinger',false,.45]])ops.push(component('fps.audio.'+id,'native.group.v1',{width:1,height:1,visible:false},{parentId:'fps.audio',assetSlots:[{slotId:'source',assetId}]}),audio('fps.'+id+'.sound','fps.audio.'+id,role,bus,loop,volume));
|
|
230
|
-
const project=applyOperations(emptyProject({id:'fps-arena-proof',name:'Cyber Arena 3D',androidUrl:'https://play.google.com/store/apps/details?id=com.tora.cyberarena'}),[...records.map(asset=>({kind:'registerAsset',asset})),...ops]).project;
|
|
231
|
-
return {project,assets};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async function main(){
|
|
235
|
-
const kind=process.argv[2]??'farm',output=resolve(process.argv[3]??'reports/native-expansion/'+kind);if(!['farm','star','frost','fps'].includes(kind))throw Error('Unknown proof '+kind);
|
|
236
|
-
const {project,assets}=await (kind==='farm'?createFarmMergeProof():kind==='star'?createStarBastionProof():kind==='frost'?createFrostCleanProof():createFpsArenaProof());await mkdir(output,{recursive:true});
|
|
237
|
-
for(const target of ['standalone-browser-draft','unity-ads-ua-playable','applovin-growth-playable']){const artifact=await compileNative(project,{assets,target}),file=target==='standalone-browser-draft'?resolve(output,'standalone.html'):resolve(output,target,'index.html');await mkdir(dirname(file),{recursive:true});await writeFile(file,artifact.html);await writeFile(file.replace(/\.html$/,'.manifest.json'),JSON.stringify(artifact.manifest,null,2));}
|
|
238
|
-
await writeFile(resolve(output,'project.json'),JSON.stringify(project,null,2));globalThis.console.log(output);
|
|
239
|
-
}
|
|
240
|
-
if(process.argv[1]&&resolve(process.argv[1])===fileURLToPath(import.meta.url))await main();
|