Skip to content

Commit

Permalink
feat - entry names to person machines and add context debugs on hotspots
Browse files Browse the repository at this point in the history
  • Loading branch information
sdubourg committed Jul 26, 2023
1 parent 8c368c1 commit 97d16a6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
20 changes: 12 additions & 8 deletions src/components/gl/Person/Person.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { a, useSpring } from '@react-spring/three';
import { Html, useCursor, useTexture } from '@react-three/drei';
import { Html, Text, useCursor, useTexture } from '@react-three/drei';
import { useFrame } from '@react-three/fiber';
import { useSelector } from '@xstate/react';
import { useControls } from 'leva';
Expand Down Expand Up @@ -88,10 +88,10 @@ export const Person = ({
const tex = useTexture('assets/dudess.png');
const serviceId = actor.id;

const { hype, pee, thirst } = useSelector(
actor,
(state) => state.context.meters,
);
const {
meters: { hype, pee, thirst },
name,
} = useSelector(actor, (state) => state.context);

const isBeingDragged = draggingId === serviceId;

Expand Down Expand Up @@ -200,9 +200,13 @@ export const Person = ({
emissiveMap={tex}
/>
</a.mesh>
<Statbar position-y={6} value={thirst} />
<Statbar position-y={6.25} value={pee} />
<Statbar position-y={6.5} value={hype} />
<Statbar position-y={4} value={thirst} />
<Statbar position-y={4.25} value={pee} />
<Statbar position-y={4.5} value={hype} />

<Text fontSize={0.5} position-y={3} color="yellow">
{name}
</Text>

{/* Debug */}
{showActionButtons && (
Expand Down
22 changes: 22 additions & 0 deletions src/machines/person.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const names = [
'Simbala',
'Plumbob',
'Llamanade',
'Gibberish',
'Wuhoo',
'BellaGoth',
'Simoleon',
'Woohookie',
'Simberly',
'Llamalette',
'Whippna',
'Simmette',
'BobNewbie',
'Zigaloo',
'SulSul',
'Freetushi',
'Vadish',
'Retgirb',
'Blahort',
'Graaable',
];
8 changes: 6 additions & 2 deletions src/machines/person.machine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MathUtils } from 'three';
import { assign, createMachine, send } from 'xstate';
import { sendTo } from 'xstate/lib/actions';
import { assign, createMachine } from 'xstate';
import { names } from './person.constants';

const METERS_CONFIG = {
thirst: {
Expand Down Expand Up @@ -35,6 +35,10 @@ export const personMachine = createMachine(
'A person is a character in the game, with its needs and actions.',
type: 'parallel',
initial: 'actionFlow',
entry: assign((context) => ({
...context,
name: names[Math.floor(Math.random() * names.length)],
})),
context: {
name: '',
meters: {
Expand Down

0 comments on commit 97d16a6

Please sign in to comment.