/// <summary> /// Sets a variant for a new location. /// </summary> /// <param name="regionIndex">Region index</param> /// <param name="locationName">Location name (as index is assigned at runtime)</param> /// <param name="variant">Variant name</param> /// <returns>True if overwriting an existing variant set for this location</returns> public static bool SetNewLocationVariant(int regionIndex, string locationName, string variant) { int locationIndex = WorldDataReplacement.GetNewDFLocationIndex(regionIndex, locationName); if (locationIndex >= 0) { int locationKey = WorldDataReplacement.MakeLocationKey(regionIndex, locationIndex); bool overwrite = !locationVariants.ContainsKey(locationKey); if (variant == NoVariant) { locationVariants.Remove(locationKey); } else { locationVariants[locationKey] = variant; } if (!newLocationVariants.Contains(locationKey)) { newLocationVariants.Add(locationKey); } Debug.LogFormat("Set variant \"{0}\" for the new location \"{1}\" in region {2}", variant, locationName, regionIndex); RMBLayout.ClearLocationCache(); return(overwrite); } DaggerfallUnity.LogMessage("Failed to set a new location variant.", true); return(false); }
/// <summary> /// Sets a variant for a location. /// </summary> /// <param name="regionIndex">Region index</param> /// <param name="locationIndex">Location index</param> /// <param name="variant">Variant name</param> /// <returns>True if overwriting an existing variant set for this location</returns> public static bool SetLocationVariant(int regionIndex, int locationIndex, string variant) { int locationKey = WorldDataReplacement.MakeLocationKey(regionIndex, locationIndex); bool overwrite = !locationVariants.ContainsKey(locationKey); if (variant == NoVariant) { locationVariants.Remove(locationKey); } else { locationVariants[locationKey] = variant; } Debug.LogFormat("Set variant \"{0}\" for the location index \"{1}\" in region {2}", variant, locationIndex, regionIndex); RMBLayout.ClearLocationCache(); return(overwrite); }
/// <summary> /// Sets a variant for a building. (block record) /// </summary> /// <param name="blockName">Block name</param> /// <param name="variant">Variant name</param> /// <param name="locationKey">Location key if the variant is only for a specific location</param> /// <returns>True if overwriting an existing variant set for this location</returns> public static bool SetBuildingVariant(string blockName, int recordIndex, string variant, int locationKey = AnyLocationKey) { VariantBuildingKey buildingKey = new VariantBuildingKey(locationKey, blockName, recordIndex); bool overwrite = !buildingVariants.ContainsKey(buildingKey); if (variant == NoVariant) { buildingVariants.Remove(buildingKey); } else { buildingVariants[buildingKey] = variant; } Debug.LogFormat("Set variant \"{0}\" for building {2} of {1} at locationKey {3}", variant, blockName, recordIndex, locationKey); RMBLayout.ClearLocationCache(); return(overwrite); }
/// <summary> /// Sets a variant for a block. /// </summary> /// <param name="blockName">Block name</param> /// <param name="variant">Variant name</param> /// <param name="locationKey">Location key if the variant is only for a specific location</param> /// <returns>True if overwriting an existing variant set for this location</returns> public static bool SetBlockVariant(string blockName, string variant, int locationKey = AnyLocationKey) { VariantBlockKey blockKey = new VariantBlockKey(locationKey, blockName); bool overwrite = !blockVariants.ContainsKey(blockKey); if (variant == NoVariant) { blockVariants.Remove(blockKey); } else { blockVariants[blockKey] = variant; } Debug.LogFormat("Set variant \"{0}\" for the block {1} at locationKey {2}", variant, blockName, locationKey); RMBLayout.ClearLocationCache(); return(overwrite); }