SovietKitKat
Member-
Content Count
4 -
Joined
-
Last visited
-
Medals
Community Reputation
4 NeutralAbout SovietKitKat
-
Rank
Rookie
-
SovietKitKat started following Spawning a Prefab with child entities
-
Spawning a Prefab with child entities
SovietKitKat posted a topic in Arma Reforger - Configs & Scripting
Hello! I've been struggling with getting spawning prefabs with child entities working in my mod. Even with a Hierarchy component, it only appears to spawn the root entity. Using IEntity's GetChildren method on the instanced prefab doesn't return the first child as I would expect. The method I'm currently using to spawn the prefab is to load the resource using Resource.Load, and then to instantiate the prefab with g_Game.SpawnEntityPrefab It doesn't need to use Replication, as the mod is single-player only. Has anyone else struggled with this and come up with a solution? Not being able to access prefab children is a major blocker for progressing on my mod. Here's some screenshots showing my current setup. -
Handling inputs on a GUI / Menu questions.
SovietKitKat replied to SovietKitKat's topic in Arma Reforger - Configs & Scripting
Figured it out for my purposes after digging into Hexcavate and some additional trial and error. Here's what I had to do to get a new interactive menu defined. 1. Inherit chimeraMenus.conf and adding my layout as a new MenuPreset. Adding a different menu config to the menuManager through addon.gproj didn't work during my earlier testing, but something else I did wrong further down the chain could have been mucking things up. 2. Creating a modded enum for ChimeraMenuPreset only containing my new dialog name. modded enum ChimeraMenuPreset : ScriptMenuPresetEnum { NPCTalkDialog } Again, trying to define my own enum instead of modding the existing preset didn't work. Other Notes For handling button inputs, I created my own Menu class inheriting MenuBase. You can get the widgets pretty easily from that point. Here's a snippet of my class in case it helps anyone else. class POK_NPCTalkMenu : ChimeraMenuBase { Widget m_widget; ... private ButtonWidget confirmButton; private SCR_ButtonBaseComponent confirmButtonComponent; override void OnMenuOpen() { m_widget = GetRootWidget(); if(m_widget == null) return; ... confirmButton = ButtonWidget.Cast( m_widget.FindAnyWidget( "Confirm" ) ); confirmButtonComponent = SCR_ButtonBaseComponent.Cast(confirmButton.FindHandler(SCR_ButtonBaseComponent)); // Add event to confirm button component to close the dialogue confirmButtonComponent.m_OnClicked.Insert(CloseDialogue); } void CloseDialogue() { confirmButtonComponent.m_OnClicked.Remove(CloseDialogue); auto menu = ChimeraMenuPreset.NPCTalkDialog; g_Game.GetMenuManager().CloseMenuByPreset(menu); } -
[solved] How to delete a item?
SovietKitKat replied to pescadorrr's topic in Arma Reforger - Configs & Scripting
One thing you could try is to get the entity's parent and remove the entity from its children. IEntity ent = ... ent.GetParent().RemoveChild(ent); I doubt this is best practice and may leave the entity straggling in memory, but it should get the job done. I haven't tested this code myself, but it should work as long as the parent isn't null for some reason. -
Handling inputs on a GUI / Menu questions.
SovietKitKat posted a topic in Arma Reforger - Configs & Scripting
Does anyone have any ideas where to start with properly handling dialog/menu input capturing? From digging around around the Reforger resources, it seems like a menu is the most appropriate class for what I'm trying to achieve (NPC quest menu) I can display my dialog layout using the HUD manager, but I need to be able to handle inputs, so I've been trying to figure out how to define a Menu in a way that I can use the MenuManager, but OpenMenu requires an enum as a menu input and I haven't been able to determine how Reforger associates Menus to enums. ChimeraMenuBase defines its own inherited enum, but I can't find where those enums associate to the UI classes with different names. They don't appear to exist in the project files at all. Am I missing something?