Add Cooldown to raygun

This commit is contained in:
Sofia 2020-08-08 09:09:34 +03:00
parent d2f59a26fa
commit 4188656855
3 changed files with 14 additions and 1 deletions

View File

@ -655,6 +655,7 @@ MonoBehaviour:
BulletHitLayer:
serializedVersion: 2
m_Bits: 512
Cooldown: 1
Lerpables:
- {fileID: 2566772175078312154}
- {fileID: 1798037817325599949}

View File

@ -12,7 +12,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
private NetChaperone Net;
private Dictionary<ulong, NetPlayer> Players = new Dictionary<ulong, NetPlayer>();
public Dictionary<ulong, NetPlayer> Players { get; private set; } = new Dictionary<ulong, NetPlayer>();
public List<NetPlayer> PlayerList { get; private set; } = new List<NetPlayer>();
private ulong PlayerIdCounter;

View File

@ -29,6 +29,7 @@ namespace NeonTea.Quakeball.Players {
public Transform CameraRoot;
public Transform BulletSourcePoint;
public LayerMask BulletHitLayer;
public float Cooldown;
[Header("Visuals")]
public DesyncLerper[] Lerpables;
@ -87,6 +88,8 @@ namespace NeonTea.Quakeball.Players {
private CharacterController CharacterController;
private Vector3 FeetPosition;
private float LastShot;
/// <summary>Creates a PlayerUpdatePckt representing this Player's current status, for sending to other peers.</summary>
public PlayerUpdatePckt CreateUpdatePacket(ulong id = 0) {
return new PlayerUpdatePckt(MoveDirection, CurrentMoveStyle, Pitch, Yaw, id);
@ -154,6 +157,15 @@ namespace NeonTea.Quakeball.Players {
}
public void Shoot() {
float delta = Time.time - LastShot;
if (Net.Singleton.Instance is Server) {
float ping = ((Server)Net.Singleton.Instance).Players[NetId].Ping;
delta += ping;
}
if (delta < Cooldown) {
return;
}
LastShot = Time.time;
Vector3 GunPoint = BulletSourcePoint.position;
Vector3 ShotDelta = CameraRoot.forward * 1000f;