#pragma once

#include <common/impulses/all.qh>

int autocvar_sv_cheats;
float autocvar_g_grab_range;
int autocvar_g_max_info_autoscreenshot;
int autocvar_sv_clones;

float cheatcount_total;
.float cheatcount;
void CheatInit();
void CheatShutdown();
float CheatsAllowed(entity this, float impulse, int argc, float cheatframe, bool logattempt, bool ignoredead);
float CheatImpulse(entity this, int imp);
float CheatCommand(entity this, int argc);
float CheatFrame(entity this);

const float CHRAME_DRAG = 8;

// speedrun: when 1, player auto teleports back when capture timeout happens
.bool speedrunning;

.entity personal;

.int grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and teammates can grab, 3 = anyone can grab

bool drag_undraggable(entity draggee, entity dragger);

.bool(entity this, entity dragger) draggable;
void Drag_MoveDrag(entity from, entity to); // call this from CopyBody
void DragBox_Think(entity this);
float Drag(entity this, float force_allow_pick, float ischeat);
void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
void Drag_Finish(entity dragger);
bool Drag_IsDraggable(entity draggee, entity dragger);
float Drag_MayChangeAngles(entity draggee);
void Drag_MoveForward(entity dragger);
void Drag_SetSpeed(entity dragger, float s);
void Drag_MoveBackward(entity dragger);
void Drag_Update(entity dragger);
float Drag_CanDrag(entity dragger);
float Drag_IsDragging(entity dragger);
void Drag_MoveDrag(entity from, entity to);
