extend("skarlet:ultron_comics_base");
loadTextures({
    "base": "skarlet:ultron/ultron_gold_base",
    "lights": "skarlet:ultron/ultron_gold_lights",
    "null": "skarlet:null"
});

var utils = implement("fiskheroes:external/utils");
var boosters = implement("fiskheroes:external/bloom_booster");

var booster_back;

function initEffects(renderer) {
    parent.initEffects(renderer);

    var beam = renderer.createResource("BEAM_RENDERER", "fiskheroes:atom_booster");
    var red_fire = renderer.createResource("ICON", "fiskheroes:red_fire_layer_%s");
    var color = 0xFF2227;
    booster_back = boosters.create(renderer, "body", false, color, red_fire, beam).setOffset(0.0, 2.0, 1.75).setSize(2.0, 3.0);

    utils.bindParticles(renderer, "skarlet:ultron_mouth_blue");

    utils.bindBeam(renderer, "fiskheroes:charged_beam", "skarlet:encephalo_beam", "head", 0x89E3FF, [
        { "firstPerson": [0.0, 3.15, 0.0], "offset": [0.0, -2.75, 0.0], "size": [8.0, 4.0] }
    ]).setParticles(renderer.createResource("PARTICLE_EMITTER", "fiskheroes:impact_heat_vision"));
}

function render(entity, renderLayer, isFirstPersonArm) {
    parent.render(entity, renderLayer, isFirstPersonArm);
    if (!isFirstPersonArm && renderLayer == "HELMET") {
        cape.render();
    }
}

function render(entity, renderLayer, isFirstPersonArm) {
    parent.render(entity, renderLayer, isFirstPersonArm);
    if (!isFirstPersonArm && renderLayer == "HELMET") {
        var boost = entity.getInterpolatedData("fiskheroes:flight_boost_timer");
        booster_back.speedScale = 0.5 * boost;
        booster_back.flutter = 1 + boost;

        var f = Math.min(Math.max(boost * 3 - 1.25, 0), 1);
        f = entity.isSprinting() ? 0.5 - Math.cos(2 * f * Math.PI) / 2 : 0;
        booster_back.render(entity, entity.getInterpolatedData("fiskheroes:dyn/booster_timer"));
        booster_back.setRotation(15 - 10 * boost, 0, 0);
    }
}