public ObjectAsset(Bundle bundle, Data data, Local localization, ushort id) : base(bundle, data, localization, id) { if (id < 2000 && !bundle.hasResource && !data.has("Bypass_ID_Limit")) { throw new NotSupportedException("ID < 2000"); } this._objectName = localization.format("Name"); this.type = (EObjectType)Enum.Parse(typeof(EObjectType), data.readString("Type"), true); if (this.type == EObjectType.NPC) { if (Dedicator.isDedicated) { this._modelGameObject = (GameObject)Resources.Load("Characters/NPC_Server"); } else { this._modelGameObject = (GameObject)Resources.Load("Characters/NPC_Client"); } this.useScale = true; this.interactability = EObjectInteractability.NPC; } else if (this.type == EObjectType.DECAL) { float num = data.readSingle("Decal_X"); float num2 = data.readSingle("Decal_Y"); float num3 = 1f; if (data.has("Decal_LOD_Bias")) { num3 = data.readSingle("Decal_LOD_Bias"); } Texture2D texture2D = (Texture2D)bundle.load("Decal"); this._modelGameObject = Object.Instantiate <GameObject>(Resources.Load <GameObject>("Materials/Decal_Template")); this._modelGameObject.hideFlags = 61; Object.DontDestroyOnLoad(this._modelGameObject); BoxCollider component = this.modelGameObject.GetComponent <BoxCollider>(); component.size = new Vector3(num2, num, 1f); Decal component2 = this.modelGameObject.transform.FindChild("Decal").GetComponent <Decal>(); Material material = Object.Instantiate <Material>(component2.material); material.name = "Decal_Deferred"; material.hideFlags = 52; material.SetTexture("_MainTex", texture2D); component2.material = material; component2.lodBias = num3; component2.transform.localScale = new Vector3(num, num2, 1f); MeshRenderer component3 = this.modelGameObject.transform.FindChild("Mesh").GetComponent <MeshRenderer>(); Material material2 = Object.Instantiate <Material>(component3.sharedMaterial); material2.name = "Decal_Forward"; material2.hideFlags = 52; material2.SetTexture("_MainTex", texture2D); component3.sharedMaterial = material2; component3.transform.localScale = new Vector3(num2, num, 1f); this.useScale = true; } else { if (Dedicator.isDedicated) { this._modelGameObject = (GameObject)bundle.load("Clip"); if (this.modelGameObject == null && this.type != EObjectType.SMALL) { Debug.LogError(this.objectName + " is missing collision data. Highly recommended to fix."); } } else { this._modelGameObject = (GameObject)bundle.load("Object"); if (this.modelGameObject == null) { throw new NotSupportedException("Missing object gameobject"); } this._skyboxGameObject = (GameObject)bundle.load("Skybox"); } if (this.modelGameObject != null) { if (Mathf.Abs(this.modelGameObject.transform.localScale.x - 1f) > 0.01f || Mathf.Abs(this.modelGameObject.transform.localScale.y - 1f) > 0.01f || Mathf.Abs(this.modelGameObject.transform.localScale.z - 1f) > 0.01f) { this.useScale = false; Assets.errors.Add(this.objectName + " should have a scale of one."); } else { this.useScale = true; } Transform transform = this.modelGameObject.transform.FindChild("Block"); if (transform != null && transform.GetComponent <Collider>() != null && transform.GetComponent <Collider>().sharedMaterial == null) { Assets.errors.Add(this.objectName + " has a clip object but no physics material."); } Transform transform2 = this.modelGameObject.transform.FindChild("Model_0"); if (this.type == EObjectType.SMALL) { if (!this.modelGameObject.CompareTag("Small")) { Assets.errors.Add(this.objectName + " is set up as small, but is not tagged as small."); } if (this.modelGameObject.layer != LayerMasks.SMALL) { Assets.errors.Add(this.objectName + " is set up as small, but is not layered as small."); } if (transform2 != null) { if (!transform2.CompareTag("Small")) { Assets.errors.Add(this.objectName + " is set up as small, but is not tagged as small."); } if (transform2.gameObject.layer != LayerMasks.SMALL) { Assets.errors.Add(this.objectName + " is set up as small, but is not layered as small."); } } } else if (this.type == EObjectType.MEDIUM) { if (!this.modelGameObject.CompareTag("Medium")) { Assets.errors.Add(this.objectName + " is set up as medium, but is not tagged as medium."); } if (this.modelGameObject.layer != LayerMasks.MEDIUM) { Assets.errors.Add(this.objectName + " is set up as medium, but is not layered as medium."); } if (transform2 != null) { if (!transform2.CompareTag("Medium")) { Assets.errors.Add(this.objectName + " is set up as medium, but is not tagged as medium."); } if (transform2.gameObject.layer != LayerMasks.MEDIUM) { Assets.errors.Add(this.objectName + " is set up as medium, but is not layered as medium."); } } } else if (this.type == EObjectType.LARGE) { if (!this.modelGameObject.CompareTag("Large")) { Assets.errors.Add(this.objectName + " is set up as large, but is not tagged as large."); } if (this.modelGameObject.layer != LayerMasks.LARGE) { Assets.errors.Add(this.objectName + " is set up as large, but is not layered as large."); } if (transform2 != null) { if (!transform2.CompareTag("Large")) { Assets.errors.Add(this.objectName + " is set up as large, but is not tagged as large."); } if (transform2.gameObject.layer != LayerMasks.LARGE) { Assets.errors.Add(this.objectName + " is set up as large, but is not layered as large."); } } } } this._navGameObject = (GameObject)bundle.load("Nav"); if (this.navGameObject == null && this.type == EObjectType.LARGE) { Assets.errors.Add(this.objectName + " is missing navigation data. Highly recommended to fix."); } if (this.navGameObject != null) { if (!this.navGameObject.CompareTag("Navmesh")) { Assets.errors.Add(this.objectName + " is set up as navmesh, but is not tagged as navmesh."); } if (this.navGameObject.layer != LayerMasks.NAVMESH) { Assets.errors.Add(this.objectName + " is set up as navmesh, but is not layered as navmesh."); } } this._slotsGameObject = (GameObject)bundle.load("Slots"); this._triggersGameObject = (GameObject)bundle.load("Triggers"); this.isSnowshoe = data.has("Snowshoe"); if (data.has("Chart")) { this.chart = (EObjectChart)Enum.Parse(typeof(EObjectChart), data.readString("Chart"), true); } else { this.chart = EObjectChart.NONE; } this.isFuel = data.has("Fuel"); this.isRefill = data.has("Refill"); this.isSoft = data.has("Soft"); this.isCollisionImportant = data.has("Collision_Important"); if (this.isFuel || this.isRefill) { Assets.errors.Add(this.objectName + " is using the legacy fuel/water system."); } if (data.has("LOD")) { this.lod = (EObjectLOD)Enum.Parse(typeof(EObjectLOD), data.readString("LOD"), true); this.lodBias = data.readSingle("LOD_Bias"); if (this.lodBias < 0.01f) { this.lodBias = 1f; } this.lodCenter = data.readVector3("LOD_Center"); this.lodSize = data.readVector3("LOD_Size"); } if (data.has("Interactability")) { this.interactability = (EObjectInteractability)Enum.Parse(typeof(EObjectInteractability), data.readString("Interactability"), true); this.interactabilityRemote = data.has("Interactability_Remote"); this.interactabilityDelay = data.readSingle("Interactability_Delay"); this.interactabilityReset = data.readSingle("Interactability_Reset"); if (data.has("Interactability_Hint")) { this.interactabilityHint = (EObjectInteractabilityHint)Enum.Parse(typeof(EObjectInteractabilityHint), data.readString("Interactability_Hint"), true); } this.interactabilityEmission = data.has("Interactability_Emission"); if (this.interactability == EObjectInteractability.NOTE) { ushort num4 = data.readUInt16("Interactability_Text_Lines"); StringBuilder stringBuilder = new StringBuilder(); for (ushort num5 = 0; num5 < num4; num5 += 1) { string value = localization.format("Interactability_Text_Line_" + num5); stringBuilder.AppendLine(value); } this.interactabilityText = stringBuilder.ToString(); } else { this.interactabilityText = localization.read("Interact"); } if (data.has("Interactability_Power")) { this.interactabilityPower = (EObjectInteractabilityPower)Enum.Parse(typeof(EObjectInteractabilityPower), data.readString("Interactability_Power"), true); } else { this.interactabilityPower = EObjectInteractabilityPower.NONE; } if (data.has("Interactability_Editor")) { this.interactabilityEditor = (EObjectInteractabilityEditor)Enum.Parse(typeof(EObjectInteractabilityEditor), data.readString("Interactability_Editor"), true); } else { this.interactabilityEditor = EObjectInteractabilityEditor.NONE; } if (data.has("Interactability_Nav")) { this.interactabilityNav = (EObjectInteractabilityNav)Enum.Parse(typeof(EObjectInteractabilityNav), data.readString("Interactability_Nav"), true); } else { this.interactabilityNav = EObjectInteractabilityNav.NONE; } this.interactabilityDrops = new ushort[(int)data.readByte("Interactability_Drops")]; byte b = 0; while ((int)b < this.interactabilityDrops.Length) { this.interactabilityDrops[(int)b] = data.readUInt16("Interactability_Drop_" + b); b += 1; } this.interactabilityRewardID = data.readUInt16("Interactability_Reward_ID"); this.interactabilityEffect = data.readUInt16("Interactability_Effect"); this.interactabilityConditions = new INPCCondition[(int)data.readByte("Interactability_Conditions")]; NPCTool.readConditions(data, localization, "Interactability_Condition_", this.interactabilityConditions); this.interactabilityRewards = new INPCReward[(int)data.readByte("Interactability_Rewards")]; NPCTool.readRewards(data, localization, "Interactability_Reward_", this.interactabilityRewards); this.interactabilityResource = data.readUInt16("Interactability_Resource"); this.interactabilityResourceState = BitConverter.GetBytes(this.interactabilityResource); } else { this.interactability = EObjectInteractability.NONE; this.interactabilityPower = EObjectInteractabilityPower.NONE; this.interactabilityEditor = EObjectInteractabilityEditor.NONE; } if (this.interactability == EObjectInteractability.RUBBLE) { this.rubble = EObjectRubble.DESTROY; this.rubbleReset = data.readSingle("Interactability_Reset"); this.rubbleHealth = data.readUInt16("Interactability_Health"); this.rubbleEffect = data.readUInt16("Interactability_Effect"); this.rubbleFinale = data.readUInt16("Interactability_Finale"); this.rubbleRewardID = data.readUInt16("Interactability_Reward_ID"); this.rubbleRewardXP = data.readUInt32("Interactability_Reward_XP"); this.rubbleIsVulnerable = !data.has("Interactability_Invulnerable"); this.rubbleProofExplosion = data.has("Interactability_Proof_Explosion"); } else if (data.has("Rubble")) { this.rubble = (EObjectRubble)Enum.Parse(typeof(EObjectRubble), data.readString("Rubble"), true); this.rubbleReset = data.readSingle("Rubble_Reset"); this.rubbleHealth = data.readUInt16("Rubble_Health"); this.rubbleEffect = data.readUInt16("Rubble_Effect"); this.rubbleFinale = data.readUInt16("Rubble_Finale"); this.rubbleRewardID = data.readUInt16("Rubble_Reward_ID"); this.rubbleRewardXP = data.readUInt32("Rubble_Reward_XP"); this.rubbleIsVulnerable = !data.has("Rubble_Invulnerable"); this.rubbleProofExplosion = data.has("Rubble_Proof_Explosion"); if (data.has("Rubble_Editor")) { this.rubbleEditor = (EObjectRubbleEditor)Enum.Parse(typeof(EObjectRubbleEditor), data.readString("Rubble_Editor"), true); } else { this.rubbleEditor = EObjectRubbleEditor.ALIVE; } } if (data.has("Foliage")) { this.foliage = new AssetReference <FoliageInfoCollectionAsset>(new Guid(data.readString("Foliage"))); } this.useWaterHeightTransparentSort = data.has("Use_Water_Height_Transparent_Sort"); if (data.has("Material_Palette")) { this.materialPalette = new AssetReference <MaterialPaletteAsset>(data.readGUID("Material_Palette")); } if (data.has("Landmark_Quality")) { this.landmarkQuality = (EGraphicQuality)Enum.Parse(typeof(EGraphicQuality), data.readString("Landmark_Quality"), true); } else { this.landmarkQuality = EGraphicQuality.LOW; } } this.conditions = new INPCCondition[(int)data.readByte("Conditions")]; NPCTool.readConditions(data, localization, "Condition_", this.conditions); bundle.unload(); }
// Token: 0x06001CDC RID: 7388 RVA: 0x0009C460 File Offset: 0x0009A860 public VehicleAsset(Bundle bundle, Data data, Local localization, ushort id) : base(bundle, data, localization, id) { if (id < 200 && !bundle.hasResource && !data.has("Bypass_ID_Limit")) { throw new NotSupportedException("ID < 200"); } this._vehicleName = localization.format("Name"); this._vehicle = (GameObject)bundle.load("Vehicle"); if (this.vehicle == null) { throw new NotSupportedException("Missing vehicle gameobject"); } this._clip = (GameObject)bundle.load("Clip"); this._size2_z = data.readSingle("Size2_Z"); this._sharedSkinName = data.readString("Shared_Skin_Name"); if (data.has("Shared_Skin_Lookup_ID")) { this._sharedSkinLookupID = data.readUInt16("Shared_Skin_Lookup_ID"); } else { this._sharedSkinLookupID = id; } if (data.has("Engine")) { this._engine = (EEngine)Enum.Parse(typeof(EEngine), data.readString("Engine"), true); if (this.engine == EEngine.BOAT || this.engine == EEngine.BLIMP) { if (this.vehicle.transform.FindChild("Buoyancy") == null) { this._engine = EEngine.CAR; } } else if (this.engine != EEngine.CAR && this.engine != EEngine.TRAIN && this.vehicle.transform.FindChild("Rotors") == null) { this._engine = EEngine.CAR; } } else { this._engine = EEngine.CAR; } if (data.has("Rarity")) { this._rarity = (EItemRarity)Enum.Parse(typeof(EItemRarity), data.readString("Rarity"), true); } else { this._rarity = EItemRarity.COMMON; } this._hasHeadlights = (this.vehicle.transform.FindChild("Headlights") != null); this._hasSirens = (this.vehicle.transform.FindChild("Sirens") != null); this._hasHook = (this.vehicle.transform.FindChild("Hook") != null); this._hasZip = data.has("Zip"); this._hasBicycle = data.has("Bicycle"); this.isReclined = data.has("Reclined"); this._hasCrawler = data.has("Crawler"); this._hasLockMouse = data.has("LockMouse"); this._hasTraction = data.has("Traction"); this._hasSleds = data.has("Sleds"); this._ignition = (AudioClip)bundle.load("Ignition"); this._horn = (AudioClip)bundle.load("Horn"); if (this.clip == null) { Assets.errors.Add(this.vehicleName + " is missing collision data. Highly recommended to fix."); } if (this.vehicle != null && this.vehicle.transform.FindChild("Seats") == null) { Assets.errors.Add(this.vehicleName + " vehicle is missing seats."); } if (this.clip != null && this.clip.transform.FindChild("Seats") == null) { Assets.errors.Add(this.vehicleName + " clip is missing seats."); } if (data.has("Pitch_Idle")) { this._pitchIdle = data.readSingle("Pitch_Idle"); } else { this._pitchIdle = 0.5f; AudioSource component = this.vehicle.GetComponent <AudioSource>(); if (component != null) { AudioClip clip = component.clip; if (clip != null) { if (clip.name == "Engine_Large") { this._pitchIdle = 0.625f; } else if (clip.name == "Engine_Small") { this._pitchIdle = 0.75f; } } else { Assets.errors.Add(this.vehicleName + " missing engine audio!"); } } } if (data.has("Pitch_Drive")) { this._pitchDrive = data.readSingle("Pitch_Drive"); } else { this._pitchDrive = 0.05f; AudioSource component2 = this.vehicle.GetComponent <AudioSource>(); if (component2 != null) { AudioClip clip2 = component2.clip; if (clip2 != null) { if (clip2.name == "Engine_Large") { this._pitchDrive = 0.025f; } else if (clip2.name == "Engine_Small") { this._pitchDrive = 0.075f; } } else { Assets.errors.Add(this.vehicleName + " missing engine audio!"); } } } this._speedMin = data.readSingle("Speed_Min"); this._speedMax = data.readSingle("Speed_Max"); if (this.engine != EEngine.TRAIN) { this._speedMax *= 1.25f; } this._steerMin = data.readSingle("Steer_Min"); this._steerMax = data.readSingle("Steer_Max") * 0.75f; this._brake = data.readSingle("Brake"); this._lift = data.readSingle("Lift"); this._fuelMin = data.readUInt16("Fuel_Min"); this._fuelMax = data.readUInt16("Fuel_Max"); this._fuel = data.readUInt16("Fuel"); this._healthMin = data.readUInt16("Health_Min"); this._healthMax = data.readUInt16("Health_Max"); this._health = data.readUInt16("Health"); this._explosion = data.readUInt16("Explosion"); if (data.has("Explosion_Min_Force_Y")) { this.minExplosionForce = data.readVector3("Explosion_Min_Force"); } else { this.minExplosionForce = new Vector3(0f, 1024f, 0f); } if (data.has("Explosion_Max_Force_Y")) { this.maxExplosionForce = data.readVector3("Explosion_Max_Force"); } else { this.maxExplosionForce = new Vector3(0f, 1024f, 0f); } if (data.has("Exit")) { this._exit = data.readSingle("Exit"); } else { this._exit = 2f; } if (data.has("Cam_Follow_Distance")) { this._camFollowDistance = data.readSingle("Cam_Follow_Distance"); } else { this._camFollowDistance = 5.5f; } this._camDriverOffset = data.readSingle("Cam_Driver_Offset"); if (data.has("Bumper_Multiplier")) { this._bumperMultiplier = data.readSingle("Bumper_Multiplier"); } else { this._bumperMultiplier = 1f; } if (data.has("Passenger_Explosion_Armor")) { this._passengerExplosionArmor = data.readSingle("Passenger_Explosion_Armor"); } else { this._passengerExplosionArmor = 1f; } if (this.engine == EEngine.HELICOPTER || this.engine == EEngine.BLIMP) { this._sqrDelta = Mathf.Pow(this.speedMax * 0.125f, 2f); } else { this._sqrDelta = Mathf.Pow(this.speedMax * 0.1f, 2f); } this._turrets = new TurretInfo[(int)data.readByte("Turrets")]; byte b = 0; while ((int)b < this.turrets.Length) { TurretInfo turretInfo = new TurretInfo(); turretInfo.seatIndex = data.readByte("Turret_" + b + "_Seat_Index"); turretInfo.itemID = data.readUInt16("Turret_" + b + "_Item_ID"); turretInfo.yawMin = data.readSingle("Turret_" + b + "_Yaw_Min"); turretInfo.yawMax = data.readSingle("Turret_" + b + "_Yaw_Max"); turretInfo.pitchMin = data.readSingle("Turret_" + b + "_Pitch_Min"); turretInfo.pitchMax = data.readSingle("Turret_" + b + "_Pitch_Max"); turretInfo.useAimCamera = !data.has("Turret_" + b + "_Ignore_Aim_Camera"); turretInfo.aimOffset = data.readSingle("Turret_" + b + "_Aim_Offset"); this._turrets[(int)b] = turretInfo; b += 1; } this.isVulnerable = !data.has("Invulnerable"); this.isVulnerableToExplosions = !data.has("Explosions_Invulnerable"); this.isVulnerableToEnvironment = !data.has("Environment_Invulnerable"); this.isVulnerableToBumper = !data.has("Bumper_Invulnerable"); this.canTiresBeDamaged = !data.has("Tires_Invulnerable"); if (data.has("Air_Turn_Responsiveness")) { this.airTurnResponsiveness = data.readSingle("Air_Turn_Responsiveness"); } else { this.airTurnResponsiveness = 2f; } if (data.has("Air_Steer_Min")) { this.airSteerMin = data.readSingle("Air_Steer_Min"); } else { this.airSteerMin = this.steerMin; } if (data.has("Air_Steer_Max")) { this.airSteerMax = data.readSingle("Air_Steer_Max"); } else { this.airSteerMax = this.steerMax; } this.bicycleAnimSpeed = data.readSingle("Bicycle_Anim_Speed"); this.staminaBoost = data.readSingle("Stamina_Boost"); this.useStaminaBoost = data.has("Stamina_Boost"); this.isStaminaPowered = data.has("Stamina_Powered"); this.supportsMobileBuildables = data.has("Supports_Mobile_Buildables"); this.trunkStorage_X = data.readByte("Trunk_Storage_X"); this.trunkStorage_Y = data.readByte("Trunk_Storage_Y"); this.trainTrackOffset = data.readSingle("Train_Track_Offset"); this.trainWheelOffset = data.readSingle("Train_Wheel_Offset"); this.trainCarLength = data.readSingle("Train_Car_Length"); this._shouldVerifyHash = !data.has("Bypass_Hash_Verification"); if (!Dedicator.isDedicated) { this._albedoBase = (Texture2D)bundle.load("Albedo_Base"); this._metallicBase = (Texture2D)bundle.load("Metallic_Base"); this._emissionBase = (Texture2D)bundle.load("Emission_Base"); } bundle.unload(); }