2019-04-23 23:59:56 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Mirror;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Behaviours
|
|
|
|
|
{
|
|
|
|
|
public partial class Ped
|
|
|
|
|
{
|
|
|
|
|
[SyncVar(hook=nameof(Net_OnIdChanged))] int m_net_pedId = 0;
|
|
|
|
|
[SyncVar(hook=nameof(Net_OnStateChanged))] string m_net_state = "";
|
|
|
|
|
//[SyncVar] Weapon m_net_weapon = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake_Net()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start_Net()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-24 00:50:28 +00:00
|
|
|
|
public override void OnStartClient()
|
|
|
|
|
{
|
|
|
|
|
base.OnStartClient();
|
|
|
|
|
|
|
|
|
|
if (this.isServer)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-24 13:54:17 +00:00
|
|
|
|
//this.PlayerModel.Load(m_net_pedId);
|
2019-04-24 00:50:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-23 23:59:56 +00:00
|
|
|
|
void Update_Net()
|
|
|
|
|
{
|
2019-04-24 13:54:17 +00:00
|
|
|
|
if (!this.isServer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (this.PedDef != null)
|
|
|
|
|
m_net_pedId = this.PedDef.Id;
|
2019-04-23 23:59:56 +00:00
|
|
|
|
m_net_state = this.CurrentState != null ? this.CurrentState.GetType().Name : "";
|
|
|
|
|
//m_net_weapon = this.CurrentWeapon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Net_OnIdChanged(int newId)
|
|
|
|
|
{
|
|
|
|
|
if (this.isServer)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-24 13:54:17 +00:00
|
|
|
|
Debug.LogFormat("ped id changed to {0}", newId);
|
|
|
|
|
|
2019-04-23 23:59:56 +00:00
|
|
|
|
this.PlayerModel.Load(newId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Net_OnStateChanged(string newState)
|
|
|
|
|
{
|
|
|
|
|
if (this.isServer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|