public override void Read(CGameCtnMediaBlockFxBloom n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => { return(new Key() { Time = r.ReadSingle(), Intensity = r.ReadSingle(), Sensitivity = r.ReadSingle() }); }); }
public override void Read(CGameCtnMediaBlockFxBlurDepth n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => { return(new Key() { Time = r.ReadSingle(), LensSize = r.ReadSingle(), ForceFocus = r.ReadBoolean(), FocusZ = r.ReadSingle(), }); }); }
public override void Read(CGameCtnMediaBlockDirtyLens n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var intensity = r.ReadSingle(); return(new Key() { Time = time, Intensity = intensity }); }); }
public override void Read(CGameCtnMediaClipGroup n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); var clips = r.ReadArray(i => r.ReadNodeRef<CGameCtnMediaClip>()); var triggers = r.ReadArray(i => { var u01 = r.ReadInt32(); var u02 = r.ReadInt32(); var u03 = r.ReadInt32(); var u04 = r.ReadInt32(); var condition = (ECondition)r.ReadInt32(); var conditionValue = r.ReadSingle(); var coords = r.ReadArray(j => r.ReadInt3()); return new Trigger() { Coords = coords, U01 = u01, U02 = u02, U03 = u03, U04 = u04, Condition = condition, ConditionValue = conditionValue }; }); n.Clips = clips.Select((clip, index) => Tuple.Create(clip, triggers[index]) ).ToList(); }
public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var position = r.ReadVec3(); var pitchYawRoll = r.ReadVec3(); // in radians var fov = r.ReadSingle(); var anchorRot = r.ReadBoolean(); var anchor = r.ReadInt32(); var anchorVis = r.ReadBoolean(); var target = r.ReadInt32(); var targetPosition = r.ReadVec3(); var a = r.ReadSingle(); // 1 var b = r.ReadSingle(); // -0.48 var c = r.ReadSingle(); // 0 var d = r.ReadSingle(); // 0 var e = r.ReadSingle(); return(new Key() { Time = time, Position = position, PitchYawRoll = pitchYawRoll, FOV = fov, AnchorRot = anchorRot, Anchor = anchor, AnchorVis = anchorVis, Target = target, TargetPosition = targetPosition, Unknown = new object[] { a, b, c, d, e } }); }); }
public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var position = r.ReadVec3(); var pitchYawRoll = r.ReadVec3(); // in radians var fov = r.ReadSingle(); float?nearZ = null; if (Version >= 3) { nearZ = r.ReadSingle(); } var anchorRot = r.ReadBoolean(); var anchor = r.ReadInt32(); var anchorVis = r.ReadBoolean(); var target = r.ReadInt32(); var targetPosition = r.ReadVec3(); var unknown = r.ReadArray <float>(5).Cast <object>().ToList(); if (Version >= 4) { unknown.AddRange(r.ReadArray <int>(2).Cast <object>()); } return(new Key() { Time = time, Position = position, PitchYawRoll = pitchYawRoll, FOV = fov, NearZ = nearZ, AnchorRot = anchorRot, Anchor = anchor, AnchorVis = anchorVis, Target = target, TargetPosition = targetPosition, Unknown = unknown.Cast <object>().ToArray() }); }); }
public override void Read(CGameCtnMediaBlockCameraCustom n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var u01 = r.ReadInt32(); // 1 var u02 = r.ReadInt32(); // 0 var u03 = r.ReadInt32(); // 0 var position = r.ReadVec3(); var pitchYawRoll = r.ReadVec3(); // in radians var fov = r.ReadSingle(); var u04 = r.ReadInt32(); // 0 var u05 = r.ReadInt32(); // -1 var u06 = r.ReadInt32(); // 1 var u07 = r.ReadInt32(); // -1 var u08 = r.ReadSingle(); var u09 = r.ReadSingle(); var u10 = r.ReadSingle(); var u11 = r.ReadSingle(); var u12 = r.ReadSingle(); return(new Key() { Time = time, Position = position, PitchYawRoll = pitchYawRoll, FOV = fov, Unknown = new object[] { u01, u02, u03, u04, u05, u06, u07, u08, u09, u10, u11, u12 } }); }).ToList(); }
public override void Read(CGameCtnMediaBlockCameraCustom n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var a = r.ReadInt32(); // 1 var anchorRot = r.ReadBoolean(); // 0 var anchor = r.ReadInt32(); // -1 if not set, 0 for local player var anchorVis = r.ReadBoolean(); // 1 var target = r.ReadInt32(); // -1 var position = r.ReadVec3(); var pitchYawRoll = r.ReadVec3(); // in radians var fov = r.ReadSingle(); var f = r.ReadInt32(); // 0 var g = r.ReadInt32(); // 0 var h = r.ReadInt32(); // 0 var zIndex = r.ReadSingle(); var leftTangent = r.ReadVec3(); var ii = r.ReadArray <float>(8); var rightTangent = r.ReadVec3(); var j = r.ReadArray <float>(8); return(new Key() { Time = time, AnchorRot = anchorRot, Anchor = anchor, AnchorVis = anchorVis, Target = target, Position = position, PitchYawRoll = pitchYawRoll, FOV = fov, ZIndex = zIndex, LeftTangent = leftTangent, RightTangent = rightTangent, Unknown = new object[] { a, f, g, h, ii, j } }); }).ToList(); }
public override void Read(CGameCtnMediaBlockCameraCustom n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var a = r.ReadInt32(); // 1 var b = r.ReadInt32(); // 0 var c = r.ReadInt32(); // 0 var position = r.ReadVec3(); var pitchYawRoll = r.ReadVec3(); // in radians var fov = r.ReadSingle(); var d = r.ReadInt32(); // 0 var anchor = r.ReadInt32(); // -1 if not set, 0 for local player var f = r.ReadInt32(); // 1 var target = r.ReadInt32(); // -1 if not set, 0 for local player var targetPosition = r.ReadVec3(); var leftTangent = r.ReadVec3(); var rightTangent = r.ReadVec3(); return(new Key() { Time = time, Position = position, PitchYawRoll = pitchYawRoll, FOV = fov, Anchor = anchor, Target = target, TargetPosition = targetPosition, LeftTangent = leftTangent, RightTangent = rightTangent, Unknown = new object[] { a, b, c, d, f } }); }).ToList(); }
public override void Read(CGameCtnBlockInfoMobil n, GameBoxReader r) { Version = r.ReadInt32(); r.ReadByte(); var num = r.ReadInt32(); if (num == 16777216) // TODO: figure out why { r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); } if (Version >= 20) { r.ReadInt32(); r.ReadInt32(); } r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); if (Version >= 20) { r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); // 3 r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadInt32(); r.ReadByte(); r.ReadVec3(); n.RoadChunks = r.ReadArray(r => r.ReadNodeRef <CPlugRoadChunk>()); } }
public override void Read(CGameCtnMediaBlockFog n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); n.Keys = r.ReadArray(i => { var time = r.ReadSingle(); var intensity = r.ReadSingle(); var skyIntensity = r.ReadSingle(); var distance = r.ReadSingle(); float?coefficient = null; Vec3?color = null; float?cloudsOpacity = null; float?cloudsSpeed = null; if (Version >= 1) { coefficient = r.ReadSingle(); color = r.ReadVec3(); if (Version >= 2) { cloudsOpacity = r.ReadSingle(); cloudsSpeed = r.ReadSingle(); } } return(new Key() { Time = time, Intensity = intensity, SkyIntensity = skyIntensity, Distance = distance, Coefficient = coefficient, Color = color, CloudsOpacity = cloudsOpacity, CloudsSpeed = cloudsSpeed }); }); }
public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW) { Version = r.ReadInt32(); n.AnchoredObjects = r.ReadArray(i => { var v = r.ReadInt32(); var itemModel = r.ReadIdent(); Vec3 pitchYawRoll = default; Vec3 pivotPosition = default; float scale = 1; if (v < 3) { var quarterY = r.ReadByte(); if (v != 0) { var additionalDir = r.ReadByte(); } } else { pitchYawRoll = r.ReadVec3(); } var blockCoord = r.ReadInt3(); var lookback = r.ReadId(); var pos = r.ReadVec3(); if (v < 5) { r.ReadInt32(); } if (v < 6) { r.ReadInt32(); } if (v >= 6) { r.ReadInt16(); // 0 } if (v >= 7) { pivotPosition = r.ReadVec3(); } if (v >= 8) { r.ReadNodeRef(); // probably waypoint } if (v >= 9) { scale = r.ReadSingle(); // 1 } if (v >= 10) { r.ReadArray <int>(3); // 0 1 -1 } return(new CGameCtnAnchoredObject() { ItemModel = itemModel, PitchYawRoll = pitchYawRoll, BlockUnitCoord = (Byte3)blockCoord, AbsolutePositionInMap = pos, PivotPosition = pivotPosition, Scale = scale, }); }); var num = r.ReadInt32(); if (num == 1) { r.ReadInt32(); r.ReadInt32(); } }
public override void Read(CGameCtnMediaBlockFxColors n, GameBoxReader r, GameBoxWriter unknownW) { n.Keys = r.ReadArray(i => new Key() { Time = r.ReadSingle(), Intensity = r.ReadSingle(), BlendZ = r.ReadSingle(), Distance = r.ReadSingle(), FarDistance = r.ReadSingle(), Inverse = r.ReadSingle(), Hue = r.ReadSingle(), Saturation = r.ReadSingle(), // from center Brightness = r.ReadSingle(), // from center Contrast = r.ReadSingle(), // from center RGB = r.ReadVec3(), U01 = r.ReadSingle(), U02 = r.ReadSingle(), U03 = r.ReadSingle(), U04 = r.ReadSingle(), FarInverse = r.ReadSingle(), FarHue = r.ReadSingle(), FarSaturation = r.ReadSingle(), // from center FarBrightness = r.ReadSingle(), // from center FarContrast = r.ReadSingle(), // from center FarRGB = r.ReadVec3(), FarU01 = r.ReadSingle(), FarU02 = r.ReadSingle(), FarU03 = r.ReadSingle(), FarU04 = r.ReadSingle() }); }
private static ScriptStruct ReadScriptStruct(out int defaultLength, GameBoxReader r) { var strc = new ScriptStruct(); var numMembers = r.ReadByte(); var structName = r.ReadString(); strc.StructName = structName; strc.Members = new ScriptVariable[numMembers]; defaultLength = 0; for (var i = 0; i < numMembers; i++) { ScriptVariable member; var memberName = r.ReadString(); var memberType = r.ReadByte(); switch ((ScriptType)memberType) { case ScriptType.Array: member = ReadScriptArray(r); break; case ScriptType.Struct: member = ReadScriptStruct(out int defLength, r); defaultLength += defLength; break; default: member = new ScriptVariable((ScriptType)memberType); break; } switch (member.Type) { case ScriptType.Integer: r.ReadInt32(); defaultLength += 4; break; case ScriptType.Real: r.ReadSingle(); defaultLength += 4; break; case ScriptType.Vec2: r.ReadVec2(); defaultLength += 8; break; case ScriptType.Vec3: r.ReadVec3(); defaultLength += 12; break; case ScriptType.Int3: r.ReadInt3(); defaultLength += 12; break; case ScriptType.Int2: r.ReadInt2(); defaultLength += 8; break; case ScriptType.Array: break; case ScriptType.Struct: break; default: r.ReadByte(); defaultLength += 1; break; } member.Name = memberName; strc.Members[i] = member; } int counter = 0; while (r.ReadByte() == 0) { counter++; } r.BaseStream.Position -= 1; //int counter = 0; //while (r.ReadByte() == 0) counter++; // probably size of the struct in byte count? //r.BaseStream.Position -= 1; strc.Size = defaultLength + counter; // strc.Unknown = counter; //Progress += defaultLength; return(strc); }
private static ScriptVariable ReadType(ScriptVariable type, GameBoxReader r) { switch (type.Type) { case ScriptType.Boolean: type.Value = r.ReadBoolean(true); break; case ScriptType.Integer: type.Value = r.ReadInt32(); break; case ScriptType.Real: type.Value = r.ReadSingle(); break; case ScriptType.Text: type.Value = r.ReadString(StringLengthPrefix.Byte); break; case ScriptType.Vec2: type.Value = r.ReadVec2(); break; case ScriptType.Vec3: type.Value = r.ReadVec3(); break; case ScriptType.Int3: type.Value = r.ReadInt3(); break; case ScriptType.Int2: type.Value = r.ReadInt2(); break; case ScriptType.Array: var array = (ScriptArray)type; var numElements = r.ReadByte(); if (numElements > 0) { ScriptVariable key; if (array.Reference.Key.Type == ScriptType.Void) { for (var i = 0; i < numElements; i++) { array.Elements[new ScriptVariable(ScriptType.Void) { Value = i }] = ReadType(array.Reference.Value.Clone(), r); } } else { key = ReadType(array.Reference.Key.Clone(), r); for (var i = 0; i < numElements; i++) { array.Elements[key] = ReadType(array.Reference.Value.Clone(), r); } } } break; case ScriptType.Struct: var strc = (ScriptStruct)type; for (var i = 0; i < strc.Members.Length; i++) { strc.Members[i] = ReadType(strc.Members[i], r); } break; default: throw new Exception(type.Type.ToString()); } return(type); }
public void Read(GameBoxReader r) { var classId = r.ReadUInt32(); Version = r.ReadInt32(); var typeCount = r.ReadByte(); var types = new ScriptVariable[typeCount]; for (var i = 0; i < typeCount; i++) { var varType = r.ReadByte(); switch ((ScriptType)varType) { case ScriptType.Array: types[i] = ReadScriptArray(); break; case ScriptType.Struct: types[i] = ReadScriptStruct(out int defaultLength); break; default: types[i] = new ScriptVariable((ScriptType)varType); break; } } var varCount = r.ReadByte(); var metadata = new ScriptVariable[varCount]; for (var i = 0; i < varCount; i++) { var metadataVarName = r.ReadString(StringLengthPrefix.Byte); var typeIndex = r.ReadByte(); var type = types[typeIndex]; metadata[i] = ReadType(type.Clone()); metadata[i].Name = metadataVarName; } Metadata = metadata.ToList(); var facade = r.ReadUInt32(); ScriptArray ReadScriptArray() { ScriptVariable indexVar; var indexType = r.ReadByte(); // index if ((ScriptType)indexType == ScriptType.Struct) { indexVar = ReadScriptStruct(out int defaultLength); } else { indexVar = new ScriptVariable((ScriptType)indexType); } ScriptVariable valueVar; var arrayType = r.ReadByte(); // value if ((ScriptType)arrayType == ScriptType.Array) { valueVar = ReadScriptArray(); } else if ((ScriptType)arrayType == ScriptType.Struct) { valueVar = ReadScriptStruct(out int defaultLength); } else { valueVar = new ScriptVariable((ScriptType)arrayType); } ScriptArray array = new ScriptArray(new KeyValuePair <ScriptVariable, ScriptVariable>(indexVar, valueVar)); int counterArray = 0; while (r.ReadByte() == 0) { counterArray++; } r.BaseStream.Position -= 1; array.Unknown = counterArray; return(array); } ScriptStruct ReadScriptStruct(out int defaultLength) { var strc = new ScriptStruct(); var numMembers = r.ReadByte(); var structName = r.ReadString(); strc.StructName = structName; strc.Members = new ScriptVariable[numMembers]; defaultLength = 0; for (var i = 0; i < numMembers; i++) { ScriptVariable member; var memberName = r.ReadString(); var memberType = r.ReadByte(); switch ((ScriptType)memberType) { case ScriptType.Array: member = ReadScriptArray(); break; case ScriptType.Struct: member = ReadScriptStruct(out int defLength); defaultLength += defLength; break; default: member = new ScriptVariable((ScriptType)memberType); break; } switch (member.Type) { case ScriptType.Integer: r.ReadInt32(); defaultLength += 4; break; case ScriptType.Real: r.ReadSingle(); defaultLength += 4; break; case ScriptType.Vec2: r.ReadVec2(); defaultLength += 8; break; case ScriptType.Vec3: r.ReadVec3(); defaultLength += 12; break; case ScriptType.Int3: r.ReadInt3(); defaultLength += 12; break; case ScriptType.Int2: r.ReadInt2(); defaultLength += 8; break; case ScriptType.Array: break; case ScriptType.Struct: break; default: r.ReadByte(); defaultLength += 1; break; } member.Name = memberName; strc.Members[i] = member; } int counter = 0; while (r.ReadByte() == 0) { counter++; } r.BaseStream.Position -= 1; //int counter = 0; //while (r.ReadByte() == 0) counter++; // probably size of the struct in byte count? //r.BaseStream.Position -= 1; strc.Size = defaultLength + counter; // strc.Unknown = counter; //Progress += defaultLength; return(strc); } ScriptVariable ReadType(ScriptVariable type) { switch (type.Type) { case ScriptType.Boolean: type.Value = Convert.ToBoolean(r.ReadBoolean(true)); break; case ScriptType.Integer: type.Value = r.ReadInt32(); break; case ScriptType.Real: type.Value = r.ReadSingle(); break; case ScriptType.Text: type.Value = r.ReadString(StringLengthPrefix.Byte); break; case ScriptType.Vec2: type.Value = r.ReadVec2(); break; case ScriptType.Vec3: type.Value = r.ReadVec3(); break; case ScriptType.Int3: type.Value = r.ReadInt3(); break; case ScriptType.Int2: type.Value = r.ReadInt2(); break; case ScriptType.Array: var array = type as ScriptArray; var numElements = r.ReadByte(); if (numElements > 0) { ScriptVariable key; if (array.Reference.Key.Type == ScriptType.Void) { for (var i = 0; i < numElements; i++) { array.Elements[new ScriptVariable(ScriptType.Void) { Value = i }] = ReadType(array.Reference.Value.Clone()); } } else { key = ReadType(array.Reference.Key.Clone()); for (var i = 0; i < numElements; i++) { array.Elements[key] = ReadType(array.Reference.Value.Clone()); } } } break; case ScriptType.Struct: var strc = type as ScriptStruct; for (var i = 0; i < strc.Members.Length; i++) { strc.Members[i] = ReadType(strc.Members[i]); } break; default: throw new Exception(type.Type.ToString()); } return(type); } }
public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW) { _ = r.ReadSingle(); }
public override void Read(CGameCtnCollection n, GameBoxReader r) { _ = r.ReadSingle(); }