-
Notifications
You must be signed in to change notification settings - Fork 12
Rework of Tube Distribution Blocks Description #84
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
Open
Jovinull
wants to merge
3
commits into
stabu-dev:v8-port
Choose a base branch
from
Jovinull:feature/tube-blocks-rework
base: v8-port
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6b54afd
refactor(tube-router): implement buffered item transport and dynamic …
Jovinull b8959e3
feat(tube-gates): split TubeGate into separate Overflow and Underflow…
Jovinull 7270dc9
refactor(content): update distribution block definitions to use new g…
Jovinull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
main/src/omaloon/world/blocks/distribution/TubeOverflowGate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package omaloon.world.blocks.distribution; | ||
|
|
||
| import mindustry.gen.*; | ||
| import mindustry.type.*; | ||
| import mindustry.world.*; | ||
| import arc.util.*; | ||
| import arc.graphics.g2d.*; | ||
| import mindustry.graphics.*; | ||
|
|
||
| import static mindustry.Vars.itemSize; | ||
|
|
||
| public class TubeOverflowGate extends TubeRouter { | ||
| public TubeOverflowGate(String name){ | ||
| super(name); | ||
| rotate = false; | ||
| } | ||
|
|
||
| public class TubeOverflowGateBuild extends TubeRouterBuild { | ||
|
|
||
| @Override | ||
| public void draw(){ | ||
| Draw.z(Layer.block - 0.2f); | ||
| Draw.rect(bottomRegion, x, y); | ||
|
|
||
| Draw.z(Layer.block - 0.1f); | ||
| Building target = getTileTarget(lastItem, lastInput, false); | ||
| float rot = 0f; | ||
|
|
||
| if(target != null && lastItem != null && lastInput != null){ | ||
| int turn = arc.math.Mathf.mod(relativeTo(target) + 1 - relativeTo(lastInput), 4) - 1; | ||
| rot = turn * 90f * arc.math.Mathf.clamp(time); | ||
| float d = itemInterp.apply(arc.math.Mathf.clamp(time)); | ||
|
|
||
| Draw.rect( | ||
| lastItem.uiIcon, | ||
| x + arc.math.Angles.trnsx(rot + relativeTo(lastInput) * 90f, 4f * d), | ||
| y + arc.math.Angles.trnsy(rot + relativeTo(lastInput) * 90f, 4f * d), | ||
| itemSize, | ||
| itemSize | ||
| ); | ||
| } | ||
|
|
||
| Draw.z(Layer.block); | ||
|
|
||
| float rotatorAngle = 45f; | ||
| if(target != null && lastItem != null && lastInput != null){ | ||
| int turn = arc.math.Mathf.mod(relativeTo(target) + 1 - relativeTo(lastInput), 4) - 1; | ||
| rotatorAngle = rot + relativeTo(lastInput) * 90f + (turn > 0 ? -45f : 45f); | ||
| } | ||
|
|
||
| Drawf.spinSprite(rotatorRegion, x, y, rotatorAngle); | ||
| Draw.rect(region, x, y); | ||
| if(sideRegion[0].found()) Draw.rect(sideRegion[0], x, y, rotdeg()); | ||
| } | ||
|
|
||
| @Override | ||
| public Building getTileTarget(Item item, Tile from, boolean set){ | ||
| if(item == null || from == null) return null; | ||
|
|
||
| int otherDir = relativeTo(from); | ||
| Building front = nearby((otherDir + 2) % 4); | ||
|
|
||
| if(front != null && front.acceptItem(this, item)){ | ||
| return front; | ||
| }else{ | ||
| return lookSides(item, from, set); | ||
| } | ||
| } | ||
|
|
||
| public @Nullable Building lookSides(Item item, Tile from, boolean set){ | ||
| int otherDir = relativeTo(from); | ||
| for(int i = 0; i < 4; i += 2){ | ||
| Building other = nearby((otherDir + 1 + i + targetRot) % 4); | ||
| if(set) targetRot = (byte)((i + targetRot + 2) % 4); | ||
| if(other == null || other.tile == from) continue; | ||
| if(other.acceptItem(this, item)){ | ||
| return other; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
main/src/omaloon/world/blocks/distribution/TubeUnderflowGate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package omaloon.world.blocks.distribution; | ||
|
|
||
| import mindustry.gen.*; | ||
| import mindustry.type.*; | ||
| import mindustry.world.*; | ||
| import arc.util.*; | ||
|
|
||
| public class TubeUnderflowGate extends TubeOverflowGate { | ||
| public TubeUnderflowGate(String name) { | ||
| super(name); | ||
| } | ||
|
|
||
| public class TubeUnderflowGateBuild extends TubeOverflowGateBuild { | ||
| @Override | ||
| public Building getTileTarget(Item item, Tile from, boolean set){ | ||
| if(item == null || from == null) return null; | ||
|
|
||
| int otherDir = relativeTo(from); | ||
| Building front = nearby((otherDir + 2) % 4); | ||
|
|
||
| Building side = lookSides(item, from, set); | ||
| if(side != null){ | ||
| return side; | ||
| }else if (front != null && front.acceptItem(this, item)){ | ||
| return front; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for separate classes when you just can reverse an overflow gate