Refactor entity creation logic in App.tsx
This commit is contained in:
@@ -737,15 +737,41 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
const handlePlaceEntity = (kind: EntityKind) => {
|
const handlePlaceEntity = (kind: EntityKind) => {
|
||||||
try {
|
try {
|
||||||
const basePosition = resolveNewEntityPosition(kind);
|
const basePosition = resolveNewEntityPosition(kind);
|
||||||
const nextEntity =
|
let nextEntity: EntityInstance;
|
||||||
kind === "triggerVolume" && selectedBrush !== null
|
|
||||||
? createTriggerVolumeEntity({
|
switch (kind) {
|
||||||
position: basePosition,
|
case "playerStart":
|
||||||
size: selectedBrush.size
|
nextEntity = createPlayerStartEntity({
|
||||||
})
|
position: basePosition
|
||||||
: createDefaultEntityInstance(kind, {
|
});
|
||||||
position: basePosition
|
break;
|
||||||
});
|
case "soundEmitter":
|
||||||
|
nextEntity = createSoundEmitterEntity({
|
||||||
|
position: basePosition
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "triggerVolume":
|
||||||
|
nextEntity =
|
||||||
|
selectedBrush === null
|
||||||
|
? createTriggerVolumeEntity({
|
||||||
|
position: basePosition
|
||||||
|
})
|
||||||
|
: createTriggerVolumeEntity({
|
||||||
|
position: basePosition,
|
||||||
|
size: selectedBrush.size
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "teleportTarget":
|
||||||
|
nextEntity = createTeleportTargetEntity({
|
||||||
|
position: basePosition
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "interactable":
|
||||||
|
nextEntity = createInteractableEntity({
|
||||||
|
position: basePosition
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createUpsertEntityCommand({
|
createUpsertEntityCommand({
|
||||||
@@ -1319,7 +1345,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
<header className="toolbar">
|
<header className="toolbar">
|
||||||
<div className="toolbar__brand">
|
<div className="toolbar__brand">
|
||||||
<div className="toolbar__title">WebEditor3D</div>
|
<div className="toolbar__title">WebEditor3D</div>
|
||||||
<div className="toolbar__subtitle">Slice 1.5 world lighting basics</div>
|
<div className="toolbar__subtitle">Slice 2.1 entity system foundation</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="toolbar__actions">
|
<div className="toolbar__actions">
|
||||||
|
|||||||
Reference in New Issue
Block a user