private void Awake() { defaultColor = transform.GetComponentInChildren <SpriteRenderer>().color; // Add empty child holder for interactions GameObject go = new GameObject("InteractionsTemp"); go.transform.parent = transform; slotInteractions = InteractiveEnvirounment.AttachScript(go); slotInteractions.transform.position = transform.position; // Attach interactions from structures on this slot. fillAsStructure = SelectionManager.GetAsStructure2D(transform.position); if (fillAsStructure) { slotInteractions.interactions.AddRange(fillAsStructure.GetComponent <InteractiveEnvirounment>().Copies()); } }
private static void OverlayUI(GridItem slot) { InteractiveEnvirounment interaction = slot.slotInteractions; for (int i = 0; i < interaction.interactions.Count; i++) { if (interaction.interactions[i].GetType() == typeof(Combustible)) { Transform t = Instantiate(m.combustibleUIPref, slot.transform.position + new Vector3(0, i), new Quaternion(), m.canvasParent); ButtonInteraction bi = t.gameObject.GetComponent <ButtonInteraction>(); bi.interaction = interaction.interactions[i]; bi.source = slot.fillAsStructure; m.AddUIPiece(t); } else if (interaction.interactions[i].GetType() == typeof(Pickable)) { Transform t = Instantiate(m.pickableUIPref, slot.transform.position + new Vector3(0, i), new Quaternion(), m.canvasParent); ButtonInteraction bi = t.gameObject.GetComponent <ButtonInteraction>(); bi.interaction = interaction.interactions[i]; bi.weaponSource = slot.fillAsPickup; m.AddUIPiece(t); } } }