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