public static bool UpdateBinaryBlueprint(BinaryBlueprint binaryBlueprint, string[] allPoolNames)
{
var allPools = findAllPools();
if (allPools == null)
{
return(false);
}
var blueprint = binaryBlueprint.Deserialize();
var needsUpdate = false;
var poolIndex = Array.IndexOf(allPoolNames, blueprint.poolIdentifier);
if (poolIndex < 0)
{
poolIndex = 0;
needsUpdate = true;
}
var pool = allPools[poolIndex];
blueprint.poolIdentifier = pool.metaData.poolName;
foreach (var component in blueprint.components)
{
var type = component.fullTypeName.ToType();
var index = Array.IndexOf(pool.metaData.componentTypes, type);
if (index != component.index)
{
Debug.Log(string.Format(
"Blueprint '{0}' has invalid or outdated component index for '{1}'. Index was {2} but should be {3}. This will be fixed now!",
blueprint.name, component.fullTypeName, component.index, index));
component.index = index;
needsUpdate = true;
}
}
if (needsUpdate)
{
Debug.Log("Updating Blueprint '" + blueprint.name + "'");
binaryBlueprint.Serialize(blueprint);
}
return(needsUpdate);
}