public static List <QuestAction> CreateList(QuestActionProxy[] actionListProxy) { var list = new List <QuestAction>(); if (actionListProxy == null) { Debug.LogWarning("Quest Machine: QuestActionProxy.CreateList source is null."); return(list); } for (int i = 0; i < actionListProxy.Length; i++) { var actionProxy = actionListProxy[i]; if (actionProxy == null || string.IsNullOrEmpty(actionProxy.t) || string.IsNullOrEmpty(actionProxy.s)) { continue; } var action = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(actionProxy.t)) as QuestAction; if (action != null) { JsonUtility.FromJsonOverwrite(actionProxy.s, action); action.OnAfterProxyDeserialization(); list.Add(action); } } return(list); }
public static System.Type GetWrapperType(System.Type type) { try { if (string.Equals(type.Namespace, "PixelCrushers.QuestMachine")) { var wrapperName = "PixelCrushers.QuestMachine.Wrappers." + type.Name; var assemblies = RuntimeTypeUtility.GetAssemblies(); foreach (var assembly in assemblies) { try { var wrapperList = (from assemblyType in assembly.GetExportedTypes() where string.Equals(assemblyType.FullName, wrapperName) select assemblyType).ToArray(); if (wrapperList.Length > 0) { return(wrapperList[0]); } } catch (System.Exception) { // Ignore exceptions and try next assembly. } } } } catch (System.Exception) { // Ignore exceptions. } return(null); }
private static List <Type> FindAllDerivedTypes <T>() { var list = new List <Type>(); try { var derivedType = typeof(T); var assemblies = RuntimeTypeUtility.GetAssemblies(); foreach (var assembly in assemblies) { try { var wrapperList = (from assemblyType in assembly.GetExportedTypes() where derivedType.IsAssignableFrom(assemblyType) && assemblyType != derivedType select assemblyType).ToArray(); list.AddRange(wrapperList); } catch (System.Exception) { // If error, ignore assembly and move on. } } } catch (Exception e) { Debug.LogWarning("Dialogue Editor: FindAllDerivedTypes error: " + e.Message + ". Please contact [email protected]."); } return(list); }
public static List <QuestContent> CreateList(QuestContentProxy[] contentListProxy) { var list = new List <QuestContent>(); if (contentListProxy == null) { Debug.LogWarning("Quest Machine: QuestContentProxy.CreateList source is null."); return(list); } for (int i = 0; i < contentListProxy.Length; i++) { var contentProxy = contentListProxy[i]; if (contentProxy == null || string.IsNullOrEmpty(contentProxy.t) || string.IsNullOrEmpty(contentProxy.s)) { continue; } QuestContent content = null; if (string.Equals(contentProxy.t, HeadingTypeString)) { content = ScriptableObject.CreateInstance <HeadingTextQuestContent>(); ApplyHeadingTextQuestContentProxyData(content as HeadingTextQuestContent, contentProxy.s); } else if (string.Equals(contentProxy.t, BodyTypeString)) { content = ScriptableObject.CreateInstance <BodyTextQuestContent>(); ApplyBodyTextQuestContentProxyData(content as BodyTextQuestContent, contentProxy.s); } else if (string.Equals(contentProxy.t, IconTypeString)) { content = ScriptableObject.CreateInstance <IconQuestContent>(); ApplyIconQuestContentProxyData(content as IconQuestContent, contentProxy.s); } else if (string.Equals(contentProxy.t, ButtonTypeString)) { content = ScriptableObject.CreateInstance <ButtonQuestContent>(); ApplyButtonQuestContentProxyData(content as ButtonQuestContent, contentProxy.s); } else { content = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(contentProxy.t)) as QuestContent; if (content != null) { JsonUtility.FromJsonOverwrite(contentProxy.s, content); } } if (content != null) { content.OnAfterProxyDeserialization(); list.Add(content); } } return(list); }
public static DialogueDatabase CreateDialogueDatabaseInstance(bool createDefaultAssets = false) { var template = Template.FromDefault(); var wrapperType = RuntimeTypeUtility.GetWrapperType(typeof(DialogueDatabase)) ?? typeof(DialogueDatabase); var database = ScriptableObjectUtility.CreateScriptableObject(wrapperType) as DialogueDatabase; database.ResetEmphasisSettings(); if (createDefaultAssets) { database.actors.Add(template.CreateActor(1, "Player", true)); database.variables.Add(template.CreateVariable(1, "Alert", string.Empty)); } return(database); }
public static List <QuestCondition> CreateList(QuestConditionProxy[] conditionsProxy) { var list = new List <QuestCondition>(); if (conditionsProxy == null) { Debug.LogWarning("Quest Machine: QuestConditionProxy.CreateList source is null."); return(list); } for (int i = 0; i < conditionsProxy.Length; i++) { var conditionProxy = conditionsProxy[i]; if (conditionProxy == null || string.IsNullOrEmpty(conditionProxy.t) || string.IsNullOrEmpty(conditionProxy.s)) { continue; } QuestCondition condition = null; if (string.Equals(conditionProxy.t, CounterTypeString)) { condition = ScriptableObject.CreateInstance <CounterQuestCondition>(); ApplyCounterQuestConditionProxyData(condition as CounterQuestCondition, conditionProxy.s); } else if (string.Equals(conditionProxy.t, MessageTypeString)) { condition = ScriptableObject.CreateInstance <MessageQuestCondition>(); ApplyMessageQuestConditionProxyData(condition as MessageQuestCondition, conditionProxy.s); } else if (string.Equals(conditionProxy.t, TimerTypeString)) { condition = ScriptableObject.CreateInstance <TimerQuestCondition>(); ApplyTimerQuestConditionProxyData(condition as TimerQuestCondition, conditionProxy.s); } else { condition = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(conditionProxy.t)) as QuestCondition; if (condition != null) { JsonUtility.FromJsonOverwrite(conditionProxy.s, condition); } } if (condition != null) { condition.OnAfterProxyDeserialization(); list.Add(condition); } } return(list); }
protected override void CreateNewAsset(List <AssetInfo> assetInfoList) { // Create a list of all urgency function types, excluding abstract types and // types that have wrappers: var list = new List <System.Type>(); var assemblies = RuntimeTypeUtility.GetAssemblies(); foreach (var assembly in assemblies) { try { var assemblyList = (from assemblyType in assembly.GetExportedTypes() where typeof(UrgencyFunction).IsAssignableFrom(assemblyType) select assemblyType).ToArray(); list.AddRange(assemblyList); } catch (System.Exception) { // Ignore exceptions and move on to next assembly. } } var menu = new GenericMenu(); for (int i = 0; i < list.Count; i++) { var type = list[i]; if (type == null) { continue; } if (type.IsAbstract) { continue; } if (QuestEditorUtility.HasWrapperType(type)) { continue; } menu.AddItem(new GUIContent(type.Name), false, OnClickNewUrgencyFunction, type); } menu.ShowAsContext(); }
private static void AddAllSequencerCommands(GenericMenu menu) { var list = new List <string>(InternalSequencerCommands); var assemblies = RuntimeTypeUtility.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { var assembly = assemblies[i]; try { foreach (var type in assembly.GetTypes().Where(t => typeof(PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommand).IsAssignableFrom(t))) { var commandName = type.Name.Substring("SequencerCommand".Length); list.Add(commandName); } } catch (System.Exception) { } } list.Sort(); for (int i = 0; i < list.Count; i++) { menu.AddItem(new GUIContent("All Sequencer Commands/" + list[i]), false, StartSequencerCommand, list[i]); } }