Move the projectile refresh to Bouncer.
Bouncer now has an OnSecondUpdate(). Move projectile created tracking to GetDataHandler from Bouncer.
This commit is contained in:
parent
9209ac0b73
commit
b73088306d
3 changed files with 33 additions and 27 deletions
|
|
@ -19,18 +19,17 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Terraria.ID;
|
using Terraria.ID;
|
||||||
using TShockAPI.DB;
|
|
||||||
using TShockAPI.Net;
|
using TShockAPI.Net;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using OTAPI.Tile;
|
using OTAPI.Tile;
|
||||||
using TShockAPI.Localization;
|
using TShockAPI.Localization;
|
||||||
using static TShockAPI.GetDataHandlers;
|
using static TShockAPI.GetDataHandlers;
|
||||||
using TerrariaApi.Server;
|
|
||||||
using Terraria.ObjectData;
|
using Terraria.ObjectData;
|
||||||
using Terraria.DataStructures;
|
using Terraria.DataStructures;
|
||||||
using Terraria.Localization;
|
using Terraria.Localization;
|
||||||
using TShockAPI.Models.PlayerUpdate;
|
using TShockAPI.Models.PlayerUpdate;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -962,18 +961,6 @@ namespace TShockAPI
|
||||||
// Denotes that the player has recently set a fuse - used for cheat detection.
|
// Denotes that the player has recently set a fuse - used for cheat detection.
|
||||||
args.Player.RecentFuse = 10;
|
args.Player.RecentFuse = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectileCreatesLiquid.ContainsKey(type))
|
|
||||||
{
|
|
||||||
lock (args.Player.RecentlyCreatedProjectiles)
|
|
||||||
{
|
|
||||||
args.Player.RecentlyCreatedProjectiles.Add(new ProjectileStruct()
|
|
||||||
{
|
|
||||||
Index = ident,
|
|
||||||
CreatedAt = DateTime.Now
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Handles the NPC Strike event for Bouncer.</summary>
|
/// <summary>Handles the NPC Strike event for Bouncer.</summary>
|
||||||
|
|
@ -2069,6 +2056,24 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void OnSecondUpdate()
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
foreach (var player in TShock.Players)
|
||||||
|
{
|
||||||
|
if (player != null && player.TPlayer.whoAmI >= 0)
|
||||||
|
{
|
||||||
|
var threshold = DateTime.Now.AddSeconds(-5);
|
||||||
|
lock (player.RecentlyCreatedProjectiles)
|
||||||
|
{
|
||||||
|
player.RecentlyCreatedProjectiles = player.RecentlyCreatedProjectiles.Where(s => s.CreatedAt > threshold).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// These time values are references from Projectile.cs, at npc.AddBuff() calls.
|
// These time values are references from Projectile.cs, at npc.AddBuff() calls.
|
||||||
private static Dictionary<int, short> NPCAddBuffTimeMax = new Dictionary<int, short>()
|
private static Dictionary<int, short> NPCAddBuffTimeMax = new Dictionary<int, short>()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2322,6 +2322,18 @@ namespace TShockAPI
|
||||||
if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player))
|
if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (projectileCreatesLiquid.ContainsKey(type))
|
||||||
|
{
|
||||||
|
lock (args.Player.RecentlyCreatedProjectiles)
|
||||||
|
{
|
||||||
|
args.Player.RecentlyCreatedProjectiles.Add(new ProjectileStruct()
|
||||||
|
{
|
||||||
|
Index = ident,
|
||||||
|
CreatedAt = DateTime.Now
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ using Microsoft.Xna.Framework;
|
||||||
using TShockAPI.Sockets;
|
using TShockAPI.Sockets;
|
||||||
using TShockAPI.CLI;
|
using TShockAPI.CLI;
|
||||||
using TShockAPI.Localization;
|
using TShockAPI.Localization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -1065,19 +1064,9 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
if (player != null && player.TPlayer.whoAmI >= 0)
|
|
||||||
{
|
|
||||||
var threshold = DateTime.Now.AddSeconds(-5);
|
|
||||||
lock (player.RecentlyCreatedProjectiles)
|
|
||||||
{
|
|
||||||
player.RecentlyCreatedProjectiles = player.RecentlyCreatedProjectiles.Where(s => s.CreatedAt > threshold).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bouncer.OnSecondUpdate();
|
||||||
Utils.SetConsoleTitle(false);
|
Utils.SetConsoleTitle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue