#pragma once
#include "global.h"
//前置声明
class Entity;
struct MyView;

class MyCamera
{
public:
	void Init(MyView* pView, int* pMapW, int* pMapH);
	void SetTarget(std::weak_ptr<Entity> target, float focusTimes = 16);
	void SetTarget2(std::weak_ptr<Entity> target2);//对焦第二个玩家
	void SwapTarget();
	void EnableLRUD(bool bEnbale);
	void Step();
	void DeltaTime(float deltaTime);//绘制更新
	void FocusOnce();//立即聚焦一次
	void Reset();
	void SetQuake(int times, int mode);
	void QuakeStep();//屏幕晃动
	void ResetQuake();
	void SetLocalCamera(std::weak_ptr<Entity> localTarget, float focusTimes);//设置局部相机
	void UnsetLocalCamera(std::weak_ptr<Entity> e);//取消该单位的聚焦
private:
	MyView* pView = nullptr;
	int* pMapW = nullptr;
	int* pMapH = nullptr;
	float camera_offx = 0;
	float camera_offy = 0;
	float camera_last_offx = 0;
	float camera_last_offy = 0;
	std::weak_ptr<Entity> target;
	std::weak_ptr<Entity> target2;
	float focusTimes = 16;
	std::weak_ptr<Entity> target_local;
	float focusTimes_local = 16;
	bool enableLRUD = true;//启用lrud偏移
	float focus_lr_counter_target1 = 0;
	float focus_ud_counter_target1 = 0;
	float focus_lr_counter_target2 = 0;
	float focus_ud_counter_target2 = 0;
	float quakeCenterX = 0, quakeCenterY = 0;
	int quake = 0;
	int quake2 = 0;
	bool LocalCameraStep();
};

