internal override void LinkToParent(ModCraftTreeLinkingNode parent) { base.LinkToParent(parent); if (IsExistingTab) { return; } LanguagePatcher.AddCustomLanguageLine(ModName, $"{base.SchemeAsString}Menu_{Name}", DisplayText); string spriteID = $"{SchemeAsString}_{Name}"; #if SUBNAUTICA ModSprite modSprite; if (Asprite != null) { modSprite = new ModSprite(SpriteManager.Group.Category, spriteID, Asprite); } else { modSprite = new ModSprite(SpriteManager.Group.Category, spriteID, Usprite); } ModSprite.Add(modSprite); #elif BELOWZERO ModSprite modSprite; modSprite = new ModSprite(SpriteManager.Group.Category, spriteID, Usprite); ModSprite.Add(modSprite); #endif }
/// <summary> /// Populates a new ModCraftTreeRoot from a CraftNode tree. /// </summary> /// <param name="tree">The tree to create the ModCraftTreeRoot from.</param> /// <param name="root"></param> internal static void CreateFromExistingTree(CraftNode tree, ref ModCraftTreeLinkingNode root) { foreach (CraftNode node in tree) { if (node.action == TreeAction.Expand) { ModCraftTreeTab tab = root.AddTabNode(node.id); var thing = (ModCraftTreeLinkingNode)tab; CreateFromExistingTree(node, ref thing); } if (node.action == TreeAction.Craft) { var techType = TechType.None; TechTypeExtensions.FromString(node.id, out techType, false); if (node.id == "SeamothHullModule2") { techType = TechType.VehicleHullModule2; } else if (node.id == "SeamothHullModule3") { techType = TechType.VehicleHullModule3; } root.AddCraftingNode(techType); } } }
/// <summary> /// Removes the calling node from parent. /// </summary> public void RemoveNode() { Assert.IsNotNull(this.Parent, "No parent found to remove node from!"); Assert.IsNotNull(this.Parent.CraftNode, "No CraftNode found on parent!"); if (this is ModCraftTreeLinkingNode) { ModCraftTreeLinkingNode linkingNode = this as ModCraftTreeLinkingNode; foreach (ModCraftTreeNode cNode in linkingNode.ChildNodes) { cNode.RemoveNode(); } } this.Parent.ChildNodes.Remove(this); this.Parent.CraftNode.RemoveNode(this.CraftNode); this.Parent = null; }
/// <summary> /// Populates a new ModCraftTreeRoot from a CraftNode tree. /// </summary> /// <param name="tree">The tree to create the ModCraftTreeRoot from.</param> /// <param name="root"></param> internal static void CreateFromExistingTree(CraftNode tree, ref ModCraftTreeLinkingNode root) { foreach (CraftNode node in tree) { if (node.action == TreeAction.Expand) { ModCraftTreeTab tab = root.AddTabNode(node.id); var thing = (ModCraftTreeLinkingNode)tab; CreateFromExistingTree(node, ref thing); } if (node.action == TreeAction.Craft) { TechTypeExtensions.FromString(node.id, out TechType techType, false); root.AddCraftingNode(techType); } } }
internal virtual void LinkToParent(ModCraftTreeLinkingNode parent) { parent.CraftNode.AddNode(this.CraftNode); this.Parent = parent; }