Esempio n. 1
0
 public static void AddToConversationTable(List <Conversation> conversations, List <DialogueDatabase> loadedDatabases)
 {
     foreach (Conversation conversation in conversations)
     {
         if (!DialogueDatabase.Contains(loadedDatabases, conversation))
         {
             SetFields(string.Format("Conversation[{0}]", new System.Object[] { conversation.id }), conversation.fields, "Dialog = {}");
         }
     }
     if (!includeSimStatus)
     {
         return;
     }
     foreach (Conversation conversation in conversations)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendFormat("Conversation[{0}].Dialog = {{ ", new System.Object[] { conversation.id });
         foreach (DialogueEntry dialogueEntry in conversation.dialogueEntries)
         {
             // [NOTE] To reduce Lua memory use, we only record SimStatus of dialogue entries:
             sb.AppendFormat("[{0}]={{SimStatus=\"Untouched\"}},", new System.Object[] { dialogueEntry.id });
         }
         sb.Append('}');
         bool luaExceptionOccurred = false;
         try {
             Lua.Run(sb.ToString(), false, true);
         } catch (System.Exception) {
             luaExceptionOccurred = true;
         }
         if (luaExceptionOccurred && DialogueDebug.LogErrors)
         {
             Debug.LogError(string.Format("{0}: LuaExceptions above indicate a dialogue database inconsistency. Is an invalid conversation ID recorded in a dialogue entry?", new System.Object[] { DialogueDebug.Prefix }));
         }
     }
 }
Esempio n. 2
0
 private static void AddToVariableTable(List <Variable> variables, List <DialogueDatabase> loadedDatabases)
 {
     foreach (Variable variable in variables)
     {
         if (!DialogueDatabase.Contains(loadedDatabases, variable))
         {
             Lua.Run(string.Format("Variable[\"{0}\"] = {1}", new System.Object[] { StringToTableIndex(variable.Name), ValueAsString(variable.Type, variable.InitialValue) }), DialogueDebug.LogInfo);
         }
     }
 }
Esempio n. 3
0
 private static void AddToTable <T>(string arrayName, List <T> assets, List <DialogueDatabase> loadedDatabases) where T : Asset
 {
     foreach (T asset in assets)
     {
         if (!DialogueDatabase.Contains(loadedDatabases, asset))
         {
             SetFields(string.Format("{0}[\"{1}\"]", new System.Object[] { arrayName, StringToTableIndex(asset.Name) }), asset.fields);
         }
     }
 }
Esempio n. 4
0
 private static void RemoveFromTable <T>(string arrayName, List <T> assets, List <DialogueDatabase> loadedDatabases) where T : Asset
 {
     foreach (T asset in assets)
     {
         if (!DialogueDatabase.Contains(loadedDatabases, asset))
         {
             if (asset is Conversation)
             {
                 Lua.Run(string.Format("{0}[{1}] = nil", new System.Object[] { arrayName, asset.id }), DialogueDebug.LogInfo);
             }
             else
             {
                 Lua.Run(string.Format("{0}[\"{1}\"] = nil", new System.Object[] { arrayName, StringToTableIndex(asset.Name) }), DialogueDebug.LogInfo);
             }
         }
     }
 }