Inheritance: UnityEngine.ScriptableObject
        public static bool UpdateBinaryBlueprint(BinaryBlueprint binaryBlueprint, Context[] allContexts, string[] allContextNames)
        {
            var blueprint = binaryBlueprint.Deserialize();
            var needsUpdate = false;

            var contextIndex = Array.IndexOf(allContextNames, blueprint.contextIdentifier);
            if(contextIndex < 0) {
                contextIndex = 0;
                needsUpdate = true;
            }

            var context = allContexts[contextIndex];
            blueprint.contextIdentifier = context.contextInfo.name;

            foreach(var component in blueprint.components) {
                var type = component.fullTypeName.ToType();
                var index = Array.IndexOf(context.contextInfo.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;
        }
        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);
        }
Example #3
0
        public static bool UpdateBinaryBlueprint(BinaryBlueprint binaryBlueprint, Context[] allContexts, string[] allContextNames)
        {
            var blueprint   = binaryBlueprint.Deserialize();
            var needsUpdate = false;

            var contextIndex = Array.IndexOf(allContextNames, blueprint.contextIdentifier);

            if (contextIndex < 0)
            {
                contextIndex = 0;
                needsUpdate  = true;
            }

            var context = allContexts[contextIndex];

            blueprint.contextIdentifier = context.contextInfo.name;

            foreach (var component in blueprint.components)
            {
                var type  = component.fullTypeName.ToType();
                var index = Array.IndexOf(context.contextInfo.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);
        }
        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;
        }