Tweaking Machines

Marcin Sciesinski

Code ALL the Ages!
Contributor
World
Architecture
Yeah, sound good. As for pulling items from inventories, I'd recommend event-driver approach, rather than periodically polling if there is any item to pull. So, you would listen on inventory change in an entity, and then find if there is anything that pulls items from that block, and if so - pull the item. Then if it is capable of pulling only 1 pack of items in a specified period, you can use the "DelayedActionSystem" to schedule a recheck. This I think will be the most efficient approach.
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Would it make sense to throw in "Level of Detail" at this point? If the animation is just a visual enhancement on client side you could show it just within a range from the player and remove it for machines far away... (or is it already on your TODO list?) :)
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Idea cooking - Mechanical Power
What better to power your toaster with than rotational power?
Currently cooking at: TerraTech
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Idea cooking - Windmill
Having mastered rotation, the only hard part of a windmill is the modelling/texturing (curse you texturing, why are you so hard?). I could not figure out blender's texturing, so found a tool to help called P-XCEL. Maybe it will also be handy for another 3d modeling noob, it definitely helped me out.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Very nice! I love how fast progress can work like this :)

I especially like how you actually have a rotating shaft furthering the power rather than some single magic block and cables. What next, working watermill? :D

Will post this around on the social networks early tomorrow. Can I put Machines + TerraTech into the next stable build, if you're satisfied with its state so far? How do you actually make a windmill in-game?
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Likely will not tackle a watermill until there is a better water solution. However, it will be similar code to be done in a few minutes :)

Its reallly simple to get a windmill, bring up the console, enter "giveBlock"... I am working on an actual crafting path tonight. In the next week I plan on TerraTech becoming playable from player spawn without commands.

And thanks!
 

Marcin Sciesinski

Code ALL the Ages!
Contributor
World
Architecture
Josharias I assume it works by parsing all the Prefabs to find what items match the requirements for each recipe.

My concern is, that some recipies might not have any prefab that matches their requirement, and given the choice of listing only some recipes or none at all, I'd suggest listing none, as listing only some might mislead user to believe he's seeing all recipes.

If you want to provide a "in game documentation" for recipes - I'd suggest using Journal.
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Well yes, it will only show recipes that are compatible with displaying themselves visually.

Currently it is using the process registry from the Workstation module and iterating through all the processes that the workstation supports. There has been a small amount of code noise added to the existing process parts to accommodate.

I suppose I view this more as a reference than a guide. I should modify my wording to be more precise. I also agree that the journal module is the ideal way for a visual/textual walkthrough that can add some theme and flavor to a module.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Nice to see progress :)

Getting close to when you'd consider this all stable? :D
 

Marcin Sciesinski

Code ALL the Ages!
Contributor
World
Architecture
Out of curiosity, are those fluid ducts filling blocks with FluidInventoryComponent? If so, can they be used to fill Cooking station from W&S?
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
They will be. I had to simplify things to wrap my head around the flow logic. Expect them to be FluidInventoryComponent really soon.
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Fluid transport now interacts directly with FluidInventoryComponent blocks. Multiblock entities still need some support added to BlockNetwork in order to function. I had problems getting the Cooking station to work because of this.
 

Marcin Sciesinski

Code ALL the Ages!
Contributor
World
Architecture
You could probably add multiple leaf blocks (or network blocks). One for each edge block in the multi-block?
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
UI improvements. The general procedure of input turning into output better realized with the addition of spacing and rearranging. Also added the ability for a machine to specify one or more extra widgets on the left and/or right side.
NewMachineUI.png
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
@Marcin Sciesinski: I did some performance testing with the new event handler driven model for the pushing and pulling inventory system (the IRLCorp conveyor belts). Unfortunately things didnt work out as awesomely as we would have liked. Any ideas on how to improve things?

Update Loop: conveyorupdateloop1.PNG compared to Events: conveyorevents1.PNG

And then a bigger set up to see how it scales up:
Update Loop: conveyorupdateloop2.PNG compared to Events: conveyorevents2.PNG

Full disclosure, the update times on all of these fluctuated by +-3 seconds. The screenshot was taken somewhere in this range. But even comparing best case to worst case of both methods there is a significant difference in performance (significant in a statistics sort of way).

Also, there was a similar story when it came to comparing the running means of the two systems, there was a significant percentage more processing time taken when using events than just a update loop.
 
Last edited:

Marcin Sciesinski

Code ALL the Ages!
Contributor
World
Architecture
Thanks @Josharias, I'll look into profiling it, I should be able to get it down. But you are missing one more test - when there is nothing on the conveyor belts (or very little), which is probably going to be the most usual case.

Also the scheduler implementation benefits from an undocumented feature (which might disappear at some point), that the entities are returned to you always in the same order.

The event driven model has also a couple of advantages:
- the time the item travels on a conveyor belt does not have to be divisible by 1 second,
- the item is pulled from inventory immediately after it appears in it by the item extractor.

Anyway, I'll update the PR once I do some profiling, I'll also be working on a model that uses BlockNetworks, which fits the use case perfectly, and do update on item traveling through a line of conveyors only once per chunk (to make sure client sees it).
 

Josharias

Conjurer of Grimoires
Contributor
World
SpecOps
Cool. There were also some situations where items got stuck in a chest or on a conveyor, not quite sure what they were all about. Also, there is a visual oddity when the items entered a chest at the end of the line that didnt happen in the updateloop approach.

I definitely see the advantage of going events. The average mean time for both style of systems was still less than what it takes to animate the entities. So, still acceptable IMHO.

As for a BlockNetwork impelementation, I was thinking one could probably create a whole module around that. It definitely turned into a big space on the modded MC front. The push/pull mechanism is still useful with a machine that interacts with an adjacent inventory.
 
Top