Remove ForceFullUpdate, rework entity lifecycle, move skill selection to round end
This commit is contained in:
parent
a5c0e3ca4b
commit
4b42670804
8 changed files with 251 additions and 216 deletions
|
|
@ -333,76 +333,6 @@ namespace src.utils
|
|||
return EntityManager.CreateTrackedTrigger(ownerPlayerIndex, name, radius, pos);
|
||||
}
|
||||
|
||||
public static void ForceFullUpdate(CCSPlayerController player, List<(uint PlayerIndex, QAngle LastAngle)>? batchList = null, INetworkGameServer? networkGameServer = null)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var pawn = player.PlayerPawn?.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
|
||||
|
||||
QAngle lastAngle = new(pawn.V_angle.X, pawn.V_angle.Y, pawn.V_angle.Z);
|
||||
|
||||
networkGameServer ??= new INetworkServerService().GetIGameServer();
|
||||
|
||||
var client = networkGameServer.GetClientBySlot(player.Slot);
|
||||
if (client == null) return;
|
||||
|
||||
client.ForceFullUpdate();
|
||||
// Only skip the angle restore when the captured view is a spawn-time (0,0,0) placeholder;
|
||||
// a genuine angle with a single zero component (e.g. yaw exactly 0) must still be restored.
|
||||
if (lastAngle.X == 0 && lastAngle.Y == 0 && lastAngle.Z == 0) return;
|
||||
|
||||
uint playerIndex = player.Index;
|
||||
|
||||
if (batchList != null)
|
||||
{
|
||||
batchList.Add((playerIndex, lastAngle));
|
||||
return;
|
||||
}
|
||||
|
||||
jRandomSkills.Instance.AddTickTimer(3, () =>
|
||||
{
|
||||
var target = Utilities.GetPlayerFromIndex((int)playerIndex);
|
||||
if (target == null || !target.IsValid) return;
|
||||
|
||||
var targetPawn = target.PlayerPawn?.Value;
|
||||
if (targetPawn == null || !targetPawn.IsValid || targetPawn.AbsOrigin == null) return;
|
||||
|
||||
targetPawn.Look(lastAngle);
|
||||
});
|
||||
}
|
||||
|
||||
private static int lastForceFullUpdateAll = int.MinValue;
|
||||
|
||||
public static void ForceFullUpdateToAll()
|
||||
{
|
||||
int tickCount = Server.TickCount;
|
||||
if (tickCount == lastForceFullUpdateAll) return;
|
||||
|
||||
lastForceFullUpdateAll = tickCount;
|
||||
var playersToRestore = new List<(uint PlayerIndex, QAngle LastAngle)>();
|
||||
|
||||
INetworkGameServer networkGameServer = new INetworkServerService().GetIGameServer();
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
ForceFullUpdate(player, playersToRestore, networkGameServer);
|
||||
|
||||
if (playersToRestore.Count <= 0) return;
|
||||
|
||||
jRandomSkills.Instance.AddTickTimer(3, () =>
|
||||
{
|
||||
foreach (var item in playersToRestore)
|
||||
{
|
||||
var target = Utilities.GetPlayerFromIndex((int)item.PlayerIndex);
|
||||
if (target == null || !target.IsValid) continue;
|
||||
|
||||
var targetPawn = target.PlayerPawn?.Value;
|
||||
if (targetPawn == null || !targetPawn.IsValid || targetPawn.AbsOrigin == null) continue;
|
||||
|
||||
targetPawn.Look(item.LastAngle);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static bool SetHealth(CCSPlayerPawn? pawn, int newHealth, int? maxHealth = null)
|
||||
{
|
||||
if (pawn == null || !pawn.IsValid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue