Exemple #1
0
        public override void Unmarshal(string data, bool withV = true)
        {
            XmlNode xmlNode1 = GetRoot(data).SelectSingleNode("node");

            if (xmlNode1 == null)
            {
                throw new SerializingException("node tag not found");
            }
            var heroClassDef = Type.Id.Definition as HeroClassDef;

            for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
            {
                if (xmlNode2.Name == "f")
                {
                    string       name  = xmlNode2.Attributes["name"].Value;
                    HeroFieldDef field = heroClassDef.GetField(name);
                    if (field != null)
                    {
                        HeroAnyValue heroAnyValue = Create(field.FieldType);
                        heroAnyValue.Unmarshal("<v>" + xmlNode2.InnerXml + "</v>", true);
                        Variables.Add(new Variable(new DefinitionId(field.Id), 0, heroAnyValue));
                    }
                }
            }
        }
Exemple #2
0
        public override void Deserialize(PackedStream2 stream)
        {
            hasValue = true;
            Data     = new Dictionary <HeroVarId, HeroAnyValue>();
            var defaultIndexerType = new HeroType(HeroTypes.None);

            if (Type.Indexer != null)
            {
                defaultIndexerType = Type.Indexer;
            }
            var deserializeLookupList = new DeserializeLookupList(stream, 1, defaultIndexerType);

            if (Type.Indexer == null || Type.Indexer.Type == HeroTypes.None)
            {
                Type.Indexer = deserializeLookupList.indexerType;
            }
            else
            {
                deserializeLookupList.indexerType = Type.Indexer;
            }
            if (Type.Values == null)
            {
                Type.Values = deserializeLookupList.valueType;
            }
            else
            {
                deserializeLookupList.valueType = Type.Values;
            }
            for (ulong index = 0UL; index < (ulong)deserializeLookupList.Count; ++index)
            {
                HeroAnyValue key;
                int          variableId;
                deserializeLookupList.GetKey(out key, out variableId);
                HeroAnyValue heroAnyValue = Create(Type.Values);
                heroAnyValue.Deserialize(stream);
                Data[new HeroVarId(variableId, key)] = heroAnyValue;
                if (variableId > nextId)
                {
                    nextId = variableId;
                }
            }
        }
Exemple #3
0
        public override void Deserialize(PackedStream2 stream)
        {
            hasValue  = true;
            Variables = new VariableList();
            var deserializeClass = new DeserializeClass(stream, 1);

            for (uint index = 0U; index < deserializeClass.Count; ++index)
            {
                uint  type1      = 0U;
                int   variableId = 0;
                ulong fieldId;
                int   d;
                deserializeClass.ReadFieldData(out fieldId, ref type1, ref variableId, out d);
                if (d != 2)
                {
                    var type2 = new HeroType((HeroTypes)type1);
                    var field = new DefinitionId(fieldId);
                    if (field.Definition != null)
                    {
                        var heroFieldDef = field.Definition as HeroFieldDef;
                        switch (heroFieldDef.FieldType.Type)
                        {
                        case HeroTypes.Enum:
                        case HeroTypes.ScriptRef:
                            type2.Id = heroFieldDef.FieldType.Id;
                            break;

                        case HeroTypes.LookupList:
                            type2 = heroFieldDef.FieldType;
                            break;
                        }
                    }
                    HeroAnyValue heroAnyValue = Create(type2);
                    heroAnyValue.Deserialize(stream);
                    Variables.Add(new Variable(field, variableId, heroAnyValue));
                }
            }
        }
Exemple #4
0
        public override void Unmarshal(string data, bool asXml = true)
        {
            XmlNode root = GetRoot(data);

            Data = new Dictionary <HeroVarId, HeroAnyValue>();
            HeroAnyValue heroAnyValue1 = null;

            for (XmlNode xmlNode = root.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling)
            {
                if (xmlNode.Name == "k")
                {
                    heroAnyValue1 = Create(Type.Indexer);
                    heroAnyValue1.Unmarshal("<v>" + xmlNode.InnerText + "</v>", true);
                }
                if (xmlNode.Name == "e")
                {
                    HeroAnyValue heroAnyValue2 = Create(Type.Values);
                    heroAnyValue2.Unmarshal("<v>" + xmlNode.InnerText + "</v>", true);
                    Data[new HeroVarId(0, heroAnyValue1)] = heroAnyValue2;
                    heroAnyValue1 = null;
                }
            }
            hasValue = true;
        }
Exemple #5
0
 public HeroVarId(int varID, HeroAnyValue value)
 {
     VarId = varID;
     Value = value;
 }