SanAndreasUnity/Assets/Scripts/Behaviours/Weapons/NetworkedWeapon.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2019-07-06 15:36:17 +00:00
using UnityEngine;
using Mirror;
using SanAndreasUnity.Utilities;
namespace SanAndreasUnity.Behaviours.Weapons
{
public class NetworkedWeapon : NetworkBehaviour
{
[SyncVar] int m_net_modelId;
[SyncVar] int m_net_ammoInClip;
2019-07-06 15:40:59 +00:00
[SyncVar] int m_net_ammoOutsideOfClip;
2019-07-06 15:50:26 +00:00
[SyncVar] GameObject m_net_pedOwnerGameObject;
2019-07-06 15:36:17 +00:00
public int ModelId { get { return m_net_modelId; } set { m_net_modelId = value; } }
2019-07-06 15:40:59 +00:00
public int AmmoInClip { get { return m_net_ammoInClip; } set { m_net_ammoInClip = value; } }
public int AmmoOutsideOfClip { get { return m_net_ammoOutsideOfClip; } set { m_net_ammoOutsideOfClip = value; } }
2019-07-06 15:50:26 +00:00
public Ped PedOwner { get { return m_net_pedOwnerGameObject != null ? m_net_pedOwnerGameObject.GetComponent<Ped>() : null; } set { m_net_pedOwnerGameObject = value != null ? value.gameObject : null; } }
2019-07-06 15:36:17 +00:00
public override void OnStartClient()
{
base.OnStartClient();
if (NetUtils.IsServer)
return;
// create weapon
F.RunExceptionSafe( () => Weapon.OnCreatedByServer(m_net_modelId) );
}
void Start()
{
}
}
}