import { PluginPureHook } from '@gedit/runtime-compiler'; import { RectangleGameObject } from '@gedit/runtime-render'; import { transform } from './transform'; import { rgba, rgb2hex } from '../common/color'; import { LocalComponent } from './utils'; import { addGameObjectToMap, code } from '../common'; import { attachCollisionBody } from './collision-body'; export function rect( ctx: PluginPureHook, component: RectangleGameObject, ): void { const { rectangle: data, name, displayType } = component; ctx.comment(`@type ${displayType}\n@name ${name}`); const { r, g, b, a } = rgba(data.color); const blk = new LocalComponent(ctx); blk.in(); ctx.println( `${code.create(component)}(0, 0, 0, 0, ${'0x' + rgb2hex(r, g, b)}, ${a})`, ); addGameObjectToMap(ctx, component); attachCollisionBody(ctx, component); transform(ctx, component, true); blk.out(); }