com.megacrit.cardcrawl.helpers.Hitbox Java Examples

The following examples show how to use com.megacrit.cardcrawl.helpers.Hitbox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HitboxRightClick.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(Hitbox __instance)
{
    if (rightClicked.get(__instance)) {
        rightClicked.set(__instance, false);
    } else {
        if (rightClickStarted.get(__instance) && InputHelper.justReleasedClickRight) {
            if (__instance.hovered) {
                rightClicked.set(__instance, true);
            }
            rightClickStarted.set(__instance, false);
        }

        if (__instance.hovered && InputHelper.justClickedRight) {
            rightClickStarted.set(__instance, true);
        }
    }
}
 
Example #2
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, AbstractCard card, CardGroup group, Hitbox ___upgradeHb) {
    if (card instanceof BranchingUpgradesCard) {
        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);
        try {
            Method canToggleBetaArt = SingleCardViewPopup.class.getDeclaredMethod("canToggleBetaArt");
            canToggleBetaArt.setAccessible(true);
            Method allowUpgradePreview = SingleCardViewPopup.class.getDeclaredMethod("allowUpgradePreview");
            allowUpgradePreview.setAccessible(true);
            if ((boolean) canToggleBetaArt.invoke(__instance)) {
                if ((boolean) allowUpgradePreview.invoke(__instance)) {
                    ___upgradeHb.move(Settings.WIDTH / 2f - 300f * Settings.scale, 70f * Settings.scale);
                    branchUpgradeHb.move(Settings.WIDTH / 2f - 40f * Settings.scale, 70f * Settings.scale);
                }
            } else {
                ___upgradeHb.move(Settings.WIDTH / 2f + 250f * Settings.scale, 70f * Settings.scale);
                branchUpgradeHb.move(Settings.WIDTH / 2f - 250f * Settings.scale, 70f * Settings.scale);
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
 
Example #3
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, AbstractCard card, Hitbox ___upgradeHb) {
    if (card instanceof BranchingUpgradesCard) {
        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);
        try {
            Method canToggleBetaArt = SingleCardViewPopup.class.getDeclaredMethod("canToggleBetaArt");
            canToggleBetaArt.setAccessible(true);
            if ((boolean) canToggleBetaArt.invoke(__instance)) {
                ___upgradeHb.move(Settings.WIDTH / 2f - 300f * Settings.scale, 70f * Settings.scale);
                branchUpgradeHb.move(Settings.WIDTH / 2f - 40f * Settings.scale, 70f * Settings.scale);
            } else {
                ___upgradeHb.move(Settings.WIDTH / 2f + 250f * Settings.scale, 70f * Settings.scale);
                branchUpgradeHb.move(Settings.WIDTH / 2f - 250f * Settings.scale, 70f * Settings.scale);
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
 
Example #4
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, AbstractCard ___card) {
    if (SingleCardViewPopup.isViewingUpgrade) {
        BranchUpgradeButton.isViewingBranchUpgrade.set(__instance, false);
    }

    if (___card instanceof BranchingUpgradesCard) {
        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);

        branchUpgradeHb.update();
        if (branchUpgradeHb.hovered && InputHelper.justClickedLeft) {
            branchUpgradeHb.clickStarted = true;
        }

        if (branchUpgradeHb.clicked) {
            branchUpgradeHb.clicked = false;
            SingleCardViewPopup.isViewingUpgrade = false;
            BranchUpgradeButton.isViewingBranchUpgrade.set(__instance, !BranchUpgradeButton.isViewingBranchUpgrade.get(__instance));
        }
    }
}
 
Example #5
Source File: AbstractMemory.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public AbstractMemory(final StaticMemoryInfo staticInfo, final MemoryType memoryType, final AbstractCreature owner) {
    this.ID = staticInfo.ID;
    this.name = staticInfo.NAME;
    this.baseDescription = staticInfo.DESCRIPTIONS[0];
    this.staticInfo = staticInfo;

    this.owner = owner;
    this.memoryType = memoryType;
    this.isClarified = false;
    this.isRemembered = false;

    this.hb = new Hitbox(HB_WIDTH, HB_HEIGHT);
    updateDescription();
}
 
Example #6
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 5 votes vote down vote up
public static ExprEditor Instrument() {
    return new ExprEditor() {
        private boolean accessedUpgradeHb = false;
        @Override
        public void edit(FieldAccess f) throws CannotCompileException
        {
            if (accessedUpgradeHb && f.getFieldName().equals("hovered")) {
                f.replace("$_ = $proceed($$) || ((" + Hitbox.class.getName() + ") " + BranchUpgradeButton.class.getName() + ".branchUpgradeHb.get(this)).hovered;");
                accessedUpgradeHb = false;
            } else if (f.getFieldName().equals("upgradeHb")) {
                accessedUpgradeHb = true;
            }
        }
    };
}
 
Example #7
Source File: SlayTheRelicsIntegration.java    From jorbs-spire-mod with MIT License 4 votes vote down vote up
public static void renderTipHitbox(Hitbox hb, ArrayList<PowerTip> tips) {
    slayTheRelicsHitboxes.add(hb);
    slayTheRelicsPowerTips.add(tips);
}
 
Example #8
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 4 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, SpriteBatch sb, AbstractCard ___card) {
    if (___card instanceof BranchingUpgradesCard) {
        if (uiStrings == null) {
            uiStrings = CardCrawlGame.languagePack.getUIString("stslib:SingleCardViewPopup");
        }

        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);

        sb.setColor(Color.WHITE);
        sb.draw(
                ImageMaster.CHECKBOX,
                branchUpgradeHb.cX - 80f * Settings.scale - 32f,
                branchUpgradeHb.cY - 32f,
                32f, 32f,
                64f, 64f,
                Settings.scale, Settings.scale,
                0f,
                0, 0,
                64, 64,
                false, false
        );
        Color fontColor = Settings.GOLD_COLOR;
        if (branchUpgradeHb.hovered) {
            fontColor = Settings.BLUE_TEXT_COLOR;
        }
        FontHelper.renderFont(
                sb,
                FontHelper.cardTitleFont,
                uiStrings.TEXT[0],
                branchUpgradeHb.cX - 45f * Settings.scale,
                branchUpgradeHb.cY + 10f * Settings.scale,
                fontColor
        );
        if (BranchUpgradeButton.isViewingBranchUpgrade.get(__instance)) {
            sb.setColor(Color.WHITE);
            sb.draw(
                    ImageMaster.TICK,
                    branchUpgradeHb.cX - 80f * Settings.scale - 32f,
                    branchUpgradeHb.cY - 32f,
                    32f, 32f,
                    64f, 64f,
                    Settings.scale, Settings.scale,
                    0f,
                    0, 0,
                    64, 64,
                    false, false
            );
        }
        BranchUpgradeButton.branchUpgradeHb.get(__instance).render(sb);
    }
}
 
Example #9
Source File: CommonKeywordIconsPatches.java    From StSLib with MIT License 4 votes vote down vote up
private static void drawBadge(SpriteBatch sb, AbstractCard card, Hitbox hb, Texture img, int offset) {
    float badge_w = img.getWidth();
    float badge_h = img.getHeight();
    sb.draw(img, hb.x + hb.width - (badge_w * Settings.scale) * 0.66f, hb.y + hb.height - (badge_h * Settings.scale) * 0.5f - ((offset * (badge_h * Settings.scale)*0.6f)), 0, 0, badge_w , badge_h ,
            Settings.scale, Settings.scale, card.angle, 0, 0, (int)badge_w, (int)badge_h, false, false);
}