Skip to content

Add Unity 2D mansion quest gameplay scripts#1

Open
jutiger wants to merge 1 commit intomainfrom
codex/add-npc-item-request-system
Open

Add Unity 2D mansion quest gameplay scripts#1
jutiger wants to merge 1 commit intomainfrom
codex/add-npc-item-request-system

Conversation

@jutiger
Copy link
Copy Markdown
Owner

@jutiger jutiger commented Mar 5, 2026

Motivation

  • Provide a baseline gameplay system for a Unity 2D mansion scenario where the player explores rooms, picks up randomly spawned items, uses doors to travel between rooms, and delivers specific items to NPCs that only accept the requested item.
  • Make it easy to configure three NPC requests, spawn points and item prefabs, and to detect quest completion when all NPCs are satisfied.

Description

  • Added an ItemType enum (ItemType.cs) and a simple player inventory component Inventory2D with AddItem, HasItem and RemoveItem methods.
  • Implemented ItemPickup which can be Configured at spawn time and collects items into the player's Inventory2D on trigger.
  • Added RandomItemSpawner to randomly place item prefabs at configured spawn points and set their ItemType via ItemPickup.Configure.
  • Implemented NPCRequester which requires the player to press E to deliver an exact requestedItem, optionally consumes the item, fires success/failure UnityEvents and notifies the quest manager.
  • Implemented MansionQuestManager to assign requests (optionally unique) to a list of NPCs and invoke onAllNPCsSatisfied when all are fulfilled.
  • Added DoorTeleporter to let the player interact with doors to teleport to a destination point.
  • Added a Portuguese README.md that documents setup steps and the gameplay flow.

Testing

  • Ran git diff --check to validate there are no whitespace/patch issues and it succeeded.
  • Verified all new script files exist under Assets/Scripts/ with find Assets -maxdepth 3 -type f | sort and the check succeeded.
  • Confirmed repository working tree state with git status --short after changes and it showed no outstanding changes (success).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3a10a3c7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return;
}

if (!other.CompareTag("Player") || !Input.GetKeyDown(KeyCode.E))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move interaction key check out of physics callback

The NPC hand-in gate uses Input.GetKeyDown(KeyCode.E) inside OnTriggerStay2D, but GetKeyDown is frame-based while OnTriggerStay2D runs on physics ticks, so key presses can be missed when render and fixed-update timing diverge. In play this causes intermittent failures to deliver items even when the player is inside the NPC trigger and pressing E correctly.

Useful? React with 👍 / 👎.


int index = Random.Range(0, pool.Count);
ItemType selected = pool[index];
npcs[i].SetRequest(selected);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Initialize NPC quest-manager links during assignment

Quest completion is only checked through questManager?.CheckQuestState() in NPCRequester, but MansionQuestManager.AssignRequests() currently configures only the requested item and never injects itself into the NPCs. In scenes where designers only populate the manager's NPC list (as the quick setup suggests), each NPC's questManager stays null and onAllNPCsSatisfied will never be evaluated after deliveries.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant