2020-04-15 17:22:29 +02:00
|
|
|
package com.minelittlepony.unicopia.ability;
|
|
|
|
|
2020-05-06 15:55:25 +02:00
|
|
|
import java.util.EnumMap;
|
2022-01-01 00:03:22 +01:00
|
|
|
import java.util.LinkedHashSet;
|
2022-01-02 17:07:28 +01:00
|
|
|
import java.util.List;
|
2020-04-25 22:03:36 +02:00
|
|
|
import java.util.Map;
|
2020-05-06 15:55:25 +02:00
|
|
|
import java.util.Set;
|
2022-01-02 17:07:28 +01:00
|
|
|
import java.util.function.BiFunction;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
2022-08-27 15:14:00 +02:00
|
|
|
import com.minelittlepony.unicopia.Unicopia;
|
2022-12-19 00:12:49 +01:00
|
|
|
import com.minelittlepony.unicopia.util.RegistryUtils;
|
2020-06-26 11:44:47 +02:00
|
|
|
|
2022-12-10 00:55:53 +01:00
|
|
|
import net.minecraft.util.*;
|
2022-12-18 22:07:24 +01:00
|
|
|
import net.minecraft.registry.Registry;
|
2020-04-15 17:22:29 +02:00
|
|
|
|
2020-04-25 15:37:17 +02:00
|
|
|
public interface Abilities {
|
2022-12-19 00:12:49 +01:00
|
|
|
Registry<Ability<?>> REGISTRY = RegistryUtils.createSimple(Unicopia.id("abilities"));
|
2022-01-02 17:07:28 +01:00
|
|
|
Map<AbilitySlot, Set<Ability<?>>> BY_SLOT = new EnumMap<>(AbilitySlot.class);
|
2022-12-10 00:55:53 +01:00
|
|
|
BiFunction<AbilitySlot, Race.Composite, List<Ability<?>>> BY_SLOT_AND_COMPOSITE_RACE = Util.memoize((slot, race) -> {
|
2022-01-02 17:07:28 +01:00
|
|
|
return BY_SLOT.computeIfAbsent(slot, s -> new LinkedHashSet<>())
|
|
|
|
.stream()
|
2023-08-27 15:56:18 +02:00
|
|
|
.filter(a -> a.canUse(race))
|
2022-01-02 17:07:28 +01:00
|
|
|
.toList();
|
|
|
|
});
|
2020-04-15 17:22:29 +02:00
|
|
|
|
2020-04-25 15:46:29 +02:00
|
|
|
// unicorn / alicorn
|
2020-05-10 20:45:07 +02:00
|
|
|
Ability<?> CAST = register(new UnicornCastingAbility(), "cast", AbilitySlot.PRIMARY);
|
2021-12-31 14:40:08 +01:00
|
|
|
Ability<?> SHOOT = register(new UnicornProjectileAbility(), "shoot", AbilitySlot.PRIMARY);
|
2023-08-27 15:56:18 +02:00
|
|
|
Ability<?> TIME = register(new TimeChangeAbility(), "time_control", AbilitySlot.SECONDARY);
|
2020-09-22 15:52:44 +02:00
|
|
|
Ability<?> TELEPORT = register(new UnicornTeleportAbility(), "teleport", AbilitySlot.SECONDARY);
|
2021-02-13 22:12:02 +01:00
|
|
|
Ability<?> GROUP_TELEPORT = register(new UnicornGroupTeleportAbility(), "teleport_group", AbilitySlot.SECONDARY);
|
2021-12-31 14:40:08 +01:00
|
|
|
Ability<?> DISPELL = register(new UnicornDispellAbility(), "dispell", AbilitySlot.TERTIARY);
|
2020-04-15 17:22:29 +02:00
|
|
|
|
2020-04-25 15:46:29 +02:00
|
|
|
// earth / alicorn
|
2020-10-11 13:14:41 +02:00
|
|
|
Ability<?> KICK = register(new EarthPonyKickAbility(), "kick", AbilitySlot.PRIMARY);
|
2020-05-06 15:55:25 +02:00
|
|
|
Ability<?> GROW = register(new EarthPonyGrowAbility(), "grow", AbilitySlot.SECONDARY);
|
2020-09-25 12:50:23 +02:00
|
|
|
Ability<?> STOMP = register(new EarthPonyStompAbility(), "stomp", AbilitySlot.TERTIARY);
|
2020-04-15 17:22:29 +02:00
|
|
|
|
2020-10-14 21:07:36 +02:00
|
|
|
// pegasus
|
|
|
|
Ability<?> RAINBOOM = register(new PegasusRainboomAbility(), "rainboom", AbilitySlot.PRIMARY);
|
2021-02-19 17:10:49 +01:00
|
|
|
Ability<?> CAPTURE_CLOUD = register(new PegasusCaptureStormAbility(), "capture_cloud", AbilitySlot.SECONDARY);
|
2020-10-14 21:07:36 +02:00
|
|
|
|
2020-04-25 15:46:29 +02:00
|
|
|
// pegasus / bat / alicorn / changeling
|
2020-05-06 15:55:25 +02:00
|
|
|
Ability<?> CARRY = register(new CarryAbility(), "carry", AbilitySlot.PASSIVE);
|
2022-10-08 15:45:22 +02:00
|
|
|
Ability<?> TOGGLE_SLIGHT = register(new PegasusFlightToggleAbility(), "toggle_flight", AbilitySlot.TERTIARY);
|
2020-04-25 15:46:29 +02:00
|
|
|
|
2020-04-25 15:37:17 +02:00
|
|
|
// changeling
|
2020-09-25 12:50:23 +02:00
|
|
|
Ability<?> DISGUISE = register(new ChangelingDisguiseAbility(), "disguise", AbilitySlot.SECONDARY);
|
2022-10-13 00:20:06 +02:00
|
|
|
Ability<?> FEED = register(new ChangelingFeedAbility(), "feed", AbilitySlot.SECONDARY);
|
2020-04-15 17:22:29 +02:00
|
|
|
|
2020-09-25 20:24:48 +02:00
|
|
|
// bat
|
|
|
|
Ability<?> HANG = register(new BatPonyHangAbility(), "hang", AbilitySlot.SECONDARY);
|
|
|
|
Ability<?> EEEE = register(new BatEeeeAbility(), "eee", AbilitySlot.TERTIARY);
|
|
|
|
|
2020-05-06 15:55:25 +02:00
|
|
|
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
|
2022-08-27 15:14:00 +02:00
|
|
|
Identifier id = Unicopia.id(name);
|
2022-01-01 00:03:22 +01:00
|
|
|
BY_SLOT.computeIfAbsent(slot, s -> new LinkedHashSet<>()).add(power);
|
2020-06-26 11:44:47 +02:00
|
|
|
return Registry.register(REGISTRY, id, power);
|
2020-04-15 17:22:29 +02:00
|
|
|
}
|
2022-01-02 17:07:28 +01:00
|
|
|
|
2022-08-27 16:37:37 +02:00
|
|
|
static void bootstrap() {}
|
2020-04-15 17:22:29 +02:00
|
|
|
}
|