1
1
package mindustry .world .blocks .campaign ;
2
2
3
3
import arc .*;
4
+ import arc .Graphics .*;
5
+ import arc .Graphics .Cursor .*;
4
6
import arc .graphics .*;
5
7
import arc .graphics .g2d .*;
6
8
import arc .math .*;
@@ -62,8 +64,16 @@ public LandingPad(String name){
62
64
emitLight = true ;
63
65
lightRadius = 90f ;
64
66
65
- config (Item .class , (LandingPadBuild build , Item item ) -> build .config = item );
66
- configClear ((LandingPadBuild build ) -> build .config = null );
67
+ config (Item .class , (LandingPadBuild build , Item item ) -> {
68
+ if (!accessible ()) return ;
69
+
70
+ build .config = item ;
71
+ });
72
+ configClear ((LandingPadBuild build ) -> {
73
+ if (!accessible ()) return ;
74
+
75
+ build .config = null ;
76
+ });
67
77
}
68
78
69
79
@ Override
@@ -109,6 +119,10 @@ public static void landingPadLanded(Tile tile){
109
119
build .handleLanding ();
110
120
}
111
121
122
+ public boolean accessible (){
123
+ return state .rules .editor || state .rules .allowEditWorldProcessors || state .isCampaign ();
124
+ }
125
+
112
126
public class LandingPadBuild extends Building {
113
127
public @ Nullable Item config ;
114
128
//priority collisions are possible, but should be extremely rare
@@ -120,14 +134,16 @@ public class LandingPadBuild extends Building{
120
134
public float liquidRemoved ;
121
135
122
136
public void handleLanding (){
123
- if (! state . isCampaign () || config == null ) return ;
137
+ if (config == null ) return ;
124
138
125
139
cooldown = 1f ;
126
140
arriving = config ;
127
141
arrivingTimer = 0f ;
128
142
liquidRemoved = 0f ;
129
143
130
- state .rules .sector .info .importCooldownTimers .put (config , 0f );
144
+ if (state .isCampaign () && !isFake ()){
145
+ state .rules .sector .info .importCooldownTimers .put (config , 0f );
146
+ }
131
147
}
132
148
133
149
public void updateTimers (){
@@ -276,7 +292,9 @@ public void updateTile(){
276
292
Effect .shake (3f , 3f , this );
277
293
278
294
items .set (arriving , itemCapacity );
279
- state .getSector ().info .handleItemImport (arriving , itemCapacity );
295
+ if (!isFake ()){
296
+ state .getSector ().info .handleItemImport (arriving , itemCapacity );
297
+ }
280
298
281
299
arriving = null ;
282
300
arrivingTimer = 0f ;
@@ -292,29 +310,70 @@ public void updateTile(){
292
310
cooldown = Mathf .clamp (cooldown );
293
311
}
294
312
295
- if (config != null && state .isCampaign () && !state .getPlanet ().campaignRules .legacyLaunchPads ){
313
+ if (config != null && ( isFake () || ( state .isCampaign () && !state .getPlanet ().campaignRules .legacyLaunchPads )) ){
296
314
297
- if (cooldown <= 0f && efficiency > 0f && items .total () == 0 && state .rules .sector .info .getImportRate (state .getPlanet (), config ) > 0f && state .rules .sector .info .importCooldownTimers .get (config , 0f ) >= 1f ){
315
+ if (cooldown <= 0f && efficiency > 0f && items .total () == 0 && ( isFake () || ( state .rules .sector .info .getImportRate (state .getPlanet (), config ) > 0f && state .rules .sector .info .importCooldownTimers .get (config , 0f ) >= 1f )) ){
298
316
299
- //queue landing for next frame
300
- waiting .get (config , Seq ::new ).add (this );
317
+ if (isFake ()){
318
+ //there is no queue for enemy team blocks, it's all fake
319
+ Call .landingPadLanded (tile );
320
+ }else {
321
+ //queue landing for next frame
322
+ waiting .get (config , Seq ::new ).add (this );
323
+ }
301
324
}
302
325
}
303
326
}
304
327
328
+ /** @return whether this pad should receive items forever, essentially acting as an item source for maps. */
329
+ public boolean isFake (){
330
+ return team != state .rules .defaultTeam || !state .isCampaign ();
331
+ }
332
+
305
333
@ Override
306
334
public boolean canDump (Building to , Item item ){
307
335
//hack: canDump is only ever called right before item offload, so count the item as "produced" before that.
308
- //TODO: is this necessary?
309
336
produced (item );
310
337
return true ;
311
338
}
312
339
340
+ @ Override
341
+ public void drawSelect (){
342
+ if (config != null ){
343
+ float dx = x - size * tilesize /2f , dy = y + size * tilesize /2f , s = iconSmall / 4f ;
344
+ Draw .mixcol (Color .darkGray , 1f );
345
+ Draw .rect (config .fullIcon , dx , dy - 1 , s , s );
346
+ Draw .reset ();
347
+ Draw .rect (config .fullIcon , dx , dy , s , s );
348
+ }
349
+ }
350
+
351
+ @ Override
352
+ public Cursor getCursor (){
353
+ return !accessible () ? SystemCursor .arrow : super .getCursor ();
354
+ }
355
+
356
+ @ Override
357
+ public boolean shouldShowConfigure (Player player ){
358
+ return accessible ();
359
+ }
360
+
361
+ @ Override
362
+ public boolean onConfigureBuildTapped (Building other ){
363
+ if (this == other || !accessible ()){
364
+ deselect ();
365
+ return false ;
366
+ }
367
+
368
+ return super .onConfigureBuildTapped (other );
369
+ }
370
+
313
371
@ Override
314
372
public void buildConfiguration (Table table ){
373
+
315
374
ItemSelection .buildTable (LandingPad .this , table , content .items (), () -> config , this ::configure , selectionRows , selectionColumns );
316
375
317
- if (!net .client ()){
376
+ if (!net .client () && ! isFake () ){
318
377
table .row ();
319
378
320
379
table .table (t -> {
@@ -340,11 +399,11 @@ public void buildConfiguration(Table table){
340
399
public void display (Table table ){
341
400
super .display (table );
342
401
343
- if (!state .isCampaign () || net .client () || team != player .team ()) return ;
402
+ if (!state .isCampaign () || net .client () || team != player .team () || isFake () ) return ;
344
403
345
404
table .row ();
346
405
table .label (() -> {
347
- if (!state .isCampaign ()) return "" ;
406
+ if (!state .isCampaign () || isFake () ) return "" ;
348
407
349
408
if (state .getPlanet ().campaignRules .legacyLaunchPads ){
350
409
return Core .bundle .get ("landingpad.legacy.disabled" );
0 commit comments