void setCarVisuals(CarVisuals visuals, GameObject car) { if (visuals == null) { ErrorList.add("Can't find the CarVisuals component on the base car"); return; } var skinned = car.GetComponentInChildren <SkinnedMeshRenderer>(); MakeMeshSkinned(skinned); visuals.carBodyRenderer_ = skinned; var boostJets = new List <JetFlame>(); var wingJets = new List <JetFlame>(); var rotationJets = new List <JetFlame>(); PlaceJets(car, boostJets, wingJets, rotationJets); visuals.boostJetFlames_ = boostJets.ToArray(); visuals.wingJetFlames_ = wingJets.ToArray(); visuals.rotationJetFlames_ = rotationJets.ToArray(); visuals.driverPosition_ = findCarDriver(car.transform); placeCarWheelsVisuals(visuals, car); }
private void OnEnable() { m_CarDamage = GetComponent <CarDamage>(); m_CarVisuals = GetComponent <CarVisuals>(); ApplyEnabled(WheelFL, true); ApplyEnabled(WheelFR, true); ApplyEnabled(WheelRL, true); ApplyEnabled(WheelRR, true); if (CenterOfMass) { rigidbody.centerOfMass = new Vector3(CenterOfMass.localPosition.x * tr.localScale.x, CenterOfMass.localPosition.y * tr.localScale.y, CenterOfMass.localPosition.z * tr.localScale.z); } var WheelC = WheelFL.GetComponent <WheelCollider>(); Vector3 V = rigidbody.centerOfMass - tr.InverseTransformPoint(WheelC.transform.position); float h = Mathf.Abs((V.y + WheelC.radius + WheelC.suspensionDistance / 2.0f) * tr.localScale.y); float l = Mathf.Abs(V.x * tr.localScale.x); m_maxRollAngle = Mathf.Atan2(l, h) * Mathf.Rad2Deg; rigidbody.maxAngularVelocity = 10; rigidbody.useConeFriction = false; if (optimized) { ApplyCommonParameters(WheelFL); ApplyCommonParameters(WheelFR); ApplyCommonParameters(WheelRL); ApplyCommonParameters(WheelRR); WheelFL.RecalculateStuff(); WheelFR.RecalculateStuff(); WheelRL.RecalculateStuff(); WheelRR.RecalculateStuff(); } }
//========= CONSTRUCTORS ========= #region Constructors /** <summary> Constructs the default attraction car header. </summary> */ public CarHeader() { this.LastRotationFrame = 0; this.Reserved0x01 = new byte[3]; this.Unknown0x04 = 0; this.CarSpacing = 0; this.Reserved0x07 = 0; this.CarFriction = 0; this.CarTabHeight = 0; this.RiderSettings = 0; this.SpriteFlags = CarSpriteFlags.None; this.Unknown0x0E = new byte[3]; for (int i = 0; i < this.Unknown0x0E.Length; i++) { this.Unknown0x0E[i] = 0; } this.Flags = CarFlags.None; this.Reserved0x16 = new byte[59]; for (int i = 0; i < this.Reserved0x16.Length; i++) { this.Reserved0x16[i] = 0; } this.RiderSprites = 0; this.SpinningInertia = 0; this.SpinningFriction = 0; this.Unknown0x57 = new byte[4]; for (int i = 0; i < this.Unknown0x57.Length; i++) { this.Unknown0x57[i] = 0; } this.PoweredAcceleration = 0; this.PoweredMaxSpeed = 0; this.CarVisual = CarVisuals.Default; this.UnknownSetting = CarUnknownSettings.Default; this.DrawOrder = 0; this.SpecialFrames = 0; this.Reserved0x61 = 0; }
//========= CONSTRUCTORS ========= #region Constructors /**<summary>Constructs the default attraction car header.</summary>*/ public CarHeader() { LastRotationFrame = 0; NumVerticalFramesUnused = 0; NumHorizontalFramesUnused = 0; Spacing = 0; CarFriction = 0; CarTabHeight = 0; RiderSettings = 0; SpriteFlags = CarSpriteFlags.None; SpriteWidth = 0; SpriteHeightPositive = 0; SpriteHeightNegative = 0; Animation = 0; Flags = CarFlags.None; BaseNumFrames = 0; Reserved0x18 = new byte[60]; for (int i = 0; i < Reserved0x18.Length; i++) { Reserved0x18[i] = 0; } RiderSprites = 0; SpinningInertia = 0; SpinningFriction = 0; FrictionSoundID = 0; Unknown0x58 = 0; SoundRange = 0; Unknown0x5A = 0; PoweredAcceleration = 0; PoweredMaxSpeed = 0; CarVisual = CarVisuals.Default; EffectVisual = CarEffectVisuals.Default; DrawOrder = 0; SpecialFrames = 0; Reserved0x61 = 0; }
void placeCarWheelsVisuals(CarVisuals visual, GameObject car) { for (int i = 0; i < car.transform.childCount; i++) { var c = car.transform.GetChild(i).gameObject; var name = c.name.ToLower(); if (name.Contains("wheel")) { CarWheelVisuals comp = c.AddComponent <CarWheelVisuals>(); foreach (var r in c.GetComponentsInChildren <MeshRenderer>()) { if (r.gameObject.name.ToLower().Contains("tire")) { comp.tire_ = r; break; } } if (name.Contains("front")) { if (name.Contains("left")) { visual.wheelFL_ = comp; } else if (name.Contains("right")) { visual.wheelFR_ = comp; } } else if (name.Contains("back")) { if (name.Contains("left")) { visual.wheelBL_ = comp; } else if (name.Contains("right")) { visual.wheelBR_ = comp; } } } } }
//=========== READING ============ #region Reading /**<summary>Reads the object header.</summary>*/ public void Read(BinaryReader reader) { LastRotationFrame = reader.ReadUInt16(); NumVerticalFramesUnused = reader.ReadByte(); NumHorizontalFramesUnused = reader.ReadByte(); Spacing = reader.ReadUInt32(); CarFriction = reader.ReadUInt16(); CarTabHeight = reader.ReadSByte(); RiderSettings = reader.ReadByte(); SpriteFlags = (CarSpriteFlags)reader.ReadUInt16(); SpriteWidth = reader.ReadByte(); SpriteHeightPositive = reader.ReadByte(); SpriteHeightNegative = reader.ReadByte(); Animation = reader.ReadByte(); Flags = (CarFlags)reader.ReadUInt32(); BaseNumFrames = reader.ReadUInt16(); reader.Read(Reserved0x18, 0, Reserved0x18.Length); RiderSprites = reader.ReadByte(); SpinningInertia = reader.ReadByte(); SpinningFriction = reader.ReadByte(); FrictionSoundID = reader.ReadByte(); Unknown0x58 = reader.ReadByte(); SoundRange = reader.ReadByte(); Unknown0x5A = reader.ReadByte(); PoweredAcceleration = reader.ReadByte(); PoweredMaxSpeed = reader.ReadByte(); CarVisual = (CarVisuals)reader.ReadByte(); EffectVisual = (CarEffectVisuals)reader.ReadByte(); DrawOrder = reader.ReadByte(); SpecialFrames = reader.ReadByte(); Reserved0x61 = reader.ReadUInt32(); }
//=========== READING ============ #region Reading /** <summary> Reads the object header. </summary> */ public void Read(BinaryReader reader) { this.LastRotationFrame = reader.ReadByte(); reader.Read(this.Reserved0x01, 0, this.Reserved0x01.Length); this.Unknown0x04 = reader.ReadByte(); this.CarSpacing = reader.ReadUInt16(); this.Reserved0x07 = reader.ReadByte(); this.CarFriction = reader.ReadUInt16(); this.CarTabHeight = reader.ReadByte(); this.RiderSettings = reader.ReadByte(); this.SpriteFlags = (CarSpriteFlags)reader.ReadUInt16(); reader.Read(this.Unknown0x0E, 0, this.Unknown0x0E.Length); this.Flags = (CarFlags)reader.ReadUInt64(); reader.Read(this.Reserved0x16, 0, this.Reserved0x16.Length); this.RiderSprites = reader.ReadByte(); this.SpinningInertia = reader.ReadByte(); this.SpinningFriction = reader.ReadByte(); reader.Read(this.Unknown0x57, 0, this.Unknown0x57.Length); this.PoweredAcceleration = reader.ReadByte(); this.PoweredMaxSpeed = reader.ReadByte(); this.CarVisual = (CarVisuals)reader.ReadByte(); this.UnknownSetting = (CarUnknownSettings)reader.ReadByte(); this.DrawOrder = reader.ReadByte(); this.SpecialFrames = reader.ReadByte(); this.Reserved0x61 = reader.ReadUInt32(); }
static void Postfix(CarVisuals __instance) { Scripts.LampController controller = __instance.gameObject.AddComponent <Scripts.LampController>(); controller.SetCarLogic(__instance.gameObject.GetComponentInParent <CarLogic>()); }
internal static void Postfix(CarVisuals __instance) { __instance.gameObject.AddComponent <DecorativeLampLogic>(); }
private void OnEnable() { m_CarDamage = GetComponent<CarDamage>(); m_CarVisuals = GetComponent<CarVisuals>(); ApplyEnabled(WheelFL, true); ApplyEnabled(WheelFR, true); ApplyEnabled(WheelRL, true); ApplyEnabled(WheelRR, true); if (CenterOfMass) rigidbody.centerOfMass = new Vector3(CenterOfMass.localPosition.x * tr.localScale.x, CenterOfMass.localPosition.y * tr.localScale.y, CenterOfMass.localPosition.z * tr.localScale.z); var WheelC = WheelFL.GetComponent<WheelCollider>(); Vector3 V = rigidbody.centerOfMass - tr.InverseTransformPoint(WheelC.transform.position); float h = Mathf.Abs((V.y + WheelC.radius + WheelC.suspensionDistance / 2.0f) * tr.localScale.y); float l = Mathf.Abs(V.x * tr.localScale.x); m_maxRollAngle = Mathf.Atan2(l, h) * Mathf.Rad2Deg; rigidbody.maxAngularVelocity = 10; rigidbody.useConeFriction = false; if (optimized) { ApplyCommonParameters(WheelFL); ApplyCommonParameters(WheelFR); ApplyCommonParameters(WheelRL); ApplyCommonParameters(WheelRR); WheelFL.RecalculateStuff(); WheelFR.RecalculateStuff(); WheelRL.RecalculateStuff(); WheelRR.RecalculateStuff(); } }