Mindustry
Mindustry copied to clipboard
Better power nodes yet again
It works
- [x] I have read the contribution guidelines.
- [x] I have ensured that my code compiles, if applicable.
- [x] I have ensured that any new features in this PR function correctly in-game, if applicable.
@Anuken why do all the placed methods even have a if(net.client()) return;
? They are never even be run on the client (at least in vanilla) anyways...
What are your thoughts on something like this? It would allow the node auto linking when placing powered blocks to work with surge towers and modded nodes while not sacrificing too much speed (if you use an IntFloatMap at least), I also suspect that indexer.eachBlock
would be significantly faster than iterating every tile in a circle with a high maxRange hence why that is what is used now.
EDIT: There isn't an ordered IntFloatMap, pain
EDIT2: I dont even need an IntFloatMap, I need a FloatIntMap lmao, I guess I can just use a standard ObjectIntMap since the boxing shouldnt really matter here
Is the maxRange optimization worth it? Even with surge towers, there shouldn't be that many buildings in range. My guess is that it's unnecessary.
eachBlock was added after this class was made and is generally superior to circle iteration, so yes, it should be used here.
Is the maxRange optimization worth it? Even with surge towers, there shouldn't be that many buildings in range. My guess is that it's unnecessary.
So I guess I would just set maxRange to max(maxRange, laserRange) on every placement
Its pretty bad even with a map
tempTileEnts.sort((a, b) -> {
int type = -Boolean.compare(a.block instanceof PowerNode, b.block instanceof PowerNode);
if(type != 0) return type;
return Float.compare(a.dst2(tile), b.dst2(tile));
});

I guess when this was pasted into the getNodeLinks
method, this sort wasn't changed... All of the blocks in the list are power nodes. Also wtf is up with the newline placement here
...this is getting pretty confusing and might even cause conflicts, so I'm just going to wait until the private branch merge until I can take a closer look.
why do all the placed methods even have a if(net.client()) return;? They are never even be run on the client (at least in vanilla) anyways...
It's definitely redundant now, but I believe it was called at one point (before I refactored placement calls).
~~The only issue now is that maxRange isnt set on world load... Should I add an Events.on(WorldLoadEvent) or just move the code to onproximityupdate?~~
I opted to just move it to onProximityAdded instead
ok this is ready to merge now