From 9b732017a94c11d02b242cf21a9a772ab2384f79 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 18 Nov 2019 00:55:33 -0500 Subject: [PATCH] Added contribution guide --- CONTRIBUTING.md | 51 +++++++++++++++++ README.md | 4 ++ .../liquid/liquid-overflow-gate-top.png | Bin 0 -> 1819 bytes .../blocks/liquid/liquid-overflow-gate.png | Bin 0 -> 1794 bytes .../mindustry/ui/fragments/HudFragment.java | 4 +- .../blocks/liquid/LiquidOverflowGate.java | 53 ++++++++++++++++++ gradle.properties | 2 +- 7 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate-top.png create mode 100644 core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate.png create mode 100644 core/src/io/anuke/mindustry/world/blocks/liquid/LiquidOverflowGate.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..52b3fa917f --- /dev/null +++ b/CONTRIBUTING.md @@ -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.) \ No newline at end of file diff --git a/README.md b/README.md index 4794ccbf73..c39e9ce086 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate-top.png b/core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate-top.png new file mode 100644 index 0000000000000000000000000000000000000000..f6bdf7f613269382ab5e91c5006bb025d30519b2 GIT binary patch literal 1819 zcmV+$2juvPP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U-|cmgFW3{bvcf>i10zDZ!(p&2 zLSzKohH;%4r}^R=Q0s8DI$!aSi4pNhfjSkMH1^o2!NkCW5pHH~ESqKsf9AG93G1ZE z$pMEh222`|6Oj3`g|^M`DeD{13H0MflB5zl$U>C3af*A|B zbq5y!p?StscYMhmgMU31umS{ihuPp@@%0cQz03m{Ig)zwP zKt7TvMe>O`5h0ESddls-hzYA3od17aKq zh^K`B5}Frg-Y5iK$Sur#W^p3Quu>N|ofcw1FbraybYb^E?uWQJMEBp~#_y1G3%cKd zoLkV{ko%0=8`OH)?N&BGs|pcQbVxz@fniu-D{Ei+*66xjhNO4h6{DL|A zw3J$vy^2PfNA|jT{THM2KgoEFG_hN(sZPaaV0&uh6wSXyTq}qxZXujY*UBw_Njkre zg8Oygk1!&$0pTnol#z0Q{yW;dR}E`{HC<4@L)!g@T>KjH~!R%70v(%2Q zvNx29AL+r3Z{D_CJ8E%PAy4dxvGYuVJ|Ve%1o`V8;lAHI&fajg1gFo2@#7?QpWyyxp}3ayhu5nQwiMW_&Jg;pI*F8zWg4M~cNqu^R_@ME#+;Nq;S zgR3A2et@{RIw`tHiT_IqEn+=5?#H`(kGpq(P%SdeY8wMI-8K`ksF+Hxih);jp%(&X zFd{R{n3JS9T8^)K`1pDk;aRQE{W-eTjKu(-NIc67(v6yROrHNVI)QBgE!>XoJzL4@*<-EmNE0$UPp8SQu zjJ~qWb(({SVG&D^AVNVI1r%W;LaR=Sg#_(KTlfcDzeFyDTm>+4ET9Apvg-%`gWug+ z*@A3IL%1n@rtS9-%=sshuWq*oeR_z39P1}?4}nz9F6 z?g0HyhHT2N;gwTkip000SaNLh0L04^f{04^f|c%?sf00007bV*G`2jdG80|_ZW^6>Ql z004_gL_t(o!|j%_4Zt7_1Z^)t=-DqTutN5uCrpu4NLD0-Op%Wie@FGF=PjGa<#M@R z)}GHxzXc5;=p^`eUl3Cucn35DtOFfFkRusWzyiP%sHNcmYH7Fxx;X?uo5MSB%r002ov JPDHLkV1jf?S;7DS literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate.png b/core/assets-raw/sprites/blocks/liquid/liquid-overflow-gate.png new file mode 100644 index 0000000000000000000000000000000000000000..f608e0a6d1129c1086d728b41b98e9e4315e653d GIT binary patch literal 1794 zcmV+d2mSboP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O=0{mh>hJ{I65w2p}Pro&B{0zH39tdvP%d4G2U4G(nv<7YtWkep)+5)*83Ga5h?kO!u**`63{d(mzOj`D# z*{z=QH(7c{WcePMpAofw5An`lZ?X4nUtM;dK$l;Ox-Dh)FcFkGnU8s#0Y61Q z%roJPCYuV?8kSnf6x<}sV7yyro6WY{ZMM}`KyY+ganS zsP)za=3p&&jL;_oIg8^01+0>C14?!x9^ynEvGGi>b1p0IW|S8Qq2eV#8f+AZ<(xW? z{T7iznN-xNs@I@VlV&g8dG+20Kk8Ht5?s*WLkKaXkfTHwHToE0j49^CNl?a=l20MU zlv2(Jnq7vkjQJUc!bOTJT6_s5mQ->@`czl7`WkAispiH_8cF~)-$IKmwY=F4skFIG zH@}4~ZfVOMxz?q-uHE<0V^2NbRa>gQs&-WFd)4exji*p!UU;Yma|kyVc9atxnn5vk z7K(?V01}#qW+qzacqlhCGl_*nlz~!*IL!{lprG3lPTXh`=P z%F&SSNx663PE>1omRp$uja>*%Q6UA}ua(R(b8#p?adgM~>9yU|&mKz5oEu+TIvP$| z$$9opygyp{YTy!#r|TNzs=8N9Nb;t$_JI(uKYv^sW+9UpJ0YRD*5#o=#v z!jHgp+vAlJ*64;e=h=JGAD|}OdP#pe8|W^q97>na-16u$ngUW?i#sn^^S*X`S7MVA zs*oxw0p2@nKpy@YsGA`kd$~(oG4hx4pX`crsn50!egD*TNR)pG62)JFMDb%tCPU_t z`Y8E$p{Y)Z$i+vt4;i7WOSjCg*Hi0@3i)}W(}fCnDbeW)8nB{%q%|k}%d!)2ED7{& zZJ4FN+p!;76z8`#2jU4bdMa2aNUpbZZ6fOBES1K`Svtp^N$v(BpA`Q;ZU1jaAC^b7 zbV>aWUq_$Ac>jp_8HRLx7hx09zr)bhkl(xSWB>pGg=s@WP)S2WAaHVTW@&6?004NL zeUUv#!$2IxUsI)`6$LwpIAo~0SP&HvT(k;Bs1Ry}Rvk<({emV9Ns5c3;979-W3lSs z;;gHKs~`w|fVj9iDY{6B|4RxjVm&zS$GdxvyLW(4Ei%n&8v``mHWRU^m`bmTfmd{) z7XoH5A~VaFlcYFWj<0+8_<9%NS*_3gIl9%1#Q>j3Jj)EzCf*>P+O!SM`@|uZmsR3( z;!%?>Nc_lk#p5^5IhO^V88VZJdEyYUm}_FCiCNy%h$o4|s-{!Ekn&jNyv127mRbFt z{Dr}czOu}9nuCa85lfIDLO~e?6k#Jmt4@lA1noy#_y=6SL@tF~1u$|fpac!F>j(dX z-`!f-iE%F}7zNs29Oq*Q2I1v=Nf-s<}}eE^cwRs04xI0S}sl)c{K-5t%n z{d=a~-w&kGa=R+Eit+#e010qNS#tmYE+YT{E+YYWr9XB6000McNliru;|mf42_v8< z8S4N50M|)GK~z}7W1KN-$$ths;M%o243q#ZEfu`-Obi1IMjgO{Pf|ibhCxC>hGI)z zJa|HS2vEafV$5P9$JNwy1QWSIM=eLNpyzY+eEZ_T69x$d8HRn^4v=J-la~WgMyl$3rt kS9A>i_P}W0aM(Kl0A52(2UKigYybcN07*qoM6N<$f(UImOaK4? literal 0 HcmV?d00001 diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 6afd96619b..caca0a81a9 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -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()){ diff --git a/core/src/io/anuke/mindustry/world/blocks/liquid/LiquidOverflowGate.java b/core/src/io/anuke/mindustry/world/blocks/liquid/LiquidOverflowGate.java new file mode 100644 index 0000000000..dafcef1508 --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/liquid/LiquidOverflowGate.java @@ -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); + } +} diff --git a/gradle.properties b/gradle.properties index c108499534..6b36115f05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=7f36ea330f592f43ad01b729c4cae77797476ea7 +archash=d2bb4a004b8653a8d878abda0b1e1c62b2df2aab