骑砍2霸主MOD开发(13)-常用功能组件

2024-06-08 12:12

本文主要是介绍骑砍2霸主MOD开发(13)-常用功能组件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一.MOD配置文件路径

    public class PLModuleConstans{public static string ModulePath = Utilities.GetFullModulePath("NativeAssetsTest");public static string ModuleTrackConfigPath = ModulePath + "ModuleTracks/soundtrack.xml";public static string ModuleCrashLogPath = ModulePath + "crash_log.txt";}

二.Agent

    public class PLAgentUtilities{public enum Axix{X,Y,Z}public static void AgentMoveAlongAxix(Agent agent, float distance, Axix rotateAxix){MatrixFrame frame = agent.Frame;Vec3 axixVec = Vec3.Zero;if (rotateAxix == Axix.Z){axixVec = frame.rotation.u;}else if (rotateAxix == Axix.X){axixVec = frame.rotation.s;}else if (rotateAxix == Axix.Y){axixVec = frame.rotation.f * (-1);}AgentMoveAlongVector(agent, distance, axixVec);}public static void AgentMoveAlongVector(Agent agent, float distance, Vec3 axixVec){if (agent == null){return;}MatrixFrame frame = agent.Frame;Vec3 position = frame.origin;axixVec.Normalize();position += axixVec * distance;agent.TeleportToPosition(position);}public static void GiveDamageToAgent(Agent attackerAgent, Agent attackedAgent, int damage){Blow blow = new Blow(attackerAgent.Index);blow.DamageType = DamageTypes.Blunt;blow.BoneIndex = attackerAgent.Monster.HeadLookDirectionBoneIndex;blow.GlobalPosition = attackerAgent.Position;blow.GlobalPosition.z = blow.GlobalPosition.z + attackerAgent.GetEyeGlobalHeight();blow.BaseMagnitude = 2000f;blow.WeaponRecord.FillAsMeleeBlow(null, null, -1, -1);blow.InflictedDamage = damage;blow.SwingDirection = attackerAgent.LookDirection;blow.Direction = blow.SwingDirection;blow.DamageCalculated = true;sbyte mainHandItemBoneIndex = attackerAgent.Monster.MainHandItemBoneIndex;AttackCollisionData attackCollisionDataForDebugPurpose = AttackCollisionData.GetAttackCollisionDataForDebugPurpose(false, false, false, true, false, false, false, false, false, false, false, false,CombatCollisionResult.StrikeAgent, -1, 0, 2, blow.BoneIndex, BoneBodyPartType.Head, mainHandItemBoneIndex,Agent.UsageDirection.AttackLeft, -1, CombatHitResultFlags.NormalHit, 0.5f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, Vec3.Up,blow.Direction, blow.GlobalPosition, Vec3.Zero, Vec3.Zero, attackerAgent.Velocity, Vec3.Up);attackedAgent.RegisterBlow(blow, attackCollisionDataForDebugPurpose);}}

三.GameEntity

    public class PLGameEntityUtilities{public enum Axix{X,Y,Z}public static void GameEntityMoveAlongAxix(GameEntity gameEntity, float distance, Axix rotateAxix){MatrixFrame frame = gameEntity.GetFrame();Vec3 axixVec = Vec3.Zero;if (rotateAxix == Axix.Z){axixVec = frame.rotation.u;}else if (rotateAxix == Axix.X){axixVec = frame.rotation.s;}else if (rotateAxix == Axix.Y){axixVec = frame.rotation.f;}GameEntityMoveAlongAxix(gameEntity, distance, axixVec);}public static void GameEntityMoveAlongAxix(GameEntity gameEntity, float distance, Vec3 axixVec){if (gameEntity == null){return;}MatrixFrame frame = gameEntity.GetFrame();Vec3 position = frame.origin;axixVec.Normalize();position += axixVec * distance;frame.origin = position;gameEntity.SetFrame(ref frame);}public static void SetGameEntityRotation(GameEntity gameEntity, Mat3 rotation){if (gameEntity == null){return;}MatrixFrame frame = gameEntity.GetFrame();frame.rotation = rotation;gameEntity.SetFrame(ref frame);}public static void SetGameEntityPosition(GameEntity gameEntity, Vec3 origin){if (gameEntity == null){return;}MatrixFrame frame = gameEntity.GetFrame();frame.origin = origin;gameEntity.SetFrame(ref frame);}public static void SetGameEntityScale(GameEntity gameEntity, Vec3 scale){if (gameEntity == null){return;}MatrixFrame frame = gameEntity.GetFrame();frame.Scale(scale);gameEntity.SetFrame(ref frame);}}

四.Camera

    public class PLCameraUtilities{public enum Axix{X,Y,Z}public static void CameraRotateAroundAxix(MissionScreen missionScreen, float angle, Axix rotateAxix){if (missionScreen == null){return;}MatrixFrame frame = missionScreen.CombatCamera.Frame;Mat3 rotation = frame.rotation;if (rotateAxix == Axix.Z){rotation.RotateAboutForward(angle * MathF.DegToRad);}else if (rotateAxix == Axix.X){rotation.RotateAboutSide(angle * MathF.DegToRad);}else if (rotateAxix == Axix.Y){rotation.RotateAboutUp(angle * MathF.DegToRad);}frame.rotation = rotation;missionScreen.CombatCamera.Frame = frame;missionScreen.SceneView.SetCamera(missionScreen.CombatCamera);}public static void CameraMoveAlongAxix(MissionScreen missionScreen, float distance, Axix rotateAxix){MatrixFrame frame = missionScreen.CombatCamera.Frame;Vec3 axixVec = Vec3.Zero;if (rotateAxix == Axix.Z){axixVec = frame.rotation.f;}else if (rotateAxix == Axix.X){axixVec = frame.rotation.s;}else if (rotateAxix == Axix.Y){axixVec = frame.rotation.u * (-1);}CameraMoveAlongVector(missionScreen, distance, axixVec);}public static void CameraMoveAlongVector(MissionScreen missionScreen, float distance, Vec3 axixVec){if (missionScreen == null){return;}MatrixFrame frame = missionScreen.CombatCamera.Frame;Vec3 position = frame.origin;axixVec.Normalize();position += axixVec * distance;frame.origin = position;missionScreen.CombatCamera.Frame = frame;missionScreen.SceneView.SetCamera(missionScreen.CombatCamera);}}

五.MissionTimer

public abstract class PLCommonBasicMissionTimer : BasicMissionTimer
{private float _triggerInterval = 0.0f;private bool _isTriggerOnce = false;private bool _isTriggered = false;public PLCommonBasicMissionTimer(float triggerInterval, bool isTriggerOnce){_triggerInterval = triggerInterval;_isTriggerOnce = isTriggerOnce;}public void TriggerTimer(){if (_isTriggered && _isTriggerOnce){return;}if (ElapsedTime > _triggerInterval){TriggerTimerScript();Reset();_isTriggered = true;}}public abstract void TriggerTimerScript();
}public class CheckFpsTimer : PLCommonBasicMissionTimer
{public CheckFpsTimer(float triggerInterval, bool isTriggerOnce) : base(triggerInterval, isTriggerOnce){}public override void TriggerTimerScript(){try{ShowFpsInformation();}catch (Exception ex){File.AppendAllLines(PLModuleConstans.ModuleCrashLogPath, new string[] { ex.ToString(), ex.Message, ex.StackTrace });}}private void ShowFpsInformation(){float fps = Utilities.GetFps();float mainFps = Utilities.GetMainFps();InformationManager.DisplayMessage(new InformationMessage(string.Format("fps:{0}, mainFps{1}", fps, mainFps)));}
}#创建MissionBehavior
[DefaultView]
public class MissionAgentBehavior : MissionView
{private List<PLCommonBasicMissionTimer> timers = new List<PLCommonBasicMissionTimer>();public override void OnCreated(){base.OnCreated();CheckFpsTimer checkFpsTimer = new CheckFpsTimer(3f, false);timers.Add(checkFpsTimer);}public override void OnMissionTick(float dt){base.OnMissionTick(dt);timers.ForEach(timer =>{timer.TriggerTimer();});}
}

这篇关于骑砍2霸主MOD开发(13)-常用功能组件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1042155

相关文章

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

Android使用ImageView.ScaleType实现图片的缩放与裁剪功能

《Android使用ImageView.ScaleType实现图片的缩放与裁剪功能》ImageView是最常用的控件之一,它用于展示各种类型的图片,为了能够根据需求调整图片的显示效果,Android提... 目录什么是 ImageView.ScaleType?FIT_XYFIT_STARTFIT_CENTE

Go语言开发实现查询IP信息的MCP服务器

《Go语言开发实现查询IP信息的MCP服务器》随着MCP的快速普及和广泛应用,MCP服务器也层出不穷,本文将详细介绍如何在Go语言中使用go-mcp库来开发一个查询IP信息的MCP... 目录前言mcp-ip-geo 服务器目录结构说明查询 IP 信息功能实现工具实现工具管理查询单个 IP 信息工具的实现服

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

Python正则表达式语法及re模块中的常用函数详解

《Python正则表达式语法及re模块中的常用函数详解》这篇文章主要给大家介绍了关于Python正则表达式语法及re模块中常用函数的相关资料,正则表达式是一种强大的字符串处理工具,可以用于匹配、切分、... 目录概念、作用和步骤语法re模块中的常用函数总结 概念、作用和步骤概念: 本身也是一个字符串,其中

usb接口驱动异常问题常用解决方案

《usb接口驱动异常问题常用解决方案》当遇到USB接口驱动异常时,可以通过多种方法来解决,其中主要就包括重装USB控制器、禁用USB选择性暂停设置、更新或安装新的主板驱动等... usb接口驱动异常怎么办,USB接口驱动异常是常见问题,通常由驱动损坏、系统更新冲突、硬件故障或电源管理设置导致。以下是常用解决

Android实现两台手机屏幕共享和远程控制功能

《Android实现两台手机屏幕共享和远程控制功能》在远程协助、在线教学、技术支持等多种场景下,实时获得另一部移动设备的屏幕画面,并对其进行操作,具有极高的应用价值,本项目旨在实现两台Android手... 目录一、项目概述二、相关知识2.1 MediaProjection API2.2 Socket 网络

Redis消息队列实现异步秒杀功能

《Redis消息队列实现异步秒杀功能》在高并发场景下,为了提高秒杀业务的性能,可将部分工作交给Redis处理,并通过异步方式执行,Redis提供了多种数据结构来实现消息队列,总结三种,本文详细介绍Re... 目录1 Redis消息队列1.1 List 结构1.2 Pub/Sub 模式1.3 Stream 结

MySQL索引的优化之LIKE模糊查询功能实现

《MySQL索引的优化之LIKE模糊查询功能实现》:本文主要介绍MySQL索引的优化之LIKE模糊查询功能实现,本文通过示例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录一、前缀匹配优化二、后缀匹配优化三、中间匹配优化四、覆盖索引优化五、减少查询范围六、避免通配符开头七、使用外部搜索引擎八、分

Android实现悬浮按钮功能

《Android实现悬浮按钮功能》在很多场景中,我们希望在应用或系统任意界面上都能看到一个小的“悬浮按钮”(FloatingButton),用来快速启动工具、展示未读信息或快捷操作,所以本文给大家介绍... 目录一、项目概述二、相关技术知识三、实现思路四、整合代码4.1 Java 代码(MainActivi