增加文档

This commit is contained in:
2025-10-18 15:49:45 +08:00
parent a9b10b88c0
commit a753cf4998
7 changed files with 106 additions and 88 deletions

View File

@@ -8,64 +8,64 @@
/** /**
* *
* @function * @function
* @param {ActiveObject} obj * @param {CharacterObject} obj
* @returns {void} * @returns {void}
*/ */
function checkCanChangeState_Character_Move(obj) { function checkCanChangeState_Character_Move(obj) {
//获取当前状态 //获取当前状态
local CurState = obj.GetState(); local CurState = obj.GetState()
//得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0 //得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0
local arr = obj.GetVars("_move_data_", "float"); local arr = obj.GetVars("_move_data_", "float")
if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) { if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) {
return true; return true
} else return false; } else return false
} }
/** /**
* *
* @function * @function
* @param {ActiveObject} obj * @param {CharacterObject} obj
* @returns {void} * @returns {void}
*/ */
function SetState_Character_Move(obj) { function SetState_Character_Move(obj) {
//获取移动数据 //获取移动数据
local arr = obj.GetVars("_move_data_", "float"); local arr = obj.GetVars("_move_data_", "float")
//设置人物朝向 摇杆X轴大于0则朝右小于0则朝左 //设置人物朝向 摇杆X轴大于0则朝右小于0则朝左
local SetValue = arr[0] > 0 ? 0 : 1; local SetValue = arr[0] > 0 ? 0 : 1
if (SetValue != obj.GetDirection()) { if (SetValue != obj.GetDirection()) {
if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue); if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue)
//设置动作 //设置动作
obj.SetAction("move"); obj.SetAction("move")
} else { } else {
if (obj.GetState() != 1) obj.SetAction("move"); if (obj.GetState() != 1) obj.SetAction("move")
} }
local Speed = 250; local Speed = 250
local Dir = obj.GetDirection(); local Dir = obj.GetDirection();
local Pos = obj.GetPosition(); local Pos = obj.GetPosition();
local XOffset = null; local XOffset
if (fabs(arr[0]) > 0.35) XOffset = arr[0] > 0 ? Speed : -Speed; if (fabs(arr[0]) > 0.35) XOffset = arr[0] > 0 ? Speed : -Speed
else XOffset = 0; else XOffset = 0
local YOffset = null; local YOffset
//当摇杆Y轴大于0.35或小于-0.35时设置Y轴偏移量 //当摇杆Y轴大于0.35或小于-0.35时设置Y轴偏移量
if (fabs(arr[1]) > 0.35) YOffset = arr[1] > 0 ? Speed : -Speed; if (fabs(arr[1]) > 0.35) YOffset = arr[1] > 0 ? Speed : -Speed
else YOffset = 0; else YOffset = 0
obj.SetSpeed(XOffset, YOffset, null); obj.SetSpeed(XOffset, YOffset, null)
} }
/** /**
* *
* @function * @function
* @param {ActiveObject} obj * @param {IRDSQRCharacter} obj
* @param {integer} DeltaTime * @param {integer} DeltaTime
* @returns {void} * @returns {void}
*/ */
function ProcState_Character_Move(obj, DeltaTime) { function ProcState_Character_Move(obj, DeltaTime) {
//获取移动数据 //获取移动数据
local arr = obj.GetVars("_move_data_", "float"); local arr = obj.GetVars("_move_data_", "float")
if (arr[0] == 0 && arr[1] == 0) { if (arr[0] == 0 && arr[1] == 0) {
obj.SetState(0); obj.SetState(0)
} }
} }

View File

@@ -5,11 +5,23 @@
文件用途:角色站立状态 文件用途:角色站立状态
*/ */
/**
*
* @function
* @param {IRDSQRCharacter} obj
* @returns {boolean}
*/
function checkCanChangeState_Character_Rest(obj) { function checkCanChangeState_Character_Rest(obj) {
return true; return true;
} }
/**
*
* @function
* @param {IRDSQRCharacter} obj
* @returns {void}
*/
function SetState_Character_Rest(obj) { function SetState_Character_Rest(obj) {
//设置动作 //设置动作
obj.SetAction("rest"); obj.SetAction("rest");
@@ -17,6 +29,13 @@ function SetState_Character_Rest(obj) {
obj.SetSpeed(0, 0, null); obj.SetSpeed(0, 0, null);
} }
/**
*
* @function
* @param {IRDSQRCharacter} obj
* @param {integer} DeltaTime
* @returns {void}
*/
function ProcState_Character_Rest(obj, DeltaTime) { function ProcState_Character_Rest(obj, DeltaTime) {
} }

View File

@@ -1,6 +1,5 @@
/** /**
* Description placeholder * Description placeholder
* @global
* @param {*} Object * @param {*} Object
*/ */
class ActiveObject extends BaseObject { class ActiveObject extends BaseObject {
@@ -9,7 +8,7 @@ class ActiveObject extends BaseObject {
} }
/** /**
* * 设置三轴速度
* @function * @function
* @param {integer} x * @param {integer} x
* @param {integer} y * @param {integer} y
@@ -25,7 +24,7 @@ class ActiveObject extends BaseObject {
} }
/** /**
* * 获取三轴速度
* @function * @function
* @returns {any} * @returns {any}
*/ */

View File

@@ -11,16 +11,16 @@ class BaseObject {
} }
/** /**
* * 获取坐标
* @function * @function
* @returns {any} * @returns {any}
*/ */
function GetPosition() { function GetPosition() {
return sq_GetPosition(C_Object); return sq_GetPosition(C_Object);
} }
//
/** /**
* * 设置坐标
* @function * @function
* @param {integer} x * @param {integer} x
* @param {integer} y * @param {integer} y
@@ -32,22 +32,22 @@ class BaseObject {
} }
/** /**
* * 获取储存器
* @function * @function
* @param {string} Name * @param {string} Name
* @param {any} Type * @param {string} Type
* @returns {any} * @returns {array}
*/ */
function GetVars(Name, Type) { function GetVars(Name, Type) {
return sq_GetVars(C_Object, Name, Type); return sq_GetVars(C_Object, Name, Type);
} }
/** /**
* * 设置储存器
* @function * @function
* @param {string} Name * @param {string} Name
* @param {any} Type * @param {any} Type
* @param {any} Value * @param {array} Value
* @returns {void} * @returns {void}
*/ */
function SetVars(Name, Type, Value) { function SetVars(Name, Type, Value) {
@@ -55,7 +55,7 @@ class BaseObject {
} }
/** /**
* * 获取方向
* @function * @function
* @returns {integer} * @returns {integer}
*/ */
@@ -64,7 +64,7 @@ class BaseObject {
} }
/** /**
* * 设置方向
* @function * @function
* @param {integer} Dir * @param {integer} Dir
* @returns {void} * @returns {void}

View File

@@ -3,36 +3,36 @@
* @param {*} Object * @param {*} Object
*/ */
class CharacterObject extends ActiveObject { class CharacterObject extends ActiveObject {
constructor(Object) { constructor(Object) {
base.constructor(Object); base.constructor(Object)
} }
/** /**
* * 获取状态
* @function * @function
* @returns {*} * @returns {integer} 状态编号
*/ */
function GetState() { function GetState() {
return sq_GetState(C_Object); return sq_GetState(C_Object)
} }
/** /**
* * 设置状态
* @function * @function
* @param {integer} State * @param {integer} State
* @returns {void} * @returns {void}
*/ */
function SetState(State) { function SetState(State) {
sq_SetState(C_Object, State); sq_SetState(C_Object, State)
} }
/** /**
* * 设置动作
* @function * @function
* @param {any} key * @param {string} key
* @returns {void} * @returns {void}
*/ */
function SetAction(key) { function SetAction(key) {
sq_SetAction(C_Object, key); sq_SetAction(C_Object, key)
} }
} }

View File

@@ -91,6 +91,7 @@ function StateMachine_SetState(C_Object, Job, State) {
return false; return false;
} }
function StateMachine_ProcState(C_Object, Job, State, DeltaTime) { function StateMachine_ProcState(C_Object, Job, State, DeltaTime) {
//获取状态信息 //获取状态信息
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State); local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);

View File

@@ -2,7 +2,7 @@
* *
* @function * @function
* @param {any} C_Object * @param {any} C_Object
* @param {integer} state * @param {integer} state 状态编号
* @returns {void} * @returns {void}
*/ */
function sq_SetState(C_Object, state) {} function sq_SetState(C_Object, state) {}
@@ -11,8 +11,7 @@ function sq_SetState(C_Object, state) {}
* *
* @function * @function
* @param {any} C_Object * @param {any} C_Object
* @param {any} key * @param {string} key 动作名称
*
* @returns {void} * @returns {void}
*/ */
function sq_SetAction(C_Object, key) {} function sq_SetAction(C_Object, key) {}
@@ -59,8 +58,8 @@ function sq_SetPosition(C_Object, x, y, z) {}
* *
* @function * @function
* @param {any} C_Object * @param {any} C_Object
* @param {string} Name * @param {string} Name 储存器名称
* @param {any} Type * @param {string} Type 数据类型(int,float,string,bool)
* @returns {void} * @returns {void}
*/ */
function sq_GetVars(C_Object, Name, Type) {} function sq_GetVars(C_Object, Name, Type) {}
@@ -69,8 +68,8 @@ function sq_GetVars(C_Object, Name, Type) {}
* *
* @function * @function
* @param {any} C_Object * @param {any} C_Object
* @param {string} Name * @param {string} Name 储存器名称
* @param {any} Type * @param {string} Type 数据类型(int,float,string,bool)
* @param {any} Value * @param {any} Value
* @returns {void} * @returns {void}
*/ */
@@ -89,7 +88,7 @@ function sq_GetDirection(C_Object) {
* *
* @function * @function
* @param {any} C_Object * @param {any} C_Object
* @param {integer} Dir * @param {integer} Dir 方向(0左 1右)
* @returns {void} * @returns {void}
*/ */
function sq_SetDirection(C_Object, Dir) {} function sq_SetDirection(C_Object, Dir) {}