Skip to content

Commit

Permalink
Merge pull request #163 from pocketzworld/hsein/dress-up-guide
Browse files Browse the repository at this point in the history
Dress-UP-NPC Guide
  • Loading branch information
sphinixFTW authored Dec 20, 2024
2 parents 1c5be11 + b8190f5 commit 3959b0c
Show file tree
Hide file tree
Showing 21 changed files with 1,838 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pages/learn/studio/create/examples/worlds/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"kaiju-king": {
"title": "Kaiju King"
},
"dress-up-npc": {
"title": "Dress Up NPC"
}
}
23 changes: 23 additions & 0 deletions pages/learn/studio/create/examples/worlds/dress-up-npc/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"overview": {
"title": "Overview"
},
"folder-structure": {
"title": "Folder Structure"
},
"script-relations": {
"title": "Script Relations"
},
"data-flow-state-management": {
"title": "Data Flow & State Management"
},
"utility-functions": {
"title": "Utility Functions"
},
"game-core": {
"title": "Game Core"
},
"game-mechanics": {
"title": "Game Mechanics"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Data Flow & State Management

This document explains how data flows through the game and how various systems manage state. Understanding data flow is critical for maintaining the game's logic and ensuring a seamless player experience.

## Overview
The game relies on a centralized system to manage and share data between different modules. Key elements of data flow include:
- **Initialization:** Data is loaded and initialized at game startup.
- **Runtime Updates:** Systems modify and exchange data during gameplay.
- **Persistence:** Player progress and game state are saved and loaded using `SaveManager.lua`.

## Data Flow Components

### 1. **GameManager.lua**
The `GameManager.lua` script is the central hub for initializing and managing game-wide data.

- **Responsibilities:**
- Initializes core systems (e.g., `QuestManager.lua`, `ContestManager.lua`).
- Maintains global variables for game state.
- Coordinates data flow between subsystems.

- **Example Workflow:**
1. At startup, `GameManager.lua` calls `SaveManager.lua` to load saved data.
2. It initializes managers like `QuestManager.lua` and `ContestManager.lua`, passing relevant data.
3. During gameplay, it updates and tracks global states like active quests or contests.

### 2. **SaveManager.lua**
The `SaveManager.lua` script is responsible for persisting player progress and game data.

- **Responsibilities:**
- Saves player data, including outfits, quest progress, and rewards.
- Loads saved data during initialization.
- Provides utility functions for other scripts to read or write data.

- **Example Workflow:**
1. When the game starts, `SaveManager.lua` retrieves saved data and passes it to `GameManager.lua`.
2. During gameplay, systems like `QuestManager.lua` call `SaveManager.lua` to update quest states.
3. On game exit, `SaveManager.lua` writes the current state to storage.

### 3. **QuestManager.lua**
The `QuestManager.lua` script handles quest-related data and integrates with other systems.

- **Responsibilities:**
- Tracks active, completed, and available quests.
- Updates quest states based on player actions.
- Communicates with `SaveManager.lua` to persist quest progress.

- **Example Workflow:**
1. A player interacts with an NPC, triggering `DialogManager.lua`.
2. If a quest is accepted, `QuestManager.lua` adds it to the active quests list.
3. Upon completion, `QuestManager.lua` marks the quest as completed and updates `SaveManager.lua`.

### 4. **ContestManager.lua**
The `ContestManager.lua` script manages data related to dress-up contests.

- **Responsibilities:**
- Tracks contest entries, voting progress, and results.
- Updates player rankings and rewards.
- Communicates with `SaveManager.lua` to persist player contest participation and results.

- **Example Workflow:**
1. Players submit contest entries via `UIContest.lua`.
2. `ContestManager.lua` updates the contest state with the new entry.
3. After the contest ends, `ContestManager.lua` calculates results and rewards, updating `SaveManager.lua`.

### 5. **UIDressUp.lua and OutfitUtils.lua**
These scripts handle character customization and manage outfit data.

- **Responsibilities:**
- `UIDressUp.lua` provides the UI for customizing characters.
- `OutfitUtils.lua` manages outfit data and ensures compatibility across systems.
- Updates customization data in `SaveManager.lua`.

- **Example Workflow:**
1. A player customizes their character in `UIDressUp.lua`.
2. The updated outfit data is saved using `OutfitUtils.lua`.
3. `SaveManager.lua` persists the new outfit data.

## Data Flow Diagram

### Initialization
1. `GameManager.lua` initializes core systems.
2. `SaveManager.lua` loads saved data.
3. Data is distributed to `QuestManager.lua`, `ContestManager.lua`, and `UIDressUp.lua`.

### Runtime Updates
1. Systems exchange data as events occur (e.g., quests, contests).
2. Updated data is passed back to `SaveManager.lua` for persistence.

### Persistence
1. On game exit, `SaveManager.lua` writes all data to storage.

## Key Considerations
- **Data Consistency:** Ensure systems update shared data consistently to avoid conflicts.
- **Error Handling:** Implement fallback mechanisms for corrupted or missing save data.
- **Extensibility:** Modularize data flow to allow new features to integrate seamlessly.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Folder Structure

## Overivew

This document explains the structure of the project and the purpose of each folder.

## Core Project Folders

- **Art**
Home to all visual assets like character designs, backgrounds, and icons.
*Example*: Player and NPC sprites, decorative assets for environments.

- **Audio**
Everything your ears need! Includes sound effects and background music.
*Example*: Button click sounds, ambient town noises.

- **Fonts**
Fonts used throughout the game, ensuring every text element looks just right.
*Example*: Stylish fonts for NPC dialogues or UI labels.

- **Materials & Mesh**
- Materials: Textures and shaders to give life to 3D models.
- Mesh: The 3D structures for characters and objects.

- **Music**
All the soundtracks that set the mood of the game.
*Example*: Upbeat music for the dress-up area or soft tones in the background.

- **NPCs**
This folder houses all the lovable (or not-so-lovable!) characters that populate your game world.

- **Prefabs**
Ready-to-use templates for objects like interactable items, NPCs, and environmental props.

- **Scenes**
The heart of the game. Contains the layouts and the scenes where the game unfolds.

- **ScriptableObjects**
Scriptable data assets to store configurations or game data.
*Example*: Settings for dress-up tasks or NPC dialogue options.

- **Scripts**
The brain behind the project! Contains the code that powers gameplay, UI, and interactions.
*Key scripts include*:
- `GameManager.lua`: Orchestrates game logic.
- `UIDressUp.lua`: Powers the dress-up menu UI.

## External Asset Folders

- **Downloads**
A collection of resources sourced from the Highrise Assets Catalog for use in the project.

- **JMO Assets, PolyPerfect, StylizedFountains, KawaiiCity**
External assets added to enhance the world. Think of these as the guest stars in your project, bringing unique touches to the game design.

## Utility Folders (Studio Specific)

- **Resources**
Unity's go-to folder for dynamically loaded assets. Think of it as a hidden stash for runtime goodies.

## Visualizing the Structure

├── Art/
├── Audio/
├── Downloads/
├── Fonts/
├── JMO Assets/
├── KawaiiCity/
├── Materials/
├── Mesh/
├── Music/
├── NPCs/
├── PolyPerfect/
├── Prefabs/
├── Resources/
├── Scenes/
├── ScriptableObjects/
├── Scripts/
│ ├── Core/
│ │ ├── GameManager.lua - Orchestrates game logic.
│ │ ├── SaveManager.lua - Manages saving and loading.
│ ├── UI/
│ │ ├── UIDressUp.lua - Handles the main dress-up interface.
└── StylizedFountains/

## Next Steps

Now that you understand the project structure, let's dive into the core gameplay mechanics and how to interact with the game world. Continue to the [Gameplay Mechanics](https://create.highrise.game/learn/studio/create/examples/worlds/dress-up-npc/game-mechanics/gameplay-mechanics) guide to learn more.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"game-manager": {
"title": "Game Manager"
},
"save-manager": {
"title": "Save Manager"
},
"cheat-command-manager": {
"title": "Cheat Command Manager"
},
"game-settings-manager": {
"title": "Game Settings Manager"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# CheatCommandModule

The `CheatCommandModule.lua` is a critical tool designed to facilitate debugging and testing by providing a wide array of cheat commands. These commands allow developers and testers to manipulate game states, unlock features, and validate functionalities efficiently.

## Overview

The `CheatCommandModule` provides:

- **Command Parsing**: Processes player input to identify commands and arguments.
- **Player Validation**: Ensures only authorized players can execute commands.
- **Client-Server Communication**: Supports both client-side and server-side command execution.
- **Integration**: Links with game management modules to perform actions like unlocking quests, modifying contests, or resetting data.

## Key Components

### 1. **Command Processing**

#### Parsing Commands
Commands are parsed using the `ParseCommand` function, which identifies the command keyword and associated arguments.

##### Key Functions
- `SplitString(input)`: Splits a string into individual words.
- `ParseCommand(input)`: Extracts the command keyword and arguments from a player’s input.

#### Command Execution
Commands are executed if they exist in the `commands` table and the player has the necessary permissions.

##### Key Functions
- `CommandExists(command)`: Checks if a command is defined.
- `CanPlayerRunCommand(player)`: Validates if a player is authorized to execute commands.

### 2. **Player Validation**

#### Authorization Logic
Only players listed in `_validPlayers` or in test mode (`_testMode`) can run commands.

##### Key Logic
- `CanPlayerRunCommand(player)`: Returns true if the player is authorized based on `_validPlayers` or `_testMode`.

### 3. **Command Registry**

#### Registered Commands
The module defines a set of cheat commands in the `commands` table. These commands invoke corresponding functions from other game modules.

##### Available Commands
- `/help`: Displays a list of available commands.
- `/cleardata`: Resets all player data.
- `/addreward`: Grants rewards to the player.
- `/debugquests`: Enables quest debugging mode.
- `/deletecontests`: Clears all active contests.
- `/addcontestplayers`: Adds test players to a contest.
- `/addtickets`: Grants tickets for contests.
- `/setcontestvotes`: Adjusts votes for a contest.
- `/unlockcontest`: Unlocks a specific contest.
- `/completequests`: Completes specified quests.

### 4. **Client-Side Operations**

Handles player input and executes commands locally or sends them to the server for execution.

#### Key Functions
- **Command Execution**:
- Captures and processes player input in chat.
- Executes commands locally or triggers server requests.
- **Event Handling**:
- `chatCommandRequest`: Sends commands to the server.
- `chatCommandResponse`: Processes responses from the server.
- **Help Command**:
- Displays all available commands to the player.

### 5. **Server-Side Operations**

Processes server-specific commands and broadcasts responses to all clients.

#### Key Functions
- `chatCommandRequest:Connect`: Handles incoming requests from clients.
- `chatCommandResponse:FireAllClients`: Sends responses to all connected clients.

## Workflow Examples

### Command Execution Workflow
1. **Player Input**:
- Player enters a command in chat (e.g., `/addreward`).
2. **Parsing**:
- `ParseCommand` extracts the command keyword and arguments.
3. **Validation**:
- `CanPlayerRunCommand` checks if the player is authorized.
4. **Execution**:
- The corresponding function from the `commands` table is invoked.
5. **Response**:
- Success or error messages are displayed to the player.
Loading

0 comments on commit 3959b0c

Please sign in to comment.