/// <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); }
public static string GetBuildingVariant(int regionIndex, int locationIndex, string blockName, int recordIndex) { int locationKey = WorldDataReplacement.MakeLocationKey(regionIndex, locationIndex); VariantBuildingKey buildingKey = new VariantBuildingKey(locationKey, blockName, recordIndex); return(buildingVariants.ContainsKey(buildingKey) ? buildingVariants[buildingKey] : null); }
/// <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); return(overwrite); }
/// <summary> /// Sets the last location key to specified location in region. Used before entering buildings to /// ensure that the correct location specific variant can be found. /// </summary> public static void SetLastLocationKeyTo(int regionIndex, int locationIndex) { lastLocationKey = WorldDataReplacement.MakeLocationKey(regionIndex, locationIndex); }