From 73eeb44e52eacf73870261004ae4134c383aacbd Mon Sep 17 00:00:00 2001 From: Miguel Anxo Figueirido Prado Date: Mon, 1 Apr 2024 20:26:40 +0200 Subject: [PATCH 1/4] Added FloatRectangle.IsPointInside(). --- .../FlatRedBall/Math/Geometry/FloatRectangle.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs b/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs index 754f10628..26a1b2c18 100644 --- a/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs +++ b/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs @@ -93,6 +93,11 @@ public void Inflate(float horizontalAmount, float verticalAmount) Bottom -= verticalAmount; } + public bool IsPointInside(float x, float y) + { + return x >= Left && x <= Right && y <= Top && y >= Bottom; + } + public override string ToString() { return "Top:" + Top + " Left:" + Left + " Bottom:" + Bottom + " Right:" + Right; From a6eeed67813087b7852a99232c53dc7dd7f560dc Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 1 Apr 2024 21:15:15 -0600 Subject: [PATCH 2/4] Fixed polygon setting in tile node network fixes #1386 --- .../FlatRedBall/AI/Pathfinding/NodeNetwork.cs | 8 ++++++-- .../Managers/AssetTypeInfoAdder.cs | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Engines/FlatRedBallXNA/FlatRedBall/AI/Pathfinding/NodeNetwork.cs b/Engines/FlatRedBallXNA/FlatRedBall/AI/Pathfinding/NodeNetwork.cs index 177dcb0b7..73c51421c 100644 --- a/Engines/FlatRedBallXNA/FlatRedBall/AI/Pathfinding/NodeNetwork.cs +++ b/Engines/FlatRedBallXNA/FlatRedBall/AI/Pathfinding/NodeNetwork.cs @@ -180,6 +180,7 @@ public bool Visible if (mVisible != value) { mVisible = value; + UpdateShapes(); } @@ -936,7 +937,9 @@ public virtual void UpdateShapes() #region Create nodes to match how many nodes are in the network while (mNodes.Count > mNodeVisibleRepresentation.Count) { - Polygon newPolygon = Polygon.CreateEquilateral(4, 1, MathHelper.PiOver4); + Polygon newPolygon = Polygon.CreateEquilateral(4, + 4, // radius + MathHelper.PiOver4); newPolygon.Name = "NodeNetwork Polygon"; const bool makeAutomaticallyUpdated = false; @@ -971,7 +974,8 @@ public virtual void UpdateShapes() mNodeVisibleRepresentation[i].ScaleBy( GetVisibleNodeRadius(SpriteManager.Camera, i) / mNodeVisibleRepresentation[i].BoundingRadius); - mNodeVisibleRepresentation[i].UpdateDependencies(-1, true); + + mNodeVisibleRepresentation[i].ForceUpdateDependencies(); foreach (Link link in mNodes[i].mLinks) { diff --git a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/AssetTypeInfoAdder.cs b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/AssetTypeInfoAdder.cs index ca8337382..a680ac873 100644 --- a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/AssetTypeInfoAdder.cs +++ b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/AssetTypeInfoAdder.cs @@ -353,7 +353,24 @@ private AssetTypeInfo CreateAtiForTileNodeNetwork() //toReturn.FindByNameSyntax = $"Collisions.First(item => item.Name == \"OBJECTNAME\");"; toReturn.GetObjectFromFileFunc = GetTileNodeNetworkObjectFromFileFunc; - toReturn.VariableDefinitions.Add(new VariableDefinition() { Name = "Visible", DefaultValue = "false", Type = "bool" }); + + var visibleVariableDefinition = new VariableDefinition() { Name = "Visible", DefaultValue = "false", Type = "bool" }; + visibleVariableDefinition.UsesCustomCodeGeneration = true; + visibleVariableDefinition.CustomGenerationFunc = (element, nos, rfs, layer) => + { + var isVisible = (nos.GetCustomVariable("Visible")?.Value as bool?) == true; + var visibleText = isVisible ? "true" : "false"; + return @$" +{{ + var wasSuppressedForNodeNetwork = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; + FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = false; + {nos.InstanceName}.Visible = {visibleText}; + FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = wasSuppressedForNodeNetwork; +}} +"; + }; + + toReturn.VariableDefinitions.Add(visibleVariableDefinition); toReturn.ConstructorFunc = GenerateTileNodeNetworkConstructionFunc; return toReturn; } From a9d6f9081065785fc65abfdc4802d891bc9e8f1c Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 1 Apr 2024 21:52:00 -0600 Subject: [PATCH 3/4] Added option to copy code instance name fixes #1385 --- FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs b/FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs index 42880f5a4..8ad36b2e9 100644 --- a/FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs +++ b/FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs @@ -646,7 +646,8 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu Add(L.Texts.FolderAdd, () => RightClickHelper.AddFolderClick(targetNode), image: FolderImage); AddSeparator(); Add(L.Texts.ViewInExplorer, () => RightClickHelper.ViewInExplorerClick(targetNode)); - AddEvent(L.Texts.CopyPathClipboard, (_, _) => HandleCopyToClipboardClick(targetNode)); + Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode)); + AddSeparator(); if (targetNode.IsFolderInFilesContainerNode()) { @@ -833,11 +834,18 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu Add(L.Texts.ViewInExplorer, () => RightClickHelper.ViewInExplorerClick(targetNode)); Add(L.Texts.Open, () => HandleOpen(targetNode)); AddItem(mFindAllReferences); - AddEvent(L.Texts.CopyPathClipboard, (_,_) => HandleCopyToClipboardClick(targetNode)); + Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode)); + var rfs = targetNode.Tag as ReferencedFileSave; + var name = rfs.GetInstanceName(); + Add($"Copy Code Instance Name ({name})", () => + { + Clipboard.SetText(name); + + + }); AddSeparator(); AddItem(mCreateZipPackage); - var rfs = (ReferencedFileSave)targetNode.Tag; AddSeparator(); @@ -917,7 +925,7 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu { Add("View code folder", () => ViewCodeFolderInExplorerClick(targetNode)); } - AddEvent(L.Texts.CopyPathClipboard, (_, _) => HandleCopyToClipboardClick(targetNode)); + Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode)); AddSeparator(); From 95173e7d93122d19358dcb08d7925e4f9105e162 Mon Sep 17 00:00:00 2001 From: Miguel Anxo Figueirido Prado Date: Tue, 2 Apr 2024 13:40:25 +0200 Subject: [PATCH 4/4] Allow TimeFactor = 0 --- FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs b/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs index 644a5c549..790e17d5a 100644 --- a/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs +++ b/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs @@ -39,11 +39,13 @@ public static void GenerateFieldsAndProperties(EntitySave entity, ICodeBlock cod public static void GenerateActivity(IElement saveObject, ICodeBlock codeBlock) { codeBlock.Line("#if DEBUG"); - + // in codeblock, write code to check if the mLastTimeCalledActivity is equal to the current time. If so, throw an exception // 9/2/2023 - activity gets called 2x at the beginning. I'm not sure if this is desirable, but until I figure this out, I'm going - // to tolerate double calls on frame 0 - codeBlock.Line("if(mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)") + // to tolerate double calls on frame 0. + // Miguel 02/04/2024 - Setting TimeFactor = 0 causes time to not advance causing this exception, but I think it should be a valid + // setting the user can choose. + codeBlock.Line("if(TimeManager.TimeFactor > 0 && mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)") .Line("{") .Line(" throw new System.Exception(\"Activity was called twice in the same frame. This can cause objects to move 2x as fast.\");") .Line("}")