package com.openosrs.client.api.types;

public class GameObject {
    private final int id;
    private final String name;
    private final Position position;
    private final int type;
    private final int orientation;
    private final String[] actions;

    public GameObject(int id, String name, Position position, int type,
                     int orientation, String[] actions) {
        this.id = id;
        this.name = name;
        this.position = position;
        this.type = type;
        this.orientation = orientation;
        this.actions = actions != null ? actions : new String[0];
    }

    public int getId() { return id; }
    public String getName() { return name; }
    public Position getPosition() { return position; }
    public int getType() { return type; }
    public int getOrientation() { return orientation; }
    public String[] getActions() { return actions.clone(); }

    public boolean hasAction(String action) {
        for (String a : actions) {
            if (a != null && a.equalsIgnoreCase(action)) {
                return true;
            }
        }
        return false;
    }

    public double distanceToPlayer(Position playerPos) {
        return position.distanceTo(playerPos);
    }

    @Override
    public String toString() {
        return String.format("GameObject[%d] %s at %s", id, name, position);
    }
}
