Renamed ForcedTiles to AdditionalTiles
Added backwards support (kinda, it needs to be looked at again since it probs don't work) Added two behaviours for MainRoomDoorwayGroup. The original behaviour (RemoveGroup) and the new (SetInOrder) Alternate main path's initial depth is set to the MainRoomTile's depth + 1 instead of always 1 DevDebugWindow now uses the retry counter outside of Application.IsEditor
This commit is contained in:
parent
32cebc67d6
commit
d955f6e930
|
@ -29,6 +29,10 @@ namespace DunGenPlus.Collections {
|
|||
|
||||
public NormalNodeArchetypesProperties NormalNodeArchetypesProperties = new NormalNodeArchetypesProperties();
|
||||
|
||||
public AdditionalTilesProperties AdditionalTilesProperties = new AdditionalTilesProperties();
|
||||
|
||||
[HideInInspector]
|
||||
[Obsolete("Variable field renamed to AdditionalTilesProperties. This field will be removed in future updates.")]
|
||||
public ForcedTilesProperties ForcedTilesProperties = new ForcedTilesProperties();
|
||||
|
||||
public BranchPathMultiSimulationProperties BranchPathMultiSimulationProperties = new BranchPathMultiSimulationProperties();
|
||||
|
@ -42,19 +46,26 @@ namespace DunGenPlus.Collections {
|
|||
public List<TileSet> AssetCacheTileSetList = new List<TileSet>();
|
||||
public List<DungeonArchetype> AssetCacheArchetypeList = new List<DungeonArchetype>();
|
||||
|
||||
internal void CopyFrom(DunGenExtenderProperties props) {
|
||||
internal void CopyFrom(DunGenExtenderProperties props, string version) {
|
||||
MainPathProperties = props.MainPathProperties.Copy();
|
||||
DungeonBoundsProperties = props.DungeonBoundsProperties.Copy();
|
||||
NormalNodeArchetypesProperties = props.NormalNodeArchetypesProperties.Copy();
|
||||
|
||||
// for backwards support
|
||||
ForcedTilesProperties = props.ForcedTilesProperties.Copy();
|
||||
AdditionalTilesProperties = props.AdditionalTilesProperties.Copy();
|
||||
if (version == "0") {
|
||||
AdditionalTilesProperties.CopyFrom(ForcedTilesProperties);
|
||||
}
|
||||
|
||||
BranchPathMultiSimulationProperties = props.BranchPathMultiSimulationProperties.Copy();
|
||||
LineRandomizerProperties = props.LineRandomizerProperties.Copy();
|
||||
MiscellaneousProperties = props.MiscellaneousProperties.Copy();
|
||||
}
|
||||
|
||||
internal DunGenExtenderProperties Copy() {
|
||||
internal DunGenExtenderProperties Copy(string version) {
|
||||
var copy = new DunGenExtenderProperties();
|
||||
copy.CopyFrom(this);
|
||||
copy.CopyFrom(this, version);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,34 @@ namespace DunGenPlus.Collections {
|
|||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AdditionalTilesProperties {
|
||||
|
||||
internal const string UseAdditionalTilesTooltip = "If enabled, attempts to forcefully spawn tiles from ForcedTileSets after branching paths are generated.";
|
||||
internal const string AdditionalTileSetsTooltip = "The list of tiles that will be attempted to forcefully spawn. Each entry will spawn only one tile from it's list.\n\nIf the tile cannot be forcefully spawned, the dungeon generation will not restart.";
|
||||
|
||||
[Tooltip(UseAdditionalTilesTooltip)]
|
||||
public bool UseAdditionalTiles = false;
|
||||
[Tooltip(AdditionalTileSetsTooltip)]
|
||||
public List<AdditionalTileSetList> AdditionalTileSets = new List<AdditionalTileSetList>();
|
||||
|
||||
internal void CopyFrom(AdditionalTilesProperties props) {
|
||||
UseAdditionalTiles = props.UseAdditionalTiles;
|
||||
AdditionalTileSets = props.AdditionalTileSets;
|
||||
}
|
||||
|
||||
internal void CopyFrom(ForcedTilesProperties props) {
|
||||
UseAdditionalTiles = props.UseForcedTiles;
|
||||
AdditionalTileSets = props.ForcedTileSets.Select(t => (AdditionalTileSetList)t).ToList();
|
||||
}
|
||||
|
||||
internal AdditionalTilesProperties Copy() {
|
||||
var copy = new AdditionalTilesProperties();
|
||||
copy.CopyFrom(this);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class BranchPathMultiSimulationProperties {
|
||||
|
||||
|
|
|
@ -25,4 +25,33 @@ namespace DunGenPlus.Collections {
|
|||
public float BranchPathWeight = 1f;
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AdditionalTileSetList {
|
||||
|
||||
internal const string TileSetsTooltip = "List of tiles to be forcefully spawned.";
|
||||
internal const string DepthWeightScaleTooltip = "The weight based on the path's depth.";
|
||||
internal const string MainPathWeightTooltip = "The weight for the tile spawning on the main path.";
|
||||
internal const string BranchPathWeightTooltip = "The weight for the tile spawning on the branch path.";
|
||||
|
||||
[Tooltip(TileSetsTooltip)]
|
||||
public List<TileSet> TileSets = new List<TileSet>();
|
||||
[Tooltip(DepthWeightScaleTooltip)]
|
||||
public AnimationCurve DepthWeightScale = new AnimationCurve();
|
||||
[Tooltip(MainPathWeightTooltip)]
|
||||
public float MainPathWeight = 1f;
|
||||
[Tooltip(BranchPathWeightTooltip)]
|
||||
public float BranchPathWeight = 1f;
|
||||
|
||||
public static implicit operator AdditionalTileSetList(ForcedTileSetList item) {
|
||||
var copy = new AdditionalTileSetList();
|
||||
copy.TileSets = item.TileSets;
|
||||
copy.DepthWeightScale = item.DepthWeightScale;
|
||||
copy.MainPathWeight = item.MainPathWeight;
|
||||
copy.BranchPathWeight = item.BranchPathWeight;
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using DunGen;
|
||||
using DunGenPlus.Generation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -21,10 +22,21 @@ namespace DunGenPlus.Components {
|
|||
}
|
||||
}
|
||||
|
||||
[Tooltip("When an additional main path is being generated, it will get the doorway used for the previous main path, find it's corresponding group below, and prevents the dungeon generation from using that group's doorways until the main paths are all generated.\n\nIf you want this feature, this must be attached to the tile that will act as the MainRoomTilePrefab.\n\nThis is designed for the scenario where you would like the main paths to be generated more evenly throughout the MainRoomTilePrefab.")]
|
||||
public enum DoorwayGroupBehaviour { RemoveGroup, SetInOrder };
|
||||
|
||||
[Tooltip("How the algorithm should treat these doorway groups during the main path(s) generation step.\n\nWith RemoveGroup, when a main path is being generated, it will get the doorway in this tile used to start the main path, find it's corresponding group below, and prevent the dungeon generation from using that group's doorways until all main paths are generated.\nThis is designed for the scenario where you would like the main paths to be generated more evenly throughout the MainRoomTilePrefab.\n\nWith SetInOrder, before a doorway is selected in this tile to start the main path, it will grab the first group below and only allow those doorways to start the main path. It will then select the next group for the next main path and repeat. If it cannot grab a next group, then the last group will be selected instead.\n\nIf you want this feature, this must be attached to the tile that will act as the MainRoomTilePrefab")]
|
||||
public DoorwayGroupBehaviour doorwayGroupBehaviour;
|
||||
|
||||
public List<DoorwayList> doorwayLists;
|
||||
public List<Doorway> doorwayListFirst => doorwayLists.Count > 0 ? doorwayLists[0].doorways : null;
|
||||
|
||||
public List<Doorway> GrabDoorwayGroup(int index){
|
||||
var count = doorwayLists.Count;
|
||||
if (count == 0) return null;
|
||||
if (index < count) return doorwayLists[index].doorways;
|
||||
return doorwayLists[count - 1].doorways;
|
||||
}
|
||||
|
||||
public List<Doorway> GrabDoorwayGroup(Doorway target){
|
||||
foreach(var a in doorwayLists){
|
||||
if (a.Contains(target)) return a.doorways;
|
||||
|
@ -32,5 +44,77 @@ namespace DunGenPlus.Components {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void OnlyUnlockGroup(TileProxy tileProxy, DoorwayProxy fakeDoorwayProxy, List<Doorway> selectedDoorways){
|
||||
if (selectedDoorways == null) return;
|
||||
|
||||
foreach(var doorway in tileProxy.Doorways) {
|
||||
// it's part of the group, unlock if possible
|
||||
if (selectedDoorways.Contains(doorway.DoorwayComponent)){
|
||||
if (doorway.Used && doorway.ConnectedDoorway.Index == int.MaxValue) {
|
||||
doorway.ConnectedDoorway = null;
|
||||
}
|
||||
}
|
||||
// it's not part of the group, lock unless already locked
|
||||
else {
|
||||
if (!doorway.Used) {
|
||||
doorway.ConnectedDoorway = fakeDoorwayProxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnlyLockGroup(TileProxy tileProxy, DoorwayProxy fakeDoorwayProxy){
|
||||
foreach(var d in tileProxy.UsedDoorways) {
|
||||
if (d.ConnectedDoorway.Index != int.MaxValue) {
|
||||
var groups = GrabDoorwayGroup(d.DoorwayComponent);
|
||||
if (groups == null) continue;
|
||||
|
||||
foreach(var doorway in tileProxy.UnusedDoorways){
|
||||
if (groups.Contains(doorway.DoorwayComponent)){
|
||||
doorway.ConnectedDoorway = fakeDoorwayProxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ModifyGroupBasedOnBehaviour(TileProxy tileProxy, int groupIndex){
|
||||
var doorwayGroups = tileProxy.Prefab.GetComponentInChildren<MainRoomDoorwayGroups>();
|
||||
if (doorwayGroups == null) return;
|
||||
|
||||
// index of MaxValue is how we tell which doorway proxy is fake
|
||||
var fakeDoorwayProxy = new DoorwayProxy(tileProxy, int.MaxValue, tileProxy.doorways[0].DoorwayComponent, Vector3.zero, Quaternion.identity);
|
||||
if (doorwayGroups.doorwayGroupBehaviour == DoorwayGroupBehaviour.SetInOrder) {
|
||||
doorwayGroups.OnlyUnlockGroup(tileProxy, fakeDoorwayProxy, doorwayGroups.GrabDoorwayGroup(groupIndex));
|
||||
} else {
|
||||
doorwayGroups.OnlyLockGroup(tileProxy, fakeDoorwayProxy);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ModifyGroupBasedOnBehaviourSimpleOnce = false;
|
||||
public static void ModifyGroupBasedOnBehaviourSimple(TileProxy tileProxy) {
|
||||
if (!DunGenPlusGenerator.Active || ModifyGroupBasedOnBehaviourSimpleOnce || tileProxy == null) return;
|
||||
|
||||
var properties = DunGenPlusGenerator.Properties;
|
||||
var altCount = properties.MainPathProperties.MainPathCount - 1;
|
||||
var mainRoomTilePrefab = properties.MainPathProperties.MainRoomTilePrefab;
|
||||
|
||||
// sanity check to prevent not properly configured dungeons from exploding
|
||||
if (altCount <= 0 || mainRoomTilePrefab == null) return;
|
||||
|
||||
if (tileProxy.Prefab == mainRoomTilePrefab) {
|
||||
ModifyGroupBasedOnBehaviour(tileProxy, 0);
|
||||
ModifyGroupBasedOnBehaviourSimpleOnce = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveFakeDoorwayProxies(TileProxy tileProxy){
|
||||
foreach(var doorway in tileProxy.UsedDoorways){
|
||||
if (doorway.ConnectedDoorway.Index == int.MaxValue) {
|
||||
doorway.ConnectedDoorway = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace DunGenPlus.DevTools {
|
|||
internal partial class DevDebugManager : MonoBehaviour {
|
||||
public static DevDebugManager Instance { get; private set; }
|
||||
|
||||
public static bool IsActive => Instance != null;
|
||||
|
||||
[Header("References")]
|
||||
public RuntimeDungeon dungeon;
|
||||
public GameObject devCamera;
|
||||
|
|
|
@ -38,7 +38,8 @@ namespace DunGenPlus.DevTools.Panels.Collections {
|
|||
|
||||
public DungeonFlowCacheAssets(DungeonFlow dungeonFlow, DunGenExtender extender){
|
||||
if (extender){
|
||||
originalProperties = extender.Properties.Copy();
|
||||
extender.Properties = extender.Properties.Copy(extender.Version);
|
||||
originalProperties = extender.Properties.Copy(extender.Version);
|
||||
}
|
||||
|
||||
var tileSetsHashSet = new HashSet<NullObject<TileSet>>() { new NullObject<TileSet>(null) };
|
||||
|
@ -77,7 +78,7 @@ namespace DunGenPlus.DevTools.Panels.Collections {
|
|||
|
||||
if (extender) {
|
||||
AddArchetypes(extender.Properties.NormalNodeArchetypesProperties.NormalNodeArchetypes.SelectMany(l => l.Archetypes));
|
||||
AddTileSets(extender.Properties.ForcedTilesProperties.ForcedTileSets.SelectMany(l => l.TileSets));
|
||||
AddTileSets(extender.Properties.AdditionalTilesProperties.AdditionalTileSets.SelectMany(l => l.TileSets));
|
||||
|
||||
AddTiles(extender.Properties.AssetCacheTileList);
|
||||
AddTileSets(extender.Properties.AssetCacheTileSetList);
|
||||
|
|
|
@ -113,10 +113,10 @@ namespace DunGenPlus.DevTools.Panels {
|
|||
|
||||
var forcedTilesTransform = manager.CreateVerticalLayoutUIField(parentTransform);
|
||||
forcedTilesParentGameobject = forcedTilesTransform.gameObject;
|
||||
manager.CreateHeaderUIField(parentTransform, "Forced Tiles");
|
||||
manager.CreateBoolInputField(parentTransform, ("Use Forced Tiles", ForcedTilesProperties.UseForcedTilesTooltip), properties.ForcedTilesProperties.UseForcedTiles, SetUseForcedTiles);
|
||||
manager.CreateHeaderUIField(parentTransform, "Additional Tiles");
|
||||
manager.CreateBoolInputField(parentTransform, ("Use Additional Tiles", AdditionalTilesProperties.UseAdditionalTilesTooltip), properties.AdditionalTilesProperties.UseAdditionalTiles, SetUseForcedTiles);
|
||||
forcedTilesTransform.SetAsLastSibling();
|
||||
manager.CreateListUIField(forcedTilesTransform, ("Forced Tile Sets", ForcedTilesProperties.ForcedTileSetsTooltip), properties.ForcedTilesProperties.ForcedTileSets);
|
||||
manager.CreateListUIField(forcedTilesTransform, ("Additional Tile Sets", AdditionalTilesProperties.AdditionalTileSetsTooltip), properties.AdditionalTilesProperties.AdditionalTileSets);
|
||||
manager.CreateSpaceUIField(parentTransform);
|
||||
|
||||
var branchLoopTransform = manager.CreateVerticalLayoutUIField(parentTransform);
|
||||
|
@ -156,7 +156,7 @@ namespace DunGenPlus.DevTools.Panels {
|
|||
dungeonBoundsParentGameobject.SetActive(properties.DungeonBoundsProperties.UseDungeonBounds);
|
||||
dungeonBoundsHelperGameObject.SetActive(properties.DungeonBoundsProperties.UseDungeonBounds);
|
||||
archetypesNodesParentGameobject.SetActive(properties.NormalNodeArchetypesProperties.AddArchetypesToNormalNodes);
|
||||
forcedTilesParentGameobject.SetActive(properties.ForcedTilesProperties.UseForcedTiles);
|
||||
forcedTilesParentGameobject.SetActive(properties.AdditionalTilesProperties.UseAdditionalTiles);
|
||||
branchLoopBoostParentGameobject.SetActive(properties.BranchPathMultiSimulationProperties.UseBranchPathMultiSim);
|
||||
maxShadowsParentGameobject.SetActive(properties.MiscellaneousProperties.UseMaxShadowsRequestUpdate);
|
||||
|
||||
|
@ -225,7 +225,7 @@ namespace DunGenPlus.DevTools.Panels {
|
|||
}
|
||||
|
||||
public void SetUseForcedTiles(bool state){
|
||||
selectedExtenderer.Properties.ForcedTilesProperties.UseForcedTiles = state;
|
||||
selectedExtenderer.Properties.AdditionalTilesProperties.UseAdditionalTiles = state;
|
||||
forcedTilesParentGameobject.SetActive(state);
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ namespace DunGenPlus.DevTools.Panels {
|
|||
}
|
||||
|
||||
public void RestoreOriginalState(){
|
||||
selectedExtenderer.Properties.CopyFrom(selectedAssetCache.originalProperties);
|
||||
selectedExtenderer.Properties.CopyFrom(selectedAssetCache.originalProperties, DunGenExtender.CURRENT_VERSION);
|
||||
ClearPanel();
|
||||
SetupPanel();
|
||||
}
|
||||
|
|
|
@ -46,21 +46,21 @@ namespace DunGenPlus.DevTools.UIElements.Collections {
|
|||
}
|
||||
}
|
||||
|
||||
internal class ListEntryForcedTileSetList : ListEntryType {
|
||||
internal class ListEntryAdditionalTileSetList : ListEntryType {
|
||||
public override object CreateEmptyObject() {
|
||||
var forcedTileset = new ForcedTileSetList();
|
||||
var forcedTileset = new AdditionalTileSetList();
|
||||
forcedTileset.DepthWeightScale = null;
|
||||
return forcedTileset;
|
||||
}
|
||||
|
||||
public override void CreateEntry(IList list, int index, Transform parentTransform, float layoutOffset) {
|
||||
var entry = (ForcedTileSetList)list[index];
|
||||
DevDebugManager.Instance.CreateFloatInputField(parentTransform, new TitleParameter("Main Path Weight", ForcedTileSetList.MainPathWeightTooltip, layoutOffset), entry.MainPathWeight, (t) => entry.MainPathWeight = t);
|
||||
DevDebugManager.Instance.CreateFloatInputField(parentTransform, new TitleParameter("Branch Path Weight", ForcedTileSetList.BranchPathWeightTooltip, layoutOffset), entry.BranchPathWeight, (t) => entry.BranchPathWeight = t);
|
||||
var entry = (AdditionalTileSetList)list[index];
|
||||
DevDebugManager.Instance.CreateFloatInputField(parentTransform, new TitleParameter("Main Path Weight", AdditionalTileSetList.MainPathWeightTooltip, layoutOffset), entry.MainPathWeight, (t) => entry.MainPathWeight = t);
|
||||
DevDebugManager.Instance.CreateFloatInputField(parentTransform, new TitleParameter("Branch Path Weight", AdditionalTileSetList.BranchPathWeightTooltip, layoutOffset), entry.BranchPathWeight, (t) => entry.BranchPathWeight = t);
|
||||
|
||||
// depth is weird cause we have to account for every entry's unique depth curve, even if they don't have one
|
||||
DevDebugManager.Instance.CreateAnimationCurveOptionsUIField(parentTransform, new TitleParameter("Depth Weight Scale", ForcedTileSetList.DepthWeightScaleTooltip, layoutOffset), entry.DepthWeightScale, (t) => entry.DepthWeightScale = t);
|
||||
DevDebugManager.Instance.CreateListUIField(parentTransform, new TitleParameter("Tile Sets", ForcedTileSetList.TileSetsTooltip, layoutOffset), entry.TileSets);
|
||||
DevDebugManager.Instance.CreateAnimationCurveOptionsUIField(parentTransform, new TitleParameter("Depth Weight Scale", AdditionalTileSetList.DepthWeightScaleTooltip, layoutOffset), entry.DepthWeightScale, (t) => entry.DepthWeightScale = t);
|
||||
DevDebugManager.Instance.CreateListUIField(parentTransform, new TitleParameter("Tile Sets", AdditionalTileSetList.TileSetsTooltip, layoutOffset), entry.TileSets);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace DunGenPlus.DevTools.UIElements {
|
|||
{ typeof(DungeonArchetype), new ListEntryDungeonArchetype() },
|
||||
{ typeof(TileSet), new ListEntryTileSet() },
|
||||
{ typeof(NodeArchetype), new ListEntryNodeArchetype() },
|
||||
{ typeof(ForcedTileSetList), new ListEntryForcedTileSetList() },
|
||||
{ typeof(AdditionalTileSetList), new ListEntryAdditionalTileSetList() },
|
||||
{ typeof(TileInjectionRule), new ListEntryTileInjectionRule() },
|
||||
{ typeof(GraphNode), new ListEntryGraphNode() },
|
||||
{ typeof(GraphLine), new ListEntryGraphLine() }
|
||||
|
|
|
@ -20,8 +20,17 @@ namespace DunGenPlus {
|
|||
|
||||
[Header("DEV ONLY: DON'T TOUCH")]
|
||||
[Attributes.ReadOnly]
|
||||
public string Version = "0";
|
||||
public string Version = CURRENT_VERSION;
|
||||
internal bool Active = true;
|
||||
|
||||
public static readonly string CURRENT_VERSION = "1";
|
||||
|
||||
public void OnValidate(){
|
||||
if (Version == "0"){
|
||||
Properties.AdditionalTilesProperties.CopyFrom(Properties.ForcedTilesProperties);
|
||||
Version = "1";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -18,11 +18,12 @@ namespace DunGenPlus.Generation {
|
|||
|
||||
public static GraphLine GetLineAtDepth(DungeonFlow flow, float depth) {
|
||||
if (!DunGenPlusGenerator.Active) {
|
||||
//Plugin.logger.LogInfo("Default");
|
||||
//Plugin.logger.LogInfo("LineDepth: Default");
|
||||
return flow.GetLineAtDepth(depth);
|
||||
}
|
||||
|
||||
//Plugin.logger.LogInfo(currentMainPathExtender == null ? "NULL" : "ITEM");
|
||||
//var comment = currentMainPathExtender == null ? "NULL" : "ITEM";
|
||||
//Plugin.logger.LogInfo($"LineDepth: {comment}");
|
||||
var lines = MainPathExtender.GetLines(currentMainPathExtender, flow);
|
||||
return GetLineAtDepthHelper(lines, depth);
|
||||
}
|
||||
|
@ -42,41 +43,45 @@ namespace DunGenPlus.Generation {
|
|||
|
||||
public static List<GraphNode> GetNodes(DungeonFlow flow){
|
||||
if (!DunGenPlusGenerator.Active) {
|
||||
//Plugin.logger.LogInfo("Default");
|
||||
//Plugin.logger.LogInfo("Nodes: Default");
|
||||
return flow.Nodes;
|
||||
}
|
||||
|
||||
//Plugin.logger.LogInfo(currentMainPathExtender == null ? "NULL" : "ITEM");
|
||||
//var comment = currentMainPathExtender == null ? "NULL" : "ITEM";
|
||||
//Plugin.logger.LogInfo($"Nodes: {comment}");
|
||||
return MainPathExtender.GetNodes(currentMainPathExtender, flow);
|
||||
}
|
||||
|
||||
public static BranchMode GetBranchMode(DungeonFlow flow) {
|
||||
if (!DunGenPlusGenerator.Active) {
|
||||
//Plugin.logger.LogInfo("Default M");
|
||||
//Plugin.logger.LogInfo("Branch Mode: Default");
|
||||
return flow.BranchMode;
|
||||
}
|
||||
|
||||
//Plugin.logger.LogInfo(currentMainPathExtender == null ? "NULL" : "ITEM M");
|
||||
//var comment = currentMainPathExtender == null ? "NULL" : "ITEM";
|
||||
//Plugin.logger.LogInfo($"Branch Mode: {comment}");
|
||||
return MainPathExtender.GetBranchMode(currentMainPathExtender, flow);
|
||||
}
|
||||
|
||||
public static IntRange GetBranchCount(DungeonFlow flow) {
|
||||
if (!DunGenPlusGenerator.Active) {
|
||||
//Plugin.logger.LogInfo("Default C");
|
||||
//Plugin.logger.LogInfo("Branch Count: Default");
|
||||
return flow.BranchCount;
|
||||
}
|
||||
|
||||
//Plugin.logger.LogInfo(currentMainPathExtender == null ? "NULL" : "ITEM C");
|
||||
//var comment = currentMainPathExtender == null ? "NULL" : "ITEM";
|
||||
//Plugin.logger.LogInfo($"Branch Count: {comment}");
|
||||
return MainPathExtender.GetBranchCount(currentMainPathExtender, flow);
|
||||
}
|
||||
|
||||
public static IntRange GetLength(DungeonFlow flow) {
|
||||
if (!DunGenPlusGenerator.Active) {
|
||||
Plugin.logger.LogInfo("Default");
|
||||
//Plugin.logger.LogInfo("Length: Default");
|
||||
return flow.Length;
|
||||
}
|
||||
|
||||
Plugin.logger.LogInfo(currentMainPathExtender == null ? "NULL" : "ITEM");
|
||||
//var comment = currentMainPathExtender == null ? "NULL" : "ITEM";
|
||||
//Plugin.logger.LogInfo($"Length: {comment}");
|
||||
return MainPathExtender.GetLength(currentMainPathExtender, flow);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace DunGenPlus.Generation {
|
|||
Active = true;
|
||||
ActiveAlternative = true;
|
||||
|
||||
var props = extender.Properties.Copy();
|
||||
var props = extender.Properties.Copy(extender.Version);
|
||||
var callback = new EventCallbackScenario(DevDebugManager.Instance);
|
||||
Instance.Events.OnModifyDunGenExtenderProperties.Invoke(props, callback);
|
||||
props.NormalNodeArchetypesProperties.SetupProperties(generator);
|
||||
|
@ -100,6 +100,7 @@ namespace DunGenPlus.Generation {
|
|||
}
|
||||
|
||||
public static IEnumerator GenerateAlternativeMainPaths(DungeonGenerator gen) {
|
||||
|
||||
// default behaviour
|
||||
if (!Active) {
|
||||
ActiveAlternative = false;
|
||||
|
@ -115,12 +116,12 @@ namespace DunGenPlus.Generation {
|
|||
var copyNodeBehaviour = Properties.MainPathProperties.CopyNodeBehaviour;
|
||||
|
||||
if (altCount <= 0) {
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, $"MainPathCount being {altCount + 1}", LogLevel.Info));
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, null, $"MainPathCount being {altCount + 1}", LogLevel.Info));
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (mainRoomTilePrefab == null) {
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab being null", LogLevel.Warning));
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, null, $"MainRoomTilePrefab being null", LogLevel.Warning));
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
@ -133,14 +134,11 @@ namespace DunGenPlus.Generation {
|
|||
// this MUST have multiple doorways as you can imagine
|
||||
var mainRoom = gen.proxyDungeon.MainPathTiles.FirstOrDefault(t => t.Prefab == mainRoomTilePrefab);
|
||||
if (mainRoom == null) {
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, $"MainRoomTilePrefab not spawning on the main path", LogLevel.Warning));
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, null, $"MainRoomTilePrefab not spawning on the main path", LogLevel.Warning));
|
||||
yield break;
|
||||
}
|
||||
|
||||
var doorwayGroups = mainRoom.Prefab.GetComponentInChildren<MainRoomDoorwayGroups>();
|
||||
|
||||
// index of MaxValue is how we tell which doorway proxy is fake
|
||||
var fakeDoorwayProxy = new DoorwayProxy(mainRoom, int.MaxValue, mainRoom.doorways[0].DoorwayComponent, Vector3.zero, Quaternion.identity);
|
||||
var mainRoomStartingLengthIndex = mainRoom.Placement.Depth + 1;
|
||||
Plugin.logger.LogDebug($"Length Index: {mainRoomStartingLengthIndex}");
|
||||
|
||||
//FixDoorwaysToAllFloors(mainRoom, doorwayGroups);
|
||||
|
||||
|
@ -165,7 +163,7 @@ namespace DunGenPlus.Generation {
|
|||
var index = nodesSorted.FindIndex(n => n.TileSets.SelectMany(t => t.TileWeights.Weights).Any(t => t.Value == mainRoomTilePrefab));
|
||||
|
||||
if (index == -1) {
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, $"CopyNodeBehaviour being CopyFromNodeList AND MainRoomTilePrefab not existing in the Nodes' tilesets", LogLevel.Warning));
|
||||
yield return gen.Wait(GenerateBranchPaths(gen, mainRoom, $"CopyNodeBehaviour being CopyFromNodeList AND MainRoomTilePrefab not existing in the Nodes' tilesets", LogLevel.Warning));
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
@ -181,9 +179,12 @@ namespace DunGenPlus.Generation {
|
|||
var nodes = nodesSorted.Skip(startingNodeIndex);
|
||||
var nodesVisited = new List<GraphNode>(nodes.Count());
|
||||
|
||||
// places fake doorways at the first node
|
||||
MainRoomDoorwayGroups.ModifyGroupBasedOnBehaviour(mainRoom, b + 1);
|
||||
|
||||
// most of this code is a mix of the GenerateMainPath()
|
||||
// and GenerateBranch() code
|
||||
for(var t = 1; t < targetLength; ++t){
|
||||
for(var t = mainRoomStartingLengthIndex; t < targetLength; ++t){
|
||||
var lineDepthRatio = Mathf.Clamp01((float)t / (targetLength - 1));
|
||||
var lineAtDepth = GetLineAtDepth(gen.DungeonFlow, lineDepthRatio);
|
||||
if (lineAtDepth == null){
|
||||
|
@ -215,22 +216,6 @@ namespace DunGenPlus.Generation {
|
|||
useableTileSets = archetype.TileSets;
|
||||
}
|
||||
|
||||
// places fake doorways at the first node
|
||||
if (doorwayGroups && t == 1){
|
||||
foreach(var d in mainRoom.UsedDoorways) {
|
||||
if (d.ConnectedDoorway.Index != int.MaxValue) {
|
||||
var groups = doorwayGroups.GrabDoorwayGroup(d.DoorwayComponent);
|
||||
if (groups == null) continue;
|
||||
|
||||
foreach(var doorway in mainRoom.UnusedDoorways){
|
||||
if (groups.Contains(doorway.DoorwayComponent)){
|
||||
doorway.ConnectedDoorway = fakeDoorwayProxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tileProxy = gen.AddTile(previousTile, useableTileSets, lineDepthRatio, archetype, TilePlacementResult.None);
|
||||
|
||||
if (tileProxy == null) {
|
||||
|
@ -265,11 +250,7 @@ namespace DunGenPlus.Generation {
|
|||
}
|
||||
|
||||
// okay lets fix the fakes
|
||||
foreach(var doorway in mainRoom.UsedDoorways){
|
||||
if (doorway.ConnectedDoorway.Index == int.MaxValue) {
|
||||
doorway.ConnectedDoorway = null;
|
||||
}
|
||||
}
|
||||
MainRoomDoorwayGroups.RemoveFakeDoorwayProxies(mainRoom);
|
||||
|
||||
ActiveAlternative = false;
|
||||
Plugin.logger.LogDebug($"Created {altCount} alt. paths, creating branches now");
|
||||
|
@ -299,11 +280,13 @@ namespace DunGenPlus.Generation {
|
|||
AddForcedTiles(gen);
|
||||
}
|
||||
|
||||
private static IEnumerator GenerateBranchPaths(DungeonGenerator gen, string message, LogLevel logLevel){
|
||||
private static IEnumerator GenerateBranchPaths(DungeonGenerator gen, TileProxy mainRoom, string message, LogLevel logLevel){
|
||||
Plugin.logger.Log(logLevel, $"Switching to default dungeon branch generation: {message}");
|
||||
|
||||
ActiveAlternative = false;
|
||||
SetCurrentMainPathExtender(0);
|
||||
if (mainRoom != null) MainRoomDoorwayGroups.RemoveFakeDoorwayProxies(mainRoom);
|
||||
|
||||
yield return gen.Wait(gen.GenerateBranchPaths());
|
||||
ActiveAlternative = true;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using DunGen;
|
||||
using DunGen.Graph;
|
||||
using DunGenPlus.DevTools;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -10,9 +11,9 @@ namespace DunGenPlus.Generation {
|
|||
internal partial class DunGenPlusGenerator {
|
||||
|
||||
public static void AddForcedTiles(DungeonGenerator gen){
|
||||
if (!Properties.ForcedTilesProperties.UseForcedTiles) return;
|
||||
if (!Properties.AdditionalTilesProperties.UseAdditionalTiles) return;
|
||||
|
||||
var forcedTileSetLists = Properties.ForcedTilesProperties.ForcedTileSets.ToList();
|
||||
var forcedTileSetLists = Properties.AdditionalTilesProperties.AdditionalTileSets.ToList();
|
||||
while(forcedTileSetLists.Count > 0){
|
||||
var item = forcedTileSetLists[forcedTileSetLists.Count - 1];
|
||||
|
||||
|
@ -87,5 +88,9 @@ namespace DunGenPlus.Generation {
|
|||
return archetype;
|
||||
}
|
||||
|
||||
public static bool AllowRetryStop(bool defaultState){
|
||||
return defaultState || DevDebugManager.IsActive;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ using DunGenPlus.Collections;
|
|||
using DunGenPlus.DevTools;
|
||||
using DunGen.Graph;
|
||||
using UnityEngine;
|
||||
using DunGenPlus.Components;
|
||||
|
||||
namespace DunGenPlus.Patches {
|
||||
internal class DungeonGeneratorPatch {
|
||||
|
@ -22,18 +23,21 @@ namespace DunGenPlus.Patches {
|
|||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DungeonGenerator), "InnerGenerate")]
|
||||
public static void InnerGeneratePatch(ref DungeonGenerator __instance, bool isRetry, ref IEnumerator __result){
|
||||
if (DevDebugManager.Instance && !isRetry) {
|
||||
//Plugin.logger.LogWarning($"InnerGenerate: {DunGenPlusGenerator.Active}, {DunGenPlusGenerator.ActiveAlternative}, {__instance.Status}");
|
||||
if (DevDebugManager.IsActive && !isRetry) {
|
||||
DevDebugManager.Instance.RecordNewSeed(__instance.ChosenSeed);
|
||||
}
|
||||
|
||||
if (DunGenPlusGenerator.Active && DunGenPlusGenerator.ActiveAlternative) {
|
||||
DunGenPlusGenerator.SetCurrentMainPathExtender(0);
|
||||
MainRoomDoorwayGroups.ModifyGroupBasedOnBehaviourSimpleOnce = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DungeonGenerator), "GenerateMainPath")]
|
||||
public static void GenerateMainPathPatch(ref DungeonGenerator __instance, ref IEnumerator __result){
|
||||
//Plugin.logger.LogWarning($"GenerateMainPath: {DunGenPlusGenerator.Active}, {DunGenPlusGenerator.ActiveAlternative}, {__instance.Status}");
|
||||
if (DunGenPlusGenerator.Active && DunGenPlusGenerator.ActiveAlternative) {
|
||||
DunGenPlusGenerator.RandomizeLineArchetypes(__instance, true);
|
||||
}
|
||||
|
@ -42,6 +46,7 @@ namespace DunGenPlus.Patches {
|
|||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DungeonGenerator), "GenerateBranchPaths")]
|
||||
public static void GenerateBranchPathsPatch(ref DungeonGenerator __instance, ref IEnumerator __result){
|
||||
//Plugin.logger.LogWarning($"GenerateBranchPaths: {DunGenPlusGenerator.Active}, {DunGenPlusGenerator.ActiveAlternative}, {__instance.Status}");
|
||||
if (DunGenPlusGenerator.Active && DunGenPlusGenerator.ActiveAlternative) {
|
||||
__result = DunGenPlusGenerator.GenerateAlternativeMainPaths(__instance);
|
||||
}
|
||||
|
@ -59,6 +64,9 @@ namespace DunGenPlus.Patches {
|
|||
archSequence.AddBasic(OpCodes.Ldnull);
|
||||
archSequence.AddBasic(OpCodes.Callvirt, addArchFunction);
|
||||
|
||||
var attachToSequence = new InstructionSequenceStandard("attach to");
|
||||
attachToSequence.AddBasicLocal(OpCodes.Stloc_S, 13);
|
||||
|
||||
foreach(var instruction in instructions){
|
||||
|
||||
if (archSequence.VerifyStage(instruction)){
|
||||
|
@ -75,10 +83,22 @@ namespace DunGenPlus.Patches {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (attachToSequence.VerifyStage(instruction)){
|
||||
yield return instruction;
|
||||
|
||||
var modifyMethod = typeof(MainRoomDoorwayGroups).GetMethod("ModifyGroupBasedOnBehaviourSimple", BindingFlags.Public | BindingFlags.Static);
|
||||
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_S, 13);
|
||||
yield return new CodeInstruction(OpCodes.Call, modifyMethod);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
yield return instruction;
|
||||
}
|
||||
|
||||
archSequence.ReportComplete();
|
||||
attachToSequence.ReportComplete();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
|
@ -172,10 +192,14 @@ namespace DunGenPlus.Patches {
|
|||
public static IEnumerable<CodeInstruction> InnerGenerateLengthPatch(IEnumerable<CodeInstruction> instructions){
|
||||
|
||||
var lengthField = typeof(DungeonFlow).GetField("Length", BindingFlags.Instance | BindingFlags.Public);
|
||||
var getIsEditor = typeof(Application).GetMethod("get_isEditor", BindingFlags.Static | BindingFlags.Public);
|
||||
|
||||
var lengthSequence = new InstructionSequenceStandard("Length");
|
||||
lengthSequence.AddBasic(OpCodes.Ldfld, lengthField);
|
||||
|
||||
var editorCheck = new InstructionSequenceStandard("Editor");
|
||||
editorCheck.AddBasic(OpCodes.Call, getIsEditor);
|
||||
|
||||
foreach(var instruction in instructions){
|
||||
if (lengthSequence.VerifyStage(instruction)) {
|
||||
var specialFunction = typeof(DunGenPlusGenerator).GetMethod("GetLength", BindingFlags.Static | BindingFlags.Public);
|
||||
|
@ -185,10 +209,20 @@ namespace DunGenPlus.Patches {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (editorCheck.VerifyStage(instruction)){
|
||||
var specialFunction = typeof(DunGenPlusGenerator).GetMethod("AllowRetryStop", BindingFlags.Static | BindingFlags.Public);
|
||||
|
||||
yield return instruction;
|
||||
yield return new CodeInstruction(OpCodes.Call, specialFunction);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
yield return instruction;
|
||||
}
|
||||
|
||||
lengthSequence.ReportComplete();
|
||||
editorCheck.ReportComplete();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue