Anuken / Mindustry-Suggestions

Repository for Mindustry suggestions and feedback
130 stars 58 forks source link

Purple logic beams like energy network #2217

Closed Polpo002 closed 3 years ago

Polpo002 commented 3 years ago

I'd like to have some kind of logic network beams, same as energy beams. they could connect the processors to the blocks they are linked with and you could have an opacity slider exactly like for the energy ones. there might be also a way to include units in this but I don't know how useful it would be.

this would look nice and help to organise.

    • [x] I have done a quick search in the list of suggestions to make sure this has not been suggested yet.
    • [X] I have checked the Trello to make sure my suggestion isn't planned or implemented in a development version.
    • [X] I am familiar with all the content already in the game or have glanced at the wiki to make sure my suggestion doesn't exist in the game yet.
    • [X] I have read README.md to make sure my idea is not listed under the "A few things you shouldn't suggest" category.
NiChrosia commented 3 years ago

Having a setting for this would definitely look cool, however due to it being a graphical only feature it would probably have a low priority

NiChrosia commented 3 years ago
function logicLasers() {
    Groups.build.each(b => {
        if (b.block.class.getSuperclass() == LogicBlock) {
            b.links.each(l => {
                let linkBuild = Vars.world.tile(l.x, l.y).build;

                if (linkBuild != null) {
                    Draw.z(Layer.power);
                    Draw.color(Pal.logicOperations);
                    Lines.stroke(1);
                    Drawf.laser(b.team, Core.atlas.find("laser"), Core.atlas.find("laser-end"), b.x, b.y, linkBuild.x, linkBuild.y, b.angleTo(linkBuild), 0.3);
                }
            });
        }
    });
};

logicLaserEffect = new Effect(10, e => {
    logicLasers();
});

Events.run(Trigger.update, () => {logicLaserEffect.at(Vars.player.x, Vars.player.y)});

Running the above code in console will effectively add logic lasers, until you restart Mindustry. Going to make a mod for this in a sec

NiChrosia commented 3 years ago

image In game screenshot

NiChrosia commented 3 years ago

Unfortunately, due to the strange behavior of logic blocks not actually unlinking, when you click off of it the laser won't disappear, as the block's links will still have that link in it.

NiChrosia commented 3 years ago
function logicLasers() {
    Groups.build.each(b => {
        if (b.block.class.getSuperclass() == LogicBlock) {
            b.links.each(l => {
                let linkBuild = Vars.world.tile(l.x, l.y).build;

                if (linkBuild != null) {
                    let linkAngle = b.angleTo(linkBuild);
                    let blockAngle = linkBuild.angleTo(b);

                    let blockOffset = new Vec2;
                    blockOffset.trns(linkAngle, 3 * b.block.size);
                    let linkOffset = new Vec2;
                    linkOffset.trns(blockAngle, 3 * linkBuild.block.size);

                    Draw.z(Layer.power);
                    Draw.color(Color.valueOf("a794e3"));
                    Lines.stroke(1);
                    Drawf.laser(b.team, Core.atlas.find("laser"), Core.atlas.find("laser-end"), b.x + blockOffset.x, b.y + blockOffset.y, linkBuild.x + linkOffset.x, linkBuild.y + linkOffset.y, linkAngle, 0.3);
                }
            });
        }
    });
};

logicLaserEffect = new Effect(10, e => {
    logicLasers();
});

Events.run(Trigger.update, () => {logicLaserEffect.at(Vars.player.x, Vars.player.y)});

Updated code.

NiChrosia commented 3 years ago

image

NiChrosia commented 3 years ago

If you want this @Polpo002, here's the mod

NiChrosia commented 3 years ago

Hmm. For some reason it isn't multiplayer compatible.

NiChrosia commented 3 years ago

Commiting a fix to the repo now.

Polpo002 commented 3 years ago

wow thanks that was fast

NiChrosia commented 3 years ago

It has been updated further, now has settings for it. Also has a fix for displaying inactive links, which is now disabled by default.

Humanoid-X commented 3 years ago

Wow...

Humanoid-X commented 3 years ago

Good work @nichrosia !

Bohaska commented 3 years ago

Maybe try to PR it. If it gets rejected then we stick to the mod...

stuffyAI commented 3 years ago

PR it with the option to toggle it off, I don't want to get autism looking at my base

itcannotbe commented 3 years ago

PR it with the option to toggle it off, I don't want to get autism looking at my base

Same.

Bohaska commented 3 years ago

I usually would put a link to an article saying why you can't get autism, but I'm lazy

stuffyAI commented 3 years ago

I usually would put a link to an article saying why you can't get autism, but I'm lazy

I know, I already have autism and just wanted to point out that it would get better