From f54d19acbd434e3df27569696df57581a8bcafe9 Mon Sep 17 00:00:00 2001 From: Controllerdestiny <523321293@qq.com> Date: Mon, 20 May 2024 17:55:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20EconomicsAPI=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=B0=83=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Economics.Projectile.csproj | 9 ++++ .../Internet/CustomProjectile.cs | 18 +++++++ Economics.Projectile/Plugin.cs | 48 +++++++++++++++++++ EconomicsAPI/Utils/Helper.cs | 1 - Plugin.sln | 10 ++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Economics.Projectile/Economics.Projectile.csproj create mode 100644 Economics.Projectile/Internet/CustomProjectile.cs create mode 100644 Economics.Projectile/Plugin.cs diff --git a/Economics.Projectile/Economics.Projectile.csproj b/Economics.Projectile/Economics.Projectile.csproj new file mode 100644 index 00000000..74fbae2e --- /dev/null +++ b/Economics.Projectile/Economics.Projectile.csproj @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Economics.Projectile/Internet/CustomProjectile.cs b/Economics.Projectile/Internet/CustomProjectile.cs new file mode 100644 index 00000000..553bdd54 --- /dev/null +++ b/Economics.Projectile/Internet/CustomProjectile.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Economics.Projectile.Internet; + +public class CustomProjectile +{ + [JsonProperty("弹幕ID")] + public int Id { get; set; } + + [JsonProperty("伤害")] + public int Damage { get; set; } + + [JsonProperty("击退")] + public float Knockback { get; set; } + + [JsonProperty("射速")] + public float Speed { get; set; } +} diff --git a/Economics.Projectile/Plugin.cs b/Economics.Projectile/Plugin.cs new file mode 100644 index 00000000..12214b6f --- /dev/null +++ b/Economics.Projectile/Plugin.cs @@ -0,0 +1,48 @@ +using System.Reflection; +using Terraria; +using TerrariaApi.Server; +using TShockAPI; + +namespace Economics.Projectile; + +[ApiVersion(2, 1)] +public class Plugin : TerrariaPlugin +{ + public override string Author => "少司命"; + + public override string Description => Assembly.GetExecutingAssembly().GetName().Name!; + + public override string Name => Assembly.GetExecutingAssembly().GetName().Name!; + + public override Version Version => Assembly.GetExecutingAssembly().GetName().Version!; + + internal static string PATH = Path.Combine(EconomicsAPI.Economics.SaveDirPath, "Projectile.json"); + + public Plugin(Main game) : base(game) + { + } + + public override void Initialize() + { + GetDataHandlers.NewProjectile.Register(OnProj); + ServerApi.Hooks.NetGetData.Register(this, GetData); + + } + + private void GetData(GetDataEventArgs args) + { + if(args.MsgID == PacketTypes.MinionAttackTargetUpdate) + { + var reader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)); + var who = reader.ReadByte(); + var npcid = reader.ReadInt16(); + Console.WriteLine(npcid); + Console.WriteLine(Main.npc[npcid].FullName); + } + } + + private void OnProj(object? sender, GetDataHandlers.NewProjectileEventArgs e) + { + throw new NotImplementedException(); + } +} diff --git a/EconomicsAPI/Utils/Helper.cs b/EconomicsAPI/Utils/Helper.cs index dd98c3ed..a3b76895 100644 --- a/EconomicsAPI/Utils/Helper.cs +++ b/EconomicsAPI/Utils/Helper.cs @@ -49,7 +49,6 @@ public static string GetGradientText(string text) index++; } } - Console.WriteLine(result); return result; } /// diff --git a/Plugin.sln b/Plugin.sln index 8eab994e..f79e29f9 100644 --- a/Plugin.sln +++ b/Plugin.sln @@ -154,6 +154,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignInSign", "SignInSign\Si EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeaponPlus", "WeaponPlusCostCoin\WeaponPlus.csproj", "{D860EB42-E6F5-4991-8F2D-DB84FBD6BA1D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Economics.Projectile", "Economics.Projectile\Economics.Projectile.csproj", "{1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -746,6 +748,14 @@ Global {D860EB42-E6F5-4991-8F2D-DB84FBD6BA1D}.Release|Any CPU.Build.0 = Release|Any CPU {D860EB42-E6F5-4991-8F2D-DB84FBD6BA1D}.Release|x64.ActiveCfg = Release|Any CPU {D860EB42-E6F5-4991-8F2D-DB84FBD6BA1D}.Release|x64.Build.0 = Release|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Debug|x64.ActiveCfg = Debug|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Debug|x64.Build.0 = Debug|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Release|Any CPU.Build.0 = Release|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Release|x64.ActiveCfg = Release|Any CPU + {1F11D206-B4CE-430B-A8BD-6D7C93BC4C8F}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE