public void toggle(int caller) { int hashcode = caller.GetHashCode(); AttachNode node = aNList.Find(a => a.GetHashCode() == caller.GetHashCode()); AttachNode nodeVisual = aNVisualList.Find(a => a.GetHashCode() == caller.GetHashCode()); Debug.Log("Toggling Node: " + node.id); if (part.attachNodes.Contains(node)) { Debug.Log("Node Exists, Removing"); part.attachNodes.Remove(node); Events[node.GetHashCode().ToString()].guiName = node.id + " || Inactive"; enableVisualNodes(nodeVisual, false); } else { Debug.Log("Node Absent, Adding"); part.attachNodes.Add(node); Events[node.GetHashCode().ToString()].guiName = node.id + " || Active"; enableVisualNodes(nodeVisual, true); } Debug.Log("Toggle Complete"); }
private void populateToggle(AttachNode node) { Debug.Log("-Creating Event for: " + node.id); BaseEvent item = new BaseEvent(new BaseEventList(part, this), node.GetHashCode().ToString(), () => toggle(node.GetHashCode())); item.active = true; item.guiActiveEditor = true; item.guiName = node.id + " || Active"; Events.Add(item); }
private void createVisibleNode(AttachNode node) { if (!Events[node.GetHashCode().ToString()].guiName.Contains("Inactive")) { if (node.icon == null) { node.icon = GameObject.CreatePrimitive(PrimitiveType.Sphere); node.icon.renderer.material = crashTestNodeMaterial; } node.icon.SetActive(true); node.icon.transform.localScale = ((Vector3.one * node.radius) * (node.size != 0 ? (float)node.size : (float)node.size + 0.5f)); node.icon.renderer.material.color = XKCDColors.RadioactiveGreen; node.icon.transform.position = (this.part.transform.TransformPoint(node.position)); node.icon.renderer.enabled = true; } }
private void createVisibleNode(AttachNode node) { if (!Events[node.GetHashCode().ToString()].guiName.Contains("Inactive")) { if (node.icon == null) { node.icon = GameObject.CreatePrimitive(PrimitiveType.Sphere); node.icon.renderer.material = crashTestNodeMaterial; } node.icon.SetActive(true); node.icon.transform.localScale = ((Vector3.one * node.radius) * (node.size != 0 ? (float)node.size : (float)node.size + 0.5f)); node.icon.renderer.material.color = XKCDColors.RadioactiveGreen; node.icon.transform.position = (this.part.transform.TransformPoint(node.position)); node.icon.renderer.enabled = true; } }
private void populateToggle(AttachNode node) { Debug.Log("-Creating Event for: " + node.id); BaseEvent item = new BaseEvent(new BaseEventList(part, this), node.GetHashCode().ToString(), () => toggle(node.GetHashCode())); item.active = true; item.guiActiveEditor = true; item.guiName = node.id + " || Active"; Events.Add(item); }