Exemple #1
0
        public void EffectsFromSQLResults(AbstractRunnable sender, FinishedQueueEventHandlerArgs e)
        {
            lock (loadLock)
            {
                sqlResults = e.GetSQLResults();

                // return if there is nothing to process
                if ((sqlResults == null) || (sqlResults.Count < 2))
                {
                    return;
                }

                // convert the data-strings to their respective types
                ConvertSQLResults(sqlResults, colGetTypeInfo);

                var tableEffect = sqlResults[DBTableLoadOrder.IndexOf("Effect")];
                var tableChange = sqlResults[DBTableLoadOrder.IndexOf("Change")];

                List <IDAndChanges> idAndChangesList = null;
                if (!TryGenerateIDAndChanges(tableChange, out idAndChangesList))
                {
                    MakeLogError("Aborting effect generation due to"
                                 + " failed generation of Changes from raw database-data!");
                    return;
                }

                List <int> failedIndices;
                if (!TryGenerateEffects(idAndChangesList, out effectByID, out failedIndices))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("Failed to generate Effects with [temporary index | EffectID]: ");
                    for (int i = 0; i < failedIndices.Count; i++)
                    {
                        sb.Append("[");
                        sb.Append(i);
                        sb.Append("|");
                        if ((failedIndices[i] < 0) || (failedIndices[i] > (idAndChangesList.Count - 1)))
                        {
                            sb.Append("?");
                        }
                        else
                        {
                            sb.Append(failedIndices[i]);
                        }
                        sb.Append("],");
                    }
                    MakeLogError(sb.ToString());
                }
            }
            // no return value necessary because final results, effectsByID, is already saved as property in the loader
        }
Exemple #2
0
        /// <summary>
        /// Event handler used to create visuals from completed database query.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void VisualsFromSQLResults(AbstractRunnable sender, FinishedQueueEventHandlerArgs e)
        {
            lock (loadLock)
            {
                sqlResults = e.GetSQLResults();

                if (sqlResults == null)
                {
                    return;
                }

                // convert the data-strings to their respective types
                ConvertSQLResults(sqlResults, colGetTypeInfo);

                var tableOverlayAniJob   = sqlResults[DBTableLoadOrder.IndexOf("OverlayAniJobRelation")];
                var tableOverlayModelDef = sqlResults[DBTableLoadOrder.IndexOf("ScriptOverlayModelDef")];
                var tableAniJobModelDef  = sqlResults[DBTableLoadOrder.IndexOf("ScriptAniJobModelDef")];

                var tableScriptAni     = sqlResults[DBTableLoadOrder.IndexOf("ScriptAni")];
                var tableScriptOverlay = sqlResults[DBTableLoadOrder.IndexOf("ScriptOverlay")];
                var tableScriptAniJob  = sqlResults[DBTableLoadOrder.IndexOf("ScriptAniJob")];
                var tableModelDef      = sqlResults[DBTableLoadOrder.IndexOf("ModelDef")];

                List <ScriptOverlayAniJobRelation> overlayAniJobRelations = MapOverlayAniJobRelations(tableOverlayAniJob);
                Dictionary <int, List <int> >      overlayIDByModelDefID  = MapOverlayByModelDef(tableOverlayModelDef);
                Dictionary <int, List <int> >      aniJobIDByModelDefID   = MapAniJobByModelDef(tableAniJobModelDef);

                Dictionary <int, ScriptAni> aniByID;
                if (!TryGenerateScriptAnis(tableScriptAni, out aniByID))
                {
                    MakeLogError("Failed to produce ScriptAni-objects from sql data. "
                                 + "Aborting Generation of Visuals.");
                    return;
                }

                Dictionary <int, ScriptOverlay> overlayByID;
                if (!TryGenerateScriptOverlays(tableScriptOverlay,
                                               out overlayByID))
                {
                    MakeLogError("Failed to produce ScriptOverlay-objects from sql data. "
                                 + "Aborting Generation of Visuals.");
                    return;
                }

                Dictionary <int, int>          nextIDByAniJobID;
                Dictionary <int, ScriptAniJob> aniJobByID;
                if (!TryGenerateScriptAniJobs(tableScriptAniJob, aniByID,
                                              overlayByID, overlayAniJobRelations,
                                              out nextIDByAniJobID, out aniJobByID))
                {
                    MakeLogError("Failed to produce ScriptAniJob-objects from sql data. "
                                 + "Aborting Generation of Visuals.");
                    return;
                }

                Dictionary <int, ModelDef> modelDefByID;
                if (!TryGenerateModelDefs(tableModelDef, overlayByID, aniJobByID,
                                          overlayIDByModelDefID, aniJobIDByModelDefID, nextIDByAniJobID,
                                          out modelDefByID))
                {
                    MakeLogError("Failed to produce ModelDef-objects from sql data. "
                                 + "Aborting Generation of Visuals.");
                    return;
                }
            }
        }