Skip to content

feat(#139): Add resource preview#142

Merged
MrLewyBDP merged 3 commits intomainfrom
feat/139/constructionsite-previews
Apr 2, 2026
Merged

feat(#139): Add resource preview#142
MrLewyBDP merged 3 commits intomainfrom
feat/139/constructionsite-previews

Conversation

@MrLewyBDP
Copy link
Copy Markdown
Contributor

Closes #139

using Cosmobot.BuildingSystem;
using Cosmobot.ItemSystem;
using Cosmobot.Utils;
using NUnit.Framework;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

magic

.CreateResourcePreview((SerializableDictionary<ItemInfo, int>)requiredResources, previewCount);
preview.transform.SetParent(transform);
preview.GetComponent<ResourcePreviewController>().SetRequirement(pair.Value);
preview.GetComponent<ResourcePreviewController>().SetRequirement(pair.Value, pair.Key.ModelPrefab);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pass the ItemInfo (pair.Key) instead of passing the prefab itself - it'll allow the preview to have access to other information about the item for potential future use. It will also mean that the responsibility of getting the model is given to the preview object directly.

public int ResourceRequirement => resourceRequirement;

public void SetRequirement(int requirement)
public void SetRequirement(int requirement, GameObject previewObject)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As mentioned above, this should take an ItemInfo, not a GameObject

Copy link
Copy Markdown
Collaborator

@Acu1000 Acu1000 left a comment

Choose a reason for hiding this comment

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

LGTM

@MrLewyBDP MrLewyBDP merged commit 9ea5830 into main Apr 2, 2026
2 checks passed
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.

ConstructionSite resource previews

3 participants