mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 06:34:16 +00:00
Add onStart event to Player
This commit is contained in:
parent
455b9dc04d
commit
30cc4e0384
3 changed files with 26 additions and 8 deletions
|
@ -2,6 +2,7 @@
|
|||
using UnityEngine;
|
||||
using Mirror;
|
||||
using SanAndreasUnity.Behaviours;
|
||||
using SanAndreasUnity.Utilities;
|
||||
|
||||
namespace SanAndreasUnity.Net
|
||||
{
|
||||
|
@ -15,6 +16,8 @@ namespace SanAndreasUnity.Net
|
|||
/// <summary>Local player.</summary>
|
||||
public static Player Local { get; private set; }
|
||||
|
||||
public static event System.Action<Player> onStart = delegate {};
|
||||
|
||||
[SyncVar(hook=nameof(OnOwnedGameObjectChanged))] GameObject m_ownedGameObject;
|
||||
Ped m_ownedPed;
|
||||
//public GameObject OwnedGameObject { get { return m_ownedGameObject; } internal set { m_ownedGameObject = value; } }
|
||||
|
@ -49,7 +52,7 @@ namespace SanAndreasUnity.Net
|
|||
|
||||
void Start()
|
||||
{
|
||||
|
||||
F.InvokeEventExceptionSafe(onStart, this);
|
||||
}
|
||||
|
||||
void OnOwnedGameObjectChanged(GameObject newGo)
|
||||
|
|
|
@ -361,6 +361,27 @@ namespace SanAndreasUnity.Utilities
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes all subscribed delegates, and makes sure any exception is caught and logged, so that all
|
||||
/// subscribers will get notified.
|
||||
/// </summary>
|
||||
public static void InvokeEventExceptionSafe( MulticastDelegate eventDelegate, params object[] parameters )
|
||||
{
|
||||
RunExceptionSafe( () => {
|
||||
var delegates = eventDelegate.GetInvocationList ();
|
||||
|
||||
foreach (var del in delegates) {
|
||||
if (del.Method != null) {
|
||||
try {
|
||||
del.Method.Invoke (del.Target, parameters);
|
||||
} catch(System.Exception ex) {
|
||||
UnityEngine.Debug.LogException (ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void SendMessageToObjectsOfType<T> (string msg, params object[] args) where T : UnityEngine.Object
|
||||
{
|
||||
var objects = UnityEngine.Object.FindObjectsOfType<T> ();
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
|
||||
|
||||
# What needs to be done before starting work on multiplayer
|
||||
|
||||
- create windows for: start new game ; join game ;
|
||||
|
||||
- all scripts should work when Camera.main is null
|
||||
|
||||
- killing local ped
|
||||
# TODO
|
||||
|
||||
- scene changing: When network (server/client) is stopped, offline scene should be loaded. But, when switching back to online scene, Loader should not load everything again. Instead, only Cell loading should be done, if the new scene is main scene. But, are old meshes/textures destroyed ? Do we leave memory behind, every time when network is stopped ? Or... just exit the game when network is stopped (display message box first ?).
|
||||
|
||||
|
|
Loading…
Reference in a new issue