Skip to content

Commit

Permalink
Merge pull request #2 from decentraland-scenes/proper-multiplayer
Browse files Browse the repository at this point in the history
refactor to use fixed IDs
  • Loading branch information
nearnshaw authored Jan 3, 2024
2 parents c52c8ec + 338d861 commit 0e8cd80
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 210 deletions.
294 changes: 203 additions & 91 deletions bin/game.js

Large diffs are not rendered by default.

17 changes: 4 additions & 13 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,15 @@ export const PotData = engine.defineComponent('Pot', {
state: SoupState.Empty,
hasIngredient: false,
attachedEntity: undefined,
//progressBar: 0,
})


export const GrabableObjectComponent = engine.defineComponent('GrabableObjectComponent', {
type: Schemas.EnumNumber<IngredientType>(IngredientType, IngredientType.Noodles),
beingProcessed: Schemas.Boolean,
processed: Schemas.Boolean,
// grabbed: Schemas.Boolean,
// falling: Schemas.Boolean,
// origin: Schemas.Number,
// target: Schemas.Number,
// fraction: Schemas.Number,
//progressBar: Schemas.Entity,
// attachedEntity: Schemas.Entity
}, {
type: IngredientType.Noodles,
// grabbed: false,
// falling: false,
// origin: 0.4,
// target: 0,
// fraction: 0
})

export const Cooking = engine.defineComponent('Cooking', {
Expand Down Expand Up @@ -229,6 +216,7 @@ export const CuttingBoard = engine.defineComponent('CuttingBoard', {


export const ProgressBar = engine.defineComponent('ProgressBar', {
visible: Schemas.Boolean,
active: Schemas.Boolean,
ratio: Schemas.Number,
yellowWarning: Schemas.Number,
Expand All @@ -239,6 +227,7 @@ export const ProgressBar = engine.defineComponent('ProgressBar', {
speed: Schemas.Number,
parent: Schemas.Entity
}, {
visible: true,
active: true,
ratio: 0,
yellowWarning: 0.5,
Expand All @@ -253,6 +242,7 @@ export const ProgressBar = engine.defineComponent('ProgressBar', {


export const CustomerData = engine.defineComponent('CustomerData', {
active: Schemas.Boolean,
dish: Schemas.EnumNumber<IngredientType>(IngredientType, IngredientType.Noodles),
message: Schemas.String,
speechBubble: Schemas.Entity,
Expand All @@ -264,6 +254,7 @@ export const CustomerData = engine.defineComponent('CustomerData', {
waitingTimer: Schemas.Number,
progressBar: Schemas.Entity
}, {
active: false,
receivedDish: false,
timeBeforeLeaving: 30,
timeBeforeEntering: 10,
Expand Down
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ export function main() {
}






// Pots
const pot1 = engine.getEntityOrNullByName("Pot1")
const pot2 = engine.getEntityOrNullByName("Pot2")
Expand All @@ -95,8 +91,9 @@ export function main() {


if (pot1 && pot2 && pot1_button && pot2_button) {
instancePot(pot1, SyncEntityIDs.POT1)
instancePot(pot2, SyncEntityIDs.POT2)
instancePot(pot1, SyncEntityIDs.POT1, SyncEntityIDs.PBAR5_A, SyncEntityIDs.PBAR5_B)
instancePot(pot2, SyncEntityIDs.POT2, SyncEntityIDs.PBAR6_A, SyncEntityIDs.PBAR6_B)


const pot1_button_events = getTriggerEvents(pot1_button)
pot1_button_events.on(TriggerType.ON_CLICK, () => {
Expand Down Expand Up @@ -208,6 +205,11 @@ export function main() {
syncEntity(misses, [TextShape.componentId], SyncEntityIDs.MISSES_TEXT)
}

CreateCustomer(1)
CreateCustomer(2)
CreateCustomer(3)
CreateCustomer(4)



engine.addSystem(pickingGlassSystem)
Expand Down
Loading

0 comments on commit 0e8cd80

Please sign in to comment.