public SubactionVarData(string _name, SubactionSource _source, SubactionVarType _type, string _data, string desc = "", bool _editable = true) { name = _name; source = _source; type = _type; data = _data; editable = _editable; description = desc; }
public void SetSourceString(string sourceString) { if (sourceString == "Constant") { source = SubactionSource.CONSTANT; } else if (sourceString == "Owner") { source = SubactionSource.OWNER; } else if (sourceString == "Action") { source = SubactionSource.ACTION; } else { Debug.LogError("Invalid source passed to SubactionVarData: " + sourceString); } }
void Update() { if (popup == null) { return; //This can sometimes get called before Awake. Somehow. } if (panel.varData.source != lastSource) { lastSource = panel.varData.source; switch (panel.varData.source) { case SubactionSource.OWNER: PopulateList(fighterList); break; case SubactionSource.ACTION: break; default: break; } } }
public void init(SubactionVarData varData, SubactionSource source) { varDataToEdit = varData; sourceToSet = source; }
public override void execute() { previousSource = varDataToEdit.source; varDataToEdit.source = sourceToSet; LegacyEditorData.instance.FireModelChange(); }
/// <summary> /// Given a line containing the definition of a SubactionData, return that SubactionData as an object. /// This uses reflection to get the Subactions, so the spelling of the SubName is key. /// </summary> /// <param name="line">The line being parsed</param> /// <returns>A proper SubactionData object, ready for injecting into a Dynamic Action</returns> private static SubactionData processSubactionLine(string line, int lineNumber) { string[] startParenSplit = line.Split('('); //This string should contain EXACTLY one parenthesis pair. Any more or less and you f****d up your script, dawg if (startParenSplit.Length != 2 || !line.EndsWith(")")) { //Debug.Log(startParenSplit.Length); //Debug.Log(line.EndsWith(")")); throwException("Incorrect parenthesis in subDataLine: " + line, lineNumber); return(null); } string subDataName = startParenSplit[0]; string argList = startParenSplit[1].Substring(0, startParenSplit[1].Length - 1); //Debug.Log(string.Format("PARSING SUBACTION {0}\n\tArguments: {1}",subDataName,argList)); SubactionDataDefault subDataDef = Resources.Load <SubactionDataDefault>("SubactionData/" + subDataName); if (subDataDef != null) { SubactionData subData = subDataDef.CreateSubactionData(); string[] splitArgs = new string[0]; if (argList.Length > 0) { splitArgs = argList.Split(','); } if (subDataDef.scriptArgNames.Count != splitArgs.Length) { throwException(string.Format("Subaction {0} has {1} arguments, expecting {2}", subDataName, splitArgs.Length, subDataDef.scriptArgNames.Count), lineNumber); return(null); } for (int i = 0; i < splitArgs.Length; i++) { string argumentName = subDataDef.scriptArgNames[i]; SubactionSource source = SubactionSource.CONSTANT; if (splitArgs[i].StartsWith("owner.")) { source = SubactionSource.OWNER; splitArgs[i] = splitArgs[i].Substring("owner.".Length); } else if (splitArgs[i].StartsWith("action.")) { source = SubactionSource.ACTION; splitArgs[i] = splitArgs[i].Substring("action.".Length); } SubactionVarType varType = subDataDef.arguments[argumentName].type; SubactionVarData argVarData = new SubactionVarData(argumentName, source, varType, splitArgs[i]); subData.arguments[argumentName] = argVarData; } return(subData); } else { throwException("No Subaction found with name " + subDataName, lineNumber); } return(null); }