📄 actionengine.h
字号:
// ***************************************************************
// ActionEngine version: 1.0
// -------------------------------------------------------------
// File Name: ActionEngine.h
// Created: 2007/07/18
// Modified: 2007/07/18 16:52
// Author: William.Liang
// Msn: lwq49@msn.com
// Email: lwq49@21cn.com, lwq49@msn.com
// Description:
//
// Purpose:
// -------------------------------------------------------------
// license:
//
// The contents of this file are subject to the Mozilla Public
// License Version 1.1 (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.mozilla.org/MPL/ Software dis-
// tributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
// plied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Initial Developer of the Original Code is William.Liang .
// Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#ifndef ACTION_ENGINE_HEAD_FILE
#define ACTION_ENGINE_HEAD_FILE
#pragma once
#define ACTION_DEFAULT_FRAMES 60
//系统头文件
#include "ServiceEnginer.h"
#include "ActionProcess.h"
#include "..\ComService\ServiceThread.h"
#include "QueueServiceEvent.h"
//类说明
class CActionEngine;
//////////////////////////////////////////////////////////////////////////
//定时器线程
class SERVICE_ENGINER_CLASS CActionThread : public CServiceThread
{
//变量定义
protected:
DWORD m_dwTimerSpace; //时间间隔
CActionEngine * m_pActionEngine; //定时器引擎
//函数定义
public:
//构造函数
CActionThread(void);
//析构函数
virtual ~CActionThread(void);
//功能函数
public:
//配置函数
bool InitThread(CActionEngine * pActionEngine, DWORD dwTimerSpace);
//重载函数
private:
//运行函数
virtual bool RepetitionRun();
};
//////////////////////////////////////////////////////////////////////////
//动作子项
struct tagActionItem
{
IGameObject* pIGameObject; //执行对象
IActionProcess* pIActionProcess; //动作处理接口
WORD wActionID; //动作ID
DWORD dwFrames ; //定时时间
DWORD dwPassFrames; //已过时间
DWORD dwRepeatTimes; //重复次数
WPARAM wBindParam; //绑定参数
bool bIsCallBack; //是否需要对象回调
};
struct tagActionParam{
WPARAM wProcessParam;
WPARAM wExtendParam;
};
//定时器子项数组定义
typedef CListTemplate<tagActionItem*, WORD> CActionItemPtr;
//////////////////////////////////////////////////////////////////////////
//定时器引擎
class SERVICE_ENGINER_CLASS CActionEngine : public IActionEngine, public IActionEngineManager
{
friend class CActionThread;
//配置定义
protected:
DWORD m_dwTimerSpace; //时间间隔
//状态变量
protected:
bool m_bService; //运行标志
CActionItemPtr m_ActionItems; //事件数组
//组件变量
protected:
CThreadLock m_ThreadLock; //线程锁
CActionThread m_ActionThread; //定时器线程
CQueueServiceEvent m_AttemperEvent; //通知组件
//函数定义
public:
//构造函数
CActionEngine(void);
//析构函数
virtual ~CActionEngine(void);
virtual SetFrames(WORD nFrames){ if(nFrames<1) m_dwTimerSpace = ACTION_DEFAULT_FRAMES; else m_dwTimerSpace=1000L/nFrames; };
//基础接口
public:
//释放对象
virtual bool __cdecl Release() { if (IsValid()) delete this; return true; }
//是否有效
virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CActionEngine))?true:false; }
//接口查询
virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer);
//接口函数
public:
//设置定时器
virtual bool __cdecl CreateAction(IGameObject* pIGameObject, enuActionType ActionType, WORD wActionID, DWORD dwElapse, DWORD dwRepeat, WPARAM wParam, BOOL bCheckExist = true);
//设置定时器
virtual bool __cdecl CreateAction(IGameObject* pIGameObject, IActionProcess* pIActionProcess, WORD wActionID, DWORD dwElapse, DWORD dwRepeat, WPARAM wParam, BOOL bCheckExist = true);
//删除定时器
virtual bool __cdecl Remove(WORD wActionID);
//删除定时器
virtual bool __cdecl RemoveAll();
//管理接口
public:
//开始服务
virtual bool __cdecl StartService();
//停止服务
virtual bool __cdecl StopService();
//设置接口
virtual bool __cdecl SetActionEngineSink(IUnknownEx * pIUnknownEx);
//内部函数
private:
//定时器通知
void OnActionThreadSink();
};
//////////////////////////////////////////////////////////////////////////
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -