public static void AddTarget(Transform toAdd, float weighting = 1) { if (Instance == null) { Logger.LogError("AddTarget called but Instance is null"); return; } var trackerTarget = new TrackerTarget(toAdd, weighting); Instance.TargetList.Add(trackerTarget); Instance.UpdateLargestWeight(); Logger.Log($"CameraController.AddTarget: {toAdd}"); }
public override void OnUpdate(int gameTime) { base.OnUpdate(gameTime); if (Game.GameTime - changeTargetTime > 15000) { target = null; var z = Player.Position.Z; for (int x = 1; x < sessionMgr.Current.NumPlayers; x++) { var otherPlayer = sessionMgr.Current.Players[x]; if (Player == otherPlayer.PlayerRef || Player.Info.Sess.TeamNum == otherPlayer.TeamIdx) { continue; } if (Player.Vehicle.Ref.IsOnScreen) { target = null; break; } float dist = Player.Position.DistanceTo(otherPlayer.PlayerRef.Position); if (dist < 1000.0f && Math.Abs(z - otherPlayer.PlayerRef.Position.Z) < 10.0f && !otherPlayer.PlayerRef.Vehicle.Ref.IsDamaged) { if (target == null || dist < target.Distance) { target = new TrackerTarget(otherPlayer.PlayerRef, dist); changeTargetTime = Game.GameTime; /* if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ENTITY, Game.Player.Handle, otherPlayer.PlayerRef.Vehicle.Ref)) * { * break; * }*/ } } } } if (target != null && target.Player.Vehicle.Ref.IsAlive && !target.Player.Vehicle.Ref.IsOnScreen) { DrawTracker(target.Player); } }