private static string GetStringValue(PsoFile pso, PsoStructureEntryInfo entry, byte[] data, int eoffset) { switch (entry.Unk_5h) { default: return(null); case 0: var str0len = (int)((entry.ReferenceKey >> 16) & 0xFFFF); return(Encoding.ASCII.GetString(data, eoffset, str0len).Replace("\0", "")); case 1: case 2: var dataPtr2 = MetaUtils.ConvertData <DataBlockPointer>(data, eoffset); dataPtr2.SwapEnd(); return(PsoUtils.GetString(pso, dataPtr2)); case 3: var charPtr3 = MetaUtils.ConvertData <CharPointer>(data, eoffset); charPtr3.SwapEnd(); var strval = PsoUtils.GetString(pso, charPtr3); return(strval ?? ""); case 7: case 8: MetaName hashVal = (MetaName)MetaUtils.SwapBytes(MetaUtils.ConvertData <uint>(data, eoffset)); return(HashString(hashVal)); } }
public override void Parse(object[] parameters = null) { bool parseFast = false; if (parameters != null && parameters.Length > 0) { parseFast = (bool)parameters[0]; } var CMapDataBlocks = this.ResourceFile.ResourceData.FindBlocks(MetaName.CMapData); if (CMapDataBlocks.Length == 0) { throw new Exception("CMapData block not found !"); } var CMapData = MetaUtils.ConvertData <CMapData>(CMapDataBlocks[0]); this.CMapData = new MCMapData(); if (parseFast) { this.CMapData.ParseFast(this.ResourceFile.ResourceData, CMapData); } else { this.CMapData.Parse(this.ResourceFile.ResourceData, CMapData); } for (int i = 0; i < this.CMapData.Entities.Count; i++) { this.CMapData.Entities[i].ParentIndex = this.CMapData.Entities[i].ParentIndex; } }
public override void UpdateAt(Vector3Int position) { MetaDataNode node = metaDataLayer.Get(position); MetaUtils.RemoveFromNeighbors(node); externalNodes.TryRemove(node, out MetaDataNode nothing); if (metaTileMap.IsAtmosPassableAt(position, true)) { node.ClearNeighbors(); node.Type = metaTileMap.IsSpaceAt(position, true) ? NodeType.Space : NodeType.Room; SetupNeighbors(node); MetaUtils.AddToNeighbors(node); node.IsClosedAirlock = false; } else { node.Type = NodeType.Occupied; if (matrix.GetFirst <RegisterDoor>(position, true)) { node.IsClosedAirlock = true; } } }
public override void Parse(MetaFile meta, CLODLight CLODLight) { this.Meta = meta; this.MetaStructure = CLODLight; var _direction = MetaUtils.ConvertDataArray <VECTOR3>(meta, CLODLight.direction); List <MVECTOR3> direction = _direction?.Select(e => { var msw = new MVECTOR3(); msw.Parse(meta, e); return(msw); }).ToList(); float[] falloff = MetaUtils.ConvertDataArray <float>(meta, CLODLight.falloff.Pointer, CLODLight.falloff.Count1).ToArray(); float[] falloffExponent = MetaUtils.ConvertDataArray <float>(meta, CLODLight.falloffExponent.Pointer, CLODLight.falloffExponent.Count1).ToArray(); uint[] timeAndStateFlags = MetaUtils.ConvertDataArray <uint>(meta, CLODLight.timeAndStateFlags.Pointer, CLODLight.timeAndStateFlags.Count1).ToArray(); uint[] hash = MetaUtils.ConvertDataArray <uint>(meta, CLODLight.hash.Pointer, CLODLight.hash.Count1).ToArray(); byte[] coneInnerAngle = MetaUtils.ConvertDataArray <byte>(meta, CLODLight.coneInnerAngle.Pointer, CLODLight.coneInnerAngle.Count1).ToArray(); byte[] coneOuterAngleOrCapExt = MetaUtils.ConvertDataArray <byte>(meta, CLODLight.coneOuterAngleOrCapExt.Pointer, CLODLight.coneOuterAngleOrCapExt.Count1).ToArray(); byte[] coronaIntensity = MetaUtils.ConvertDataArray <byte>(meta, CLODLight.coronaIntensity.Pointer, CLODLight.coronaIntensity.Count1).ToArray(); Entries.Clear(); for (int i = 0; i < hash.Length; i++) { Entries.Add(new LODLightEntry() { Direction = direction[i], FallOff = falloff[i], FalloffExponent = falloffExponent[i], TimeAndStateFlags = timeAndStateFlags[i], Hash = hash[i], ConeInnerAngle = coneInnerAngle[i], ConeOuterAngleOrCapExt = coneOuterAngleOrCapExt[i], CoronaIntensity = coronaIntensity[i] }); } }
public override void UpdateAt(Vector3Int localPosition) { MetaDataNode node = metaDataLayer.Get(localPosition); MetaUtils.RemoveFromNeighbors(node); externalNodes.TryRemove(node, out MetaDataNode nothing); node.IsClosedAirlock = false; // If the node is atmos passable (i.e. space or room), we need to setup its neighbors again, otherwise it's occupied and does need a neighbor check if (metaTileMap.IsAtmosPassableAt(localPosition, true)) { node.ClearNeighbors(); node.Type = metaTileMap.IsSpaceAt(localPosition, true) ? NodeType.Space : NodeType.Room; SetupNeighbors(node); MetaUtils.AddToNeighbors(node); } else { node.Type = NodeType.Occupied; if (matrix.GetFirst <RegisterDoor>(localPosition, true)) { node.IsClosedAirlock = true; } } }
public void SwapEnd() { Pointer = MetaUtils.SwapBytes(Pointer); Unk0 = MetaUtils.SwapBytes(Unk0); Count1 = MetaUtils.SwapBytes(Count1); Count2 = MetaUtils.SwapBytes(Count2); Unk1 = MetaUtils.SwapBytes(Unk1); }
public override void Parse(MetaFile meta, CMloEntitySet CMloEntitySet) { this.Meta = meta; this.MetaStructure = CMloEntitySet; this.Name = CMloEntitySet.name; this.Locations = MetaUtils.ConvertDataArray <uint>(meta, CMloEntitySet.locations.Pointer, CMloEntitySet.locations.Count1)?.ToList(); this.Entities = MetaUtils.ConvertDataArray <CEntityDef>(this.Meta, CMloEntitySet.entities)?.Select(e => { var obj = new MCEntityDef(); obj.Parse(meta, e); return(obj); }).ToList() ?? new List <MCEntityDef>(); }
public override void Parse(MetaFile meta, Unk_3538495220 Unk_3538495220) { this.Meta = meta; this.MetaStructure = Unk_3538495220; //this.Unk_3371516811 = Unk_3538495220.Unk_3371516811; var Unk_1756136273 = MetaUtils.ConvertDataArray<Unk_1535046754>(meta, Unk_3538495220.Unk_1756136273); this.Unk_1756136273 = Unk_1756136273?.Select(e => { var msw = new MUnk_1535046754(); msw.Parse(meta, e); return msw; }).ToList(); }
public override void Parse(MetaFile meta, rage__phVerletClothCustomBounds rage__phVerletClothCustomBounds) { this.Meta = meta; this.MetaStructure = rage__phVerletClothCustomBounds; this.Name = rage__phVerletClothCustomBounds.name; var CollisionData = MetaUtils.ConvertDataArray <Unk_1701774085>(meta, rage__phVerletClothCustomBounds.CollisionData); this.CollisionData = CollisionData?.Select(e => { var msw = new MUnk_1701774085(); msw.Parse(meta, e); return(msw); }).ToList(); }
public override void Parse(MetaFile meta, CExtensionDefLightEffect CExtensionDefLightEffect) { this.Meta = meta; this.MetaStructure = CExtensionDefLightEffect; this.Name = CExtensionDefLightEffect.name; this.OffsetPosition = CExtensionDefLightEffect.offsetPosition; var instances = MetaUtils.ConvertDataArray <CLightAttrDef>(meta, CExtensionDefLightEffect.instances); this.Instances = instances?.Select(e => { var msw = new MCLightAttrDef(); msw.Parse(meta, e); return(msw); }).ToList(); }
public override void Parse(MetaFile meta, rage__fwInstancedMapData rage__fwInstancedMapData) { this.Meta = meta; this.MetaStructure = rage__fwInstancedMapData; this.ImapLink = rage__fwInstancedMapData.ImapLink; // this.PropInstanceList = rage__fwInstancedMapData.PropInstanceList; var GrassInstanceList = MetaUtils.ConvertDataArray <rage__fwGrassInstanceListDef>(meta, rage__fwInstancedMapData.GrassInstanceList); this.GrassInstanceList = GrassInstanceList?.Select(e => { var msw = new Mrage__fwGrassInstanceListDef(); msw.Parse(meta, e); return(msw); }).ToList(); }
public override void Parse(MetaFile meta, CBlockDesc CBlockDesc) { this.Meta = meta; this.MetaStructure = CBlockDesc; this.Version = CBlockDesc.version; this.Flags = CBlockDesc.flags; this.Name = MetaUtils.GetString(Meta, CBlockDesc.name) ?? "GTAUtil"; this.ExportedBy = MetaUtils.GetString(Meta, CBlockDesc.exportedBy) ?? "GTAUtil"; this.Owner = MetaUtils.GetString(Meta, CBlockDesc.owner) ?? "GTAUtil"; this.Time = MetaUtils.GetString(Meta, CBlockDesc.time) ?? DateTime.UtcNow.ToString("dd MMMM yyyy HH:mm"); }
private void CreateRoom(Vector3Int origin) { if (metaDataLayer.Get(origin).RoomNumber != -1) { return; } var roomPositions = new HashSet <Vector3Int>(); var freePositions = new UniqueQueue <Vector3Int>(); freePositions.Enqueue(origin); var isSpace = false; // breadth-first search of the connected tiles that are not occupied while (!freePositions.IsEmpty) { if (freePositions.TryDequeue(out Vector3Int position)) { roomPositions.Add(position); Vector3Int[] neighbors = MetaUtils.GetNeighbors(position, null); for (var i = 0; i < neighbors.Length; i++) { Vector3Int neighbor = neighbors[i]; if (metaTileMap.IsSpaceAt(neighbor, true)) { Vector3Int worldPosition = MatrixManager.LocalToWorldInt(neighbor, MatrixManager.Get(matrix.Id)); // If matrix manager says, the neighboring positions is space, the whole room is connected to space. // Otherwise there is another matrix, blocking off the connection to space. if (MatrixManager.IsSpaceAt(worldPosition, true, matrix.MatrixInfo)) { isSpace = true; } } else if (metaTileMap.IsAtmosPassableAt(position, neighbor, true)) { // if neighbor position is not yet a room in the meta data layer and not in the room positions list, // add it to the positions that need be checked if (!roomPositions.Contains(neighbor) && !metaDataLayer.IsRoomAt(neighbor)) { freePositions.Enqueue(neighbor); } } } } } AssignType(roomPositions, isSpace ? NodeType.Space : NodeType.Room); SetupNeighbors(roomPositions); }
public override void Parse(MetaFile meta, CScenarioPointContainer CScenarioPointContainer) { this.Meta = meta; this.MetaStructure = CScenarioPointContainer; var LoadSavePoints = MetaUtils.ConvertDataArray <CExtensionDefSpawnPoint>(meta, CScenarioPointContainer.LoadSavePoints); this.LoadSavePoints = LoadSavePoints?.Select(e => { var msw = new MCExtensionDefSpawnPoint(); msw.Parse(meta, e); return(msw); }).ToList(); var MyPoints = MetaUtils.ConvertDataArray <CScenarioPoint>(meta, CScenarioPointContainer.MyPoints); this.MyPoints = MyPoints?.Select(e => { var msw = new MCScenarioPoint(); msw.Parse(meta, e); return(msw); }).ToList(); }
public static uint[] GetUintArray(PsoFile pso, Array_uint arr) { uint[] uints = GetUintArrayRaw(pso, arr); if (uints == null) { return(null); } for (int i = 0; i < uints.Length; i++) { uints[i] = MetaUtils.SwapBytes(uints[i]); } return(uints); }
public static ushort[] GetUShortArray(PsoFile pso, Array_Structure arr) { ushort[] ushorts = GetUShortArrayRaw(pso, arr); if (ushorts == null) { return(null); } for (int i = 0; i < ushorts.Length; i++) { ushorts[i] = MetaUtils.SwapBytes(ushorts[i]); } return(ushorts); }
public static float[] GetFloatArray(PsoFile pso, Array_float arr) { float[] floats = GetFloatArrayRaw(pso, arr); if (floats == null) { return(null); } for (int i = 0; i < floats.Length; i++) { floats[i] = MetaUtils.SwapBytes(floats[i]); } return(floats); }
public override void UpdateAt(Vector3Int localPosition) { MetaDataNode node = metaDataLayer.Get(localPosition); MetaUtils.RemoveFromNeighbors(node); externalNodes.TryRemove(node, out MetaDataNode nothing); node.IsIsolatedNode = false; // If the node is atmos passable (i.e. space or room), we need to setup its neighbors again, otherwise it's occupied and does need a neighbor check if (metaTileMap.IsAtmosPassableAt(localPosition, true)) { node.ClearNeighbors(); node.Type = metaTileMap.IsSpaceAt(localPosition, true) ? NodeType.Space : NodeType.Room; if (node.Type == NodeType.Space) { node.ThermalConductivity = AtmosDefines.SPACE_THERMAL_CONDUCTIVITY; node.HeatCapacity = AtmosDefines.SPACE_HEAT_CAPACITY; } } else { node.Type = NodeType.Occupied; if (matrix.GetFirst <RegisterDoor>(localPosition, true)) { node.IsIsolatedNode = true; //TODO hard coded these values, might be better to put them in register door? node.ThermalConductivity = 0.001f; node.HeatCapacity = 10000f; } } if (node.IsIsolatedNode == false && node.Type != NodeType.Space && matrix.MetaTileMap.GetTile(localPosition, true) is BasicTile tile && tile != null) { node.HeatCapacity = tile.HeatCapacity; node.ThermalConductivity = tile.ThermalConductivity; } SetupNeighbors(node); if (MatrixManager.AtPoint(node.Position.ToWorld(node.PositionMatrix).RoundToInt(), CustomNetworkManager.IsServer) == node.PositionMatrix.MatrixInfo) { MetaUtils.AddToNeighbors(node); } }
public override void Parse(MetaFile meta, CMloPortalDef CMloPortalDef) { this.Meta = meta; this.MetaStructure = CMloPortalDef; this.RoomFrom = CMloPortalDef.roomFrom; this.RoomTo = CMloPortalDef.roomTo; this.Flags = CMloPortalDef.flags; this.MirrorPriority = CMloPortalDef.mirrorPriority; this.Opacity = CMloPortalDef.opacity; this.AudioOcclusion = CMloPortalDef.audioOcclusion; this.Corners = MetaUtils.ConvertDataArray <Vector4>(meta, CMloPortalDef.corners.Pointer, CMloPortalDef.corners.Count1)?.Select(e => (Vector3)e).ToList(); this.AttachedObjects = MetaUtils.ConvertDataArray <uint>(meta, CMloPortalDef.attachedObjects.Pointer, CMloPortalDef.attachedObjects.Count1)?.ToList(); }
public override void Parse(MetaFile meta, CExtensionDefExplosionEffect CExtensionDefExplosionEffect) { this.Meta = meta; this.MetaStructure = CExtensionDefExplosionEffect; this.Name = CExtensionDefExplosionEffect.name; this.OffsetPosition = CExtensionDefExplosionEffect.offsetPosition; this.OffsetRotation = CExtensionDefExplosionEffect.offsetRotation; this.ExplosionName = MetaUtils.GetString(Meta, CExtensionDefExplosionEffect.explosionName); this.BoneTag = CExtensionDefExplosionEffect.boneTag; this.ExplosionTag = CExtensionDefExplosionEffect.explosionTag; this.ExplosionType = CExtensionDefExplosionEffect.explosionType; this.Flags = CExtensionDefExplosionEffect.flags; }
public override void Parse(MetaFile meta, CAnchorProps CAnchorProps) { this.Meta = meta; this.MetaStructure = CAnchorProps; this.Anchor = CAnchorProps.anchor; var props = MetaUtils.ConvertDataArray <byte>(meta, CAnchorProps.props.Pointer, CAnchorProps.props.Count1)?.ToList(); var linkedProps = Parent.Unk_3902803273.Where(e => e.AnchorId == (byte)Anchor).ToList(); for (int i = 0; i < linkedProps.Count; i++) { PropsMap[linkedProps[i]] = props[i]; } }
public override void Parse(MetaFile meta, CScenarioEntityOverride CScenarioEntityOverride) { this.Meta = meta; this.MetaStructure = CScenarioEntityOverride; this.EntityPosition = CScenarioEntityOverride.EntityPosition; this.EntityType = CScenarioEntityOverride.EntityType; var ScenarioPoints = MetaUtils.ConvertDataArray <CExtensionDefSpawnPoint>(meta, CScenarioEntityOverride.ScenarioPoints); this.ScenarioPoints = ScenarioPoints?.Select(e => { var msw = new MCExtensionDefSpawnPoint(); msw.Parse(meta, e); return(msw); }).ToList(); this.Unk_538733109 = CScenarioEntityOverride.Unk_538733109; this.Unk_1035513142 = CScenarioEntityOverride.Unk_1035513142; }
public static MetaName[] GetHashArray(PsoFile pso, Array_uint arr) { uint[] uints = GetUintArrayRaw(pso, arr); if (uints == null) { return(null); } MetaName[] hashes = new MetaName[uints.Length]; for (int n = 0; n < uints.Length; n++) { hashes[n] = (MetaName)MetaUtils.SwapBytes(uints[n]); } return(hashes); }
public override void Parse(MetaFile meta, Unk_1980345114 Unk_1980345114) { this.Meta = meta; this.MetaStructure = Unk_1980345114; this.AnimDict = Unk_1980345114.AnimDict; this.AnimName = Unk_1980345114.AnimName; this.AnimatedModel = Unk_1980345114.AnimatedModel; this.PunchInPhase = Unk_1980345114.punchInPhase; this.PunchOutPhase = Unk_1980345114.punchOutPhase; var effectsData = MetaUtils.ConvertDataArray <Unk_3430328684>(meta, Unk_1980345114.effectsData); this.EffectsData = effectsData?.Select(e => { var msw = new MUnk_3430328684(); msw.Parse(meta, e); return(msw); }).ToList(); }
public override void Parse(MetaFile meta, Unk_1535046754 Unk_1535046754) { this.Meta = meta; this.MetaStructure = Unk_1535046754; this.PropMask = Unk_1535046754.propMask; this.Unk_2806194106 = Unk_1535046754.Unk_2806194106; var aTexData = MetaUtils.ConvertDataArray <Unk_1036962405>(meta, Unk_1535046754.aTexData); this.ATexData = aTexData?.Select(e => { var msw = new MUnk_1036962405(); msw.Parse(meta, e); return(msw); }).ToList(); this.ClothData = new MUnk_2236980467(); this.ClothData.Parse(meta, Unk_1535046754.clothData); }
public void WriteArrays(byte[] data) { foreach (KeyValuePair <int, Array_Structure> ptr in Structures) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_StructurePointer> ptr in StructurePointers) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_uint> ptr in UInts) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_ushort> ptr in UShorts) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_byte> ptr in UBytes) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_float> ptr in Floats) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_Vector3> ptr in Float_XYZs) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } foreach (KeyValuePair <int, Array_uint> ptr in Hashes) { var _data = MetaUtils.ConvertToBytes(ptr.Value); Buffer.BlockCopy(_data, 0, data, ptr.Key, _data.Length); } }
public override void Parse(object[] parameters = null) { var Unk_376833625Blocks = this.ResourceFile.ResourceData.FindBlocks((MetaName)376833625); if (Unk_376833625Blocks.Length == 0) { throw new Exception("Unk_376833625 block not found !"); } var Unk_376833625 = MetaUtils.ConvertData <Unk_376833625>(Unk_376833625Blocks[0]); this.Unk_376833625 = new RageLib.GTA5.ResourceWrappers.PC.Meta.Structures.MUnk_376833625(); this.Unk_376833625.Parse(this.ResourceFile.ResourceData, Unk_376833625); }
public override void Parse(object[] parameters = null) { var CMapTypesBlocks = this.ResourceFile.ResourceData.FindBlocks(MetaName.CMapTypes); if (CMapTypesBlocks.Length == 0) { throw new Exception("CMapTypes block not found !"); } var CMapTypes = MetaUtils.ConvertData <CMapTypes>(CMapTypesBlocks[0]); this.CMapTypes = new MCMapTypes(); this.CMapTypes.Parse(this.ResourceFile.ResourceData, CMapTypes); }
public override void Parse(MetaFile meta, Unk_1701774085 Unk_1701774085) { this.Meta = meta; this.MetaStructure = Unk_1701774085; this.OwnerName = MetaUtils.GetString(Meta, Unk_1701774085.OwnerName); this.Rotation = Unk_1701774085.Rotation; this.Position = Unk_1701774085.Position; this.Normal = Unk_1701774085.Normal; this.CapsuleRadius = Unk_1701774085.CapsuleRadius; this.CapsuleLen = Unk_1701774085.CapsuleLen; this.CapsuleHalfHeight = Unk_1701774085.CapsuleHalfHeight; this.CapsuleHalfWidth = Unk_1701774085.CapsuleHalfWidth; this.Flags = Unk_1701774085.Flags; }
public override void Parse(MetaFile meta, CStreamingRequestRecord CStreamingRequestRecord) { this.Meta = meta; this.MetaStructure = CStreamingRequestRecord; var Frames = MetaUtils.ConvertDataArray <CStreamingRequestFrame>(meta, CStreamingRequestRecord.Frames); this.Frames = Frames?.Select(e => { var msw = new MCStreamingRequestFrame(); msw.Parse(meta, e); return(msw); }).ToList(); var CommonSets = MetaUtils.ConvertDataArray <Unk_1358189812>(meta, CStreamingRequestRecord.CommonSets); this.CommonSets = CommonSets?.Select(e => { var msw = new MUnk_1358189812(); msw.Parse(meta, e); return(msw); }).ToList(); this.NewStyle = CStreamingRequestRecord.NewStyle; }