From 0f9b5ba059f2fc78c9a8eceef0807c1b90cce665 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 1 May 2024 12:26:48 +0200 Subject: [PATCH] Show trigger tag associations from sectors to linedefs --- .../BuilderModes/General/Association.cs | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Source/Plugins/BuilderModes/General/Association.cs b/Source/Plugins/BuilderModes/General/Association.cs index 729f1220..7d2f862c 100755 --- a/Source/Plugins/BuilderModes/General/Association.cs +++ b/Source/Plugins/BuilderModes/General/Association.cs @@ -269,7 +269,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Get tags of map elements the element is referencing. This is used for the forward associations - if (element is Linedef || element is Thing) + if (element is Linedef || element is Thing || element is Sector) actiontags = GetTagsByType(); // Store presence of different types once, so that we don't have to do a lookup for each map element @@ -293,7 +293,8 @@ namespace CodeImp.DoomBuilder.BuilderModes addforward = true; // Check the reverse association (from the sector to the element) - // Nothing here yet + if (IsAssociatedToSector(s)) + addreverse = true; if (addforward || addreverse) { @@ -494,7 +495,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private Dictionary> GetTagsByType() { LinedefActionInfo action = null; - int[] actionargs = new int[5]; + int[] actionargs = new int[10]; Dictionary> actiontags = new Dictionary>(); // Get the action and its arguments from a linedef or a thing, if they have them @@ -516,7 +517,17 @@ namespace CodeImp.DoomBuilder.BuilderModes actionargs = t.Args; } - else // element is a Sector + else if (element is Sector) + { + Sector s = element as Sector; + + int triggertag = s.Fields.GetValue("triggertag", 0); + if (triggertag > 0) + { + actiontags[(int)UniversalType.LinedefTag] = new HashSet{triggertag}; + } + } + else { return actiontags; } @@ -645,6 +656,26 @@ namespace CodeImp.DoomBuilder.BuilderModes return false; } + /// + /// Checks if there's an association between the element and a Sector + /// + /// Sector to check the association against + /// true if the Sector and the element are associated, false if not + private bool IsAssociatedToSector(Sector sector) + { + int triggertag = sector.Fields.GetValue("triggertag", 0); + + if (triggertag > 0 && element is Linedef) + { + Linedef l = element as Linedef; + + if (l.Tags.Contains(triggertag)) + return true; + } + + return false; + } + /// /// Returns a string that contains the description of the action and its arguments, based on the given Linedef or Thing /// @@ -653,7 +684,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private string GetActionDescription(SelectableElement se) { int action = 0; - int[] actionargs = new int[5]; + int[] actionargs = new int[10]; if (se is Thing) {