Various improvements
This commit is contained in:
@@ -82,6 +82,16 @@ namespace FlaxEditor.States
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if play mode is starting.
|
||||
/// </summary>
|
||||
public bool IsPlayModeStarting;
|
||||
|
||||
/// <summary>
|
||||
/// True if play mode is ending.
|
||||
/// </summary>
|
||||
public bool IsPlayModeEnding;
|
||||
|
||||
internal PlayingState(Editor editor)
|
||||
: base(editor)
|
||||
{
|
||||
@@ -127,6 +137,7 @@ namespace FlaxEditor.States
|
||||
public override void OnEnter()
|
||||
{
|
||||
Profiler.BeginEvent("PlayingState.OnEnter");
|
||||
IsPlayModeStarting = true;
|
||||
Editor.OnPlayBeginning();
|
||||
|
||||
CacheSelection();
|
||||
@@ -150,6 +161,7 @@ namespace FlaxEditor.States
|
||||
RestoreSelection();
|
||||
|
||||
Editor.OnPlayBegin();
|
||||
IsPlayModeStarting = false;
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
@@ -171,6 +183,7 @@ namespace FlaxEditor.States
|
||||
public override void OnExit(State nextState)
|
||||
{
|
||||
Profiler.BeginEvent("PlayingState.OnExit");
|
||||
IsPlayModeEnding = true;
|
||||
Editor.OnPlayEnding();
|
||||
IsPaused = true;
|
||||
|
||||
@@ -194,6 +207,7 @@ namespace FlaxEditor.States
|
||||
RestoreSelection();
|
||||
|
||||
Editor.OnPlayEnd();
|
||||
IsPlayModeEnding = false;
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,12 @@ public:
|
||||
return State == NetworkConnectionState::Connected;
|
||||
}
|
||||
|
||||
// Returns true if network is online or disconnected.
|
||||
API_PROPERTY() FORCE_INLINE static bool IsOffline()
|
||||
{
|
||||
return State == NetworkConnectionState::Offline || State == NetworkConnectionState::Disconnected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the network client for a given connection. Returns null if failed to find it.
|
||||
/// </summary>
|
||||
|
||||
@@ -663,7 +663,7 @@ bool NetworkReplicator::InvokeSerializer(const ScriptingTypeHandle& typeHandle,
|
||||
|
||||
void NetworkReplicator::AddObject(ScriptingObject* obj, ScriptingObject* parent)
|
||||
{
|
||||
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
|
||||
if (!obj || NetworkManager::IsOffline())
|
||||
return;
|
||||
ScopeLock lock(ObjectsLock);
|
||||
if (Objects.Contains(obj))
|
||||
@@ -695,7 +695,7 @@ void NetworkReplicator::AddObject(ScriptingObject* obj, ScriptingObject* parent)
|
||||
|
||||
void NetworkReplicator::RemoveObject(ScriptingObject* obj)
|
||||
{
|
||||
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
|
||||
if (!obj || NetworkManager::IsOffline())
|
||||
return;
|
||||
ScopeLock lock(ObjectsLock);
|
||||
const auto it = Objects.Find(obj->GetID());
|
||||
@@ -715,7 +715,7 @@ void NetworkReplicator::SpawnObject(ScriptingObject* obj)
|
||||
|
||||
void NetworkReplicator::SpawnObject(ScriptingObject* obj, const DataContainer<uint32>& clientIds)
|
||||
{
|
||||
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
|
||||
if (!obj || NetworkManager::IsOffline())
|
||||
return;
|
||||
ScopeLock lock(ObjectsLock);
|
||||
const auto it = Objects.Find(obj->GetID());
|
||||
@@ -730,7 +730,7 @@ void NetworkReplicator::SpawnObject(ScriptingObject* obj, const DataContainer<ui
|
||||
|
||||
void NetworkReplicator::DespawnObject(ScriptingObject* obj)
|
||||
{
|
||||
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
|
||||
if (!obj || NetworkManager::IsOffline())
|
||||
return;
|
||||
ScopeLock lock(ObjectsLock);
|
||||
const auto it = Objects.Find(obj->GetID());
|
||||
@@ -887,7 +887,7 @@ NetworkStream* NetworkReplicator::BeginInvokeRPC()
|
||||
void NetworkReplicator::EndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream)
|
||||
{
|
||||
const NetworkRpcInfo* info = NetworkRpcInfo::RPCsTable.TryGet(NetworkRpcName(type, name));
|
||||
if (!info || !obj)
|
||||
if (!info || !obj || NetworkManager::IsOffline())
|
||||
return;
|
||||
ObjectsLock.Lock();
|
||||
auto& rpc = RpcQueue.AddOne();
|
||||
|
||||
Reference in New Issue
Block a user