Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory pipe system #3621

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Factory pipe system #3621

wants to merge 6 commits into from

Conversation

RecursivePineapple
Copy link
Contributor

@RecursivePineapple RecursivePineapple commented Dec 9, 2024

This system is meant to be used for complex laser-like pipes that form a network, but in practice it can be used with any mechanic that can be represented as a graph. Factory networks are completely minecraft-agnostic, so they can be used with anything.

There is an example test implementation (see TestFactoryNetwork et al) that has everything a base network should do.

There are also two base classes that remove most of the useless boilerplate for factory hatches and factory pipes. It is highly recommended to subclass these if possible.

A typical factory pipe system would subclass StandardFactoryGrid and StandardFactoryNetwork. It is highly recommended (but not necessary) to make the grid a static singleton. A grid tracks all networks & elements and generally only handles graph/network topology updates. It shouldn't hold any network or element specific state.

A network is a logical group of factory elements. If your pipe system needs to have any special logic, the network is the best place to do it. If the network holds state, it shouldn't be tied to a specific element or set of elements - it should basically be global state.

A factory element represents a real machine in the world and can be a pipe, hatch, multi, or anything else. When a machine is placed in the world, it should immediately add itself to the grid, even if it's not connected to anything. The grid will automatically join two adjacent machines together. Factory elements don't have a superclass, they all implement a shared interface (see TestFactoryElement).

A component is a way for factory elements to expose an interface network-wide. It's useful for exposing custom behaviour (i.e. storage) to all other elements on the network. The standard factory network will let you query components automatically (in a manner similar to interface dependency injection).

All three types refer to each other recursively via generics. The grid & network subclasses should refer to the others, and the element interface should refer to the grid and the network. The element interface shouldn't have any generics that refer to the pipe system - they should all be pre-specified.

The system is mostly stable, but it needs a bit more testing. This is
meant to be used for complex laser-like pipes that form a network, but
in practice it can be used with any mechanic that can be represented
as a graph. Factory networks are completely minecraft-agnostic, so they
can be used with anything.

There is an example test implementation (see TestFactoryNetwork et al)
that has everything a base network should do.

There are also two base classes that remove most of the useless
boilerplate for factory hatches and factory pipes. It is highly
recommended to subclass these if possible.

A typical factory pipe system would subclass StandardFactoryGrid and
StandardFactoryNetwork. It is highly recommended (but not necessary)
to make the grid a static singleton. A grid tracks all networks &
elements and generally only handles graph/network topology updates.
A network is a logical group of factory elements. If your pipe system
needs to do anything special, the network is the best place to do it.
A factory element represents a real machine in the world and can be a
pipe, hatch, multi, or anything else. When a machine is placed in the
world, it should immediately add itself to the grid, even if it's not
connected to anything. The grid will automatically join two adjacent
machines together. Factory elements don't have a superclass, they all
implement a shared interface (see TestFactoryElement).

All three types refer to each other recursively via generics. The grid &
network subclasses should refer to the others, and the element interface
should refer to the grid and the network. The element interface shouldn't
have any generics that refer to the pipe system - they should all be
pre-specified.
@Dream-Master Dream-Master requested a review from a team December 9, 2024 14:44
@Dream-Master Dream-Master added the new feature Add something new. Please explain in detail how it works. label Dec 9, 2024
@RecursivePineapple RecursivePineapple marked this pull request as ready for review December 21, 2024 17:35
@FourIsTheNumber
Copy link
Contributor

I'll note I'm using this system on the Artificial Organisms branch and it's working great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Add something new. Please explain in detail how it works.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants