Modified how scripts are added and updated to support runtime adding of scripts
This commit is contained in:
parent
23320863e3
commit
af361062e7
|
@ -73,8 +73,16 @@ namespace SHADE
|
|||
|
||||
// Add the script in
|
||||
entityScriptList->Insert(System::Math::Clamp(index, 0, entityScriptList->Count), script);
|
||||
awakeList.Add(script);
|
||||
startList.Add(script);
|
||||
if (Application::IsPlaying)
|
||||
{
|
||||
script->Awake();
|
||||
script->Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
awakeList.Add(script);
|
||||
startList.Add(script);
|
||||
}
|
||||
script->OnAttached();
|
||||
|
||||
return script;
|
||||
|
@ -451,9 +459,10 @@ namespace SHADE
|
|||
continue;
|
||||
|
||||
// Update each script
|
||||
for each (Script^ script in entity.Value)
|
||||
ScriptList^ scripts = entity.Value;
|
||||
for (int i = 0; i < scripts->Count; ++i)
|
||||
{
|
||||
script->FixedUpdate();
|
||||
scripts[i]->FixedUpdate();
|
||||
}
|
||||
}
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
@ -468,9 +477,10 @@ namespace SHADE
|
|||
continue;
|
||||
|
||||
// Update each script
|
||||
for each (Script^ script in entity.Value)
|
||||
ScriptList^ scripts = entity.Value;
|
||||
for (int i = 0; i < scripts->Count; ++i)
|
||||
{
|
||||
script->Update();
|
||||
scripts[i]->Update();
|
||||
}
|
||||
}
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
@ -485,9 +495,10 @@ namespace SHADE
|
|||
continue;
|
||||
|
||||
// Update each script
|
||||
for each (Script^ script in entity.Value)
|
||||
ScriptList^ scripts = entity.Value;
|
||||
for (int i = 0; i < scripts->Count; ++i)
|
||||
{
|
||||
script->LateUpdate();
|
||||
scripts[i]->LateUpdate();
|
||||
}
|
||||
}
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
@ -503,9 +514,10 @@ namespace SHADE
|
|||
continue;
|
||||
|
||||
// Update each script
|
||||
for each (Script^ script in entity.Value)
|
||||
ScriptList^ scripts = entity.Value;
|
||||
for (int i = 0; i < scripts->Count; ++i)
|
||||
{
|
||||
script->OnDrawGizmos();
|
||||
scripts[i]->OnDrawGizmos();
|
||||
}
|
||||
}
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
@ -537,8 +549,9 @@ namespace SHADE
|
|||
auto entityScripts = scripts[entity.first];
|
||||
if (entityScripts->Count > 0)
|
||||
{
|
||||
for each (Script ^ script in entityScripts)
|
||||
for (int i = 0; i < entityScripts->Count; ++i)
|
||||
{
|
||||
Script^ script = entityScripts[i];
|
||||
switch (collisionInfo.GetCollisionState())
|
||||
{
|
||||
case SHCollisionEvent::State::ENTER:
|
||||
|
@ -578,8 +591,9 @@ namespace SHADE
|
|||
auto entityScripts = scripts[entity.first];
|
||||
if (entityScripts->Count > 0)
|
||||
{
|
||||
for each (Script ^ script in entityScripts)
|
||||
for (int i = 0; i < entityScripts->Count; ++i)
|
||||
{
|
||||
Script^ script = entityScripts[i];
|
||||
switch (triggerInfo.GetCollisionState())
|
||||
{
|
||||
case SHCollisionEvent::State::ENTER:
|
||||
|
|
Loading…
Reference in New Issue