/// <summary> /// Constructor. /// </summary> public HeroList() { ints = new IntList(); floats = new FloatList(); bools = new BoolList(); strings = new StringList(); gameObjects = new GameObjectList(); heroObjects = new HeroObjectList(); unityObjects = new UnityObjectList(); }
/// <summary> /// Constructor. /// </summary> /// <param name="list">The hero list to construct.</param> public HeroList(HeroList list) { visible = list.visible; ints = (list.ints == null) ? new IntList() : list.ints.Clone(list.ints); floats = (list.floats == null) ? new FloatList() : list.floats.Clone(list.floats); bools = (list.bools == null) ? new BoolList() : list.bools.Clone(list.bools); strings = (list.strings == null) ? new StringList() : list.strings.Clone(list.strings); gameObjects = (list.gameObjects == null) ? new GameObjectList() : list.gameObjects.Clone(list.gameObjects); heroObjects = (list.heroObjects == null) ? new HeroObjectList() : list.heroObjects.Clone(list.heroObjects); unityObjects = (list.unityObjects == null) ? new UnityObjectList() : list.unityObjects.Clone(list.unityObjects); }
/// <summary> /// Get a value from a unity object field in a hero object template. /// This is for a field that contains Variable, Property, Global. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to the action field.</param> /// <returns>The value from a unity object field.</returns> public static UnityObjectField GetValueC(HeroKitObject heroKitObject, int actionFieldID, HeroObject heroObject) { // exit early if object does not exist if (heroObject == null) { return(null); } // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the item type int itemType = action.actionFields[actionFieldID].ints[3]; UnityObjectField itemValue = new UnityObjectField(); itemValue.sceneID = -1; // Get the slot in the list that contains the item int slotID = action.actionFields[actionFieldID].ints[2] - 1; // Get the lists UnityObjectList targetList = null; string itemTypeName = ""; string heroName = ""; if (itemType == 0) { Debug.LogError("Unity Object type was never specified for " + action.actionTemplate.name + " " + HeroKitCommonRuntime.GetHeroDebugInfo(heroKitObject)); return(null); } if (itemType == 1) { heroName = heroObject.name; itemTypeName = "Variables"; targetList = heroObject.lists.unityObjects; } else if (itemType == 2) { heroName = heroObject.name; itemTypeName = "Properties"; int propertyID = action.actionFields[actionFieldID].ints[6] - 1; if (propertyID < 0) { Debug.LogError("Property slot does not exist!"); } targetList = heroObject.propertiesList.properties[propertyID].itemProperties.unityObjects; } else if (itemType == 3) { heroName = "n/a"; itemTypeName = "Globals"; targetList = HeroKitDatabase.GetGlobals().unityObjects; } // exit early if the slot in the list does not exist if (targetList.items.Count <= slotID || slotID < 0) { Debug.LogError(HeroKitCommonRuntime.NoVariableDebugInfo(action.actionTemplate.name, heroName, itemTypeName, "Hero Object", slotID, 0, heroKitObject)); return(null); } // get the item in the list slot itemValue = itemValue.Clone(targetList.items[slotID]); // Return the item return(itemValue); }