File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
core/src/mindustry/service Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ private void registerEvents(){
304304 });
305305
306306 Events .on (UnitCreateEvent .class , e -> {
307- if (campaign ()){
307+ if (campaign () && e . unit . team == state . rules . defaultTeam ){
308308 if (unitsBuilt .add (e .unit .type .name )){
309309 SStat .unitTypesBuilt .max (content .units ().count (u -> unitsBuilt .contains (u .name ) && !u .isHidden ()));
310310 save ();
@@ -316,6 +316,29 @@ private void registerEvents(){
316316 }
317317 });
318318
319+ Events .on (SaveLoadEvent .class , e -> Core .app .post (() -> Core .app .post (() -> {
320+ if (campaign ()){
321+ boolean added = false ;
322+ for (UnitType type : Vars .content .units ()){
323+ var all = state .rules .defaultTeam .data ().getUnits (type );
324+ if (all != null && all .size > 0 ){
325+ if (t5s .contains (type )){
326+ buildT5 .complete ();
327+ }
328+
329+ if (unitsBuilt .add (type .name )){
330+ added = true ;
331+ }
332+ }
333+ }
334+
335+ if (added ){
336+ SStat .unitTypesBuilt .max (content .units ().count (u -> unitsBuilt .contains (u .name ) && !u .isHidden ()));
337+ save ();
338+ }
339+ }
340+ })));
341+
319342 Events .on (UnitControlEvent .class , e -> {
320343 if (e .unit instanceof BlockUnitc unit && unit .tile ().block == Blocks .router ){
321344 becomeRouter .complete ();
You can’t perform that action at this time.
0 commit comments