Ejemplo n.º 1
0
        public static IEnumerable <FormattedObject> FormatFieldObjects(Field.Info field)
        {
            if (!field.TryReadData(Field.Part.Jsm, out var jsmData))
            {
                yield break;
            }

            List <Jsm.GameObject> gameObjects = Jsm.File.Read(jsmData);

            if (gameObjects.Count == 0)
            {
                yield break;
            }

            IScriptFormatterContext formatterContext = GetFormatterContext(field);
            IServices    executionContext            = StatelessServices.Instance;
            ScriptWriter sw = new ScriptWriter();

            foreach (var obj in gameObjects)
            {
                formatterContext.GetObjectScriptNamesById(obj.Id, out String objectName, out _);
                String formattedScript = FormatObject(obj, sw, formatterContext, executionContext);
                yield return(new FormattedObject(field, objectName, formattedScript));
            }
        }
Ejemplo n.º 2
0
        private static ScriptFormatterContext GetFormatterContext(Field.Info field)
        {
            var context = new ScriptFormatterContext();

            if (field.TryReadData(Field.Part.Sym, out var symData))
            {
                context.SetSymbols(Sym.Reader.FromBytes(symData));
            }

            if (field.TryReadData(Field.Part.Msd, out var msdData))
            {
                context.SetMessages(Msd.Reader.FromBytes(msdData));
            }
            return(context);
        }
Ejemplo n.º 3
0
 public FormattedObject(Field.Info field, string objectName, string scripts)
 {
     Field      = field;
     ObjectName = objectName;
     Scripts    = scripts;
 }