Skip to content

Conversation

@hypnoshock
Copy link
Contributor

What

An addition of BuildingCategory on BuildingKind which allows us to define if a building is either a blocker, factory, extractor or other.

As part of this I have implemented the extraction category which allows you to define an extractor building that outputs an item that is comprised of one type of goo (atom)

Extractor buildings are show on the map and are the color as defined as their model which is either red, green or blue

As part of the deployment I am deploying 3 extractors that represent the 3 goo types and also placing them on the map close to the starting point.

image

I have also added some basic frontend so the item extraction can be tested

image

The `REGISTER_BUILDING_KIND` action has been extended so that `BuildingCategory` can be set. We are also setting craft recipes during registration
All tests use the new REGISTER_BUILDING action and are passing
The function that is called as part of `REGISTER_BUILDING` was hitting a stack too deep error so I put all its params in a struct

Rename `BuildingKindInfo` to `BuildingKindCfg`

To match the param name
Moved (well copied) the `_registerRecipe` function from the CraftingRule into the BuildingRule. I needed to do this as dispatching `REGISTER_CRAFT_RECIPE` from within the BuildingRule would cause the CraftingRule to revert as `ctx.sender` is the BuldingRule address not the player's account.
Both category and ID are each encoded as uint64.
Extraction rule mostly implemented
Not full coverage but I'm seeing items being crafted from extracted goo and values in reservoir being depleted
Seeing reservoir values in the frontend. Calculated value in frontend is matching the calculated value that occurs at the point of extraction
Extract button is enabled when enough items to fulfil a batch have been extracted
Updated manifest to support the new `buildingCategory` and `model` properties
updated `apply.ts` to form the BuildingKind bytes24 ID from the name and category so it matches what the contracts do
I've put all 3 extractors in one manifest.
They also use a separate contract even though it's the same code. This is because if the byte code for a contract is seen as already deployed it won't be registered which meant that only the first extractor building to register the contract would work
The deployment was falling over consistently when trying to batch.
need Jack to work his magic on this though
@hypnoshock hypnoshock force-pushed the building-kind-registration branch from 14969b2 to fbcee7f Compare August 16, 2023 18:08
Copy link
Contributor

@ldunnplaymint ldunnplaymint left a comment

Choose a reason for hiding this comment

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

Sorry, I can't spawn my seeker, keeps hitting this:
[services] 8:23AM ERR subscribe-fail error="context canceled" component=eventwatcher service=indexer simulated=true

Copy link
Contributor

@ldunnplaymint ldunnplaymint left a comment

Choose a reason for hiding this comment

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

Sorry, I was wrong...

@ldunnplaymint ldunnplaymint merged commit 6c596cc into main Aug 17, 2023
@ldunnplaymint ldunnplaymint deleted the building-kind-registration branch August 17, 2023 07:26

export const BuildingSpec = z.object({
name: Name,
category: BuildingCategoryEnum,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unused and can be removed I believe (since category is a BuildingKind thing not a Building thing)

spec:
name: Mecha-Kaiju
location: [ 10, -21, 11 ]
category: blocker
Copy link
Contributor

Choose a reason for hiding this comment

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

category field can be removed from all these Building manifests I believe

return CompoundKeyEncoder.encodeUint160(NodeSelectors.ClientPlugin, id);
};

// TODO: Is there a way of referencing the Solidity enum?
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 core has the abi (it's how it checks the types for the action strings) ... so can probably expose a category type from there .... but think that one for later

kind: Building
spec:
name: Green Goo Extractor
category: extractor
Copy link
Contributor

Choose a reason for hiding this comment

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

unused category fields

function BlockNum() external;
}

uint64 constant BLOCK_TIME_SECS = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

we might need this to be configurable at deployment time ... no change required now

Comment on lines +424 to +431
function setBlockNum(State state, bytes24 kind, uint8 slot, uint64 blockNum) internal {
// TODO: don't use generic `Has` selector as it could conflict with something else
return state.set(Rel.Has.selector, slot, kind, Node.BlockNum(), blockNum);
}

function getBlockNum(State state, bytes24 kind, uint8 slot) internal view returns (uint64 blockNum) {
( /*bytes24 item*/ , blockNum) = state.get(Rel.Has.selector, slot, kind);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

think this relationship should probably be something more specific to extraction ... Block can be a generic concept, but think it might be clearer if the relationshpi and these funcs are about the extraction not the blocknum

Node.Something --Rel.LastExtractedAt--> Node.Block

bytes24[4] memory inputItemIDs;
uint64[4] memory inputQtys;

// TODO: Is this test for name annotions necessary anymore?
Copy link
Contributor

Choose a reason for hiding this comment

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

no I don't think so ... burn it

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.

3 participants