private void SelectTriggerable(StratusTriggerable triggerable) { selectedTrigger = null; selectedTriggerable = triggerable; selectedEditor = UnityEditor.Editor.CreateEditor(triggerable) as StratusEditor; selectedEditor.backgroundStyle = EditorStyles.helpBox; }
public static bool IsConnected(Trigger trigger, StratusTriggerable triggerable) { if (trigger.targets.Contains(triggerable)) { return(true); } return(false); }
void OnTriggered(StratusTriggerable other) { current.Remove(other); if (ShouldActivate()) { Activate(); } StratusDebug.Log("Elements left = " + current.Count, this); }
private void RemoveTriggerable(StratusTriggerable triggerable) { if (selected == triggerable) { Deselect(); selectedTriggerable = null; } endOfFrameRequests.Add(() => { target.triggerables.Remove(triggerable); Undo.DestroyObjectImmediate(triggerable); }); }
private void SetTriggerableContextMenu(StratusTriggerable triggerable, GenericMenu menu) { // Connect if (selectedTrigger) { if (connectedTriggerables[triggerable]) { menu.AddItem(new GUIContent($"Disconnect from {selectedTrigger.GetType().Name}"), false, () => Disconnect(selectedTrigger, triggerable)); } else { menu.AddItem(new GUIContent($"Connect to {selectedTrigger.GetType().Name}"), false, () => Connect(selectedTrigger, triggerable)); } } }
private StratusTriggerSystem.ConnectionStatus GetStatus(StratusTriggerable triggerable) { StratusTriggerSystem.ConnectionStatus status = StratusTriggerSystem.ConnectionStatus.Disconnected; if (selected) { if (selected == triggerable) { status = StratusTriggerSystem.ConnectionStatus.Selected; } else if (selectedTrigger && connectedTriggerables.ContainsKey(triggerable) && connectedTriggerables[triggerable]) { status = StratusTriggerSystem.ConnectionStatus.Connected; } } if (!IsConnected(triggerable) && selected != triggerable) { status = StratusTriggerSystem.ConnectionStatus.Disjoint; } return(status); }
private void DrawTriggerable(StratusTriggerable triggerable) { StratusTriggerSystem.ConnectionStatus status = StratusTriggerSystem.ConnectionStatus.Disconnected; if (selected) { if (selected == triggerable) { status = StratusTriggerSystem.ConnectionStatus.Selected; } else if (selectedTrigger && connectedTriggerables.ContainsKey(triggerable) && connectedTriggerables[triggerable]) { status = StratusTriggerSystem.ConnectionStatus.Connected; } } if (!IsConnected(triggerable) && selected != triggerable) { status = StratusTriggerSystem.ConnectionStatus.Disjoint; } Color color = GetColor(triggerable, status); Draw(triggerable, color, SelectTriggerable, RemoveTriggerable, SetTriggerableContextMenu); }
private bool IsConnected(StratusTriggerable triggerable) => triggerableConnectivity.ContainsKey(triggerable) && triggerableConnectivity[triggerable] == StratusTriggerSystem.ConnectionStatus.Connected;
private bool IsConnected(StratusTriggerBehaviour trigger, StratusTriggerable triggerable) => StratusTriggerSystem.IsConnected(trigger, triggerable);
private void Disconnect(StratusTriggerBehaviour trigger, StratusTriggerable triggerable) { StratusDebug.Log($"Disconnecting {trigger.GetType().Name} and {triggerable.GetType().Name}"); trigger.targets.Remove(triggerable); UpdateConnections(); }
//------------------------------------------------------------------------/ // Methods: Connections //------------------------------------------------------------------------/ private void Connect(Trigger trigger, StratusTriggerable triggerable) { StratusDebug.Log($"Connecting {trigger.GetType().Name} and {triggerable.GetType().Name}"); trigger.targets.Add(triggerable); UpdateConnections(); }