Keep Create Object button for custom objects

This commit is contained in:
2026-10-17 20:04:10 -04:00
parent 752a87cc0f
commit 478b037e6a
2 changed files with 24 additions and 2 deletions
+23 -1
View File
@@ -1,4 +1,4 @@
import type { ConditionKind, Entrance, LayoutState, RoomConfig } from '../types';
import type { ConditionKind, Entrance, FurnitureConfig, LayoutState, RoomConfig } from '../types';
interface ControlPanelProps {
state: LayoutState;
@@ -37,6 +37,25 @@ export function ControlPanel({
onStateChange({ ...state, entrance: { x: 20, y: 20, width: 20, height: 20 } });
};
const createObject = () => {
const id = 'obj_' + Date.now();
const newItem: FurnitureConfig = {
id,
name: 'Object ' + (state.furniture.length + 1),
type: 'custom',
shape: { type: 'rectangle', x: 100, y: 100, width: 50, height: 50 },
conditions: [
{ kind: 'walk_to_and_sit', weight: 1 },
{ kind: 'accessible', weight: 1 },
],
color: '#90caf9',
lockedForOptimization: false,
placed: true,
};
onStateChange({ ...state, furniture: [...state.furniture, newItem] });
onSelect(id);
};
const toggleLock = () => {
if (!selectedId) return;
const updated = state.furniture.map((f) =>
@@ -123,6 +142,9 @@ export function ControlPanel({
<button onClick={placeEntrance} style={{ marginLeft: 8 }}>
Place Entrance
</button>
<button onClick={createObject} style={{ marginLeft: 8 }}>
Create Object
</button>
</div>
{state.entrance && (
<div style={{ marginTop: 8 }}>