1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-10 15:05:23 +03:00

Added contribution guide

This commit is contained in:
Anuken 2019-11-18 00:55:33 -05:00
parent dc1b073882
commit 9b732017a9
7 changed files with 110 additions and 4 deletions

51
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,51 @@
# Contributing
This is for code contributions. For translations, see [TRANSLATING](TRANSLATING.md).
## Basic Guidelines
#### Use an IDE.
Specifically, IntelliJ IDEA. Download the (free) Community Edition of it [here](https://www.jetbrains.com/idea/download/). Some people use other tools, like VS Code, but I would personally not recommend them for Java development.
#### Always test your changes.
Do not submit something without at least running the game to see if it compiles.
If you are submitting a new block, make sure it has a name and description, and that it works correctly in-game. If you are changing existing block mechanics, test them out first.
#### Do not make large changes before discussing it first.
If you are interested in adding a large mechanic/feature or changing large amounts of code, first contact me (Anuken) via [Discord](https://discord.gg/mindustry) (preferred method) or via e-mail (*anukendev@gmail.com*).
For most changes, this should not be necessary. I just want to know if you're doing something big so I can offer advice and/or make sure you're not wasting your time on it.
## Style Guidelines
#### Do not use incompatible Java features (java.awt.function, java.awt).
Android [does not support](https://developer.android.com/studio/write/java8-support#supported_features) many of Java 8's features, like anything out of `java.util.function`, `java.util.stream` or `forEach` in collections. Do not use these in your code.
If you need to use functional interfaces, use the ones in `io.anuke.arc.func`, which are more or less the same with different naming schemes.
The same applies to anything outside of the standard `java.[n]io` / `java.net` / `java.util` packages: Most of it is not supported.
`java.awt` is one of these packages: do not use it, ever. It is not supported on any platform, even desktop - the entire package is removed during JRE minimization.
In general, if you are using IntelliJ, you should be warned about platform incompatiblities.
#### Use `arc` collections and classes when possible.
Instead of using `java.util.List`, `java.util.HashMap`, and etc, use `Array`, `ObjectMap` and other equivalents from `io.anuke.arc.collection`.
Why? Because that's what the rest of the codebase uses, and the standard collections have a lot of cruft and usability issues associated with them.
#### Avoid bloated code and unnecessary getters/setters.
This one is situational, but in essence what this means is to avoid using any sort of getters and setters unless absolutely necessary. Public or protected fields should suffice for most things.
If something needs to be made encapsulated in the future, IntelliJ can handle it with a few clicks.
#### Do not create methods unless necessary.
Unless some code is very large or is used in more than 1-2 places, don't split it up into a separate method. Making unnecessary methods only creates confusion, and may slightly decrease performance.
#### Follow the formatting guidelines.
This means:
- No spaces around parentheses: `if(condition){`, `SomeType s = (SomeType)object`
- Same-line braces.
- 4 spaces indentation
- `camelCase`, **even for constants or enums**. Why? Because `SCREAMING_CASE` is ugly, annoying to type and does not achieve anything useful. Constants are *less* dangerous than variables, not more.
- No underscores for anything. (Yes, I know `Bindings` violates this principle, but that's for legacy reasons and really should be cleaned up some day.)

View File

@ -8,6 +8,10 @@ A sandbox tower defense game written in Java.
_[Trello Board](https://trello.com/b/aE2tcUwF/mindustry-40-plans)_
_[Wiki](https://mindustrygame.github.io/wiki)_
### Contributing
See [CONTRIBUTING](CONTRIBUTING.md).
### Building
Bleeding-edge live builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases). Old builds might still be on [jenkins](https://jenkins.hellomouse.net/job/mindustry/).

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -64,9 +64,7 @@ public class HudFragment extends Fragment{
select.addImageButton(Icon.menuLargeSmall, style, ui.paused::show);
flip = select.addImageButton(Icon.arrowUpSmall, style, this::toggleMenus).get();
select.addImageButton(Icon.pasteSmall, style, () -> {
ui.schematics.show();
});
select.addImageButton(Icon.pasteSmall, style, ui.schematics::show);
select.addImageButton(Icon.pauseSmall, style, () -> {
if(net.active()){

View File

@ -0,0 +1,53 @@
package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.meta.*;
//TODO implement later
public class LiquidOverflowGate extends LiquidBlock{
int topRegion;
public LiquidOverflowGate(String name){
super(name);
rotate = true;
topRegion = reg("-top");
}
@Override
public void setStats(){
super.setStats();
stats.remove(BlockStat.liquidCapacity);
}
@Override
public void setBars(){
super.setBars();
bars.remove("liquid");
}
@Override
public void draw(Tile tile){
Draw.rect(name, tile.drawx(), tile.drawy());
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy(), tile.rotation() * 90);
}
@Override
public TextureRegion[] generateIcons(){
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
}
@Override
public Tile getLiquidDestination(Tile tile, Tile source, Liquid liquid){
int dir = source.relativeTo(tile.x, tile.y);
dir = (dir + 4) % 4;
Tile next = tile.getNearby(dir).link();
if(!next.block().acceptLiquid(next, tile, liquid, 0.0001f) && !(next.block() instanceof LiquidOverflowGate || next.block() instanceof LiquidJunction)){
return tile;
}
return next.block().getLiquidDestination(next, tile, liquid);
}
}

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=7f36ea330f592f43ad01b729c4cae77797476ea7
archash=d2bb4a004b8653a8d878abda0b1e1c62b2df2aab