Skip to content

Commit

Permalink
Crawl unit cells (#10298)
Browse files Browse the repository at this point in the history
* Crawl unit cells

* Normal cells don't draw on crawl units
  • Loading branch information
Andromeda-Galaxy29 authored Feb 6, 2025
1 parent 52b1ef5 commit 556b2aa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/src/mindustry/type/UnitType.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public class UnitType extends UnlockableContent implements Senseable{
public TextureRegion baseRegion, legRegion, region, previewRegion, shadowRegion, cellRegion, itemCircleRegion,
softShadowRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion, treadRegion,
mineLaserRegion, mineLaserEndRegion;
public TextureRegion[] wreckRegions, segmentRegions, segmentOutlineRegions;
public TextureRegion[] wreckRegions, segmentRegions, segmentCellRegions, segmentOutlineRegions;
public TextureRegion[][] treadRegions;

//INTERNAL REQUIREMENTS
Expand Down Expand Up @@ -963,9 +963,11 @@ public void load(){

segmentRegions = new TextureRegion[segments];
segmentOutlineRegions = new TextureRegion[segments];
segmentCellRegions = new TextureRegion[segments];
for(int i = 0; i < segments; i++){
segmentRegions[i] = Core.atlas.find(name + "-segment" + i);
segmentOutlineRegions[i] = Core.atlas.find(name + "-segment-outline" + i);
segmentCellRegions[i] = Core.atlas.find(name + "-segment-cell" + i);
}

clipSize = Math.max(region.width * 2f, clipSize);
Expand Down Expand Up @@ -1286,7 +1288,7 @@ public void draw(Unit unit){
if(engines.size > 0) drawEngines(unit);
Draw.z(z);
if(drawBody) drawBody(unit);
if(drawCell) drawCell(unit);
if(drawCell && !(unit instanceof Crawlc)) drawCell(unit);
drawWeapons(unit);
if(drawItems) drawItems(unit);
if(!isPayload){
Expand Down Expand Up @@ -1652,6 +1654,13 @@ public void drawCrawl(Crawlc crawl){

//TODO merge outlines?
Draw.rect(regions[i], unit.x + tx, unit.y + ty, rot - 90);

// Draws the cells
if(drawCell && p != 0 && segmentCellRegions[i].found()){
Draw.color(cellColor(unit));
Draw.rect(segmentCellRegions[i], unit.x + tx, unit.y + ty, rot - 90);
Draw.reset();
}
}
}
}
Expand Down

0 comments on commit 556b2aa

Please sign in to comment.