public static bool IsConnected(Trigger trigger, Triggerable triggerable) { if (trigger.targets.Contains(triggerable)) { return(true); } return(false); }
private void SelectTriggerable(Triggerable triggerable) { selectedTrigger = null; selectedTriggerable = triggerable; selectedEditor = UnityEditor.Editor.CreateEditor(triggerable) as StratusEditor; selectedEditor.backgroundStyle = EditorStyles.helpBox; }
void OnTriggered(Triggerable other) { current.Remove(other); if (ShouldActivate()) { Activate(); } Trace.Script("Elements left = " + current.Count, this); }
private void RemoveTriggerable(Triggerable triggerable) { if (selected == triggerable) { Deselect(); selectedTriggerable = null; } endOfFrameRequests.Add(() => { target.triggerables.Remove(triggerable); Undo.DestroyObjectImmediate(triggerable); }); }
private void SetTriggerableContextMenu(Triggerable 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 TriggerSystem.ConnectionStatus GetStatus(Triggerable triggerable) { TriggerSystem.ConnectionStatus status = TriggerSystem.ConnectionStatus.Disconnected; if (selected) { if (selected == triggerable) { status = TriggerSystem.ConnectionStatus.Selected; } else if (selectedTrigger && connectedTriggerables.ContainsKey(triggerable) && connectedTriggerables[triggerable]) { status = TriggerSystem.ConnectionStatus.Connected; } } if (!IsConnected(triggerable) && selected != triggerable) { status = TriggerSystem.ConnectionStatus.Disjoint; } return(status); }
private void DrawTriggerable(Triggerable triggerable) { TriggerSystem.ConnectionStatus status = TriggerSystem.ConnectionStatus.Disconnected; if (selected) { if (selected == triggerable) { status = TriggerSystem.ConnectionStatus.Selected; } else if (selectedTrigger && connectedTriggerables.ContainsKey(triggerable) && connectedTriggerables[triggerable]) { status = TriggerSystem.ConnectionStatus.Connected; } } if (!IsConnected(triggerable) && selected != triggerable) { status = TriggerSystem.ConnectionStatus.Disjoint; } Color color = GetColor(triggerable, status); Draw(triggerable, color, SelectTriggerable, RemoveTriggerable, SetTriggerableContextMenu); }
private bool IsConnected(Triggerable triggerable) => triggerableConnectivity.ContainsKey(triggerable) && triggerableConnectivity[triggerable] == TriggerSystem.ConnectionStatus.Connected;
private bool IsConnected(Trigger trigger, Triggerable triggerable) => TriggerSystem.IsConnected(trigger, triggerable);
private void Disconnect(Trigger trigger, Triggerable triggerable) { Trace.Script($"Disconnecting {trigger.GetType().Name} and {triggerable.GetType().Name}"); trigger.targets.Remove(triggerable); UpdateConnections(); }