Example #1
0
        public TsRoadItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset    = startOffset + 0x34; // Set position at start of flags
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount: Common.AtsDlcGuardCount;

            Hidden   = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x06) > dlcGuardCount || (MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x03) & 0x02) != 0;
            RoadLook = Sector.Mapper.LookupRoadLook(MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x09));
            if (RoadLook == null)
            {
                Valid = false;
                Log.Msg($"Could not find RoadLook with id: {MemoryHelper.ReadUInt64(Sector.Stream, fileOffset):X}, " +
                        $"in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
            }

            if (Sector.Version >= Common.BaseFileVersion130)
            {
                StartNodeUid = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08 + 0xA4);
                EndNodeUid   = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08);
                fileOffset  += 0x08 + 0x04;
            }
            else
            {
                StartNodeUid = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08 + 0x50);
                EndNodeUid   = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x08);
                var stampCount            = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x08 + 0x134);
                var vegetationSphereCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (StampBlockSize * stampCount));
                fileOffset += 0x04 + (VegetationSphereBlockSize * vegetationSphereCount);
            }

            BlockSize = fileOffset - startOffset;
        }
Example #2
0
        public TsMapOverlayItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            ZoomLevelVisibility = Sector.Stream[fileOffset];
            var type      = Sector.Stream[fileOffset + 0x02];
            var overlayId = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x05);

            if (type == 1 && overlayId == 0)
            {
                overlayId = 0x2358E762E112CD4;                              // parking
            }
            Overlay = Sector.Mapper.LookupOverlay(overlayId);
            if (Overlay == null)
            {
                Valid = false;
                if (overlayId != 0)
                {
                    Log.Msg($"Could not find Overlay with id: {overlayId:X}, in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
                }
            }
            fileOffset += 0x08 + 0x08;
            BlockSize   = fileOffset - startOffset;
        }
Example #3
0
        public TsMapAreaItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            DrawOver = MemoryHelper.ReadUint8(Sector.Stream, fileOffset) != 0;
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount : Common.AtsDlcGuardCount;

            Hidden = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x01) > dlcGuardCount;

            NodeUids = new List <ulong>();

            var nodeCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x05);

            fileOffset += 0x04;
            for (var i = 0; i < nodeCount; i++)
            {
                NodeUids.Add(MemoryHelper.ReadUInt64(Sector.Stream, fileOffset));
                fileOffset += 0x08;
            }

            ColorIndex  = MemoryHelper.ReadUInt32(Sector.Stream, fileOffset);
            fileOffset += 0x04;
            BlockSize   = fileOffset - startOffset;
        }
Example #4
0
        public TsMapOverlayItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            ZoomLevelVisibility = MemoryHelper.ReadInt8(Sector.Stream, fileOffset);
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount : Common.AtsDlcGuardCount;

            Hidden = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x01) > dlcGuardCount || ZoomLevelVisibility == -1;

            var type      = MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x02);
            var overlayId = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x05);

            if (type == 1 && overlayId == 0)
            {
                overlayId = 0x2358E762E112CD4;                              // parking
            }
            Overlay = Sector.Mapper.LookupOverlay(overlayId);
            if (Overlay == null)
            {
                Valid = false;
                if (overlayId != 0)
                {
                    Log.Msg($"Could not find Overlay with id: {overlayId:X}, in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
                }
            }
            fileOffset += 0x08 + 0x08;
            BlockSize   = fileOffset - startOffset;
        }
Example #5
0
        public TsTriggerItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var tagCount           = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x05);
            var nodeCount          = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * tagCount));
            var triggerActionCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * nodeCount));

            fileOffset += 0x04;

            for (var i = 0; i < triggerActionCount; i++)
            {
                var isCustom = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x08);
                if (isCustom > 0)
                {
                    fileOffset += 0x04;
                }
                var hasText = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04);
                if (hasText > 0)
                {
                    var textLength = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04);
                    fileOffset += 0x04 + textLength;
                }
                var count = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + 0x08);
                fileOffset += 0x04 + count * 0x08;
            }

            fileOffset += 0x18;
            BlockSize   = fileOffset - startOffset;
        }
Example #6
0
        public TsCompanyItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset    = startOffset + 0x34; // Set position at start of flags
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount : Common.AtsDlcGuardCount;

            Hidden = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x01) > dlcGuardCount;

            var overlayId = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x05);

            Overlay = Sector.Mapper.LookupOverlay(overlayId);
            if (Overlay == null)
            {
                Valid = false;
                if (overlayId != 0)
                {
                    Log.Msg($"Could not find Company Overlay with id: {overlayId:X}, in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
                }
            }

            var count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x20);

            count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            if (sector.Version >= Common.BaseFileVersion133)
            {
                count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            }
            fileOffset += 0x04 + (0x08 * count);
            BlockSize   = fileOffset - startOffset;
        }
Example #7
0
        public TsPrefabItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            Nodes = new List <ulong>();
            var fileOffset    = startOffset + 0x34; // Set position at start of flags
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount : Common.AtsDlcGuardCount;

            Hidden = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x01) > dlcGuardCount || (MemoryHelper.ReadUint8(Sector.Stream, fileOffset + 0x02) & 0x02) != 0;

            var prefabId = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x05);

            Prefab = Sector.Mapper.LookupPrefab(prefabId);
            if (Prefab == null)
            {
                Valid = false;
                Log.Msg($"Could not find Prefab with id: {MemoryHelper.ReadUInt64(Sector.Stream, fileOffset):X}, " +
                        $"in {Path.GetFileName(Sector.FilePath)} @ {fileOffset} (item uid: 0x{Uid:X})");
            }

            if (Sector.Version >= Common.BaseFileVersion130)
            {
                var additionalItemCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x08 + 0x08);
                var nodeCount           = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (additionalItemCount * 0x08));
                fileOffset += 0x04;
                for (var i = 0; i < nodeCount; i++)
                {
                    Nodes.Add(MemoryHelper.ReadUInt64(Sector.Stream, fileOffset));
                    fileOffset += 0x08;
                }
                var connectedItemCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset);
                Origin      = MemoryHelper.ReadUint8(Sector.Stream, fileOffset += 0x04 + (0x08 * connectedItemCount) + 0x08);
                fileOffset += 0x02 + nodeCount * 0x0C;
                if (Sector.Version >= Common.BaseFileVersion132)
                {
                    fileOffset += 0x08;
                }
            }
            else
            {
                var additionalItemCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x08 + 0x10);

                var nodeCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * additionalItemCount));
                fileOffset += 0x04;
                for (var i = 0; i < nodeCount; i++)
                {
                    Nodes.Add(MemoryHelper.ReadUInt64(Sector.Stream, fileOffset));
                    fileOffset += 0x08;
                }

                var connectedItemCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset);
                Origin = MemoryHelper.ReadUint8(Sector.Stream, fileOffset += 0x04 + (0x08 * connectedItemCount) + 0x08);
                var prefabVegetationCount = MemoryHelper.ReadInt32(Sector.Stream,
                                                                   fileOffset += 0x01 + (NodeLookBlockSize * nodeCount) + 0x01);
                var vegetationSphereCount = MemoryHelper.ReadInt32(Sector.Stream,
                                                                   fileOffset += 0x04 + (PrefabVegetaionBlockSize * prefabVegetationCount) + 0x04);
                fileOffset += 0x04 + (VegetationSphereBlockSize * vegetationSphereCount) + (0x18 * nodeCount);
            }

            BlockSize = fileOffset - startOffset;
        }
Example #8
0
        public TsCompanyItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var overlayId = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x05);

            Overlay = Sector.Mapper.LookupOverlay(overlayId);
            if (Overlay == null)
            {
                Valid = false;
                if (overlayId != 0)
                {
                    Log.Msg($"Could not find Company Overlay with id: {overlayId:X}, in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
                }
            }

            var count = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x20);

            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            fileOffset += 0x04 + (0x08 * count);
            BlockSize   = fileOffset - startOffset;
        }
Example #9
0
        public TsRoadItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            Hidden   = (Sector.Stream[fileOffset += 0x03] & 0x02) != 0;
            RoadLook = Sector.Mapper.LookupRoadLook(BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x06));
            if (RoadLook == null)
            {
                Valid = false;
                Log.Msg($"Could not find RoadLook with id: {BitConverter.ToUInt64(Sector.Stream, fileOffset):X}, " +
                        $"in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
            }

            if (Sector.Version >= Common.BaseFileVersion130)
            {
                StartNodeUid = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x08 + 0xA4);
                EndNodeUid   = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x08);
                fileOffset  += 0x08 + 0x04;
            }
            else
            {
                StartNodeUid = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x08 + 0x50);
                EndNodeUid   = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x08);
                var stampCount            = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x08 + 0x134);
                var vegetationSphereCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (StampBlockSize * stampCount));
                fileOffset += 0x04 + (VegetationSphereBlockSize * vegetationSphereCount);
            }

            BlockSize = fileOffset - startOffset;
        }
Example #10
0
        public TsBusStopItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            fileOffset += 0x05 + 0x18;
            BlockSize   = fileOffset - startOffset;
        }
Example #11
0
        public TsMapAreaItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var nodeCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x05);

            fileOffset += 0x04 + (0x08 * nodeCount) + 0x04;
            BlockSize   = fileOffset - startOffset;
        }
Example #12
0
        public TsCutPlaneItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var nodeCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x05);

            fileOffset += 0x04 + (0x08 * nodeCount);
            BlockSize   = fileOffset - startOffset;
        }
Example #13
0
        public TsPrefabItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid      = true;
            Nodes      = new List <ulong>();
            Navigation = new Dictionary <TsPrefabItem, Tuple <float, List <TsItem> > >();
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            Hidden = (Sector.Stream[fileOffset += 0x02] & 0x02) != 0;
            var prefabId = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x03);

            Prefab = Sector.Mapper.LookupPrefab(prefabId);
            if (Prefab == null)
            {
                Valid = false;
                Log.Msg($"Could not find Prefab with id: {BitConverter.ToUInt64(Sector.Stream, fileOffset):X}, " +
                        $"in {Path.GetFileName(Sector.FilePath)} @ {fileOffset} (item uid: 0x{Uid:X})");
            }

            if (Sector.Version >= Common.BaseFileVersion130)
            {
                var additionalItemCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x08 + 0x08);
                var nodeCount           = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (additionalItemCount * 0x08));
                fileOffset += 0x04;
                for (var i = 0; i < nodeCount; i++)
                {
                    Nodes.Add(BitConverter.ToUInt64(Sector.Stream, fileOffset));
                    fileOffset += 0x08;
                }
                var connectedItemCount = BitConverter.ToInt32(Sector.Stream, fileOffset);
                Origin      = Sector.Stream[fileOffset += 0x04 + (0x08 * connectedItemCount) + 0x08];
                fileOffset += 0x02 + nodeCount * 0x0C;
            }
            else
            {
                var additionalItemCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x08 + 0x10);

                var nodeCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * additionalItemCount));
                fileOffset += 0x04;
                for (var i = 0; i < nodeCount; i++)
                {
                    Nodes.Add(BitConverter.ToUInt64(Sector.Stream, fileOffset));
                    fileOffset += 0x08;
                }

                var connectedItemCount = BitConverter.ToInt32(Sector.Stream, fileOffset);
                Origin = Sector.Stream[fileOffset += 0x04 + (0x08 * connectedItemCount) + 0x08];
                var prefabVegetationCount = BitConverter.ToInt32(Sector.Stream,
                                                                 fileOffset += 0x01 + (NodeLookBlockSize * nodeCount) + 0x01);
                var vegetationSphereCount = BitConverter.ToInt32(Sector.Stream,
                                                                 fileOffset += 0x04 + (PrefabVegetaionBlockSize * prefabVegetationCount) + 0x04);
                fileOffset += 0x04 + (VegetationSphereBlockSize * vegetationSphereCount) + (0x18 * nodeCount);
            }

            BlockSize = fileOffset - startOffset;
        }
Example #14
0
        public TsTrafficRuleItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var count = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x05);

            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            count       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * count));
            fileOffset += 0x04 + 0x08;
            BlockSize   = fileOffset - startOffset;
        }
Example #15
0
        public TsTrajectoryItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var nodeCount       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x05);
            var ruleCount       = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * nodeCount) + 0x0C);
            var checkPointCount = BitConverter.ToInt32(Sector.Stream, fileOffset += 0x04 + (0x1C * ruleCount));

            fileOffset += 0x04 + (0x10 * checkPointCount) + 0x04;
            BlockSize   = fileOffset - startOffset;
        }
Example #16
0
        public TsNode(TsSector sector, int fileOffset)
        {
            Uid = MemoryHelper.ReadUInt64(sector.Stream, fileOffset);
            X   = MemoryHelper.ReadInt32(sector.Stream, fileOffset += 0x08) / 256f;
            Z   = MemoryHelper.ReadInt32(sector.Stream, fileOffset += 0x08) / 256f;

            var rX = MemoryHelper.ReadSingle(sector.Stream, fileOffset += 0x04);
            var rZ = MemoryHelper.ReadSingle(sector.Stream, fileOffset + 0x08);

            var rot = Math.PI - Math.Atan2(rZ, rX);

            Rotation = (float)(rot % Math.PI * 2);
        }
Example #17
0
        public TsItem(TsSector sector, int offset)
        {
            Sector = sector;

            var fileOffset = offset;

            Type = (TsItemType)BitConverter.ToUInt32(Sector.Stream, fileOffset);

            Uid = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x04);

            X = BitConverter.ToSingle(Sector.Stream, fileOffset += 0x08);
            Z = BitConverter.ToSingle(Sector.Stream, fileOffset += 0x08);
        }
Example #18
0
        public TsFuelPumpItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            fileOffset += 0x05 + 0x10;
            if (Sector.Version >= Common.BaseFileVersion132)
            {
                var count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset);
                fileOffset += 0x08 * count + 0x04;
            }
            BlockSize = fileOffset - startOffset;
        }
Example #19
0
        public TsItem(TsSector sector, int offset)
        {
            Sector = sector;

            var fileOffset = offset;

            Type = (TsItemType)MemoryHelper.ReadUInt32(Sector.Stream, fileOffset);

            Uid = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset += 0x04);

            X = MemoryHelper.ReadSingle(Sector.Stream, fileOffset += 0x08);
            Z = MemoryHelper.ReadSingle(Sector.Stream, fileOffset += 0x08);
        }
Example #20
0
        public TsRoadSideItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = false;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            var tmplTextLength = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x05 + 0x58);

            if (tmplTextLength != 0)
            {
                fileOffset += 0x04 + tmplTextLength;
            }
            var count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04);

            fileOffset += 0x04;
            for (var i = 0; i < count; i++)
            {
                var subItemCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x0C);
                fileOffset += 0x04;
                for (var x = 0; x < subItemCount; x++)
                {
                    var itemType = MemoryHelper.ReadInt16(Sector.Stream, fileOffset);

                    var someCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x02);
                    fileOffset += 0x04;

                    if (itemType == 0x05)
                    {
                        var textLength = MemoryHelper.ReadInt32(Sector.Stream, fileOffset);
                        fileOffset += 0x04 + 0x04 + textLength;
                    }
                    else if (itemType == 0x06)
                    {
                        fileOffset += 0x04 + 0x04 * someCount;
                    }
                    else if (itemType == 0x01)
                    {
                        fileOffset += 0x01;
                    }
                    else
                    {
                        fileOffset += 0x04;
                    }
                }
            }
            BlockSize = fileOffset - startOffset;
        }
Example #21
0
        public TsCityItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            Hidden = (Sector.Stream[fileOffset] & 0x01) != 0;
            var cityId = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x05);

            CityName = Sector.Mapper.LookupCity(cityId)?.Name;
            if (CityName == null)
            {
                Valid = false;
                Log.Msg($"Could not find City with id: {cityId:X}, " +
                        $"in {Path.GetFileName(Sector.FilePath)} @ {fileOffset}");
            }
            fileOffset += 0x08 + 0x10;
            BlockSize   = fileOffset - startOffset;
        }
Example #22
0
        public TsTriggerItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset    = startOffset + 0x34; // Set position at start of flags
            var dlcGuardCount = (Sector.Mapper.IsEts2) ? Common.Ets2DlcGuardCount : Common.AtsDlcGuardCount;

            Hidden = MemoryHelper.ReadInt8(Sector.Stream, fileOffset + 0x01) > dlcGuardCount;
            var tagCount           = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x05);
            var nodeCount          = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * tagCount));
            var triggerActionCount = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + (0x08 * nodeCount));

            fileOffset += 0x04;

            for (var i = 0; i < triggerActionCount; i++)
            {
                var action = MemoryHelper.ReadUInt64(Sector.Stream, fileOffset);
                if (action == 0x18991B7A99E279C) // hud_parking
                {
                    Overlay = Sector.Mapper.LookupOverlay(0x2358E762E112CD4);
                    if (Overlay == null)
                    {
                        Console.WriteLine("Could not find parking overlay");
                        Valid = false;
                    }
                }
                var overloadTag = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x08);
                if (overloadTag > 0)
                {
                    fileOffset += 0x04 * overloadTag;
                }
                var hasText = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04);
                if (hasText > 0)
                {
                    var textLength = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04);
                    fileOffset += 0x04 + textLength;
                }
                var count = MemoryHelper.ReadInt32(Sector.Stream, fileOffset += 0x04 + 0x08);
                fileOffset += 0x04 + count * 0x08;
            }

            fileOffset += 0x18;
            BlockSize   = fileOffset - startOffset;
        }
Example #23
0
        public TsNode(TsSector sector, int fileOffset)
        {
            Uid = BitConverter.ToUInt64(sector.Stream, fileOffset);

            ForwardItemUID  = BitConverter.ToUInt64(sector.Stream, fileOffset + 0x2C);
            BackwardItemUID = BitConverter.ToUInt64(sector.Stream, fileOffset + 0x24);
            ForwardItem     = null;
            BackwardItem    = null;

            X = BitConverter.ToInt32(sector.Stream, fileOffset += 0x08) / 256f;
            Z = BitConverter.ToInt32(sector.Stream, fileOffset += 0x08) / 256f;

            var rX = BitConverter.ToSingle(sector.Stream, fileOffset += 0x04);
            var rZ = BitConverter.ToSingle(sector.Stream, fileOffset + 0x08);

            var rot = Math.PI - Math.Atan2(rZ, rX);

            Rotation = (float)(rot % Math.PI * 2);
        }
Example #24
0
        public TsFerryItem(TsSector sector, int startOffset) : base(sector, startOffset)
        {
            Valid = true;
            var fileOffset = startOffset + 0x34; // Set position at start of flags

            Train = (Sector.Stream[fileOffset] != 0);
            if (Train)
            {
                Overlay = Sector.Mapper.LookupOverlay(ScsHash.StringToToken("train_ico"));
            }
            else
            {
                Overlay = Sector.Mapper.LookupOverlay(ScsHash.StringToToken("port_overlay"));
            }

            FerryPortId = BitConverter.ToUInt64(Sector.Stream, fileOffset += 0x05);
            sector.Mapper.AddFerryPortLocation(FerryPortId, X, Z);
            fileOffset += 0x08 + 0x1C;
            BlockSize   = fileOffset - startOffset;
        }