Exemplo n.º 1
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ItemData)node.Value;

            writer.Write(data.ItemTdbId);
            WriteHeaderThing(writer, data.Header);

            writer.Write(data.Flags.Raw);
            writer.Write(data.CreationTime);

            switch (data.Header.Kind)
            {
            case 0:
                WriteModableItemWithQuantityData(writer, data.Data as ItemData.ModableItemWithQuantityData);
                break;

            case 1:
                WriteSimpleItemData(writer, data.Data as ItemData.SimpleItemData);
                break;

            case 2:
                WriteModableItemData(writer, data.Data as ItemData.ModableItemData);
                break;
            }
        }
Exemplo n.º 2
0
        private static void Write(
            ExpressionSyntax expression,
            ExpressionSyntax nextExpression,
            SyntaxToken token,
            string newText,
            NodeWriter writer)
        {
            if (IsFixable(expression, token))
            {
                if (expression.GetTrailingTrivia().Any(f => !f.IsWhitespaceOrEndOfLineTrivia()) ||
                    token.LeadingTrivia.Any(f => !f.IsWhitespaceOrEndOfLineTrivia()))
                {
                    writer.WriteTrailingTrivia(expression);
                    writer.WriteLeadingTrivia(token);
                }

                writer.WriteTrailingTrivia(token);
                writer.WriteLeadingTrivia(nextExpression);
                writer.Write(newText);
                writer.WriteSpan(nextExpression);
            }
            else
            {
                writer.WriteTrailingTrivia(expression);
                writer.WriteFullSpan(token);
                writer.WriteLeadingTriviaAndSpan(nextExpression);
            }
        }
Exemplo n.º 3
0
        public static Task <Document> RefactorAsync(
            Document document,
            ConditionalExpressionSyntax conditionalExpression,
            CancellationToken cancellationToken)
        {
            ExpressionSyntax condition     = conditionalExpression.Condition;
            ExpressionSyntax whenTrue      = conditionalExpression.WhenTrue;
            ExpressionSyntax whenFalse     = conditionalExpression.WhenFalse;
            SyntaxToken      questionToken = conditionalExpression.QuestionToken;
            SyntaxToken      colonToken    = conditionalExpression.ColonToken;

            var writer = new NodeWriter(conditionalExpression);

            writer.WriteLeadingTrivia();
            writer.WriteSpan(condition);

            Write(condition, whenTrue, questionToken, "? ", writer);

            Write(whenTrue, whenFalse, colonToken, ": ", writer);

            writer.WriteTrailingTrivia();

            ExpressionSyntax newNode = SyntaxFactory.ParseExpression(writer.ToString());

            return(document.ReplaceNodeAsync(conditionalExpression, newNode, cancellationToken));
        }
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (DSDynamicConnections)node.Value;

            writer.WritePackedInt(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unknown1);
            }

            foreach (var entry in data.Entries)
            {
                writer.WritePackedString(entry.Unknown2);

                writer.WritePackedInt(entry.Unknown3.Count);
                foreach (var val in entry.Unknown3)
                {
                    writer.Write(val);
                }

                writer.WritePackedInt(entry.Unknown4.Count);
                foreach (var val in entry.Unknown4)
                {
                    writer.Write(val);
                }

                writer.Write(entry.Unknown5);
                writer.WritePackedString(entry.Unknown6);
            }
        }
Exemplo n.º 5
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (PlayerSystem)node.Value;

            writer.Write(data.Unk_Hash);
            writer.Write(data.Unk_Id);
        }
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (CharacterCustomizationAppearances)node.Value;

            writer.Write(data.DataExists);
            writer.Write(data.Unknown1);
            if (data.DataExists)
            {
                writer.Write(data.UnknownFirstBytes);

                WriteSection(writer, data.FirstSection);
                WriteSection(writer, data.SecondSection);
                WriteSection(writer, data.ThirdSection);

                writer.Write(data.StringTriples.Count);
                foreach (var st in data.StringTriples)
                {
                    WriteStringTriple(writer, st);
                }

                // Only when SaveVersion > 171
                writer.WritePackedInt(data.Strings.Count);
                foreach (var s in data.Strings)
                {
                    writer.WritePackedString(s);
                }
            }
        }
Exemplo n.º 7
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (JournalManager)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unk1_PathHash);
                writer.Write(entry.Unk2_State);
                writer.Write(entry.Unknown3);
                writer.Write(entry.Unknown4);
            }
            writer.Write(data.Unk1_TrackedQuestPath);

            writer.Write(data.Unknown2.Count);
            foreach (var entry in data.Unknown2)
            {
                writer.Write(entry);
            }

            writer.Write(data.Unknown3.Count);
            foreach (var entry in data.Unknown3)
            {
                writer.Write(entry.Unknown1);
                writer.Write(entry.Unknown2);
                writer.Write(entry.Unknown3);
                writer.Write(entry.Unknown4);
            }

            writer.Write(data.TrailingBytes);
        }
        private async void NodeWriterTestInternal()
        {
            // One node description to file
            File.Delete(filePath);
            INodeWriter implementation = new NodeWriter(new NodeDescriber(new NodesHelper()));
            await implementation.WriteToFileAsync(new NoChildrenNode("root"), filePath);

            var result = File.ReadAllText(filePath, Encoding.Unicode);

            Assert.AreEqual("new NoChildrenNode(\"root\");", result);


            // Multiple nodes description to file
            File.Delete(filePath);
            implementation = new NodeWriter(new NodeDescriber(new NodesHelper()));
            await implementation.WriteToFileAsync(new SingleChildNode("root",
                                                                      new TwoChildrenNode("child1",
                                                                                          new NoChildrenNode("leaf1"),
                                                                                          new SingleChildNode("child2",
                                                                                                              new NoChildrenNode("leaf2")))), filePath);

            result = File.ReadAllText(filePath, Encoding.Unicode);

            StringBuilder sb = new StringBuilder();

            sb.Append("new SingleChildNode(\"root\","); sb.Append(Environment.NewLine);
            sb.Append(tab); sb.Append("new TwoChildrenNode(\"child1\","); sb.Append(Environment.NewLine);
            sb.Append(tab); sb.Append(tab); sb.Append("new NoChildrenNode(\"leaf1\"),"); sb.Append(Environment.NewLine);
            sb.Append(tab); sb.Append(tab); sb.Append("new SingleChildNode(\"child2\","); sb.Append(Environment.NewLine);
            sb.Append(tab); sb.Append(tab); sb.Append(tab); sb.Append("new NoChildrenNode(\"leaf2\"))));");
            string expectedResult = sb.ToString();

            Assert.AreEqual(sb.ToString(), result);
        }
Exemplo n.º 9
0
 public void Write(NodeWriter writer, NodeEntry node)
 {
     foreach (var child in node.Children)
     {
         writer.Write(child);
     }
 }
Exemplo n.º 10
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ItemDropStorage)node.Value;

            writer.WritePackedString(data.UnknownString);
            writer.Write(data.HeaderBytes);
            InventoryParser.WriteSubInventory(writer, data.Inventory);
        }
Exemplo n.º 11
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (QuestDebugLogManager)node.Value;

            var text = string.Join("\n", data.Lines);

            writer.WritePackedString(text);
        }
Exemplo n.º 12
0
 public sealed override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode(NodeName);
     writer.EnsureSpace();
     Expression.ToString(writer);
     writer.CloseNode();
 }
Exemplo n.º 13
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (TimeSystemCore)node.Value;

            writer.Write(data.Unknown1);
            writer.Write(data.CurrentGameTime);
            writer.Write(data.Unknown2);
        }
Exemplo n.º 14
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("import");
     writer.Write($" \"{Module}\" \"{Field}\" ");
     Node?.ToString(writer);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Exemplo n.º 15
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (Inventory)node.Value;

            writer.Write(data.NumberOfInventories);
            for (var i = 0; i < data.NumberOfInventories; ++i)
            {
                WriteSubInventory(writer, data.SubInventories[i]);
            }
        }
Exemplo n.º 16
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (DirectorSystem)node.Value;

            writer.Write(data.Unknown1);
            writer.WritePackedString(data.Unknown2);
            writer.Write(data.Unknown3);
            writer.WritePackedString(data.Unknown4);
            writer.Write(data.Unknown5);
        }
Exemplo n.º 17
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ContainerManagerNPCLootBagsVer3LootedIDs)node.Value;

            writer.WritePackedInt(data.EntityIds.Count);
            foreach (var entityId in data.EntityIds)
            {
                writer.Write(entityId);
            }
        }
Exemplo n.º 18
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (GameSessionConfig)node.Value;

            writer.Write(data.Hash1);
            writer.Write(data.Hash2);
            writer.WritePackedString(data.TextValue);
            writer.Write(data.Hash3);
            writer.Write(data.TrailingBytes);
        }
Exemplo n.º 19
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (CustomArray)node.Value;

            writer.Write(data.Unknown.Count);
            foreach (var entry in data.Unknown)
            {
                writer.Write(entry);
            }
        }
Exemplo n.º 20
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ContainerManager)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.CNameHash);
                writer.Write(entry.Unknown1);
            }
        }
Exemplo n.º 21
0
        public async Task WriteEmpty()
        {
            var filePath = "test-tree-empty.txt";

            INodeWriter implementation = new NodeWriter();
            await implementation.WriteToFileAsync(null, filePath);

            var result = File.ReadAllText(filePath);

            Assert.AreEqual("", result);
        }
Exemplo n.º 22
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (CommunitySystem)node.Value;

            writer.Write(data.Unk_HashList.Count);
            foreach (var entry in data.Unk_HashList)
            {
                writer.Write(entry);
            }
            writer.Write(data.TrailingBytes);
        }
Exemplo n.º 23
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (CAttitudeManager)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unk_Hash1);
                writer.Write(entry.Unknown2);
            }
            writer.Write(data.Unknown2);
        }
Exemplo n.º 24
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (CCoverManager)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unk_Hash1);
                writer.Write(entry.Unk_EntityHash);
                writer.Write(entry.Unknown3);
            }
        }
Exemplo n.º 25
0
        public static void WriteSubInventory(NodeWriter writer, Inventory.SubInventory subInventory)
        {
            writer.Write(subInventory.InventoryId);
            writer.Write(subInventory.NumberOfItems);

            for (var i = 0; i < subInventory.NumberOfItems; ++i)
            {
                var nextItem = subInventory.Items[i];
                ItemDataParser.WriteNextItemEntryFromItem(writer, nextItem);
                writer.Write(nextItem.Node);
            }
        }
Exemplo n.º 26
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (WorkspotInstancesSavedata)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unk_Hash1);
                writer.Write(entry.Unk_EntityHash);
                writer.Write(entry.Unknown3);
            }
        }
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ItemDropStorageManager)node.Value;

            writer.Write(data.NumberOfItemDropStorages);

            for (var i = 0; i < data.NumberOfItemDropStorages; ++i)
            {
                writer.Write(node.Children[i]);
            }

            writer.Write(data.TrailingBytes);
        }
Exemplo n.º 28
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (EventManager)node.Value;

            writer.Write(data.Unknown.Count);
            foreach (var entry in data.Unknown)
            {
                writer.Write(entry.Unknown1);
                writer.Write(entry.Unknown2);
                writer.Write(entry.Unknown3);
                writer.Write(entry.Unknown4);
            }
        }
Exemplo n.º 29
0
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (QuestMusicHistory)node.Value;

            writer.Write(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unknown1);
                writer.Write(entry.Unknown2);
                writer.Write(entry.Unknown3);
                writer.Write(entry.Unknown4);
                writer.Write(entry.Unknown5);
                writer.Write(entry.Unknown6);
            }
        }
        public void Write(NodeWriter writer, NodeEntry node)
        {
            var data = (ContainerManagerLootSlotAvailability)node.Value;

            writer.WritePackedInt(data.Entries.Count);
            foreach (var entry in data.Entries)
            {
                writer.Write(entry.CNameHash);
            }

            foreach (var entry in data.Entries)
            {
                writer.Write(entry.Unknown1);
            }
        }