8
8
import mindustry .gen .Iconc ;
9
9
import mindustry .content .*;
10
10
import mindustry .world .Tile ;
11
- import mindustry .entities .comp .*;
12
11
import arc .Core .*;
13
12
import arc .math .*;
14
13
import arc .util .*;
@@ -27,6 +26,7 @@ public class routerSnake{
27
26
public Seq <float []> segments = new Seq <>();
28
27
public int length = 12 ;
29
28
public boolean canDecay = false ;
29
+ public static float [] tmp = new float [2 ];
30
30
31
31
public routerSnake (float x , float y , boolean canDecay , int length ){
32
32
this .x = x ;
@@ -41,9 +41,15 @@ public routerSnake(float x, float y, boolean canDecay, int length){
41
41
public void update (){
42
42
i += Time .delta ;
43
43
if (i > 10f ){
44
+ if (length < 1 ){
45
+ routerSnakeMod .snakes .remove (this );
46
+ return ;
47
+ };
44
48
Call .label (routerSnakeMod .rout , length / 6f , x , y );
45
- segments .remove (0 );
46
- segments .add (new float []{x , y });
49
+ tmp = segments .remove (0 );
50
+ tmp [0 ] = x ;
51
+ tmp [1 ] = y ;
52
+ segments .add (tmp );
47
53
while (segments .size < length ){
48
54
segments .add (new float []{x , y });
49
55
};
@@ -70,12 +76,8 @@ public void update(){
70
76
target = null ;
71
77
};
72
78
if ((length > 12 || canDecay ) && Mathf .chance (0.0005f * Math .max ((float )length , 10 ))){
73
- if (length == 1 ){
74
- routerSnakeMod .snakes .remove (this );
75
- }else {
76
- length --;
77
- segments .remove (0 );
78
- };
79
+ length --;
80
+ segments .remove (0 );
79
81
};
80
82
if (target != null && target .unit ().type != null ){
81
83
heading = Mathf .slerp (heading , Mathf .angle (target .x - x , target .y - y ), 0.25f );
@@ -98,10 +100,14 @@ public void update(){
98
100
if (newTile != null && newTile .build != null ){
99
101
Building newBuild = newTile .build ;
100
102
if (newBuild .block == Blocks .distributor ){
101
- newBuild .damage (40f * (float )length / 12f );
103
+ newBuild .damage (Math . min ( 40f * (float )length / 12f , 80f ) );
102
104
x -= Mathf .cosDeg (heading ) * 10f ;
103
105
y -= Mathf .sinDeg (heading ) * 10f ;
104
106
heading = Mathf .angle (x - newBuild .x , y - newBuild .y );
107
+ if (Mathf .chance (0.02f * length )){
108
+ length ++;
109
+ segments .add (new float []{x , y });
110
+ };
105
111
}else if (newBuild .block == Blocks .router && Mathf .chance ((length < 10 && length != 0 ) ? 0.5f / length : 0.05f )){
106
112
if (Mathf .chance (0.005f * length )){
107
113
routerSnakeMod .snakes .add (new routerSnake (x , y , true , length / 2 ));
0 commit comments