/*
 *  Copyright 2025-2026 R3944Realms
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package top.r3944realms.eroticdungeongame.api.workspace;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.IEventBus;
import top.r3944realms.eroticdungeongame.api.capability.IPlayerDungeonData;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * The interface Work space helper.
 */
public interface IWorkSpaceHelper {
    /**
     * Is in device boolean.
     *
     * @param player the player
     * @return the boolean
     */
    boolean isInDevice(Entity player);

    /**
     * Try to do if in device.
     *
     * @param player   the player
     * @param action   the action
     * @param fallback the fallback
     */
    void tryToDoIfInDevice(Entity player, Consumer<IPlayerDungeonData> action, Runnable fallback);

    /**
     * Try to do if in device.
     *
     * @param player the player
     * @param action the action
     */
    default void tryToDoIfInDevice(Entity player,Consumer<IPlayerDungeonData> action) {
        tryToDoIfInDevice(player, action, () -> {});
    }

    /**
     * Try to do if in device and ret t.
     *
     * @param <T>      the type parameter
     * @param player   the player
     * @param action   the action
     * @param fallback the fallback
     * @return the t
     */
    <T> T tryToDoIfInDeviceAndRet(Entity player, Function<IPlayerDungeonData, T> action, Supplier<T> fallback);

    /**
     * Try to do if in device and ret t.
     *
     * @param <T>    the type parameter
     * @param player the player
     * @param action the action
     * @return the t
     */
    default <T> T tryToDoIfInDeviceAndRet(Entity player, Function<IPlayerDungeonData, T> action) {
        return tryToDoIfInDeviceAndRet(player, action, () -> null);
    }

    /**
     * Check is player boolean.
     *
     * @param entity the entity
     * @return the boolean
     */
    default boolean checkIsPlayer(Entity entity) {
        return entity instanceof Player;
    }

    /**
     * Gets mod event bus.
     *
     * @return the mod event bus
     */
    IEventBus getModEventBus();
}
