diff --git a/Code/Loading/AssetLoader.cs b/Code/Loading/AssetLoader.cs index 253f536..185a026 100644 --- a/Code/Loading/AssetLoader.cs +++ b/Code/Loading/AssetLoader.cs @@ -297,6 +297,22 @@ public IEnumerator LoadCustomContent() } } + if (LevelLoader.DLC(2144480u)) + { + Package.Asset asset4 = PackageManager.FindAssetByName("System." + DistrictStyle.kModderPack14StyleName); + if (asset4 != null && asset4.isEnabled) + { + DistrictStyle districtStyle = new DistrictStyle(DistrictStyle.kModderPack14StyleName, builtIn: true); + Util.InvokeVoid(Singleton.instance, "AddChildrenToBuiltinStyle", GameObject.Find("Modder Pack 14"), districtStyle, false); + if (LSMRSettings.SkipPrefabs) + { + PrefabLoader.RemoveSkippedFromStyle(districtStyle); + } + + districtStyles.Add(districtStyle); + } + } + // LSM insert. // Unload any skipped assets. if (LSMRSettings.SkipPrefabs) @@ -884,7 +900,8 @@ private Package.Asset[] GetLoadQueue(HashSet styleBuildings) List assetRefList = new List(8); HashSet assetNames = new HashSet(); string previousPackageName = string.Empty; - SteamHelper.DLC_BitMask dLC_BitMask = ~SteamHelper.GetOwnedDLCMask(); + SteamHelper.ExpansionBitMask ownedExpansionMask = ~SteamHelper.GetOwnedExpansionMask(); + SteamHelper.ModderPackBitMask ownedModderPackMask = ~SteamHelper.GetOwnedModderPackMask(); // 'Load enabled' and 'load used' settings. bool loadEnabled = LSMRSettings.LoadEnabled & !LSMRSettings.EnableDisable; @@ -919,7 +936,8 @@ private Package.Asset[] GetLoadQueue(HashSet styleBuildings) bool isUsed = loadUsed && UsedAssets.Instance.IsUsed(finalAsset, type); // Disable asset if relevant DLC isn't active. - enabled &= (AssetImporterAssetTemplate.GetAssetDLCMask(assetRefs) & dLC_BitMask) == 0; + AssetImporterAssetTemplate.GetAssetDLCMask(assetRefs, out SteamHelper.ExpansionBitMask expansionMask, out SteamHelper.ModderPackBitMask modderPackMask); + enabled &= (expansionMask & ownedExpansionMask) == 0 & (modderPackMask & ownedModderPackMask) == 0; // If we're loading used assets, and the main asset isn't used, but there are other assets in the package - check if any of the other assets are used. if (assetCount > 1 & !isUsed & loadUsed) @@ -1523,7 +1541,7 @@ private void EnableDisableAssets() } // Iterate through all packages. - foreach (object item in LoadingScreenModRevisited.CustomDeserializer.Instance.AllPackages) + foreach (object item in CustomDeserializer.Instance.AllPackages) { // Single-package items. if (item is Package singlePackage) diff --git a/Code/Loading/CustomDeserializer.cs b/Code/Loading/CustomDeserializer.cs index f36ada0..b35183c 100644 --- a/Code/Loading/CustomDeserializer.cs +++ b/Code/Loading/CustomDeserializer.cs @@ -47,7 +47,9 @@ public sealed class CustomDeserializer private const int TypeVehicleInfoDoor = 70; private const int TypeBuildingInfo = 74; private const int TypeBuildingInfoSub = 77; + private const int TypeBuildingSpawnPoint = 80; private const int TypeDepotSpawnPoint = 81; + private const int TypePropInfo = 85; private const int TypePropInfoEffect = 86; private const int TypePropInfoVariation = 89; private const int TypeVehicleInfoMesh = 95; @@ -96,7 +98,9 @@ internal CustomDeserializer() { [typeof(ModInfo)] = TypeModInfo, [typeof(TerrainModify.Surface)] = TypeInt32, +#pragma warning disable CS0618 // Type or member is obsolete [typeof(SteamHelper.DLC_BitMask)] = TypeInt32, +#pragma warning restore CS0618 // Type or member is obsolete [typeof(ItemClass.Availability)] = TypeInt32, [typeof(ItemClass.Placement)] = TypeInt32, [typeof(ItemClass.Service)] = TypeInt32, @@ -135,7 +139,9 @@ internal CustomDeserializer() [typeof(VehicleInfo.VehicleDoor)] = TypeVehicleInfoDoor, [typeof(BuildingInfo)] = TypeBuildingInfo, [typeof(BuildingInfo.SubInfo)] = TypeBuildingInfoSub, + [typeof(BuildingAI.SpawnPoint)] = TypeBuildingSpawnPoint, [typeof(DepotAI.SpawnPoint)] = TypeDepotSpawnPoint, + [typeof(PropInfo)] = TypePropInfo, [typeof(PropInfo.Effect)] = TypePropInfoEffect, [typeof(PropInfo.Variation)] = TypePropInfoVariation, [typeof(VehicleInfo.MeshInfo)] = TypeVehicleInfoMesh, @@ -541,9 +547,15 @@ internal object CustomDeserialize(Package package, Type type, PackageReader read case TypeBuildingInfoSub: return ReadBuildingInfoSubInfo(package, reader); + case TypeBuildingSpawnPoint: + return ReadBuildingAISpawnPoint(reader); + case TypeDepotSpawnPoint: return ReadDepotAISpawnPoint(reader); + case TypePropInfo: + return ReadPropInfo(package, reader); + case TypePropInfoEffect: return ReadPropInfoEffect(reader); @@ -683,7 +695,7 @@ private Package.Asset ReadPackageAsset(Package package, PackageReader reader) /// New NetInfo.Lane. private NetInfo.Lane ReadNetInfoLane(Package package, PackageReader reader) { - return new NetInfo.Lane + NetInfo.Lane lane = new NetInfo.Lane { m_position = reader.ReadSingle(), m_width = reader.ReadSingle(), @@ -700,6 +712,20 @@ private NetInfo.Lane ReadNetInfoLane(Package package, PackageReader reader) m_centerPlatform = reader.ReadBoolean(), m_elevated = reader.ReadBoolean(), }; + + // 1.15.1 addition. + if (package.version >= 9) + { + lane.m_vehicleCategoryPart1 = (VehicleInfo.VehicleCategoryPart1)reader.ReadInt32(); + lane.m_vehicleCategoryPart2 = (VehicleInfo.VehicleCategoryPart2)reader.ReadInt32(); + } + else + { + lane.m_vehicleCategoryPart1 = VehicleInfo.VehicleCategoryPart1.All; + lane.m_vehicleCategoryPart2 = VehicleInfo.VehicleCategoryPart2.All; + } + + return lane; } /// @@ -899,6 +925,32 @@ private NetInfo.Node ReadNetInfoNode(Package package, PackageReader reader) node.m_directConnect = reader.ReadBoolean(); node.m_emptyTransparent = reader.ReadBoolean(); + // 1.15.1 addition. + if (package.version >= 9) + { + node.m_flagsRequired2 = (NetNode.Flags2)reader.ReadInt32(); + node.m_flagsForbidden2 = (NetNode.Flags2)reader.ReadInt32(); + node.m_tagsRequired = reader.ReadStringArray(); + node.m_tagsForbidden = reader.ReadStringArray(); + node.m_forbidAnyTags = reader.ReadBoolean(); + node.m_minSameTags = reader.ReadByte(); + node.m_maxSameTags = reader.ReadByte(); + node.m_minOtherTags = reader.ReadByte(); + node.m_maxOtherTags = reader.ReadByte(); + } + else + { + node.m_flagsRequired2 = NetNode.Flags2.None; + node.m_flagsForbidden2 = NetNode.Flags2.None; + node.m_tagsRequired = new string[0]; + node.m_tagsForbidden = new string[0]; + node.m_forbidAnyTags = false; + node.m_minSameTags = 0; + node.m_maxSameTags = 7; + node.m_minOtherTags = 0; + node.m_maxOtherTags = 7; + } + return node; } @@ -1106,6 +1158,22 @@ private BuildingInfo.SubInfo ReadBuildingInfoSubInfo(Package package, PackageRea }; } + /// + /// Deserializes a BuildingAI.SpawnPoint. + /// + /// PackageReader instance. + /// New BuildingAI.SpawnPoint. + private BuildingAI.SpawnPoint ReadBuildingAISpawnPoint(PackageReader reader) + { + return new BuildingAI.SpawnPoint + { + m_position = reader.ReadVector3(), + m_target = reader.ReadVector3(), + m_vehicleCategoryPart1 = (VehicleInfo.VehicleCategoryPart1)reader.ReadInt32(), + m_vehicleCategoryPart2 = (VehicleInfo.VehicleCategoryPart2)reader.ReadInt32(), + }; + } + /// /// Deserializes a DepotAI.SpawnPoint. /// @@ -1120,6 +1188,23 @@ private DepotAI.SpawnPoint ReadDepotAISpawnPoint(PackageReader reader) }; } + /// + /// Deserializes a PropInfo. + /// + /// Package to deserialize. + /// PackageReader instance. + /// New PropInfo. + private PropInfo ReadPropInfo(Package package, PackageReader reader) + { + // 1.15.1 addition. + if (package.version >= 9) + { + return PrefabCollection.FindLoaded(reader.ReadString()); + } + + return null; + } + /// /// Deserializes a PropInfo.Effect. /// @@ -1179,10 +1264,7 @@ private VehicleInfo.MeshInfo ReadVehicleInfoMeshInfo(Package package, PackageRea GameObject gameObject = AssetDeserializer.Instantiate(package.FindByChecksum(checksum), isMain: true, isTop: false) as GameObject; meshInfo.m_subInfo = gameObject.GetComponent(); gameObject.SetActive(value: false); - if (meshInfo.m_subInfo.m_lodObject != null) - { - meshInfo.m_subInfo.m_lodObject.SetActive(value: false); - } + meshInfo.m_subInfo.m_lodObject?.SetActive(value: false); } else { @@ -1213,10 +1295,7 @@ private BuildingInfo.MeshInfo ReadBuildingInfoMeshInfo(Package package, PackageR GameObject gameObject = AssetDeserializer.Instantiate(package.FindByChecksum(checksum), isMain: true, isTop: false) as GameObject; meshInfo.m_subInfo = gameObject.GetComponent(); gameObject.SetActive(value: false); - if (meshInfo.m_subInfo.m_lodObject != null) - { - meshInfo.m_subInfo.m_lodObject.SetActive(value: false); - } + meshInfo.m_subInfo.m_lodObject?.SetActive(value: false); } else { @@ -1226,6 +1305,17 @@ private BuildingInfo.MeshInfo ReadBuildingInfoMeshInfo(Package package, PackageR // Flags etc. meshInfo.m_flagsForbidden = (Building.Flags)reader.ReadInt32(); meshInfo.m_flagsRequired = (Building.Flags)reader.ReadInt32(); + + // 1.15.1 addition. + if (package.version >= 9) + { + meshInfo.m_flagsRequired2 = (Building.Flags2)reader.ReadInt32(); + } + else + { + meshInfo.m_flagsRequired2 = Building.Flags2.None; + } + meshInfo.m_position = reader.ReadVector3(); meshInfo.m_angle = reader.ReadSingle(); @@ -1398,6 +1488,22 @@ private NetLaneProps.Prop ReadNetLaneProp(Package package, PackageReader reader) prop.m_upgradable = prop.m_tree != null && prop.m_repeatDistance > 0f; } + // 1.15.1 additions. + if (package.version >= 9) + { + prop.m_startFlagsRequired2 = (NetNode.Flags2)reader.ReadInt32(); + prop.m_startFlagsForbidden2 = (NetNode.Flags2)reader.ReadInt32(); + prop.m_endFlagsRequired2 = (NetNode.Flags2)reader.ReadInt32(); + prop.m_endFlagsForbidden2 = (NetNode.Flags2)reader.ReadInt32(); + } + else + { + prop.m_startFlagsRequired2 = NetNode.Flags2.None; + prop.m_startFlagsForbidden2 = NetNode.Flags2.None; + prop.m_endFlagsRequired2 = NetNode.Flags2.None; + prop.m_endFlagsForbidden2 = NetNode.Flags2.None; + } + return prop; } diff --git a/Code/Loading/LevelLoader.cs b/Code/Loading/LevelLoader.cs index 1be1265..6b41721 100644 --- a/Code/Loading/LevelLoader.cs +++ b/Code/Loading/LevelLoader.cs @@ -1078,15 +1078,27 @@ private static List> SetLevels() { prefabScenes.Add(new KeyValuePair("Station13Prefabs", 0.01f)); } + if (DLC(1992292u)) { prefabScenes.Add(new KeyValuePair("Station14Prefabs", 0.01f)); } + if (DLC(1992293u)) { prefabScenes.Add(new KeyValuePair("Station15Prefabs", 0.01f)); } + if (DLC(2144483u)) + { + prefabScenes.Add(new KeyValuePair("Station16Prefabs", 0.01f)); + } + + if (DLC(2144482u)) + { + prefabScenes.Add(new KeyValuePair("Station17Prefabs", 0.01f)); + } + if (DLC(1992290u)) { Package.Asset asset4 = PackageManager.FindAssetByName("System." + DistrictStyle.kModderPack11StyleName); @@ -1169,6 +1181,16 @@ private static List> SetLevels() prefabScenes.Add(new KeyValuePair("ModderPack10Prefabs", 0.03f)); } + if (DLC(2144481u)) + { + prefabScenes.Add(new KeyValuePair("ModderPack13Prefabs", 0.03f)); + } + + if (DLC(2144480u)) + { + prefabScenes.Add(new KeyValuePair("ModderPack14Prefabs", 0.03f)); + } + Package.Asset europeanStyles = PackageManager.FindAssetByName("System." + DistrictStyle.kEuropeanStyleName); if (europeanStyles != null && europeanStyles.isEnabled) { @@ -1182,8 +1204,9 @@ private static List> SetLevels() } } - loadingManager.m_ownedMask1 = SteamHelper.GetOwnedDLCMask(); - loadingManager.m_ownedMask2 = SteamHelper.GetOwnedDLCMask2(); + loadingManager.m_ownedExpansionMask = SteamHelper.GetOwnedExpansionMask(); + loadingManager.m_ownedModderPackMask = SteamHelper.GetOwnedModderPackMask(); + loadingManager.m_ownedRadioMask = SteamHelper.GetOwnedRadioMask(); return prefabScenes; }