Skip to content

Flower puzzle combination#59

Open
Kieran-42 wants to merge 15 commits intomainfrom
flower-puzzle-combination
Open

Flower puzzle combination#59
Kieran-42 wants to merge 15 commits intomainfrom
flower-puzzle-combination

Conversation

@Kieran-42
Copy link
Copy Markdown
Contributor

Added the ability to combine flowers through the use of a new flower menu prefab.

Added new InteractCanvas prefab for interaction prompts and integrated it into GreenHouseRoomScene. Updated Canvas prefab settings and improved text rendering options. Refactored Dialogue prefabs into Button/Dialogue directory. Enhanced FlowerSystem prefab with new collider and renderer properties. Added FlowerMenuController script for UI control.
Adds a new Flower Menu UI prefab and a new FlowerMenu script and updates to FlowerMenuController.cs.
Refactor the flower combiner to manage two explicit Slot1/Slot2 items instead of using Inventory items and Inventory events.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a flower-combination (“flower puzzle”) flow by introducing a dedicated Flower Menu UI and a FlowerInventory combiner component, then wiring it into the GreenHouse scene/prefabs.

Changes:

  • Added FlowerMenuController + FlowerMenu UI to display an inventory and transfer selected flowers into a 2-slot combiner.
  • Added FlowerInventory (recipes + combine result) and hooked it up in GreenHouseRoomScene/FlowerSystem prefabs.
  • Updated various prefabs/assets (InteractCanvas, dialogue tablet prefabs, new item assets) and applied a broad “position → offset” wording pass to several scripts/vendor DOTween module comments.

Reviewed changes

Copilot reviewed 36 out of 46 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
Assets/Scripts/UI/FlowerController/FlowerMenuController.cs.meta Unity meta for new script asset.
Assets/Scripts/UI/FlowerController/FlowerMenuController.cs New controller to open/close the Flower Menu and provide inventory/combiner references.
Assets/Scripts/UI/FlowerController/FlowerMenu.cs.meta Unity meta for new script asset.
Assets/Scripts/UI/FlowerController/FlowerMenu.cs New menu UI to browse inventory, transfer items to combiner, and trigger combine.
Assets/Scripts/UI/FlowerController.meta Unity folder meta for new UI scripts folder.
Assets/Scripts/Puzzles/Sliding Box/SlidingBox.cs Comment-only wording changes (“position” → “offset”).
Assets/Scripts/Puzzles/Sliding Box/DraggableObject.cs Comment-only wording changes (“position” → “offset”), incl. commented-out code block.
Assets/Scripts/Puzzles/PipePuzzle.cs Comment-only wording changes (“position” → “offset”).
Assets/Scripts/Puzzles/LaserPuzzle.cs Comment-only wording changes (“position” → “offset”).
Assets/Scripts/Puzzles/InsightPuzzle.cs Comment-only wording changes (“position” → “offset”).
Assets/Scripts/Puzzles/IcePuzzlePlayerController.cs Comment-only wording changes (“position” → “offset”).
Assets/Scripts/Puzzles/ButtonScreenScript.cs Comment-only wording changes (“position” → “offset”) inside commented block.
Assets/Scripts/Inventory/FlowerInventory/FlowerInventory.cs.meta Unity meta for new script asset.
Assets/Scripts/Inventory/FlowerInventory/FlowerInventory.cs New combiner inventory logic (2 slots, recipes, combine result, UI slot binding).
Assets/Scripts/Inventory/FlowerInventory.meta Unity folder meta for new FlowerInventory folder.
Assets/Scripts/Environment/InteractionTrigger.cs Adds configurable popup offset and changes popup positioning behavior.
Assets/Scenes/RoomScenes/GreenHouseRoomScene.unity Scene wiring for the combiner/menu components and related scene object adjustments.
Assets/Prefabs/UI/InteractCanvas.prefab.meta Unity meta for new/updated prefab asset.
Assets/Prefabs/UI/InteractCanvas.prefab New/updated world-space interaction popup canvas prefab.
Assets/Prefabs/UI/Flowers/Flower Menu.prefab.meta Unity meta for new Flower Menu prefab.
Assets/Prefabs/UI/Flowers/Flower Menu.prefab New Flower Menu prefab layout (item list + combiner panels + combine button).
Assets/Prefabs/UI/Flowers.meta Unity folder meta for new Flowers prefab folder.
Assets/Prefabs/UI/Canvas.prefab Changes canvas sorting settings (override sorting + high order).
Assets/Prefabs/Player.prefab Adjusts player collider geometry and Rigidbody2D collision detection mode.
Assets/Prefabs/Game Objects/FlowerSystem.prefab Updates interaction trigger serialization and other prefab serialization changes.
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt2.prefab.meta Unity meta for new dialogue prefab.
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt2.prefab New dialogue content for tablet (part 2).
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt1.prefab.meta Unity meta for new dialogue prefab.
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt1.prefab New dialogue content for tablet (part 1).
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt1.5.prefab.meta Unity meta for new dialogue prefab.
Assets/Prefabs/Button/Dialogue/Tablet/TabletPt1.5.prefab New dialogue content for tablet (part 1.5).
Assets/Prefabs/Button/Dialogue/Tablet.meta Unity folder meta for new Tablet dialogue folder.
Assets/Prefabs/Button/Dialogue/DialogueComponent.prefab.meta Unity meta for new dialogue component prefab.
Assets/Prefabs/Button/Dialogue/DialogueComponent.prefab New empty dialogue component prefab baseline.
Assets/Prefabs/Button/Dialogue.meta Unity folder meta for new Dialogue folder.
Assets/Items/Refuse.asset.meta Unity meta for new item asset.
Assets/Items/Refuse.asset New “Refuse/Trash” item asset (used as failed-combination output).
Assets/Items/PrettyFlower.asset.meta Unity meta for new item asset.
Assets/Items/PrettyFlower.asset New PrettyFlower item asset (currently missing categories/icons).
Assets/Items/OrangeSapling.asset.meta Unity meta for new item asset.
Assets/Items/OrangeSapling.asset New OrangeSapling item asset (currently missing categories/icons).
Assets/DOTween/Modules/DOTweenModuleUnityVersion.cs Comment-only wording changes (“position” → “offset”) in vendor file.
Assets/DOTween/Modules/DOTweenModuleUI.cs Comment-only wording changes (“position” → “offset”) in vendor file.
Assets/DOTween/Modules/DOTweenModulePhysics2D.cs Comment-only wording changes (“position” → “offset”) in vendor file.
Assets/DOTween/Modules/DOTweenModulePhysics.cs Comment-only wording changes (“position” → “offset”) in vendor file.
Assets/DOTween/Modules/DOTweenModuleAudio.cs Comment-only wording changes (“position” → “offset”) in vendor file.
Comments suppressed due to low confidence (2)

Assets/Items/PrettyFlower.asset:22

  • These new flower items have categories: left blank. FlowerInventory.AddFlower requires the Item.Category.FLOWER category, so these items won’t be addable/combinnable. Set the categories to match existing flower items (e.g., compare Hydrangea.asset / InfectedDandelion.asset, which have categories: 01000000).
  displayName: New Item
  description: I am an item!
  icon: {fileID: 0}
  preview: {fileID: 0}
  maxStackSize: 99
  inspectMenuPrefab: {fileID: 4999652605848861478, guid: 161ff6344f6d842b1ae9a6e079838e30, type: 3}
  categories: 

Assets/Items/OrangeSapling.asset:22

  • These new flower items have categories: left blank. FlowerInventory.AddFlower requires the Item.Category.FLOWER category, so these items won’t be addable/combinnable. Set the categories to match existing flower items (e.g., Hydrangea.asset / InfectedDandelion.asset).
  displayName: New Item
  description: I am an item!
  icon: {fileID: 0}
  preview: {fileID: 0}
  maxStackSize: 99
  inspectMenuPrefab: {fileID: 4999652605848861478, guid: 161ff6344f6d842b1ae9a6e079838e30, type: 3}
  categories: 


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +41
public void Start()
{
if (textPopup == null)
{
popupText = triggerKey.ToString();
}
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Start() currently overwrites popupText whenever textPopup is null (which is always true until a popup is shown). This prevents setting a custom popup message in the inspector. Consider only defaulting when popupText is empty (e.g., string.IsNullOrEmpty(popupText)) or when no popup was explicitly configured.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 48
public void Update()
{
if(this.textPopup != null)
{
this.textPopup.transform.position = this.transform.position + new Vector3(0, 1, 0);
this.textPopup.transform.position = this.transform.position + new Vector3(offset.x, offset.y, 10);
this.textPopup.canvas.sortingOrder = 9999;
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Update() sets canvas.sortingOrder every frame and uses a hardcoded Z=10 when positioning the popup. This adds per-frame work and makes layering dependent on a magic number. Consider setting the canvas sorting order once when creating the popup (in ToggleTextPopup(true)) and keep Z consistent with the World Canvas (or make the Z offset configurable).

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +117
Instantiate(this.menuPrefab, canvas.transform).Init(inventory, this.flowerInventory);
this.onMenuOpen.Invoke(this);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The instantiated FlowerMenu is only Init(...)'d but never Open()'d. Since MenuBase drives activation/animations via Open()/Close(), skipping Open() can leave the menu in an unexpected state (no open animation/events, and close/rewind logic may not behave as intended). Call Open() on the instantiated menu (similar to Inventory.OpenMenu()).

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +114
string playerInvLog = "Player Inventory: ";
foreach (var item in inventory.GetItems())
playerInvLog += $"{item.GetDisplayName()} (x{inventory.GetCount(item)}), ";
Debug.Log(playerInvLog);

if (this.flowerInventory != null)
{
string combinerLog = "Combiner Inventory: ";
if (this.flowerInventory.Slot1 != null) combinerLog += $"{this.flowerInventory.Slot1.GetDisplayName()} (x1), ";
if (this.flowerInventory.Slot2 != null) combinerLog += $"{this.flowerInventory.Slot2.GetDisplayName()} (x1), ";
Debug.Log(combinerLog);
}
else
{
Debug.LogWarning("Combiner Inventory is NULL on the controller!");
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

OpenMenu() logs full player inventory and combiner inventory contents every time the menu opens. This is noisy in normal gameplay and can impact performance in large inventories. Consider removing these logs or gating them behind a debug flag / conditional compilation.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +44
public FlowerMenu Init(Inventory associatedInventory, FlowerInventory combiner = null)
{
associatedInventory.itemAddedEvent.AddListener(this.AddItemEntry);
associatedInventory.itemRemovedEvent.AddListener(this.RemoveItemEntry);
associatedInventory.itemChangedEvent.AddListener(this.UpdateItemEntry);

Item[] items = associatedInventory.GetItems();

for (int i = 0; i < items.Length; ++i)
{
this.AddItemEntry(associatedInventory, items[i]);
}

Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

After populating the toggle list in Init, the menu never sets an initial selection (unlike InventoryMenuController, which forces selection to the first item). As a result GetSelectedItem() can stay null until the player clicks an entry, and Space-to-transfer won’t do anything. Consider calling MoveSelection(-GetSelectedPosition()) (or explicitly toggling the first entry on) after adding item entries.

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +106
public Item Combine()
{
if (_craftMap == null || Slot1 == null || Slot2 == null) return null;

if (!_craftMap.TryGetValue((Slot1, Slot2), out Item result) || result == null)
{
result = failedCombinationItem;
}

if (result == null) return null;

Slot1 = null;
Slot2 = null;
contentChangedEvent?.Invoke();

GameManager.inst?.player?.Inventory?.AddItem(result, 1);
return result;
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Combine() returns null if no recipe matches and failedCombinationItem is not set, but the input items have already been removed from the player inventory via AddFlower(). This can permanently delete items. Consider either requiring failedCombinationItem (validate in Awake) or, on failure, returning the slotted items to the player and clearing the slots before returning.

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +125
Inventory player = GameManager.inst?.player?.Inventory;
if (player == null || !player.HasItem(item)) return;

if (Slot1 == null) Slot1 = item;
else Slot2 = item;

player.RemoveItem(item, 1);
contentChangedEvent?.Invoke();
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

AddFlower always removes the item from GameManager.inst.player.Inventory, even though the flower menu is initialized with an associatedInventory that could be different (inventoryToShow). If the menu ever shows a non-player inventory, this will desync the UI and can duplicate or fail to remove items. Consider having FlowerMenu pass the source inventory into AddFlower (or storing the associatedInventory in FlowerMenu/FlowerInventory) and removing from that inventory instead.

Copilot uses AI. Check for mistakes.
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Press [Space] to Insepect
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The on-screen instruction text has a typo ("Insepect" → "Inspect") and it also doesn’t match the implemented input: in FlowerMenu.Update() Space transfers the selected flower into the combiner, not an inspect action. Update this text to reflect the actual Space behavior (and fix the spelling).

Suggested change
m_text: Press [Space] to Insepect
m_text: Press [Space] to transfer to combiner

Copilot uses AI. Check for mistakes.
Comment on lines +799 to +811
m_Calls:
- m_Target: {fileID: 1637139246085363424}
m_TargetAssemblyTypeName: FlowerMenu, Assembly-CSharp
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The Combine button has a persistent onClick entry whose m_MethodName is empty. Even though code later calls RemoveAllListeners() and rebinds at runtime, leaving an invalid persistent call in the prefab can lead to editor/runtime warnings and makes the prefab harder to reason about. Remove the empty persistent call (or wire it up correctly in the prefab).

Suggested change
m_Calls:
- m_Target: {fileID: 1637139246085363424}
m_TargetAssemblyTypeName: FlowerMenu, Assembly-CSharp
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 23
#region Rigidbody2D Shortcuts

/// <summary>Tweens a Rigidbody2D's position to the given value.
/// <summary>Tweens a Rigidbody2D's offset to the given value.
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

This modifies DOTween vendor source comments to replace “position” with “offset”, but these APIs (e.g. DOMove) still tween position. This makes the documentation incorrect and introduces noisy diffs in third-party code. Consider reverting vendor comment changes and limiting wording changes to your own scripts/UI where “offset” is actually meant.

Copilot uses AI. Check for mistakes.
Mark AddTo(Player) as [Obsolete] and add a new parameterless AddTo().
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 37 out of 47 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +321 to +327
protected virtual void OnDestroy()
{
if (this.flowerInventory != null)
{
this.flowerInventory.ReturnItems();
}
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

OnDestroy here is declared as protected virtual instead of overriding MenuBase.OnDestroy(). Unity will invoke this method and not the base implementation, so MenuBase's cleanup (killing the DOTween Sequence) won’t run. Change this to public override void OnDestroy() and call base.OnDestroy() before returning items.

Copilot uses AI. Check for mistakes.
Comment on lines 181 to +198
onInteract:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1280110820353676496}
m_TargetAssemblyTypeName: ItemStack, Assembly-CSharp
m_MethodName: AddTo
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: Inventory, Assembly-CSharp
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
triggerKey: 101
textPopUp: {fileID: 3139249615064918060}
ActionCount: 0
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

This prefab still serializes InteractionTrigger fields that don’t exist on the current script (onInteract, textPopUp, ActionCount). Since InteractionTrigger now exposes playerInteractEvent, popupText, and actionCount, these values won’t deserialize and the interaction/pickup logic and popup text will not work. Re-save/update the prefab to use the current fields and rewire the UnityEvent accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +27
/// <summary>
/// Add the item stack to the specified inventory.
/// </summary>
/// <param name="inventory">The inventory to add to.</param>
public void AddTo()
{
GameManager.inst.player.Inventory.AddItem(this.item, this.count);
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

AddTo()’s XML docs still describe an inventory parameter, but the method is now parameterless and always uses GameManager.inst.player.Inventory. Update the doc comment to match the signature, and consider null-checking GameManager.inst/player/Inventory (or keeping an overload that takes an explicit Player/Inventory) to avoid runtime NREs in non-standard contexts.

Copilot uses AI. Check for mistakes.
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Press [Space] to Insepect
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Typo in UI text: Press [Space] to InsepectPress [Space] to Inspect.

Suggested change
m_text: Press [Space] to Insepect
m_text: Press [Space] to Inspect

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 24
#region Rigidbody2D Shortcuts

/// <summary>Tweens a Rigidbody2D's position to the given value.
/// <summary>Tweens a Rigidbody2D's offset to the given value.
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

These DOTween module comments were edited to replace “position” with “offset”, but the APIs and parameter names are still about position (e.g., DOMove/position). This makes the documentation incorrect and adds a maintenance burden when updating DOTween. Prefer reverting vendor comment edits or keeping terminology consistent with the upstream library.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants