Shift tracking of dynamicObjects from strict child objects for Scenes, to tracking the objects but keeping them in the Cleanup Group to fix prefab loading behavior

Shifted to utilizing SimGroupInterator and persistenceManager to fix saving issues with SubScenes
Shifted to utilizing SimGroupIterator for Scene saving to standardize and minimize object misses
Changed prefab load file logic to add loaded child simgroup to rootscene for consistent tracking and avoiding conflicts with subScene's hijacking the ImmediateGroup var
Reduced duplication of build<type>field callback for inspectors
Added more standard field type lookups to inspector group when creating a field to avoid misses for types like 'F32' or similar.
Folded the added-on MinSize/MaxSize/SimgroupSelect fields for SimGroup editing into a single compound field and fixed bugs with it's behavior so it works as expected now
This commit is contained in:
JeffR 2024-10-27 20:04:13 -05:00
parent 484ece3d28
commit 10d1aeca1f
9 changed files with 221 additions and 128 deletions

View file

@ -1,6 +1,7 @@
#include "SubScene.h"
#include "gameMode.h"
#include "console/persistenceManager.h"
#include "console/script.h"
#include "scene/sceneRenderState.h"
#include "renderInstance/renderPassManager.h"
@ -391,34 +392,28 @@ bool SubScene::save()
if (mStartUnloadTimerMS != -1)
mStartUnloadTimerMS = Sim::getCurrentTime();
PersistenceManager prMger;
StringTableEntry levelPath = mLevelAsset->getLevelPath();
for (SimGroup::iterator itr = begin(); itr != end(); itr++)
FileStream fs;
fs.open(levelPath, Torque::FS::File::Write);
fs.close();
for (SimGroupIterator itr(this); *itr; ++itr)
{
//Inform our objects we're saving, so if they do any special stuff
//they can do it before the actual write-out
SimGroup* sg = dynamic_cast<SimGroup*>(*itr);
if (sg)
if ((*itr)->isMethod("onSaving"))
{
ConsoleValue vars[3];
vars[2].setString(mLevelAssetId);
sg->callOnChildren("onSaving", 3, vars);
Con::execute((*itr), 3, vars);
}
SceneObject* scO = dynamic_cast<SceneObject*>(*itr);
if (scO)
{
scO->onSaving_callback(mLevelAssetId);
}
SimObject* sO = static_cast<SimObject*>(*itr);
if (!sO->save(levelPath))
{
Con::errorf("SubScene::save() - error, failed to write object %s to file: %s", sO->getIdString(), levelPath);
return false;
}
prMger.setDirty((*itr), levelPath);
}
prMger.saveDirty();
//process our gameModeList and write it out to the levelAsset for metadata stashing
bool saveSuccess = false;