Trainguy9512 / trainguys-animation-overhaul

Other
375 stars 267 forks source link

Switch to using Enums for all locators #99

Closed ellieisjelly closed 1 year ago

ellieisjelly commented 1 year ago

Switching to Enums would make the code cleaner and would allow re-use between classes. The following code located under the PlayerPartAnimation made me make this issue:

 private static final String LOCATOR_ROOT = "root";
    private static final String LOCATOR_HEAD = "head";
    private static final String LOCATOR_BODY = "body";
    private static final String LOCATOR_LEFT_LEG = "leftLeg";
    private static final String LOCATOR_RIGHT_LEG = "rightLeg";
    private static final String LOCATOR_LEFT_ARM = "leftArm";
    private static final String LOCATOR_RIGHT_ARM = "rightArm";
    private static final String LOCATOR_CAPE = "cape";
    private static final String LOCATOR_LEFT_HAND = "leftHand";
    private static final String LOCATOR_RIGHT_HAND = "rightHand";

    private static final List<String> LOCATOR_LIST_ALL = List.of(
            LOCATOR_HEAD,
            LOCATOR_BODY,
            LOCATOR_LEFT_LEG,
            LOCATOR_RIGHT_LEG,
            LOCATOR_LEFT_ARM,
            LOCATOR_RIGHT_ARM,
            LOCATOR_CAPE,
            LOCATOR_LEFT_HAND,
            LOCATOR_RIGHT_HAND
    );
    private static final List<String> LOCATOR_LIST_NO_HANDS = List.of(
            LOCATOR_HEAD,
            LOCATOR_BODY,
            LOCATOR_LEFT_LEG,
            LOCATOR_RIGHT_LEG,
            LOCATOR_LEFT_ARM,
            LOCATOR_RIGHT_ARM,
            LOCATOR_CAPE
    );
    private static final List<String> LOCATOR_LIST_MASTER = List.of(
            LOCATOR_ROOT,
            LOCATOR_HEAD,
            LOCATOR_BODY,
            LOCATOR_LEFT_LEG,
            LOCATOR_RIGHT_LEG,
            LOCATOR_LEFT_ARM,
            LOCATOR_RIGHT_ARM,
            LOCATOR_CAPE,
            LOCATOR_LEFT_HAND,
            LOCATOR_RIGHT_HAND
    );

The Locator variables could easily be replaced by Enums and would make the code cleaner

Trainguy9512 commented 1 year ago

ill look into switching these to enums, they used to be entire objects but i simplified it to string identifiers just to make it easier- them being strings is also used to associate each locator with the stored JSON joint names and the reuse between classes issue i fixed just by making them public instead of private

Trainguy9512 commented 1 year ago

done! thx