package electrosphere.client.collision;

import org.joml.Vector3d;

import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.game.data.collidable.HitboxData;
import electrosphere.logger.LoggerInterface;

/**
 * Client methods for handling hitbox collisions reported by the server
 */
public class ClientHitboxCollision {
    
    /**
     * Performs client logic for a collision that the server reports
     * @param position The real-space position of the collision
     * @param hitboxType The type of hitbox
     * @param hurtboxType The type of hurtbox
     */
    public static void handleHitboxCollision(Entity senderEntity, Entity receiverEntity, Vector3d position, String hitboxType, String hurtboxType){
        switch(hitboxType){
            case HitboxData.HITBOX_TYPE_HIT_CONNECTED:
            case HitboxData.HITBOX_TYPE_HIT: {
                switch(hurtboxType){
                    case HitboxData.HITBOX_TYPE_HURT:
                    case HitboxData.HITBOX_TYPE_HURT_CONNECTED: {
                        Globals.hitboxAudioService.playAudioPositional(senderEntity, receiverEntity, hitboxType, hurtboxType, position);
                    } break;
                    case HitboxData.HITBOX_TYPE_BLOCK_CONNECTED: {
                        Globals.hitboxAudioService.playAudioPositional(senderEntity, receiverEntity, hitboxType, hurtboxType, position);
                    } break;
                    default: {
                        LoggerInterface.loggerEngine.WARNING("Client handling undefined hurtbox type: " + hurtboxType);
                    } break;
                }
            } break;
            default: {
                LoggerInterface.loggerEngine.WARNING("Client handling undefined hitbox type: " + hitboxType);
            } break;
        }
    }

}
