public static void SetExtraData(this ContentPresenter cp, LinkedListNode<ContentPresenter> node, int resolvedIndex)
 {
     ExtraData extraData = cp.Tag as ExtraData;
     if (extraData == null)
     {
         cp.Tag = extraData = new ExtraData();
     }
     extraData.Node = node;
     extraData.ResolvedIndex = resolvedIndex;
 }
 public static void SetExtraData(this ContentPresenter cp, int resolvedIndex, double lastDesiredHeight)
 {
     ExtraData extraData = cp.Tag as ExtraData;
     if (extraData == null)
     {
         cp.Tag = extraData = new ExtraData();                
     }
     extraData.ResolvedIndex = resolvedIndex;
     extraData.LastDesiredHeight = lastDesiredHeight;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Empty level with null/default values that need to be assigned after initialized
        /// </summary>
        /// <param name="size">Base size of map (can be changed)</param>
        public Level(Vector3S size)
        {
            Size = size;
            SpawnPos = size / 2;
            SpawnRot = new byte[] { 128, 128 };
            //data = new byte[Size.x, Size.z, Size.y];
            Data = new byte[TotalBlocks];
            BackupLevel = true;
            ExtraData = new ExtraData<object, object>();
            //if (ServerSettings.HasKey("PhysicsInterval")) {
            //    physicsSleep = ServerSettings.GetSettingInt("PhysicsInterval");

               // }
            //else physicsSleep = 100;
            physics = new Thread(() => {
                //while (!Server.ShuttingDown) {
                //    Thread.Sleep(physicsSleep);
                //    MCForge.Interfaces.Blocks.Block.DoTick(this);
                //}
            });
            physics.Start();
        }
Ejemplo n.º 4
0
        public static SentryMessage message(
            string loggerName, ApiKeys keys, ErrorReporter.AppInfo appInfo,
            ErrorReporter.ErrorData data, ExtraData addExtraData
            )
        {
            var timestamp = DateTime.UtcNow;

            // The list of frames should be ordered by the oldest call first.
            // ReSharper disable once ConvertClosureToMethodGroup - MCS bug
            var stacktraceFrames = data.backtrace.Select(a => backtraceElemToJson(a)).Reverse().ToList();

            // Tags are properties that can be filtered/grouped by.
            var tags = new Dictionary <string, object> {
                // max tag name length = 32
                { "ProductName", tag(appInfo.productName) },
                { "BundleIdentifier", tag(appInfo.bundleIdentifier) },
                { "App:LoadedLevelNames", tag(
                      Enumerable2.fromImperative(SceneManager.sceneCount, SceneManager.GetSceneAt).
                      Select(_ => $"{_.name}({_.buildIndex})").OrderBy(_ => _).mkString(", ")
                      ) },
                { "App:LevelCount", tag(SceneManager.sceneCountInBuildSettings) },
                { "App:Platform", tag(Application.platform) },
                { "App:UnityVersion", tag(Application.unityVersion) },
                { "App:Version", tag(Application.version) },
                { "App:BundleIdentifier", tag(Application.bundleIdentifier) },
                { "App:InstallMode", tag(Application.installMode) },
                { "App:SandboxType", tag(Application.sandboxType) },
                { "App:ProductName", tag(Application.productName) },
                { "App:CompanyName", tag(Application.companyName) },
                { "App:CloudProjectId", tag(Application.cloudProjectId) },
                { "App:WebSecurityEnabled", tag(Application.webSecurityEnabled) },
                { "App:WebSecurityHostUrl", tag(Application.webSecurityHostUrl) },
                { "App:TargetFrameRate", tag(Application.targetFrameRate) },
                { "App:SystemLanguage", tag(Application.systemLanguage) },
                { "App:BackgroundLoadingPriority", tag(Application.backgroundLoadingPriority) },
                { "App:InternetReachability", tag(Application.internetReachability) },
                { "App:GenuineCheckAvailable", tag(Application.genuineCheckAvailable) },
                { "App:Genuine", tag(Application.genuineCheckAvailable && Application.genuine) },
                { "SI:OperatingSystem", tag(SystemInfo.operatingSystem) },
                { "SI:ProcessorType", tag(SystemInfo.processorType) },
                { "SI:ProcessorCount", tag(SystemInfo.processorCount) },
                { "SI:SystemMemorySize", tag(SystemInfo.systemMemorySize) },
                { "SI:GraphicsMemorySize", tag(SystemInfo.graphicsMemorySize) },
                { "SI:GraphicsDeviceName", tag(SystemInfo.graphicsDeviceName) },
                { "SI:GraphicsDeviceVendor", tag(SystemInfo.graphicsDeviceVendor) },
                { "SI:GraphicsDeviceID", tag(SystemInfo.graphicsDeviceID) },
                { "SI:GraphicsDeviceVendorID", tag(SystemInfo.graphicsDeviceVendorID) },
                { "SI:GraphicsDeviceType", tag(SystemInfo.graphicsDeviceType) },
                { "SI:GraphicsDeviceVersion", tag(SystemInfo.graphicsDeviceVersion) },
                { "SI:GraphicsShaderLevel", tag(SystemInfo.graphicsShaderLevel) },
                { "SI:GraphicsMultiThreaded", tag(SystemInfo.graphicsMultiThreaded) },
                { "SI:SupportsShadows", tag(SystemInfo.supportsShadows) },
                { "SI:SupportsRenderTextures", tag(SystemInfo.supportsRenderTextures) },
                { "SI:SupportsRenderToCubemap", tag(SystemInfo.supportsRenderToCubemap) },
                { "SI:SupportsImageEffects", tag(SystemInfo.supportsImageEffects) },
                { "SI:Supports3DTextures", tag(SystemInfo.supports3DTextures) },
                { "SI:SupportsComputeShaders", tag(SystemInfo.supportsComputeShaders) },
                { "SI:SupportsInstancing", tag(SystemInfo.supportsInstancing) },
                { "SI:SupportsSparseTextures", tag(SystemInfo.supportsSparseTextures) },
                { "SI:SupportedRenderTargetCount", tag(SystemInfo.supportedRenderTargetCount) },
                { "SI:SupportsStencil", tag(SystemInfo.supportsStencil) },
                { "SI:NPOTsupport", tag(SystemInfo.npotSupport) },
                { "SI:DeviceName", tag(SystemInfo.deviceName) },
                { "SI:DeviceModel", tag(SystemInfo.deviceModel) },
                { "SI:SupportsAccelerometer", tag(SystemInfo.supportsAccelerometer) },
                { "SI:SupportsGyroscope", tag(SystemInfo.supportsGyroscope) },
                { "SI:SupportsLocationService", tag(SystemInfo.supportsLocationService) },
                { "SI:SupportsVibration", tag(SystemInfo.supportsVibration) },
                { "SI:DeviceType", tag(SystemInfo.deviceType) },
                { "SI:MaxTextureSize", tag(SystemInfo.maxTextureSize) },
            };

            addExtraData.addTags((name, value) => tags[name] = tag(value));

            // Extra contextual data is limited to 4096 characters.
            var extras = new Dictionary <string, object> {
                { "App:StreamedBytes", Application.streamedBytes },
            };

            addExtraData.addExtras((name, value) => extras[name] = value);

            var json = new Dictionary <string, object> {
                { "event_id", Guid.NewGuid().ToString("N") },
                // max length - 1000 chars
                { "message", data.message.trimTo(1000) },
                { "timestamp", timestamp.ToString("yyyy-MM-ddTHH:mm:ss") },
                { "level", logTypeToSentryLevel(data.errorType) },
                { "logger", loggerName },
                { "platform", Application.platform.ToString() },
                { "release", appInfo.bundleVersion },
                { "tags", tags },
                { "extra", extras },
                { "stacktrace", new Dictionary <string, object> {
                      { "frames", stacktraceFrames }
                  } }
            };

            if (!data.backtrace.isEmpty())
            {
                json.Add("culprit", data.backtrace[0].method);
            }

            var serialized = Formats.MiniJSON.Json.Serialize(json);

            return(new SentryMessage(keys, timestamp, serialized));
        }
Ejemplo n.º 5
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "OBND":
                    if (ObjectBounds == null)
                    {
                        ObjectBounds = new ObjectBounds();
                    }

                    ObjectBounds.ReadBinary(reader);
                    break;

                case "FULL":
                    if (Name == null)
                    {
                        Name = new SimpleSubrecord <String>();
                    }

                    Name.ReadBinary(reader);
                    break;

                case "MODL":
                    if (Model == null)
                    {
                        Model = new Model();
                    }

                    Model.ReadBinary(reader);
                    break;

                case "ICON":
                    if (LargeIcon == null)
                    {
                        LargeIcon = new SimpleSubrecord <String>();
                    }

                    LargeIcon.ReadBinary(reader);
                    break;

                case "MICO":
                    if (SmallIcon == null)
                    {
                        SmallIcon = new SimpleSubrecord <String>();
                    }

                    SmallIcon.ReadBinary(reader);
                    break;

                case "SCRI":
                    if (Script == null)
                    {
                        Script = new RecordReference();
                    }

                    Script.ReadBinary(reader);
                    break;

                case "DEST":
                    if (Destructable == null)
                    {
                        Destructable = new Destructable();
                    }

                    Destructable.ReadBinary(reader);
                    break;

                case "YNAM":
                    if (PickUpSound == null)
                    {
                        PickUpSound = new RecordReference();
                    }

                    PickUpSound.ReadBinary(reader);
                    break;

                case "ZNAM":
                    if (DropSound == null)
                    {
                        DropSound = new RecordReference();
                    }

                    DropSound.ReadBinary(reader);
                    break;

                case "DATA":
                    if (Data == null)
                    {
                        Data = new AmmoData();
                    }

                    Data.ReadBinary(reader);
                    break;

                case "DAT2":
                    if (ExtraData == null)
                    {
                        ExtraData = new AmmoExtraData();
                    }

                    ExtraData.ReadBinary(reader);
                    break;

                case "ONAM":
                    if (ShortName == null)
                    {
                        ShortName = new SimpleSubrecord <String>();
                    }

                    ShortName.ReadBinary(reader);
                    break;

                case "QNAM":
                    if (Abbreviation == null)
                    {
                        Abbreviation = new SimpleSubrecord <String>();
                    }

                    Abbreviation.ReadBinary(reader);
                    break;

                case "RCIL":
                    if (AmmoEffects == null)
                    {
                        AmmoEffects = new List <RecordReference>();
                    }

                    RecordReference tempRCIL = new RecordReference();
                    tempRCIL.ReadBinary(reader);
                    AmmoEffects.Add(tempRCIL);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
Ejemplo n.º 6
0
        public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (EditorID != null)
            {
                ele.TryPathTo("EditorID", true, out subEle);
                EditorID.WriteXML(subEle, master);
            }
            if (ObjectBounds != null)
            {
                ele.TryPathTo("ObjectBounds", true, out subEle);
                ObjectBounds.WriteXML(subEle, master);
            }
            if (Name != null)
            {
                ele.TryPathTo("Name", true, out subEle);
                Name.WriteXML(subEle, master);
            }
            if (Model != null)
            {
                ele.TryPathTo("Model", true, out subEle);
                Model.WriteXML(subEle, master);
            }
            if (LargeIcon != null)
            {
                ele.TryPathTo("Icon/Large", true, out subEle);
                LargeIcon.WriteXML(subEle, master);
            }
            if (SmallIcon != null)
            {
                ele.TryPathTo("Icon/Small", true, out subEle);
                SmallIcon.WriteXML(subEle, master);
            }
            if (Script != null)
            {
                ele.TryPathTo("Script", true, out subEle);
                Script.WriteXML(subEle, master);
            }
            if (Destructable != null)
            {
                ele.TryPathTo("Destructable", true, out subEle);
                Destructable.WriteXML(subEle, master);
            }
            if (PickUpSound != null)
            {
                ele.TryPathTo("PickUpSound", true, out subEle);
                PickUpSound.WriteXML(subEle, master);
            }
            if (DropSound != null)
            {
                ele.TryPathTo("DropSound", true, out subEle);
                DropSound.WriteXML(subEle, master);
            }
            if (Data != null)
            {
                ele.TryPathTo("Data", true, out subEle);
                Data.WriteXML(subEle, master);
            }
            if (ExtraData != null)
            {
                ele.TryPathTo("ExtraData", true, out subEle);
                ExtraData.WriteXML(subEle, master);
            }
            if (ShortName != null)
            {
                ele.TryPathTo("ShortName", true, out subEle);
                ShortName.WriteXML(subEle, master);
            }
            if (Abbreviation != null)
            {
                ele.TryPathTo("Abbreviation", true, out subEle);
                Abbreviation.WriteXML(subEle, master);
            }
            if (AmmoEffects != null)
            {
                ele.TryPathTo("AmmoEffects", true, out subEle);
                List <string> xmlNames = new List <string> {
                    "Effect"
                };
                int i = 0;
                foreach (var entry in AmmoEffects)
                {
                    i = i % xmlNames.Count();
                    XElement newEle = new XElement(xmlNames[i]);
                    entry.WriteXML(newEle, master);
                    subEle.Add(newEle);
                    i++;
                }
            }
        }
Ejemplo n.º 7
0
 public void Add(ushort x, ushort z, ushort y, byte type) {
     ExtraData<ushort, ExtraData<ushort, RedoList>> xLevel = changes[x];
     ExtraData<ushort, RedoList> zLevel;
     RedoList yLevel;
     if (xLevel == null) {
         xLevel = new ExtraData<ushort, ExtraData<ushort, RedoList>>();
         zLevel = new ExtraData<ushort, RedoList>();
         yLevel = new RedoList();
         yLevel.Add(type);
         zLevel[y] = yLevel;
         xLevel[z] = zLevel;
         changes[x] = xLevel;
     }
     else {
         zLevel = xLevel[z];
         if (zLevel == null) {
             zLevel = new ExtraData<ushort, RedoList>();
             yLevel = new RedoList();
             yLevel.Add(type);
             zLevel[y] = yLevel;
             xLevel[z] = zLevel;
         }
         else {
             yLevel = zLevel[y];
             if (yLevel == null) {
                 yLevel = new RedoList();
                 yLevel.Add(type);
                 zLevel[y] = yLevel;
             }
             else {
                 yLevel.Add(type);
             }
         }
     }
 }
Ejemplo n.º 8
0
        public override void Read(BinaryReader reader, Resource resource)
        {
            Reader   = reader;
            Resource = resource;

            reader.BaseStream.Position = Offset;

            Version = reader.ReadUInt16();

            if (Version != 1)
            {
                throw new InvalidDataException(string.Format("Unknown vtex version. ({0} != expected 1)", Version));
            }

            Flags = (VTexFlags)reader.ReadUInt16();

            Reflectivity = new[]
            {
                reader.ReadSingle(),
                    reader.ReadSingle(),
                    reader.ReadSingle(),
                    reader.ReadSingle(),
            };
            Width         = reader.ReadUInt16();
            Height        = reader.ReadUInt16();
            Depth         = reader.ReadUInt16();
            NonPow2Width  = 0;
            NonPow2Height = 0;
            Format        = (VTexFormat)reader.ReadByte();
            NumMipLevels  = reader.ReadByte();
            Picmip0Res    = reader.ReadUInt32();

            var extraDataOffset = reader.ReadUInt32();
            var extraDataCount  = reader.ReadUInt32();

            if (extraDataCount > 0)
            {
                reader.BaseStream.Position += extraDataOffset - 8; // 8 is 2 uint32s we just read

                for (var i = 0; i < extraDataCount; i++)
                {
                    var type   = (VTexExtraData)reader.ReadUInt32();
                    var offset = reader.ReadUInt32() - 8;
                    var size   = reader.ReadUInt32();

                    var prevOffset = reader.BaseStream.Position;

                    reader.BaseStream.Position += offset;

                    if (type == VTexExtraData.FILL_TO_POWER_OF_TWO)
                    {
                        reader.ReadUInt16();
                        var nw = reader.ReadUInt16();
                        var nh = reader.ReadUInt16();
                        if (nw > 0 && nh > 0 && Width >= nw && Height >= nh)
                        {
                            NonPow2Width  = nw;
                            NonPow2Height = nh;
                        }

                        reader.BaseStream.Position -= 6;
                    }

                    ExtraData.Add(type, reader.ReadBytes((int)size));

                    if (type == VTexExtraData.COMPRESSED_MIP_SIZE)
                    {
                        reader.BaseStream.Position -= size;

                        var int1 = reader.ReadUInt32(); // 1?
                        var int2 = reader.ReadUInt32(); // 8?
                        var mips = reader.ReadUInt32();

                        if (int1 != 1 && int1 != 0)
                        {
                            throw new Exception($"int1 got: {int1}");
                        }

                        if (int2 != 8)
                        {
                            throw new Exception($"int2 expected 8 but got: {int2}");
                        }

                        IsActuallyCompressedMips = int1 == 1; // TODO: Verify whether this int is the one that actually controls compression

                        CompressedMips = new int[mips];

                        for (var mip = 0; mip < mips; mip++)
                        {
                            CompressedMips[mip] = reader.ReadInt32();
                        }
                    }

                    reader.BaseStream.Position = prevOffset;
                }
            }

            DataOffset = Offset + Size;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Empty level with null/default values that need to be assigned after initialized
        /// </summary>
        /// <param name="size">Base size of map (can be changed)</param>
        public Level(Vector3S size)
        {
            CWMap = new ClassicWorld(size.x, size.z, size.y)
            {
                SpawnPos = new Vector3S((short)(size.x / 2),
                (short)(size.y / 2),
                (short)(size.z / 2)),
                SpawnRotation = new Vector2S(128, 128),
                BlockData = new byte[size.x * size.y * size.z]
            };

            Settings = new Metadata(); // -- Hypercube specific settings, woo.
            Settings.perbuild = 0; // -- Enable building, history and physics by default.
            Settings.pervisit = 0;

            CWMap.MetadataParsers.Add("MCForge", Settings); // -- Add the parser so it will save with the map :)

            CWMap.GeneratingSoftware = "MCForge";
            CWMap.GeneratorName = "Blank";
            CWMap.CreatingService = "Classicube";
            CWMap.CreatingUsername = "******";

            var myRef = (CPEMetadata)CWMap.MetadataParsers["CPE"];

            if (myRef.CustomBlocksFallback == null)
            {
                myRef.CustomBlocksLevel = 1;
                myRef.CustomBlocksVersion = 1;
                myRef.CustomBlocksFallback = new byte[256];

                CWMap.MetadataParsers["CPE"] = myRef;
            }
               //         a = new byte[CWMap.Size.x, CWMap.Size.z, CWMap.Size.y];
            BackupLevel = true;
            ExtraData = new ExtraData<object, object>();
        }
Ejemplo n.º 10
0
        static object _ReadXmlElement(XmlReader reader, System.Type elementType, ExtraData extraData)
        {
            System.Object obj = null;

            System.Collections.ArrayList arrayList = null;
            System.Type arrayElementType           = null;
            if (elementType.IsArray)
            {
                arrayList        = new System.Collections.ArrayList();
                arrayElementType = elementType.GetElementType();
            }

            while (reader.Read())
            {
                //Debug.Log( "NodeType: " + reader.NodeType + " Name:" + reader.Name + " Value:" + reader.Value + " ValueType:" + reader.ValueType );
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (elementType.IsArray)
                    {
                        arrayList.Add(_ReadXmlElement(reader, arrayElementType, extraData));
                    }
                    else
                    {
                        var field = elementType.GetField(reader.Name, BindingFlags.Public | BindingFlags.Instance);
                        if (field != null)
                        {
                            if (obj == null)
                            {
                                try {
                                    obj = System.Activator.CreateInstance(elementType);
                                } catch (System.Exception) {
                                    Debug.LogWarning("Instanciate failed: " + elementType.ToString());
                                }
                            }

                            if (obj != null)                        // Failsafe.
                            {
                                if (typeof(UnityEngine.Object).IsAssignableFrom(field.FieldType))
                                {
                                    var element = _ReadXmlElement_UnityEngine_Object(reader, field.FieldType, extraData);
                                    if (element != null)
                                    {
                                        try {
                                            field.SetValue(obj, element);
                                        } catch (System.Exception e) {                                  // Type mismatch.
                                            Debug.LogWarning(e.ToString());
                                        }
                                    }
                                }
                                else
                                {
                                    var element = _ReadXmlElement(reader, field.FieldType, extraData);
                                    if (element != null)
                                    {
                                        try {
                                            field.SetValue(obj, element);
                                        } catch (System.Exception e) {                                  // Type mismatch.
                                            Debug.LogWarning(e.ToString());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                _SkipXmlElement(reader);
                            }
                        }
                        else
                        {
                            _SkipXmlElement(reader);
                        }
                    }
                    break;

                case XmlNodeType.Text:
                    if (!elementType.IsArray)                // Failsafe.
                    {
                        if (typeof(UnityEngine.Object).IsAssignableFrom(elementType))
                        {
                            Debug.LogWarning("Unsupported type: " + elementType.ToString());
                        }
                        else
                        {
                            if (elementType == typeof(string))
                            {
                                obj = reader.Value;
                            }
                            else
                            {
                                var parse = elementType.GetMethod("Parse",
                                                                  BindingFlags.Public | BindingFlags.Static, null, new [] { typeof(string) }, null);
                                if (parse != null)
                                {
                                    try {
                                        obj = parse.Invoke(null, new object[] { reader.Value });
                                    } catch (System.Exception) {
                                        Debug.LogWarning("Parse failed: " + elementType.ToString() + " Value: " + reader.Value);
                                    }
                                }
                                else
                                {
                                    Debug.LogWarning("Unsupported type: " + elementType.ToString());
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Unknown flow.");
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (elementType.IsArray)
                    {
                        obj = System.Array.CreateInstance(arrayElementType, arrayList.Count);
                        for (int i = 0; i < arrayList.Count; ++i)
                        {
                            ((System.Array)obj).SetValue(arrayList[i], i);
                        }
                    }

                    return(obj);
                }
            }

            Debug.LogWarning("Element is not terminated.");
            return(null);
        }
Ejemplo n.º 11
0
        static void _WriteXmlValue_UnityEngine_Object(XmlWriter writer, object value, ExtraData extraData)
        {
            var meta = ObjectMeta.GetAt((UnityEngine.Object)value, extraData);

            if (extraData != null && extraData.objects != null && value != null)
            {
                meta.extraDataObjectIndex = extraData.objects.IndexOf((UnityEngine.Object)value);
                if (meta.extraDataObjectIndex < 0)
                {
                    meta.extraDataObjectIndex = extraData.objects.Count;
                    extraData.objects.Add((UnityEngine.Object)value);
                }
            }

            meta.WriteToXml(writer, extraData);
        }
Ejemplo n.º 12
0
            public UnityEngine.Object Find(ExtraData extraData)
            {
                if (this.extraDataObjectIndex >= 0 && extraData != null && extraData.objects != null)
                {
                    if (this.extraDataObjectIndex < extraData.objects.Count)
                    {
                        var obj = extraData.objects[this.extraDataObjectIndex];
                        if (obj != null)
                        {
                            return(obj);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(transformPath) && extraData.rootTransform != null)
                {
                    var transform = extraData.rootTransform.FindChild(transformPath);
                    if (transform != null)
                    {
                        if (this.typeName == "UnityEngine.Transform")
                        {
                            return(transform);
                        }
                        else if (this.typeName == "UnityEngine.GameObject")
                        {
                            return(transform.gameObject);
                        }
                    }
                }

                string modifiedAssetPath = this.assetPath;

                if (!string.IsNullOrEmpty(this.relativeAssetPath) && !string.IsNullOrEmpty(extraData.rootDirectory))
                {
                    modifiedAssetPath = AssetPathHelper.GenerateAssetPath(extraData.rootDirectory, this.relativeAssetPath);
                }

                // GUID & assetPath(relativeAssetPath)
                if (!string.IsNullOrEmpty(this.guid))
                {
                    string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(this.guid);
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        if (assetPath == modifiedAssetPath || assetPath == this.assetPath)
                        {
                            var obj = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetPath);
                            if (obj != null && obj.GetType().FullName == this.typeName)
                            {
                                return(obj);
                            }
                        }
                    }
                }

                // Relative assetPath
                if (!string.IsNullOrEmpty(modifiedAssetPath))
                {
                    var obj = UnityEditor.AssetDatabase.LoadMainAssetAtPath(modifiedAssetPath);
                    if (obj != null && obj.GetType().FullName == this.typeName)
                    {
                        return(obj);
                    }
                }

                // Abusolute assetPath
                if (!string.IsNullOrEmpty(this.assetPath))
                {
                    var obj = UnityEditor.AssetDatabase.LoadMainAssetAtPath(this.assetPath);
                    if (obj != null && obj.GetType().FullName == this.typeName)
                    {
                        return(obj);
                    }
                }

                // Finally, find by guid only.
                if (!string.IsNullOrEmpty(this.guid))
                {
                    string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(this.guid);
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        var obj = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetPath);
                        if (obj != null && obj.GetType().FullName == this.typeName)
                        {
                            return(obj);
                        }
                    }
                }

                return(null);
            }
Ejemplo n.º 13
0
 /// <summary>
 /// Empty level with null/default values that need to be assigned after initialized
 /// </summary>
 /// <param name="size">Base size of map (can be changed)</param>
 public Level(Vector3S size) {
     Size = size;
     SpawnPos = size / 2;
     SpawnRot = new byte[] { 128, 128 };
     //data = new byte[Size.x, Size.z, Size.y];
     Data = new byte[TotalBlocks];
     BackupLevel = true;
     ExtraData = new ExtraData<object, object>();
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NewPlayer"/> class.
        /// </summary>
        public NewPlayer() {

            ExtraData = new ExtraData<object, object>();
            this._displayName = string.Empty;
            this.Username = string.Empty;
            this.Title = string.Empty;
            this.Group = PlayerGroup.Default;
            // BlockChangeHistory = new BlockChangeHistory(this);

        }
Ejemplo n.º 15
0
            public Series AddExtra(string label, string prefix, object value , bool setTrend = true)
            {
                var newExtra = new ExtraData()
                {
                    label = label,
                    prefix = prefix,
                    value = (decimal)value
                };

                if (setTrend)
                {
                    if (newExtra.value > 0)
                        newExtra.trend = TrendType.Up;
                    else
                        newExtra.trend = TrendType.Down;
                }

                this.extras.Add(newExtra);

                return this;
            }
Ejemplo n.º 16
0
        /// <summary>
        /// Create a ShellLing from a given byte array
        /// </summary>
        /// <param name="ba">The byte array</param>
        /// <returns>A Shortcut object</returns>
        public static new Shortcut FromByteArray(byte[] ba)
        {
            Shortcut lnk = new Shortcut();

            #region SHELL_LINK_HEADER
            ShellLinkHeader Header     = ShellLinkHeader.FromByteArray(ba);
            UInt32          HeaderSize = BitConverter.ToUInt32(ba, 0);
            Boolean         IsUnicode  = (Header.LinkFlags & LinkFlags.IsUnicode) != 0;
            lnk.LinkFlags      = Header.LinkFlags;
            lnk.FileAttributes = Header.FileAttributes;
            lnk.CreationTime   = Header.CreationTime;
            lnk.AccessTime     = Header.AccessTime;
            lnk.WriteTime      = Header.WriteTime;
            lnk.FileSize       = Header.FileSize;
            lnk.IconIndex      = Header.IconIndex;
            lnk.ShowCommand    = Header.ShowCommand;
            lnk.HotKey         = Header.HotKey;
            ba = ba.Skip((int)HeaderSize).ToArray();
            #endregion // SHELL_LINK_HEADER

            #region LINKTARGET_IDLIST
            if ((Header.LinkFlags & LinkFlags.HasLinkTargetIDList) != 0)
            {
                lnk.LinkTargetIDList = LinkTargetIDList.FromByteArray(ba);
                UInt16 IDListSize = BitConverter.ToUInt16(ba, 0);
                ba = ba.Skip(IDListSize + 2).ToArray();
            }
            #endregion // LINKTARGET_IDLIST

            #region LINKINFO
            if ((Header.LinkFlags & LinkFlags.HasLinkInfo) != 0)
            {
                lnk.LinkInfo = LinkInfo.FromByteArray(ba);
                UInt32 LinkInfoSize = BitConverter.ToUInt32(ba, 0);
                ba = ba.Skip((int)LinkInfoSize).ToArray();
            }
            #endregion // LINKINFO

            #region STRING_DATA
            if ((Header.LinkFlags & LinkFlags.HasName) != 0)
            {
                if (lnk.StringData == null)
                {
                    lnk.StringData = new StringData(IsUnicode);
                }

                UInt16 CountCharacters = BitConverter.ToUInt16(ba, 0);
                if (IsUnicode)
                {
                    lnk.StringData.NameString = Encoding.Unicode.GetString(ba.Skip(2).Take(CountCharacters * 2).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters * 2 + 2).ToArray();
                }
                else
                {
                    lnk.StringData.NameString = Encoding.Default.GetString(ba.Skip(2).Take(CountCharacters).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters + 2).ToArray();
                }
            }

            if ((Header.LinkFlags & LinkFlags.HasRelativePath) != 0)
            {
                if (lnk.StringData == null)
                {
                    lnk.StringData = new StringData(IsUnicode);
                }

                UInt16 CountCharacters = BitConverter.ToUInt16(ba, 0);
                if (IsUnicode)
                {
                    lnk.StringData.RelativePath = Encoding.Unicode.GetString(ba.Skip(2).Take(CountCharacters * 2).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters * 2 + 2).ToArray();
                }
                else
                {
                    lnk.StringData.RelativePath = Encoding.Default.GetString(ba.Skip(2).Take(CountCharacters).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters + 2).ToArray();
                }
            }

            if ((Header.LinkFlags & LinkFlags.HasWorkingDir) != 0)
            {
                if (lnk.StringData == null)
                {
                    lnk.StringData = new StringData(IsUnicode);
                }

                UInt16 CountCharacters = BitConverter.ToUInt16(ba, 0);
                if (IsUnicode)
                {
                    lnk.StringData.WorkingDir = Encoding.Unicode.GetString(ba.Skip(2).Take(CountCharacters * 2).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters * 2 + 2).ToArray();
                }
                else
                {
                    lnk.StringData.WorkingDir = Encoding.Default.GetString(ba.Skip(2).Take(CountCharacters).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters + 2).ToArray();
                }
            }

            if ((Header.LinkFlags & LinkFlags.HasArguments) != 0)
            {
                if (lnk.StringData == null)
                {
                    lnk.StringData = new StringData(IsUnicode);
                }

                UInt16 CountCharacters = BitConverter.ToUInt16(ba, 0);
                if (IsUnicode)
                {
                    lnk.StringData.CommandLineArguments = Encoding.Unicode.GetString(ba.Skip(2).Take(CountCharacters * 2).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters * 2 + 2).ToArray();
                }
                else
                {
                    lnk.StringData.CommandLineArguments = Encoding.Default.GetString(ba.Skip(2).Take(CountCharacters).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters + 2).ToArray();
                }
            }

            if ((Header.LinkFlags & LinkFlags.HasIconLocation) != 0)
            {
                if (lnk.StringData == null)
                {
                    lnk.StringData = new StringData(IsUnicode);
                }

                UInt16 CountCharacters = BitConverter.ToUInt16(ba, 0);
                if (IsUnicode)
                {
                    lnk.StringData.IconLocation = Encoding.Unicode.GetString(ba.Skip(2).Take(CountCharacters * 2).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters * 2 + 2).ToArray();
                }
                else
                {
                    lnk.StringData.IconLocation = Encoding.Default.GetString(ba.Skip(2).Take(CountCharacters).ToArray()).TrimEnd(new char[] { (char)0 });
                    ba = ba.Skip(CountCharacters + 2).ToArray();
                }
            }
            #endregion // STRING_DATA

            #region EXTRA_DATA
            if (ba.Length >= 4)
            {
                lnk.ExtraData = ExtraData.FromByteArray(ba);
            }
            #endregion // EXTRA_DATA

            return(lnk);
        }
Ejemplo n.º 17
0
        protected Stream CreateDecompressionStream(Stream stream, ZipCompressionMethod method)
        {
            switch (method)
            {
            case ZipCompressionMethod.None:
            {
                return(stream);
            }

            case ZipCompressionMethod.Deflate:
            {
                return(new DeflateStream(stream, CompressionMode.Decompress));
            }

            case ZipCompressionMethod.Deflate64:
            {
                return(new Deflate64Stream(stream, CompressionMode.Decompress));
            }

            case ZipCompressionMethod.BZip2:
            {
                return(new BZip2Stream(stream, CompressionMode.Decompress, false));
            }

            case ZipCompressionMethod.LZMA:
            {
                if (FlagUtility.HasFlag(Header.Flags, HeaderFlags.Encrypted))
                {
                    throw new NotSupportedException("LZMA with pkware encryption.");
                }
                var reader = new BinaryReader(stream);
                reader.ReadUInt16();         //LZMA version
                var props = new byte[reader.ReadUInt16()];
                reader.Read(props, 0, props.Length);
                return(new LzmaStream(props, stream,
                                      Header.CompressedSize > 0 ? Header.CompressedSize - 4 - props.Length : -1,
                                      FlagUtility.HasFlag(Header.Flags, HeaderFlags.Bit1)
                                                  ? -1
                                                  : (long)Header.UncompressedSize));
            }

            case ZipCompressionMethod.PPMd:
            {
                Span <byte> props = stackalloc byte[2];
                stream.ReadFully(props);
                return(new PpmdStream(new PpmdProperties(props), stream, false));
            }

            case ZipCompressionMethod.WinzipAes:
            {
                ExtraData data = Header.Extra.SingleOrDefault(x => x.Type == ExtraDataType.WinZipAes);
                if (data is null)
                {
                    throw new InvalidFormatException("No Winzip AES extra data found.");
                }
                if (data.Length != 7)
                {
                    throw new InvalidFormatException("Winzip data length is not 7.");
                }
                ushort compressedMethod = BinaryPrimitives.ReadUInt16LittleEndian(data.DataBytes);

                if (compressedMethod != 0x01 && compressedMethod != 0x02)
                {
                    throw new InvalidFormatException("Unexpected vendor version number for WinZip AES metadata");
                }

                ushort vendorId = BinaryPrimitives.ReadUInt16LittleEndian(data.DataBytes.AsSpan(2));
                if (vendorId != 0x4541)
                {
                    throw new InvalidFormatException("Unexpected vendor ID for WinZip AES metadata");
                }
                return(CreateDecompressionStream(stream, (ZipCompressionMethod)BinaryPrimitives.ReadUInt16LittleEndian(data.DataBytes.AsSpan(5))));
            }

            default:
            {
                throw new NotSupportedException("CompressionMethod: " + Header.CompressionMethod);
            }
            }
        }
Ejemplo n.º 18
0
        static UnityEngine.Object _ReadXmlElement_UnityEngine_Object(XmlReader reader, System.Type elementType, ExtraData extraData = null)
        {
            var meta = new ObjectMeta();

            meta.ReadFromXml(reader);
            return(meta.Find(extraData));
        }
Ejemplo n.º 19
0
 internal ActivityDetails(string rememberMeId, string parentRememberMeId, DateTime?timestamp, YotiProfile yotiProfile, ApplicationProfile applicationProfile, string receiptId, ExtraData extraData)
 {
     RememberMeId       = rememberMeId;
     ParentRememberMeId = parentRememberMeId;
     Timestamp          = timestamp;
     Profile            = yotiProfile;
     ApplicationProfile = applicationProfile;
     ReceiptId          = receiptId;
     ExtraData          = extraData;
 }
Ejemplo n.º 20
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "OBND":
                    if (ObjectBounds == null)
                    {
                        ObjectBounds = new ObjectBounds();
                    }

                    ObjectBounds.ReadBinary(reader);
                    break;

                case "FULL":
                    if (Name == null)
                    {
                        Name = new SimpleSubrecord <String>();
                    }

                    Name.ReadBinary(reader);
                    break;

                case "SCRI":
                    if (Script == null)
                    {
                        Script = new RecordReference();
                    }

                    Script.ReadBinary(reader);
                    break;

                case "EITM":
                    if (ObjectEffect == null)
                    {
                        ObjectEffect = new RecordReference();
                    }

                    ObjectEffect.ReadBinary(reader);
                    break;

                case "BMDT":
                    if (BipedData == null)
                    {
                        BipedData = new BipedData();
                    }

                    BipedData.ReadBinary(reader);
                    break;

                case "MODL":
                    if (MaleBipedModelFileName == null)
                    {
                        MaleBipedModelFileName = new SimpleSubrecord <String>();
                    }

                    MaleBipedModelFileName.ReadBinary(reader);
                    break;

                case "MODT":
                    if (MaleBipedModelTextureHashes == null)
                    {
                        MaleBipedModelTextureHashes = new SimpleSubrecord <Byte[]>();
                    }

                    MaleBipedModelTextureHashes.ReadBinary(reader);
                    break;

                case "MODS":
                    if (MaleBipedModelAlternateTextures == null)
                    {
                        MaleBipedModelAlternateTextures = new AlternateTextures();
                    }

                    MaleBipedModelAlternateTextures.ReadBinary(reader);
                    break;

                case "MODD":
                    if (MaleBipedModelFaceGenModelFlags == null)
                    {
                        MaleBipedModelFaceGenModelFlags = new SimpleSubrecord <FaceGenModelFlags>();
                    }

                    MaleBipedModelFaceGenModelFlags.ReadBinary(reader);
                    break;

                case "MOD2":
                    if (MaleWorldModelFileName == null)
                    {
                        MaleWorldModelFileName = new SimpleSubrecord <String>();
                    }

                    MaleWorldModelFileName.ReadBinary(reader);
                    break;

                case "MO2T":
                    if (MaleWorldModelTextureHashes == null)
                    {
                        MaleWorldModelTextureHashes = new SimpleSubrecord <Byte[]>();
                    }

                    MaleWorldModelTextureHashes.ReadBinary(reader);
                    break;

                case "MO2S":
                    if (MaleWorldModelAlternateTextures == null)
                    {
                        MaleWorldModelAlternateTextures = new AlternateTextures();
                    }

                    MaleWorldModelAlternateTextures.ReadBinary(reader);
                    break;

                case "ICON":
                    if (MaleInventoryIcon == null)
                    {
                        MaleInventoryIcon = new SimpleSubrecord <String>();
                    }

                    MaleInventoryIcon.ReadBinary(reader);
                    break;

                case "MICO":
                    if (MaleMessageIcon == null)
                    {
                        MaleMessageIcon = new SimpleSubrecord <String>();
                    }

                    MaleMessageIcon.ReadBinary(reader);
                    break;

                case "MOD3":
                    if (FemaleBipedModelFileName == null)
                    {
                        FemaleBipedModelFileName = new SimpleSubrecord <String>();
                    }

                    FemaleBipedModelFileName.ReadBinary(reader);
                    break;

                case "MO3T":
                    if (FemaleBipedModelTextureHashes == null)
                    {
                        FemaleBipedModelTextureHashes = new SimpleSubrecord <Byte[]>();
                    }

                    FemaleBipedModelTextureHashes.ReadBinary(reader);
                    break;

                case "MO3S":
                    if (FemaleBipedModelAlternateTextures == null)
                    {
                        FemaleBipedModelAlternateTextures = new AlternateTextures();
                    }

                    FemaleBipedModelAlternateTextures.ReadBinary(reader);
                    break;

                case "MOSD":
                    if (FemaleBipedModelFaceGenModelFlags == null)
                    {
                        FemaleBipedModelFaceGenModelFlags = new SimpleSubrecord <FaceGenModelFlags>();
                    }

                    FemaleBipedModelFaceGenModelFlags.ReadBinary(reader);
                    break;

                case "MOD4":
                    if (FemaleWorldModelFileName == null)
                    {
                        FemaleWorldModelFileName = new SimpleSubrecord <String>();
                    }

                    FemaleWorldModelFileName.ReadBinary(reader);
                    break;

                case "MO4T":
                    if (FemaleWorldModelTextureHashes == null)
                    {
                        FemaleWorldModelTextureHashes = new SimpleSubrecord <Byte[]>();
                    }

                    FemaleWorldModelTextureHashes.ReadBinary(reader);
                    break;

                case "MO4S":
                    if (FemaleWorldModelAlternateTextures == null)
                    {
                        FemaleWorldModelAlternateTextures = new AlternateTextures();
                    }

                    FemaleWorldModelAlternateTextures.ReadBinary(reader);
                    break;

                case "ICO2":
                    if (FemaleInventoryIcon == null)
                    {
                        FemaleInventoryIcon = new SimpleSubrecord <String>();
                    }

                    FemaleInventoryIcon.ReadBinary(reader);
                    break;

                case "MIC2":
                    if (FemaleMessageIcon == null)
                    {
                        FemaleMessageIcon = new SimpleSubrecord <String>();
                    }

                    FemaleMessageIcon.ReadBinary(reader);
                    break;

                case "BMCT":
                    if (RagdollConstraintTemplate == null)
                    {
                        RagdollConstraintTemplate = new SimpleSubrecord <String>();
                    }

                    RagdollConstraintTemplate.ReadBinary(reader);
                    break;

                case "REPL":
                    if (RepairList == null)
                    {
                        RepairList = new RecordReference();
                    }

                    RepairList.ReadBinary(reader);
                    break;

                case "BIPL":
                    if (BipedModelList == null)
                    {
                        BipedModelList = new RecordReference();
                    }

                    BipedModelList.ReadBinary(reader);
                    break;

                case "ETYP":
                    if (EquipmentType == null)
                    {
                        EquipmentType = new SimpleSubrecord <EquipmentType>();
                    }

                    EquipmentType.ReadBinary(reader);
                    break;

                case "YNAM":
                    if (PickupSound == null)
                    {
                        PickupSound = new RecordReference();
                    }

                    PickupSound.ReadBinary(reader);
                    break;

                case "ZNAM":
                    if (DropSound == null)
                    {
                        DropSound = new RecordReference();
                    }

                    DropSound.ReadBinary(reader);
                    break;

                case "DATA":
                    if (Data == null)
                    {
                        Data = new ArmorData();
                    }

                    Data.ReadBinary(reader);
                    break;

                case "DNAM":
                    if (ExtraData == null)
                    {
                        ExtraData = new ArmorExtraData();
                    }

                    ExtraData.ReadBinary(reader);
                    break;

                case "BNAM":
                    if (OverridesAnimationSounds == null)
                    {
                        OverridesAnimationSounds = new SimpleSubrecord <NoYes>();
                    }

                    OverridesAnimationSounds.ReadBinary(reader);
                    break;

                case "SNAM":
                    if (AnimationSounds == null)
                    {
                        AnimationSounds = new List <AnimationSound>();
                    }

                    AnimationSound tempSNAM = new AnimationSound();
                    tempSNAM.ReadBinary(reader);
                    AnimationSounds.Add(tempSNAM);
                    break;

                case "TNAM":
                    if (AnimationSoundsTemplate == null)
                    {
                        AnimationSoundsTemplate = new RecordReference();
                    }

                    AnimationSoundsTemplate.ReadBinary(reader);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
Ejemplo n.º 21
0
        private void LoadHeader(ZipFileEntry entryHeader, Stream stream)
        {
            if (FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.Encrypted))
            {
                if (!entryHeader.IsDirectory && entryHeader.CompressedSize == 0 &&
                    FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
                {
                    throw new NotSupportedException("SharpCompress cannot currently read non-seekable Zip Streams with encrypted data that has been written in a non-seekable manner.");
                }

                if (_password == null)
                {
                    throw new CryptographicException("No password supplied for encrypted zip.");
                }

                entryHeader.Password = _password;

                if (entryHeader.CompressionMethod == ZipCompressionMethod.WinzipAes)
                {
                    ExtraData data = entryHeader.Extra.SingleOrDefault(x => x.Type == ExtraDataType.WinZipAes);
                    if (data != null)
                    {
                        var keySize = (WinzipAesKeySize)data.DataBytes[4];

                        var salt = new byte[WinzipAesEncryptionData.KeyLengthInBytes(keySize) / 2];
                        var passwordVerifyValue = new byte[2];
                        stream.Read(salt, 0, salt.Length);
                        stream.Read(passwordVerifyValue, 0, 2);
                        entryHeader.WinzipAesEncryptionData =
                            new WinzipAesEncryptionData(keySize, salt, passwordVerifyValue, _password);

                        entryHeader.CompressedSize -= (uint)(salt.Length + 2);
                    }
                }
            }

            if (entryHeader.IsDirectory)
            {
                return;
            }

            //if (FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
            //{
            //    entryHeader.PackedStream = new ReadOnlySubStream(stream);
            //}
            //else
            //{
            switch (_mode)
            {
            case StreamingMode.Seekable:
            {
                entryHeader.DataStartPosition = stream.Position;
                stream.Position += entryHeader.CompressedSize;
                break;
            }

            case StreamingMode.Streaming:
            {
                entryHeader.PackedStream = stream;
                break;
            }

            default:
            {
                throw new InvalidFormatException("Invalid StreamingMode");
            }
            }

            //}
        }
Ejemplo n.º 22
0
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (ObjectBounds != null)
     {
         ObjectBounds.WriteBinary(writer);
     }
     if (Name != null)
     {
         Name.WriteBinary(writer);
     }
     if (Script != null)
     {
         Script.WriteBinary(writer);
     }
     if (ObjectEffect != null)
     {
         ObjectEffect.WriteBinary(writer);
     }
     if (BipedData != null)
     {
         BipedData.WriteBinary(writer);
     }
     if (MaleBipedModelFileName != null)
     {
         MaleBipedModelFileName.WriteBinary(writer);
     }
     if (MaleBipedModelTextureHashes != null)
     {
         MaleBipedModelTextureHashes.WriteBinary(writer);
     }
     if (MaleBipedModelAlternateTextures != null)
     {
         MaleBipedModelAlternateTextures.WriteBinary(writer);
     }
     if (MaleBipedModelFaceGenModelFlags != null)
     {
         MaleBipedModelFaceGenModelFlags.WriteBinary(writer);
     }
     if (MaleWorldModelFileName != null)
     {
         MaleWorldModelFileName.WriteBinary(writer);
     }
     if (MaleWorldModelTextureHashes != null)
     {
         MaleWorldModelTextureHashes.WriteBinary(writer);
     }
     if (MaleWorldModelAlternateTextures != null)
     {
         MaleWorldModelAlternateTextures.WriteBinary(writer);
     }
     if (MaleInventoryIcon != null)
     {
         MaleInventoryIcon.WriteBinary(writer);
     }
     if (MaleMessageIcon != null)
     {
         MaleMessageIcon.WriteBinary(writer);
     }
     if (FemaleBipedModelFileName != null)
     {
         FemaleBipedModelFileName.WriteBinary(writer);
     }
     if (FemaleBipedModelTextureHashes != null)
     {
         FemaleBipedModelTextureHashes.WriteBinary(writer);
     }
     if (FemaleBipedModelAlternateTextures != null)
     {
         FemaleBipedModelAlternateTextures.WriteBinary(writer);
     }
     if (FemaleBipedModelFaceGenModelFlags != null)
     {
         FemaleBipedModelFaceGenModelFlags.WriteBinary(writer);
     }
     if (FemaleWorldModelFileName != null)
     {
         FemaleWorldModelFileName.WriteBinary(writer);
     }
     if (FemaleWorldModelTextureHashes != null)
     {
         FemaleWorldModelTextureHashes.WriteBinary(writer);
     }
     if (FemaleWorldModelAlternateTextures != null)
     {
         FemaleWorldModelAlternateTextures.WriteBinary(writer);
     }
     if (FemaleInventoryIcon != null)
     {
         FemaleInventoryIcon.WriteBinary(writer);
     }
     if (FemaleMessageIcon != null)
     {
         FemaleMessageIcon.WriteBinary(writer);
     }
     if (RagdollConstraintTemplate != null)
     {
         RagdollConstraintTemplate.WriteBinary(writer);
     }
     if (RepairList != null)
     {
         RepairList.WriteBinary(writer);
     }
     if (BipedModelList != null)
     {
         BipedModelList.WriteBinary(writer);
     }
     if (EquipmentType != null)
     {
         EquipmentType.WriteBinary(writer);
     }
     if (PickupSound != null)
     {
         PickupSound.WriteBinary(writer);
     }
     if (DropSound != null)
     {
         DropSound.WriteBinary(writer);
     }
     if (Data != null)
     {
         Data.WriteBinary(writer);
     }
     if (ExtraData != null)
     {
         ExtraData.WriteBinary(writer);
     }
     if (OverridesAnimationSounds != null)
     {
         OverridesAnimationSounds.WriteBinary(writer);
     }
     if (AnimationSounds != null)
     {
         foreach (var item in AnimationSounds)
         {
             item.WriteBinary(writer);
         }
     }
     if (AnimationSoundsTemplate != null)
     {
         AnimationSoundsTemplate.WriteBinary(writer);
     }
 }
Ejemplo n.º 23
0
        protected Stream CreateDecompressionStream(Stream stream)
        {
            switch (Header.CompressionMethod)
            {
            case ZipCompressionMethod.None:
            {
                return(stream);
            }

            case ZipCompressionMethod.Deflate:
            {
                return(new System.IO.Compression.DeflateStream(stream,
                                                               System.IO.Compression.CompressionMode.Decompress));
            }

#if BZIP2
            case ZipCompressionMethod.BZip2:
            {
                return(new BZip2Stream(stream, CompressionMode.Decompress));
            }
#endif
#if LZMA
            case ZipCompressionMethod.LZMA:
            {
                if (FlagUtility.HasFlag(Header.Flags, HeaderFlags.Encrypted))
                {
                    throw new NotSupportedException("LZMA with pkware encryption.");
                }
                var reader = new BinaryReader(stream);
                reader.ReadUInt16();         //LZMA version
                var props = new byte[reader.ReadUInt16()];
                reader.Read(props, 0, props.Length);
                return(new LzmaStream(props, stream,
                                      Header.CompressedSize > 0 ? Header.CompressedSize - 4 - props.Length : -1,
                                      FlagUtility.HasFlag(Header.Flags, HeaderFlags.Bit1)
                                                  ? -1
                                                  : (long)Header.UncompressedSize));
            }
#endif
#if PPMd
            case ZipCompressionMethod.PPMd:
            {
                var props = new byte[2];
                stream.Read(props, 0, props.Length);
                return(new PpmdStream(new PpmdProperties(props), stream, false));
            }
#endif
            case ZipCompressionMethod.WinzipAes:
            {
                ExtraData data = Header.Extra.Where(x => x.Type == ExtraDataType.WinZipAes).SingleOrDefault();
                if (data == null)
                {
                    throw new InvalidFormatException("No Winzip AES extra data found.");
                }
                if (data.Length != 7)
                {
                    throw new InvalidFormatException("Winzip data length is not 7.");
                }
                ushort method = BitConverter.ToUInt16(data.DataBytes, 0);

                if (method != 0x01 && method != 0x02)
                {
                    throw new InvalidFormatException("Unexpected vendor version number for WinZip AES metadata");
                }

                ushort vendorId = BitConverter.ToUInt16(data.DataBytes, 2);
                if (vendorId != 0x4541)
                {
                    throw new InvalidFormatException("Unexpected vendor ID for WinZip AES metadata");
                }
                Header.CompressionMethod = (ZipCompressionMethod)BitConverter.ToUInt16(data.DataBytes, 5);
                return(CreateDecompressionStream(stream));
            }

            default:
            {
                throw new NotSupportedException("CompressionMethod: " + Header.CompressionMethod);
            }
            }
        }
Ejemplo n.º 24
0
        public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (EditorID != null)
            {
                ele.TryPathTo("EditorID", true, out subEle);
                EditorID.WriteXML(subEle, master);
            }
            if (ObjectBounds != null)
            {
                ele.TryPathTo("ObjectBounds", true, out subEle);
                ObjectBounds.WriteXML(subEle, master);
            }
            if (Name != null)
            {
                ele.TryPathTo("Name", true, out subEle);
                Name.WriteXML(subEle, master);
            }
            if (Script != null)
            {
                ele.TryPathTo("Script", true, out subEle);
                Script.WriteXML(subEle, master);
            }
            if (ObjectEffect != null)
            {
                ele.TryPathTo("ObjectEffect", true, out subEle);
                ObjectEffect.WriteXML(subEle, master);
            }
            if (BipedData != null)
            {
                ele.TryPathTo("BipedData", true, out subEle);
                BipedData.WriteXML(subEle, master);
            }
            if (MaleBipedModelFileName != null)
            {
                ele.TryPathTo("Models/Biped/Male/FileName", true, out subEle);
                MaleBipedModelFileName.WriteXML(subEle, master);
            }
            if (MaleBipedModelTextureHashes != null)
            {
                ele.TryPathTo("Models/Biped/Male/TextureHashes", true, out subEle);
                MaleBipedModelTextureHashes.WriteXML(subEle, master);
            }
            if (MaleBipedModelAlternateTextures != null)
            {
                ele.TryPathTo("Models/Biped/Male/AlternateTextures", true, out subEle);
                MaleBipedModelAlternateTextures.WriteXML(subEle, master);
            }
            if (MaleBipedModelFaceGenModelFlags != null)
            {
                ele.TryPathTo("Models/Biped/Male/FaceGenModelFlags", true, out subEle);
                MaleBipedModelFaceGenModelFlags.WriteXML(subEle, master);
            }
            if (MaleWorldModelFileName != null)
            {
                ele.TryPathTo("Models/World/Male/FileName", true, out subEle);
                MaleWorldModelFileName.WriteXML(subEle, master);
            }
            if (MaleWorldModelTextureHashes != null)
            {
                ele.TryPathTo("Models/World/Male/TextureHashes", true, out subEle);
                MaleWorldModelTextureHashes.WriteXML(subEle, master);
            }
            if (MaleWorldModelAlternateTextures != null)
            {
                ele.TryPathTo("Models/World/Male/AlternateTextures", true, out subEle);
                MaleWorldModelAlternateTextures.WriteXML(subEle, master);
            }
            if (MaleInventoryIcon != null)
            {
                ele.TryPathTo("Icon/Inventory/Male", true, out subEle);
                MaleInventoryIcon.WriteXML(subEle, master);
            }
            if (MaleMessageIcon != null)
            {
                ele.TryPathTo("Icon/Message/Male", true, out subEle);
                MaleMessageIcon.WriteXML(subEle, master);
            }
            if (FemaleBipedModelFileName != null)
            {
                ele.TryPathTo("Models/Biped/Female/FileName", true, out subEle);
                FemaleBipedModelFileName.WriteXML(subEle, master);
            }
            if (FemaleBipedModelTextureHashes != null)
            {
                ele.TryPathTo("Models/Biped/Female/TextureHashes", true, out subEle);
                FemaleBipedModelTextureHashes.WriteXML(subEle, master);
            }
            if (FemaleBipedModelAlternateTextures != null)
            {
                ele.TryPathTo("Models/Biped/Female/AlternateTextures", true, out subEle);
                FemaleBipedModelAlternateTextures.WriteXML(subEle, master);
            }
            if (FemaleBipedModelFaceGenModelFlags != null)
            {
                ele.TryPathTo("Models/Biped/Female/FaceGenModelFlags", true, out subEle);
                FemaleBipedModelFaceGenModelFlags.WriteXML(subEle, master);
            }
            if (FemaleWorldModelFileName != null)
            {
                ele.TryPathTo("Models/World/Female/FileName", true, out subEle);
                FemaleWorldModelFileName.WriteXML(subEle, master);
            }
            if (FemaleWorldModelTextureHashes != null)
            {
                ele.TryPathTo("Models/World/Female/TextureHashes", true, out subEle);
                FemaleWorldModelTextureHashes.WriteXML(subEle, master);
            }
            if (FemaleWorldModelAlternateTextures != null)
            {
                ele.TryPathTo("Models/World/Female/AlternateTextures", true, out subEle);
                FemaleWorldModelAlternateTextures.WriteXML(subEle, master);
            }
            if (FemaleInventoryIcon != null)
            {
                ele.TryPathTo("Icon/Inventory/Female", true, out subEle);
                FemaleInventoryIcon.WriteXML(subEle, master);
            }
            if (FemaleMessageIcon != null)
            {
                ele.TryPathTo("Icon/Message/Female", true, out subEle);
                FemaleMessageIcon.WriteXML(subEle, master);
            }
            if (RagdollConstraintTemplate != null)
            {
                ele.TryPathTo("RagdollConstraintTemplate", true, out subEle);
                RagdollConstraintTemplate.WriteXML(subEle, master);
            }
            if (RepairList != null)
            {
                ele.TryPathTo("RepairList", true, out subEle);
                RepairList.WriteXML(subEle, master);
            }
            if (BipedModelList != null)
            {
                ele.TryPathTo("BipedModelList", true, out subEle);
                BipedModelList.WriteXML(subEle, master);
            }
            if (EquipmentType != null)
            {
                ele.TryPathTo("EquipmentType", true, out subEle);
                EquipmentType.WriteXML(subEle, master);
            }
            if (PickupSound != null)
            {
                ele.TryPathTo("PickupSound", true, out subEle);
                PickupSound.WriteXML(subEle, master);
            }
            if (DropSound != null)
            {
                ele.TryPathTo("DropSound", true, out subEle);
                DropSound.WriteXML(subEle, master);
            }
            if (Data != null)
            {
                ele.TryPathTo("Data", true, out subEle);
                Data.WriteXML(subEle, master);
            }
            if (ExtraData != null)
            {
                ele.TryPathTo("ExtraData", true, out subEle);
                ExtraData.WriteXML(subEle, master);
            }
            if (OverridesAnimationSounds != null)
            {
                ele.TryPathTo("OverridesAnimationSounds", true, out subEle);
                OverridesAnimationSounds.WriteXML(subEle, master);
            }
            if (AnimationSounds != null)
            {
                ele.TryPathTo("AnimationSounds", true, out subEle);
                List <string> xmlNames = new List <string> {
                    "Sound"
                };
                int i = 0;
                foreach (var entry in AnimationSounds)
                {
                    i = i % xmlNames.Count();
                    XElement newEle = new XElement(xmlNames[i]);
                    entry.WriteXML(newEle, master);
                    subEle.Add(newEle);
                    i++;
                }
            }
            if (AnimationSoundsTemplate != null)
            {
                ele.TryPathTo("AnimationSoundsTemplate", true, out subEle);
                AnimationSoundsTemplate.WriteXML(subEle, master);
            }
        }
Ejemplo n.º 25
0
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (ObjectBounds != null)
     {
         ObjectBounds.WriteBinary(writer);
     }
     if (Name != null)
     {
         Name.WriteBinary(writer);
     }
     if (Model != null)
     {
         Model.WriteBinary(writer);
     }
     if (LargeIcon != null)
     {
         LargeIcon.WriteBinary(writer);
     }
     if (SmallIcon != null)
     {
         SmallIcon.WriteBinary(writer);
     }
     if (Script != null)
     {
         Script.WriteBinary(writer);
     }
     if (Destructable != null)
     {
         Destructable.WriteBinary(writer);
     }
     if (PickUpSound != null)
     {
         PickUpSound.WriteBinary(writer);
     }
     if (DropSound != null)
     {
         DropSound.WriteBinary(writer);
     }
     if (Data != null)
     {
         Data.WriteBinary(writer);
     }
     if (ExtraData != null)
     {
         ExtraData.WriteBinary(writer);
     }
     if (ShortName != null)
     {
         ShortName.WriteBinary(writer);
     }
     if (Abbreviation != null)
     {
         Abbreviation.WriteBinary(writer);
     }
     if (AmmoEffects != null)
     {
         foreach (var item in AmmoEffects)
         {
             item.WriteBinary(writer);
         }
     }
 }
Ejemplo n.º 26
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ObjectBounds", false, out subEle))
            {
                if (ObjectBounds == null)
                {
                    ObjectBounds = new ObjectBounds();
                }

                ObjectBounds.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Name", false, out subEle))
            {
                if (Name == null)
                {
                    Name = new SimpleSubrecord <String>();
                }

                Name.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Script", false, out subEle))
            {
                if (Script == null)
                {
                    Script = new RecordReference();
                }

                Script.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ObjectEffect", false, out subEle))
            {
                if (ObjectEffect == null)
                {
                    ObjectEffect = new RecordReference();
                }

                ObjectEffect.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("BipedData", false, out subEle))
            {
                if (BipedData == null)
                {
                    BipedData = new BipedData();
                }

                BipedData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Male/FileName", false, out subEle))
            {
                if (MaleBipedModelFileName == null)
                {
                    MaleBipedModelFileName = new SimpleSubrecord <String>();
                }

                MaleBipedModelFileName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Male/TextureHashes", false, out subEle))
            {
                if (MaleBipedModelTextureHashes == null)
                {
                    MaleBipedModelTextureHashes = new SimpleSubrecord <Byte[]>();
                }

                MaleBipedModelTextureHashes.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Male/AlternateTextures", false, out subEle))
            {
                if (MaleBipedModelAlternateTextures == null)
                {
                    MaleBipedModelAlternateTextures = new AlternateTextures();
                }

                MaleBipedModelAlternateTextures.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Male/FaceGenModelFlags", false, out subEle))
            {
                if (MaleBipedModelFaceGenModelFlags == null)
                {
                    MaleBipedModelFaceGenModelFlags = new SimpleSubrecord <FaceGenModelFlags>();
                }

                MaleBipedModelFaceGenModelFlags.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Male/FileName", false, out subEle))
            {
                if (MaleWorldModelFileName == null)
                {
                    MaleWorldModelFileName = new SimpleSubrecord <String>();
                }

                MaleWorldModelFileName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Male/TextureHashes", false, out subEle))
            {
                if (MaleWorldModelTextureHashes == null)
                {
                    MaleWorldModelTextureHashes = new SimpleSubrecord <Byte[]>();
                }

                MaleWorldModelTextureHashes.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Male/AlternateTextures", false, out subEle))
            {
                if (MaleWorldModelAlternateTextures == null)
                {
                    MaleWorldModelAlternateTextures = new AlternateTextures();
                }

                MaleWorldModelAlternateTextures.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Inventory/Male", false, out subEle))
            {
                if (MaleInventoryIcon == null)
                {
                    MaleInventoryIcon = new SimpleSubrecord <String>();
                }

                MaleInventoryIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Message/Male", false, out subEle))
            {
                if (MaleMessageIcon == null)
                {
                    MaleMessageIcon = new SimpleSubrecord <String>();
                }

                MaleMessageIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Female/FileName", false, out subEle))
            {
                if (FemaleBipedModelFileName == null)
                {
                    FemaleBipedModelFileName = new SimpleSubrecord <String>();
                }

                FemaleBipedModelFileName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Female/TextureHashes", false, out subEle))
            {
                if (FemaleBipedModelTextureHashes == null)
                {
                    FemaleBipedModelTextureHashes = new SimpleSubrecord <Byte[]>();
                }

                FemaleBipedModelTextureHashes.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Female/AlternateTextures", false, out subEle))
            {
                if (FemaleBipedModelAlternateTextures == null)
                {
                    FemaleBipedModelAlternateTextures = new AlternateTextures();
                }

                FemaleBipedModelAlternateTextures.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/Biped/Female/FaceGenModelFlags", false, out subEle))
            {
                if (FemaleBipedModelFaceGenModelFlags == null)
                {
                    FemaleBipedModelFaceGenModelFlags = new SimpleSubrecord <FaceGenModelFlags>();
                }

                FemaleBipedModelFaceGenModelFlags.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Female/FileName", false, out subEle))
            {
                if (FemaleWorldModelFileName == null)
                {
                    FemaleWorldModelFileName = new SimpleSubrecord <String>();
                }

                FemaleWorldModelFileName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Female/TextureHashes", false, out subEle))
            {
                if (FemaleWorldModelTextureHashes == null)
                {
                    FemaleWorldModelTextureHashes = new SimpleSubrecord <Byte[]>();
                }

                FemaleWorldModelTextureHashes.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Models/World/Female/AlternateTextures", false, out subEle))
            {
                if (FemaleWorldModelAlternateTextures == null)
                {
                    FemaleWorldModelAlternateTextures = new AlternateTextures();
                }

                FemaleWorldModelAlternateTextures.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Inventory/Female", false, out subEle))
            {
                if (FemaleInventoryIcon == null)
                {
                    FemaleInventoryIcon = new SimpleSubrecord <String>();
                }

                FemaleInventoryIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Message/Female", false, out subEle))
            {
                if (FemaleMessageIcon == null)
                {
                    FemaleMessageIcon = new SimpleSubrecord <String>();
                }

                FemaleMessageIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("RagdollConstraintTemplate", false, out subEle))
            {
                if (RagdollConstraintTemplate == null)
                {
                    RagdollConstraintTemplate = new SimpleSubrecord <String>();
                }

                RagdollConstraintTemplate.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("RepairList", false, out subEle))
            {
                if (RepairList == null)
                {
                    RepairList = new RecordReference();
                }

                RepairList.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("BipedModelList", false, out subEle))
            {
                if (BipedModelList == null)
                {
                    BipedModelList = new RecordReference();
                }

                BipedModelList.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EquipmentType", false, out subEle))
            {
                if (EquipmentType == null)
                {
                    EquipmentType = new SimpleSubrecord <EquipmentType>();
                }

                EquipmentType.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("PickupSound", false, out subEle))
            {
                if (PickupSound == null)
                {
                    PickupSound = new RecordReference();
                }

                PickupSound.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("DropSound", false, out subEle))
            {
                if (DropSound == null)
                {
                    DropSound = new RecordReference();
                }

                DropSound.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new ArmorData();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ExtraData", false, out subEle))
            {
                if (ExtraData == null)
                {
                    ExtraData = new ArmorExtraData();
                }

                ExtraData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("OverridesAnimationSounds", false, out subEle))
            {
                if (OverridesAnimationSounds == null)
                {
                    OverridesAnimationSounds = new SimpleSubrecord <NoYes>();
                }

                OverridesAnimationSounds.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("AnimationSounds", false, out subEle))
            {
                if (AnimationSounds == null)
                {
                    AnimationSounds = new List <AnimationSound>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    AnimationSound tempSNAM = new AnimationSound();
                    tempSNAM.ReadXML(e, master);
                    AnimationSounds.Add(tempSNAM);
                }
            }
            if (ele.TryPathTo("AnimationSoundsTemplate", false, out subEle))
            {
                if (AnimationSoundsTemplate == null)
                {
                    AnimationSoundsTemplate = new RecordReference();
                }

                AnimationSoundsTemplate.ReadXML(subEle, master);
            }
        }
Ejemplo n.º 27
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ObjectBounds", false, out subEle))
            {
                if (ObjectBounds == null)
                {
                    ObjectBounds = new ObjectBounds();
                }

                ObjectBounds.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Name", false, out subEle))
            {
                if (Name == null)
                {
                    Name = new SimpleSubrecord <String>();
                }

                Name.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Model", false, out subEle))
            {
                if (Model == null)
                {
                    Model = new Model();
                }

                Model.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Large", false, out subEle))
            {
                if (LargeIcon == null)
                {
                    LargeIcon = new SimpleSubrecord <String>();
                }

                LargeIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Small", false, out subEle))
            {
                if (SmallIcon == null)
                {
                    SmallIcon = new SimpleSubrecord <String>();
                }

                SmallIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Script", false, out subEle))
            {
                if (Script == null)
                {
                    Script = new RecordReference();
                }

                Script.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Destructable", false, out subEle))
            {
                if (Destructable == null)
                {
                    Destructable = new Destructable();
                }

                Destructable.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("PickUpSound", false, out subEle))
            {
                if (PickUpSound == null)
                {
                    PickUpSound = new RecordReference();
                }

                PickUpSound.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("DropSound", false, out subEle))
            {
                if (DropSound == null)
                {
                    DropSound = new RecordReference();
                }

                DropSound.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new AmmoData();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ExtraData", false, out subEle))
            {
                if (ExtraData == null)
                {
                    ExtraData = new AmmoExtraData();
                }

                ExtraData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ShortName", false, out subEle))
            {
                if (ShortName == null)
                {
                    ShortName = new SimpleSubrecord <String>();
                }

                ShortName.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Abbreviation", false, out subEle))
            {
                if (Abbreviation == null)
                {
                    Abbreviation = new SimpleSubrecord <String>();
                }

                Abbreviation.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("AmmoEffects", false, out subEle))
            {
                if (AmmoEffects == null)
                {
                    AmmoEffects = new List <RecordReference>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    RecordReference tempRCIL = new RecordReference();
                    tempRCIL.ReadXML(e, master);
                    AmmoEffects.Add(tempRCIL);
                }
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Adds extra data to this item
 /// </summary>
 /// <param name="data">The data to add to the item</param>
 public void AddExtraData(params DataHolderBase[] data)
 {
     ExtraData ??= new ExtraDataList();
     ExtraData.AddData(data);
 }
Ejemplo n.º 29
0
 public GateEvent(ICompositeKey <GateEvent> id, string name, ExtraData extraData = null) : base(id, name,
                                                                                                extraData)
 {
 }
Ejemplo n.º 30
0
 public GateTariff(CompositeKey <GateTariff> id, string name, ExtraData extraData = null) : base(id, name,
                                                                                                 extraData)
 {
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Shortcut() : base()
 {
     ExtraData = new ExtraData();
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Creates a new asset by the card params.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="cost"></param>
 /// <param name="artPath"></param>
 /// <param name="extraData"></param>
 private void ImportCardsToResources(string name, int cost, string artPath, ExtraData extraData)
 {
     CardData.BuildNewAsset(name, cost, artPath.ToString(), extraData);
 }
Ejemplo n.º 33
0
 public GateCustomer(ICompositeKey <GateCustomer> id, string name, ExtraData extraData = null) : base(id, name,
                                                                                                      extraData)
 {
 }
Ejemplo n.º 34
0
 public void Redo(long since, Level l) {
     ExtraData<Tuple<short, short, short>, Tuple<long, byte>> toChange = new ExtraData<Tuple<short, short, short>, Tuple<long, byte>>();
     toChange = redo(player.UID, since, l);
     redo(toChange, l, player.UID, player);
 }
Ejemplo n.º 35
0
 public GateHallArea(ICompositeKey <GateHallArea> id, string name, GateHallAreaType areaType,
                     ExtraData extraData = null) : base(id, name, extraData)
 {
     AreaType = areaType;
 }
Ejemplo n.º 36
0
 private static void redo(ExtraData<Tuple<short, short, short>, Tuple<long, byte>> toChange, Level l, long UID, Player p = null) {
     MemoryStream ms = new MemoryStream();
     BinaryWriter bw = new BinaryWriter(ms);
     foreach (Tuple<short, short, short> v in toChange.Keys) {
         byte currentBlock = l.GetBlock(v.Item1, v.Item2, v.Item3);
         byte newBlock = toChange[v].Item2;
         if (currentBlock != newBlock) {
             if (p != null && p.Level == l) {
                 lock (p.history.lock_recent) {
                     p.history.recentTimes.Add(DateTime.Now.Ticks);
                     p.history.recentChanges.Add(new Tuple<Tuple<short, short, short>, byte, byte>(v, currentBlock, newBlock));
                 }
             }
             else {
                 bw.Write(DateTime.Now.Ticks);
                 bw.Write(v.Item1);
                 bw.Write(v.Item2);
                 bw.Write(v.Item3);
                 bw.Write(currentBlock);
                 bw.Write(newBlock);
             }
             l.BlockChange(new Vector3S(v.Item1, v.Item2, v.Item3), newBlock); //TODO: Create BlockChange(short,short,short);
         }
     }
     bw.Close();
     if (ms.Length != 0) {
         string path = GetFullPath((p == null) ? UID : p.UID, l);
         ms.Position = 0;
         BinaryReader br = new BinaryReader(ms);
         long initialTime = br.ReadInt64();
         br.Close();
         FileStream fs = new FileStream(path + initialTime + historyEnding, FileMode.Create, FileAccess.Write);
         GZipStream gz = new GZipStream(fs, CompressionMode.Compress);
         gz.Write(ms.ToArray(), 0, (int)ms.Length);
         gz.Close();
         fs.Close();
     }
     ms.Close();
 }
Ejemplo n.º 37
0
 public GateVenue(CompositeKey <GateVenue> id, string name, string address, ExtraData extraData = null) : base(id,
                                                                                                               name, extraData)
 {
     Address = address;
 }
Ejemplo n.º 38
0
 private static ExtraData<Tuple<short, short, short>, Tuple<long, byte>> redo(long UID, long since, Level l) {
     ExtraData<Tuple<short, short, short>, Tuple<long, byte>> toChange = new ExtraData<Tuple<short, short, short>, Tuple<long, byte>>();
     lock (lock_archive) {
         string path = GetFullPath(UID, l);
         if (Directory.Exists(path)) {
             string[] files = Directory.GetFiles(path, futureEnding);
             List<string> toRedo = new List<string>();
             foreach (string file in files) {
                 if (!file.EndsWith(futureEnding)) continue;
                 try {
                     long time = long.Parse(file.Split('.')[0]);
                     if (time >= since) toRedo.Add(file);
                 }
                 catch { }
             }
             foreach (string file in toRedo) {
                 try {
                     long time = long.Parse(file.Split('.')[0]);
                     FileStream fs = new FileStream(path + file, FileMode.Open, FileAccess.Read);
                     GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                     MemoryStream ms = new MemoryStream();
                     int r = 0;
                     byte[] buffer = new byte[1024];
                     while ((r = gz.Read(buffer, 0, buffer.Length)) != -1) {
                         ms.Write(buffer, 0, r);
                     }
                     gz.Close();
                     fs.Close();
                     ms.Position = 0;
                     BinaryReader br = new BinaryReader(ms);
                     while (ms.Position < ms.Length) {
                         Tuple<short, short, short> v = new Tuple<short, short, short>(br.ReadInt16(), br.ReadInt16(), br.ReadInt16());
                         byte t = br.ReadByte();
                         if (toChange[v] == null || toChange[v].Item1 < time)
                             toChange[v] = new Tuple<long, byte>(time, t);
                     }
                     br.Close();
                     ms.Close();
                 }
                 catch { }
             }
         }
     }
     return toChange;
 }
Ejemplo n.º 39
0
 public GateHall(ICompositeKey <GateHall> id, string name, GateEntityReference <GateVenue> venueReference,
                 ExtraData extraData = null) : base(id, name, extraData)
 {
     VenueReference = venueReference;
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Returns all the blocks in the state they were before they got changed and removes them from history.
 /// </summary>
 /// <param name="since">The date time of the oldest blockchange</param>
 /// <returns>An ExtraData collection containing positions, times and types of the old blocks</returns>
 private ExtraData<Tuple<short, short, short>, Tuple<long, byte>> GetOriginalBlocks(long since, Level l) {
     ExtraData<Tuple<short, short, short>, Tuple<long, byte>> ret = new ExtraData<Tuple<short, short, short>, Tuple<long, byte>>();
     lock (lock_recent) {
         if (l == player.Level && recentTimes.Count > 0 && recentTimes[0] < since) {
             int i;
             for (i = recentTimes.Count - 1; recentTimes[i] >= since; i--) { //looping back in time
                 ret[recentChanges[i].Item1] = new Tuple<long, byte>(0, recentChanges[i].Item2); //if vector already exists it gets replaced else added
             }
             if (i < recentTimes.Count - 1) {
                 recentTimes.RemoveRange(i + 1, recentTimes.Count - 1 - i);
                 recentChanges.RemoveRange(i + 1, recentChanges.Count - 1 - i);
             }
             return ret; //this should later be passed to all other existing histories of level to redo their stuff during the undo timespawn
         }
     }
     lock (lock_recent) {
         if (l == player.Level) {
             for (int i = recentTimes.Count - 1; i >= 0; i--) {
                 ret[recentChanges[i].Item1] = new Tuple<long, byte>(0, recentChanges[i].Item2);
             }
             recentTimes = new List<long>();
             recentChanges = new List<Tuple<Tuple<short, short, short>, byte, byte>>();
         }
     }
     return ret;
 }
Ejemplo n.º 41
0
        public void AttributeIssuanceDetailsShouldBeNullWhenNoDataEntries()
        {
            ExtraData extraData = new ExtraData(new List <object>());

            Assert.IsNull(extraData.AttributeIssuanceDetails);
        }
Ejemplo n.º 42
0
        static ExtraData<Tuple<short, short, short>, Tuple<long, byte>> GetOriginalBlocksFromArchive(long UID, long since, Level l, ExtraData<Tuple<short, short, short>, Tuple<long, byte>> ret = null) {
            if (ret == null) ret = new ExtraData<Tuple<short, short, short>, Tuple<long, byte>>();
            lock (lock_archive) {
                string path = GetFullPath(UID, l);
                if (Directory.Exists(path)) {
                    Tuple<long, string> partialFile = null;
                    List<Tuple<long, string>> completeFiles = new List<Tuple<long, string>>();
                    //checking file times
                    foreach (string s in Directory.GetFiles(path, historyEnding)) {
                        if (s.EndsWith(historyEnding)) {
                            long filetime = 0;
                            try {
                                string time_str = s.Split('.')[0];
                                filetime = long.Parse(time_str);
                            }
                            catch {
                                continue;
                            }
                            if (filetime > since) {
                                completeFiles.Add(new Tuple<long, string>(filetime, s));
                            }
                            else if (filetime < since) {
                                if (partialFile != null && filetime > partialFile.Item1) partialFile = new Tuple<long, string>(filetime, s);
                            }
                            else {
                                //filetime == since -> there is no file containing only a few blockchanges
                                completeFiles.Add(new Tuple<long, string>(filetime, s));
                                partialFile = null;
                            }
                        }
                    }

                    //sorting files (newer first)
                    completeFiles.Sort((a, b) => { return a.Item1.CompareTo(b.Item1); });

                    //reading all files full of matching blockchanges
                    for (int i = 0; i < completeFiles.Count; i++) {
                        FileStream fs = new FileStream(path + completeFiles[i], FileMode.Open, FileAccess.Read);
                        GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                        MemoryStream ms = new MemoryStream();
                        int r = 0;
                        byte[] buffer = new byte[1024];
                        while ((r = gz.Read(buffer, 0, buffer.Length)) != -1) {
                            ms.Write(buffer, 0, r);
                        }
                        gz.Close();
                        fs.Close();
                        if (ms.Length % 16 != 0) throw new Exception("Incomplete blockchange File: " + path + completeFiles[i]);
                        BinaryReader br = new BinaryReader(ms);
                        for (long pos = ms.Length - 16; pos >= 0; pos -= 16) { //start from end (newest entry is at end of file)
                            ms.Position = pos;
                            long time = br.ReadInt64();
                            short x = br.ReadInt16();
                            short z = br.ReadInt16();
                            short y = br.ReadInt16();
                            byte t = br.ReadByte(); //old block
                            ret[new Tuple<short, short, short>(x, z, y)] = new Tuple<long, byte>(time, t); //simple overwriting preexisting matches
                        }
                        File.Delete(path + completeFiles[i]);
                    }

                    //reading the partial file if not null
                    if (partialFile != null) {
                        FileStream fs = new FileStream(path + partialFile, FileMode.Open, FileAccess.Read);
                        GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                        MemoryStream ms = new MemoryStream();
                        int r = 0;
                        byte[] buffer = new byte[1024];
                        while ((r = gz.Read(buffer, 0, buffer.Length)) != -1) {
                            ms.Write(buffer, 0, r);
                        }
                        buffer = null;
                        gz.Close();
                        fs.Close();
                        if (ms.Length % 16 != 0) throw new Exception("Incomplete .cbh-File: " + path + partialFile);
                        BinaryReader br = new BinaryReader(ms);
                        for (long pos = ms.Length - 16; pos >= 0; pos -= 16) {
                            ms.Position = pos;
                            long time = br.ReadInt64();
                            if (time < since) break; //other data will not match
                            short x = br.ReadInt16();
                            short z = br.ReadInt16();
                            short y = br.ReadInt16();
                            byte t = br.ReadByte();
                            ret[new Tuple<short, short, short>(x, z, y)] = new Tuple<long, byte>(time, t);
                        }
                        if (ms.Position > 0) {
                            int amount = (int)ms.Position;
                            ms.Position = 0;
                            FileStream overwrite = new FileStream(path + partialFile, FileMode.Create, FileAccess.Write);
                            GZipStream output = new GZipStream(overwrite, CompressionMode.Compress);
                            byte[] tmp = new byte[amount];
                            int t = 0;
                            while (t != tmp.Length) {
                                int _t = ms.Read(tmp, t, tmp.Length - t);
                                output.Write(tmp, t, tmp.Length - t);
                                t += _t;
                            }
                            output.Close();
                            overwrite.Close();
                        }
                        br.Close();
                        ms.Close();
                    }
                }
            }
            return ret;
        }
Ejemplo n.º 43
0
 // Use this for initialization
 void Start()
 {
     m_separator[0] = "<br/>";
     _extraData = new ExtraData();
     m_sendPic = new Texture2D(1,1);
     enabled = false;
 }
Ejemplo n.º 44
0
        private ExtraData<Tuple<short, short, short>, Tuple<long, byte>> redoRecentOthersUndo(ExtraData<Tuple<short, short, short>, Tuple<long, byte>> ret, long since, Level l) {
            lock (lock_recent) {
                if (l == player.Level && recentTimes.Count > 0 && recentTimes[0] < since) {

                    int i;
                    for (i = 0; i < recentTimes.Count && recentTimes[i] < since; i++) ;
                    for (; i < recentTimes.Count; i++) { //looping forward in time
                        if (ret[recentChanges[i].Item1] != null && ret[recentChanges[i].Item1].Item1 < recentTimes[i]) {
                            ret[recentChanges[i].Item1] = new Tuple<long, byte>(recentTimes[i], recentChanges[i].Item3); //adding new block
                        }
                    }
                    return ret;
                }
                if (l == player.Level) {
                    for (int i = recentTimes.Count - 1; i >= 0; i--) {
                        ret[recentChanges[i].Item1] = new Tuple<long, byte>(recentTimes[i], recentChanges[i].Item3);
                    }
                }
            }
            return ret;
        }
Ejemplo n.º 45
0
        public SpritesheetData GetSpriteSheetData()
        {
            if (ExtraData.TryGetValue(VTexExtraData.SHEET, out var bytes))
            {
                using (var memoryStream = new MemoryStream(bytes))
                    using (var reader = new BinaryReader(memoryStream))
                    {
                        var version      = reader.ReadUInt32();
                        var numSequences = reader.ReadUInt32();

                        var sequences = new SpritesheetData.Sequence[numSequences];

                        for (var i = 0; i < numSequences; i++)
                        {
                            var sequenceNumber  = reader.ReadUInt32();
                            var unknown1        = reader.ReadUInt32(); // 1?
                            var unknown2        = reader.ReadUInt32();
                            var numFrames       = reader.ReadUInt32();
                            var framesPerSecond = reader.ReadSingle();          // Not too sure about this one
                            var dataOffset      = reader.BaseStream.Position + reader.ReadUInt32();
                            var unknown4        = reader.ReadUInt32();          // 0?
                            var unknown5        = reader.ReadUInt32();          // 0?

                            var endOfHeaderOffset = reader.BaseStream.Position; // Store end of header to return to later

                            // Seek to start of the sequence data
                            reader.BaseStream.Position = dataOffset;

                            var sequenceName = reader.ReadNullTermString(Encoding.UTF8);

                            var frameUnknown = reader.ReadUInt16();

                            var frames = new SpritesheetData.Sequence.Frame[numFrames];

                            for (var j = 0; j < numFrames; j++)
                            {
                                var frameUnknown1 = reader.ReadSingle();
                                var frameUnknown2 = reader.ReadUInt32();
                                var frameUnknown3 = reader.ReadSingle();

                                frames[j] = new SpritesheetData.Sequence.Frame();
                            }

                            for (var j = 0; j < numFrames; j++)
                            {
                                frames[j].StartMins = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                                frames[j].StartMaxs = new Vector2(reader.ReadSingle(), reader.ReadSingle());

                                frames[j].EndMins = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                                frames[j].EndMaxs = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                            }

                            reader.BaseStream.Position = endOfHeaderOffset;

                            sequences[i] = new SpritesheetData.Sequence
                            {
                                Frames          = frames,
                                FramesPerSecond = framesPerSecond,
                            };
                        }

                        return(new SpritesheetData
                        {
                            Sequences = sequences,
                        });
                    }
            }

            return(null);
        }
Ejemplo n.º 46
0
        private static ExtraData<Tuple<short, short, short>, Tuple<long, byte>> redoArchiveOthersUndoForAllPlayers(ExtraData<Tuple<short, short, short>, Tuple<long, byte>> ret, long since, Level l) {
            lock (lock_archive) {
                string path = basepath + l + Path.DirectorySeparatorChar;
                if (Directory.Exists(path)) {
                    string[] dir = Directory.GetDirectories(path);
                    foreach (string playerPath in dir) {
                        //TODO: check for .. and .
                        Tuple<long, string> partialFile = null;
                        List<Tuple<long, string>> completeFiles = new List<Tuple<long, string>>();

                        //checking file times
                        foreach (string s in Directory.GetFiles(playerPath)) {
                            if (s.EndsWith(historyEnding)) {
                                long filetime = 0;
                                try {
                                    string time_str = s.Split('.')[0];
                                    filetime = long.Parse(time_str);
                                }
                                catch {
                                    continue;
                                }
                                if (filetime > since) {
                                    completeFiles.Add(new Tuple<long, string>(filetime, s));
                                }
                                else if (filetime < since) {
                                    if (partialFile != null && filetime > partialFile.Item1) partialFile = new Tuple<long, string>(filetime, s);
                                }
                                else {
                                    //filetime == since -> there is no file containing only a few blockchanges
                                    completeFiles.Add(new Tuple<long, string>(filetime, s));
                                    partialFile = null;
                                }
                            }
                        }

                        //sorting files (newer first)
                        completeFiles.Sort((a, b) => { return a.Item1.CompareTo(b.Item1); });

                        //reading the partial file if not null
                        if (partialFile != null) {
                            FileStream fs = new FileStream(playerPath + partialFile, FileMode.Open, FileAccess.Read);
                            GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                            BinaryReader br = new BinaryReader(gz);
                            while (fs.Position < fs.Length) {
                                long time = br.ReadInt64();
                                if (time >= since) {
                                    short x = br.ReadInt16();
                                    short z = br.ReadInt16();
                                    short y = br.ReadInt16();
                                    br.ReadByte(); //old block is not needed
                                    byte t = br.ReadByte(); //new block
                                    Tuple<short, short, short> v = new Tuple<short, short, short>(x, z, y);
                                    if (ret[v] != null && ret[v].Item1 < time) ret[v] = new Tuple<long, byte>(time, t);

                                    break; //all other data will match now
                                }

                            }
                            while (fs.Position < fs.Length) {
                                long time = br.ReadInt64();
                                short x = br.ReadInt16();
                                short z = br.ReadInt16();
                                short y = br.ReadInt16();
                                br.ReadByte(); //drops old block
                                byte t = br.ReadByte();
                                Tuple<short, short, short> v = new Tuple<short, short, short>(x, z, y);
                                if (ret[v] != null && ret[v].Item1 < time) ret[v] = new Tuple<long, byte>(time, t);
                            }
                            br.Close();
                            gz.Close();
                            fs.Close();
                        }

                        //reading all files full of matching blockchanges
                        for (int i = 0; i < completeFiles.Count; i++) {
                            FileStream fs = new FileStream(playerPath + completeFiles[i], FileMode.Open, FileAccess.Read);
                            GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                            BinaryReader br = new BinaryReader(gz);
                            while (fs.Position < fs.Length) {
                                long time = br.ReadInt64();
                                short x = br.ReadInt16();
                                short z = br.ReadInt16();
                                short y = br.ReadInt16();
                                br.ReadByte(); //drops old block
                                byte t = br.ReadByte(); //new block
                                Tuple<short, short, short> v = new Tuple<short, short, short>(x, z, y);
                                if (ret[v] != null && ret[v].Item1 < time) ret[v] = new Tuple<long, byte>(time, t);
                            }
                        }
                    }
                }
            }
            return ret;
        }
Ejemplo n.º 47
0
 public void About(Vector3S v, Level l, long since = 0, int max = 20) {
     string lvlPath = GetLevelPath(l);
     if (Directory.Exists(lvlPath)) {
         ExtraData<long, Tuple<long, byte>> collection = new ExtraData<long, Tuple<long, byte>>();
         lock (lock_archive) {
             ExtraData<long, string> files = new ExtraData<long, string>();
             foreach (string playerPath in Directory.GetDirectories(lvlPath)) {
                 //TODO: see if checking ../. is needed
                 foreach (string filename in Directory.GetFiles(playerPath, historyEnding)) {
                     FileInfo fi = new FileInfo(filename);
                     try {
                         files[long.Parse(fi.Name.Split('.')[0])] = filename;
                     }
                     catch { }
                 }
             }
             foreach (long time in files.Keys) {
                 long uid = long.Parse(Directory.GetParent(files[time]).Name);
                 FileStream fs = new FileStream(files[time], FileMode.Open, FileAccess.Read);
                 GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
                 MemoryStream ms = new MemoryStream();
                 int r = 0;
                 byte[] buffer = new byte[1024];
                 while ((r = gz.Read(buffer, 0, buffer.Length)) != -1) {
                     ms.Write(buffer, 0, r);
                 }
                 gz.Close();
                 fs.Close();
                 BinaryReader br = new BinaryReader(ms);
                 for (int pos = 8; pos < ms.Length; pos += 16) {
                     ms.Position = pos;
                     if (br.ReadInt16() == v.x && br.ReadInt16() == v.z && br.ReadInt16() == v.y) {
                         ms.Position = pos - 8;
                         long t = br.ReadInt64(); //time;
                         ms.Position = pos + 7;
                         byte b = br.ReadByte(); //block;
                         collection[t] = new Tuple<long, byte>(uid, b);
                     }
                 }
             }
         }
         List<long> keys = collection.Keys.ToList();
         keys.Sort((a, b) => { /*if (a == b) return 0;*/ return (a > b) ? -1 : 1; });
         string[] ret = new string[max];
         for (int i = 0; i < ret.Length && i < keys.Count; i++) {
             //TODO: get colored names from uid
             ret[i] = new DateTime(keys[i]).ToString() + collection[keys[i]].Item1 + " " + ((Block)collection[keys[i]].Item2).Name;
         }
     }
 }
Ejemplo n.º 48
0
 public static LevelUndo Read(BinaryReader br) {
     long count = br.ReadInt32();
     ushort x = br.ReadUInt16();
     ushort z = br.ReadUInt16();
     ushort y = br.ReadUInt16();
     byte[] origLvl = br.ReadBytes((int)count);
     LevelUndo ret = new LevelUndo(x, z, y, origLvl);
     count = br.ReadInt64();
     for (; count > 0; count--) {
         x = br.ReadUInt16();
         z = br.ReadUInt16();
         y = br.ReadUInt16();
         ExtraData<ushort, ExtraData<ushort, UndoList>> xLevel = ret.changes[x];
         ExtraData<ushort, UndoList> zLevel;
         if (xLevel == null) {
             xLevel = new ExtraData<ushort, ExtraData<ushort, UndoList>>();
             zLevel = new ExtraData<ushort, UndoList>();
             zLevel[y] = UndoList.Read(br);
             xLevel[z] = zLevel;
             ret.changes[x] = xLevel;
         }
         else {
             zLevel = xLevel[z];
             if (zLevel == null) {
                 zLevel = new ExtraData<ushort, UndoList>();
                 zLevel[y] = UndoList.Read(br);
                 xLevel[z] = zLevel;
             }
             else {
                 zLevel[y] = UndoList.Read(br);
             }
         }
     }
     return ret;
 }