From 9934a3935d04b91a7d84c0bf244c72cbebb1d185 Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Sat, 30 May 2020 11:22:50 +0200 Subject: [PATCH] ProjectileStruct - Adding extra data Can we store the type of the recent projectile as well? This could be used in my upcoming PR regarding the golf packet where I check for recently created projectiles, and their types. Having only the index is not useful in this scenario, because the projectile can already be killed, so cannot access the Main.projectile array to get the projectile type. Can this be public instead of internal? Developers could make good use of it, instead of having to implement their own version of RecentProjectiles in their plugins. --- TShockAPI/GetDataHandlers.cs | 4 +++- TShockAPI/TSPlayer.cs | 2 +- TShockAPI/TShock.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index a81ff597..e50e6c4c 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2398,6 +2398,7 @@ namespace TShockAPI args.Player.RecentlyCreatedProjectiles.Add(new GetDataHandlers.ProjectileStruct() { Index = index, + Type = type, CreatedAt = DateTime.Now }); } @@ -3770,9 +3771,10 @@ namespace TShockAPI {TileID.MinecartTrack, 3} }; - internal struct ProjectileStruct + public struct ProjectileStruct { public int Index { get; set; } + public short Type { get; set; } public DateTime CreatedAt { get; set; } public bool Killed { get; internal set; } } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 1a204594..81d536fb 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -768,7 +768,7 @@ namespace TShockAPI /// Keeps track of recently created projectiles by this player. TShock.cs OnSecondUpdate() removes from this in an async task. /// Projectiles older than 5 seconds are purged from this collection as they are no longer "recent." /// - internal List RecentlyCreatedProjectiles = new List(); + public List RecentlyCreatedProjectiles = new List(); /// /// The current region this player is in, or null if none. diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index a0bc4e64..e143f7a9 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1653,6 +1653,7 @@ namespace TShockAPI player.RecentlyCreatedProjectiles.Add(new GetDataHandlers.ProjectileStruct() { Index = e.number, + Type = (short)projectile.type, CreatedAt = DateTime.Now }); }