feat: api13, remove ecommon

This commit is contained in:
VeeverSW
2025-09-19 15:21:51 +08:00
parent f744cca396
commit 2d1a945a9b
75 changed files with 5122 additions and 614 deletions

View File

@@ -12,16 +12,12 @@ using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using KodakkuAssist.Extensions;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Ala_Mhigo;
[ScriptType(guid: "aa0ae191-da3f-48f1-9340-46a56cfeeabf", name: "鏖战红莲阿拉米格", territorys: [1146],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Ala_Mhigo
{
@@ -275,4 +271,112 @@ public static class EventExtensions
{
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,25 +3,19 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
using KodakkuAssist.Extensions;
namespace SaintMociannesArboretum_Hard;
[ScriptType(guid: "7e87b5d1-ae21-4115-9483-d8dc0f1d1652", name: "污染庭园圣茉夏娜植物园", territorys: [788],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class SaintMociannesArboretum_Hard
{
@@ -411,4 +405,112 @@ public static class EventExtensions
{
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,25 +3,19 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace the_Fractal_Continuum_Hard;
[ScriptType(guid: "c76136e1-1b5b-4cfb-a677-4cc0917fa050", name: "疯狂战舰无限回廊", territorys: [743],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class the_Fractal_Continuum_Hard
{
@@ -350,3 +344,111 @@ public static class Extensions
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,24 +3,18 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace O11n;
[ScriptType(guid: "2232ae84-c1e7-4382-88b4-d691887f27cf", name: "O11N", territorys: [800],
version: "0.0.0.3" , author: "Tetora", note: noteStr)]
version: "0.0.0.4" , author: "Tetora", note: noteStr)]
public class O11n
{
@@ -308,3 +302,111 @@ public static class Extensions
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,24 +3,18 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace O4n;
[ScriptType(guid: "f24f9cef-717e-4a2a-9616-d470443d6d8a", name: "O4N", territorys: [694],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class O4n
{

View File

@@ -11,16 +11,12 @@ using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace O5n;
[ScriptType(guid: "af11ce46-2c6a-46ba-b2bc-c542e5f5b7b5", name: "O5N", territorys: [748],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class O5n
{

View File

@@ -12,16 +12,12 @@ using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using KodakkuAssist.Extensions;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace O7n;
[ScriptType(guid: "70419862-28f5-4ebb-b1b3-220419cd502f", name: "O7N", territorys: [750],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class O7n
{

View File

@@ -3,8 +3,6 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using KodakkuAssist.Extensions;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Byakko;
[ScriptType(guid: "6a9e30e9-c58e-4f39-9f1e-ad26e5d49dc3", name: "白虎镇魂战", territorys: [746],
version: "0.0.0.11", author: "Tetora", note: noteStr)]
version: "0.0.0.12", author: "Tetora", note: noteStr)]
public class Byakko
{

View File

@@ -12,16 +12,12 @@ using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using KodakkuAssist.Extensions;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Emanation;
[ScriptType(guid: "a7bacd3e-834f-41ba-a210-c66e2c12d208", name: "吉祥天女歼灭战", territorys: [719],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class Lakshmi
{
@@ -220,3 +216,112 @@ public static class Extensions
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,25 +3,19 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
using KodakkuAssist.Extensions;
namespace theRoyalMenagerie;
[ScriptType(guid: "da23fd13-2d1f-41d3-b2c9-91fd8d948a98", name: "神龙歼灭战", territorys: [679],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Shinryu
{

View File

@@ -3,24 +3,18 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Susano;
[ScriptType(guid: "2c4b6205-6a77-4c89-b641-2c2359a43f25", name: "须佐之男歼灭战", territorys: [674],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Susano
{

View File

@@ -3,24 +3,18 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Suzaku;
[ScriptType(guid: "fc907987-bad9-4c70-97f6-b91e2e70544b", name: "朱雀镇魂战", territorys: [810],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Suzaku
{
@@ -298,4 +292,112 @@ public static class EventExtensions
{
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,25 +3,19 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
using KodakkuAssist.Extensions;
namespace Tsukuyomi;
[ScriptType(guid: "97415dc8-cd16-4c9b-87be-026a297c3451", name: "月读歼灭战", territorys: [778],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Tsukuyomi
{
@@ -253,3 +247,112 @@ public static class Extensions
}
}
}
#region
public static class MathTools
{
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
/// <summary>
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0以(1, 0, 0)方向为pi/2。
/// 即,逆时针方向增加。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetRadian(this Vector3 point, Vector3 center)
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
/// <summary>
/// 获得任意点与中心点的长度。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static float GetLength(this Vector3 point, Vector3 center)
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
/// <summary>
/// 将任意点以中心点为圆心,逆时针旋转并延长。
/// </summary>
/// <param name="point">任意点</param>
/// <param name="center">中心点</param>
/// <param name="radian">旋转弧度</param>
/// <param name="length">基于该点延伸长度</param>
/// <returns></returns>
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
{
var baseRad = point.GetRadian(center);
var baseLength = point.GetLength(center);
var rotRad = baseRad + radian;
return new Vector3(
center.X + MathF.Sin(rotRad) * (length + baseLength),
center.Y,
center.Z + MathF.Cos(rotRad) * (length + baseLength)
);
}
/// <summary>
/// 获得某角度所在划分区域
/// </summary>
/// <param name="radian">输入弧度</param>
/// <param name="regionNum">区域划分数量</param>
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
/// <param name="isDiagDiv">是否为斜分割默认为false</param>
/// <param name="isCw">是否顺时针增加默认为false</param>
/// <returns></returns>
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
{
var sepRad = float.Pi * 2 / regionNum;
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
}
/// <summary>
/// 将输入点左右折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerX">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
=> point with { X = 2 * centerX - point.X };
/// <summary>
/// 将输入点上下折叠
/// </summary>
/// <param name="point">待折叠点</param>
/// <param name="centerZ">中心折线坐标点</param>
/// <returns></returns>
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
=> point with { Z = 2 * centerZ - point.Z };
/// <summary>
/// 将输入点中心对称
/// </summary>
/// <param name="point">输入点</param>
/// <param name="center">中心点</param>
/// <returns></returns>
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
=> point.RotateAndExtend(center, float.Pi, 0);
/// <summary>
/// 获取给定数的指定位数
/// </summary>
/// <param name="val">给定数值</param>
/// <param name="x">对应位数个位为1</param>
/// <returns></returns>
public static int GetDecimalDigit(this int val, int x)
{
var valStr = val.ToString();
var length = valStr.Length;
if (x < 1 || x > length) return -1;
var digitChar = valStr[length - x]; // 从右往左取第x位
return int.Parse(digitChar.ToString());
}
}
#endregion

View File

@@ -3,24 +3,18 @@ using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
// using Dalamud.Game.ClientState.Objects.Subkinds;
// using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json;
using Dalamud.Utility.Numerics;
using KodakkuAssist.Script;
using KodakkuAssist.Module.GameEvent;
using KodakkuAssist.Module.Draw;
using KodakkuAssist.Data;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.MathHelpers;
using System.Threading.Tasks;
namespace Kugane_Ohashi;
[ScriptType(guid: "944c8879-0d4e-4182-87ea-c38769990f2d", name: "保镖歼灭战", territorys: [806],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Yojimbo
{
const string noteStr =