2019-05-25 23:51:29 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
using SanAndreasUnity.Behaviours;
|
2021-01-05 02:10:00 +00:00
|
|
|
using SanAndreasUnity.Behaviours.Peds;
|
2019-05-25 23:51:29 +00:00
|
|
|
using SanAndreasUnity.Behaviours.Vehicles;
|
2020-06-06 18:04:10 +00:00
|
|
|
using SanAndreasUnity.Utilities;
|
2019-05-25 23:51:29 +00:00
|
|
|
|
|
|
|
namespace SanAndreasUnity.Stats
|
|
|
|
{
|
|
|
|
public class MiscStats : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
Utilities.Stats.RegisterStat(new Utilities.Stats.Entry(){category = "MISC", onGUI = OnStatGUI});
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnStatGUI()
|
|
|
|
{
|
|
|
|
|
2019-06-23 21:00:35 +00:00
|
|
|
var sb = new System.Text.StringBuilder();
|
|
|
|
|
2019-07-06 20:43:10 +00:00
|
|
|
sb.AppendFormat("num peds: {0}\n", Ped.NumPeds);
|
|
|
|
sb.AppendFormat("num vehicles: {0}\n", Vehicle.NumVehicles);
|
2021-01-05 02:10:00 +00:00
|
|
|
sb.AppendFormat("num dead bodies: {0}\n", DeadBody.NumDeadBodies);
|
2021-01-08 01:57:39 +00:00
|
|
|
sb.AppendFormat("num bones in dead bodies: {0}\n", DeadBody.DeadBodies.Sum(db => db.NumBones));
|
2021-01-08 02:00:03 +00:00
|
|
|
sb.AppendFormat("num rigid bodies in dead bodies: {0}\n", DeadBody.DeadBodies.Sum(db => db.NumRigidBodies));
|
2019-07-06 20:43:10 +00:00
|
|
|
sb.AppendFormat("num ped state changes received: {0}\n", Ped.NumStateChangesReceived);
|
|
|
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
2019-06-23 21:00:35 +00:00
|
|
|
// info about local ped
|
|
|
|
|
|
|
|
var ped = Ped.Instance;
|
|
|
|
if (ped != null)
|
|
|
|
{
|
2019-07-06 20:59:48 +00:00
|
|
|
sb.AppendFormat("Local ped:\n");
|
2019-06-23 21:00:35 +00:00
|
|
|
sb.AppendFormat("position: {0}\n", ped.transform.position);
|
|
|
|
sb.AppendFormat("net id: {0}\n", ped.netId);
|
|
|
|
sb.AppendFormat("sync interval: {0}\n", ped.NetTransform.syncInterval);
|
|
|
|
sb.AppendFormat("state: {0}\n", ped.CurrentState != null ? ped.CurrentState.GetType().Name : "");
|
|
|
|
sb.AppendFormat("velocity: {0}\n", ped.Velocity);
|
|
|
|
sb.AppendFormat("is grounded: {0}\n", ped.IsGrounded);
|
2020-03-21 23:29:54 +00:00
|
|
|
sb.AppendFormat("vehicle offset: {0}\n", ped.PlayerModel.VehicleParentOffset);
|
2019-06-23 21:00:35 +00:00
|
|
|
sb.AppendFormat("model id: {0}\n", ped.PedDef != null ? ped.PedDef.Id.ToString() : "");
|
|
|
|
sb.AppendFormat("model name: {0}\n", ped.PedDef != null ? ped.PedDef.ModelName : "");
|
|
|
|
sb.AppendFormat("\n");
|
|
|
|
|
|
|
|
// info about current vehicle
|
|
|
|
|
|
|
|
var vehicle = ped.CurrentVehicle;
|
|
|
|
if (vehicle != null)
|
|
|
|
{
|
|
|
|
List<System.Object> objects = new List<System.Object>(){
|
|
|
|
vehicle.Velocity,
|
|
|
|
vehicle.Accelerator,
|
|
|
|
vehicle.Braking,
|
|
|
|
vehicle.Steering,
|
|
|
|
vehicle.AverageWheelHeight,
|
|
|
|
vehicle.NetTransform.netId,
|
|
|
|
vehicle.NetTransform.syncInterval,
|
|
|
|
vehicle.NetTransform.ComponentIndex,
|
|
|
|
};
|
|
|
|
|
|
|
|
var texts = new List<string>() {"velocity", "accelerator", "braking", "steering", "average wheel height",
|
|
|
|
"net id", "sync interval", "component index"};
|
|
|
|
|
|
|
|
|
|
|
|
texts.Add("wheels");
|
|
|
|
objects.Add("");
|
|
|
|
foreach (var w in vehicle.Wheels)
|
|
|
|
{
|
|
|
|
texts.Add("\t" + w.Alignment);
|
|
|
|
objects.Add( string.Format("travel {0} rpm {1} radius {2} motor torque {3} mass {4} is grounded {5}",
|
|
|
|
w.Travel, w.Collider.rpm, w.Collider.radius, w.Collider.motorTorque, w.Collider.mass, w.Collider.isGrounded) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicle.Definition != null)
|
|
|
|
{
|
|
|
|
var def = vehicle.Definition;
|
|
|
|
texts.Add("game name");
|
|
|
|
texts.Add("type");
|
|
|
|
objects.Add(def.GameName);
|
|
|
|
objects.Add(def.VehicleType);
|
|
|
|
}
|
|
|
|
|
|
|
|
texts.Add("rigid body");
|
|
|
|
objects.Add("");
|
|
|
|
if (vehicle.RigidBody != null)
|
|
|
|
{
|
|
|
|
var rb = vehicle.RigidBody;
|
|
|
|
texts.AddRange(new string[]{"\tmass", "\tvelocity", "\tangular velocity"});
|
|
|
|
objects.AddRange(new object[]{rb.mass, rb.velocity, rb.angularVelocity});
|
|
|
|
}
|
|
|
|
|
|
|
|
texts.Add("seats");
|
|
|
|
objects.Add("");
|
|
|
|
foreach(var seat in vehicle.Seats)
|
|
|
|
{
|
|
|
|
texts.Add("\t" + seat.Alignment);
|
|
|
|
var p = seat.OccupyingPed;
|
|
|
|
objects.Add(p != null ? ("ped: net id " + p.netId) : "empty");
|
|
|
|
}
|
|
|
|
|
|
|
|
var closestSeat = vehicle.FindClosestSeatTransform(ped.transform.position);
|
|
|
|
if (closestSeat != null)
|
|
|
|
{
|
|
|
|
texts.Add("distance to closest seat");
|
|
|
|
objects.Add(Vector3.Distance(closestSeat.position, ped.transform.position));
|
|
|
|
}
|
|
|
|
|
2020-06-21 14:35:39 +00:00
|
|
|
// damage
|
|
|
|
|
|
|
|
texts.Add("damage");
|
|
|
|
objects.Add("");
|
|
|
|
|
|
|
|
texts.AddRange(new string[] { "\thealth", "\tmax health", "\tis under flame", "\tis under smoke", "\ttime since became under flame" });
|
|
|
|
objects.AddRange(new object[] { vehicle.Health, vehicle.MaxHealth, vehicle.IsUnderFlame, vehicle.IsUnderSmoke, vehicle.TimeSinceBecameUnderFlame });
|
|
|
|
|
2020-05-05 12:02:35 +00:00
|
|
|
// radio
|
|
|
|
|
|
|
|
texts.Add("radio");
|
|
|
|
objects.Add("");
|
|
|
|
|
|
|
|
texts.AddRange(new string[] { "\tis playing", "\tstation index", "\tis waiting for new sound" });
|
|
|
|
objects.AddRange(new object[] { vehicle.IsPlayingRadio, vehicle.CurrentRadioStationIndex, vehicle.IsWaitingForNewRadioSound });
|
|
|
|
|
|
|
|
if (vehicle.RadioAudioSource != null && vehicle.RadioAudioSource.clip != null)
|
|
|
|
{
|
|
|
|
var clip = vehicle.RadioAudioSource.clip;
|
|
|
|
texts.AddRange(new string[] { "\tclip time", "\tclip length", "\tclip size" });
|
|
|
|
objects.AddRange(new object[] { vehicle.RadioAudioSource.time, clip.length, (Utilities.F.GetAudioClipSizeInBytes(clip) / 1024.0f) + " KB" });
|
|
|
|
}
|
|
|
|
|
2019-06-23 21:00:35 +00:00
|
|
|
|
|
|
|
sb.AppendFormat("Current vehicle:\n");
|
|
|
|
for (int i = 0; i < objects.Count; i++)
|
|
|
|
{
|
|
|
|
sb.AppendFormat("{0}: {1}\n", texts[i], objects[i]);
|
|
|
|
}
|
2019-06-23 22:04:17 +00:00
|
|
|
sb.AppendFormat("\n");
|
2019-06-23 21:00:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-06 20:59:48 +00:00
|
|
|
// info about current weapon
|
|
|
|
var weapon = ped.CurrentWeapon;
|
|
|
|
if (weapon != null)
|
|
|
|
{
|
|
|
|
sb.AppendFormat("Current weapon:\n");
|
|
|
|
|
|
|
|
sb.AppendFormat("net id: {0}\n", weapon.NetWeapon.netId);
|
|
|
|
|
|
|
|
var def = weapon.Definition;
|
|
|
|
if (def != null)
|
|
|
|
{
|
|
|
|
sb.AppendFormat("model id: {0}\n", def.Id);
|
|
|
|
sb.AppendFormat("name: {0}\n", def.ModelName);
|
|
|
|
}
|
|
|
|
|
|
|
|
sb.AppendFormat("max range: {0}\n", weapon.MaxRange);
|
|
|
|
sb.AppendFormat("damage: {0}\n", weapon.Damage);
|
|
|
|
sb.AppendFormat("ammo clip size: {0}\n", weapon.AmmoClipSize);
|
|
|
|
sb.AppendFormat("ammo: {0} / {1}\n", weapon.AmmoInClip, weapon.AmmoOutsideOfClip);
|
|
|
|
sb.AppendFormat("slot: {0}\n", weapon.SlotIndex);
|
|
|
|
|
|
|
|
sb.AppendLine();
|
|
|
|
}
|
|
|
|
|
2019-07-06 21:18:02 +00:00
|
|
|
// info about all weapons
|
|
|
|
sb.AppendFormat("All weapons:\n");
|
|
|
|
foreach (var w in ped.WeaponHolder.AllWeapons)
|
|
|
|
{
|
|
|
|
sb.AppendFormat("\tslot: {0} name: {1}\n", w.SlotIndex, w.Definition.ModelName);
|
|
|
|
}
|
|
|
|
sb.AppendLine();
|
|
|
|
|
2019-06-23 21:00:35 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 18:04:10 +00:00
|
|
|
// on-screen messages
|
|
|
|
sb.AppendFormat("num on-screen messages: {0}\n", OnScreenMessageManager.Instance.Messages.Count);
|
|
|
|
sb.AppendFormat("num pooled on-screen messages: {0}\n", OnScreenMessageManager.Instance.NumPooledMessages);
|
|
|
|
|
|
|
|
|
2019-06-23 22:04:17 +00:00
|
|
|
GUILayout.Label(sb.ToString());
|
2019-06-23 21:00:35 +00:00
|
|
|
|
2019-05-25 23:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|