From 9934a3935d04b91a7d84c0bf244c72cbebb1d185 Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Sat, 30 May 2020 11:22:50 +0200 Subject: [PATCH 1/3] 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 }); } From 71cc7f482b109f020daa2f8fe2c71e0ae49e766c Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Sun, 31 May 2020 15:57:23 +0200 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a69b28a0..4d6dc6e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * `tshock.journey.biomespreadfreeze` * `tshock.journey.setspawnrate` * Changed default thresholds for some changes in the config file to accommodate new items & changes to Terraria. (@hakusaro) +* Store projectile type in `ProjectileStruct RecentlyCreatedProjectiles` to identify the recently created projectiles by type. Make `RecentlyCreatedProjectiles` and `ProjectileStruct` public for developers to access from plugins. ## TShock 4.4.0 (Pre-release 7 (Entangled)) * Fixed bed spawn issues when trying to remove spawn point in SSC. (@Olink) From a7166536c2be2f98a2050bfb9f1b88509ecca431 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Mon, 1 Jun 2020 19:12:14 +0930 Subject: [PATCH 3/3] Update projectilestruct to add brief documentation --- TShockAPI/GetDataHandlers.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index e50e6c4c..587683d4 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3770,12 +3770,27 @@ namespace TShockAPI { {TileID.MinecartTrack, 3} }; - + + /// + /// Contains brief information about a projectile + /// public struct ProjectileStruct { + /// + /// Index inside Main.projectile + /// public int Index { get; set; } + /// + /// Projectile's type ID + /// public short Type { get; set; } + /// + /// Time at which the projectile was created + /// public DateTime CreatedAt { get; set; } + /// + /// Whether or not the projectile has been killed + /// public bool Killed { get; internal set; } }