Beispiel #1
0
        private void Produce(WcDataWriter writer, WtgTrigger trigger)
        {
            if (trigger.IsComment)
            {
                writer.Write(16u);
            }
            else if (trigger.IsText)
            {
                writer.Write(32u);
            }
            else
            {
                writer.Write(8u);
            }
            writer.Write(trigger.Name);
            writer.Write(trigger.Description);
            if (FormatVersion >= 7)
            {
                writer.Write(trigger.IsComment);
            }
            writer.Write(trigger.Id);
            writer.Write(trigger.IsEnabled);
            writer.Write(trigger.IsText);
            writer.Write(trigger.IsEnabledFromStart);
            writer.Write(trigger.InitializeOnMapStart);
            writer.Write(trigger.ParentId);
            writer.Write(trigger.EACCount);

            if (trigger.EACCount > 0)
            {
                throw new NotImplementedException("Maps with ANY GUI triggers are not supported yet.");
            }
        }
Beispiel #2
0
 private void Produce2(WcDataWriter writer, WtgVariable variable)
 {
     if (!variable.StoreAsElement)
     {
         return;
     }
     writer.Write(64u);
     writer.Write(variable.Id);
     writer.Write(variable.Name);
     writer.Write(variable.ParentId);
 }
Beispiel #3
0
 private void Produce(WcDataWriter writer, WtgCategory category)
 {
     writer.Write(4u);
     writer.Write(category.Id);
     writer.Write(category.Name);
     if (FormatVersion >= 7)
     {
         writer.Write(category.IsComment);
     }
     writer.Write(category.HasChildren);
     writer.Write(category.ParentId);
 }
Beispiel #4
0
 private void Produce(WcDataWriter writer, WtgVariable variable)
 {
     writer.Write(variable.Name);
     writer.Write(variable.Type);
     writer.Write(variable.ToKeep);
     writer.Write(variable.IsArray);
     if (FormatVersion >= 7)
     {
         writer.Write(variable.ArraySize);
     }
     writer.Write(variable.HasStartingValue);
     writer.Write(variable.Id);
     writer.Write(variable.ParentId);
 }
Beispiel #5
0
        public void Save(Stream to)
        {
            using var writer = new WcDataWriter(to);
            writer.Write(MagicNumber);
            writer.Write(FormatVersion);

            if (FormatVersion != 0)
            {
                writer.Write(MainComment);
                writer.WritePrefixed(MainCT);
            }

            foreach (var ct in Triggers)
            {
                writer.WritePrefixed(ct);
            }
        }
Beispiel #6
0
        public void Save(Stream to)
        {
            using var writer = new WcDataWriter(to);
            writer.Write(Encoding.ASCII.GetBytes(MagicNumber0));
            writer.Write(MagicNumber1);
            writer.Write(FormatVersion);
            foreach (var uv in UG0)
            {
                writer.Write(uv);
            }

            writer.Write(Categories.Count() + 1);
            writer.Write(0u);
            writer.Write(Triggers.Count());
            writer.Write(0u);
            writer.Write(TriggerComments.Count());
            writer.Write(0u);
            writer.Write(CustomScripts.Count());
            writer.Write(0u);
            writer.Write(Variables.Count());
            writer.Write(0u);

            foreach (var uv in UG1)
            {
                writer.Write(uv);
            }
            writer.Write(WarcraftVersion);
            writer.Write(Variables.Count());
            foreach (var v in Variables)
            {
                Produce(writer, v !);
            }
            writer.Write(Elements.Count + 1);
            foreach (var uv in UG2)
            {
                writer.Write(uv);
            }
            writer.Write(MapFileName);
            foreach (var uv in UG3)
            {
                writer.Write(uv);
            }
            if (FormatVersion >= 7)
            {
                foreach (var uv in UG4)
                {
                    writer.Write(uv);
                }
            }

            foreach (var obj in Elements)
            {
                switch (obj)
                {
                case WtgCategory cat: Produce(writer, cat); break;

                case WtgTrigger trig: Produce(writer, trig); break;

                case WtgVariable v: Produce2(writer, v); break;
                }
            }
        }