// ------------------------------------------------------------------------- /// Determines if the enable port is always _true_. /// /// @param enablePort The enable port. /// @return _true_ if the enable is always true. _false_ otherwise. /// public static bool IsEnableAlwaysTrue(iCS_EditorObject enablePort) { var producerPort = GraphInfo.GetProducerPort(enablePort); if (producerPort.IsInputPort) { var initialValue = producerPort.Value; if (initialValue is UndefinedTag) { return(false); } var value = (bool)initialValue; return(value == true); } return(false); }
// ====================================================================== /// Sets the default port specification for the given port. /// /// @param p The port on which to set the default port specification. /// public static void SetDefaultPortSpec(iCS_EditorObject p) { // -- Setup spec for control ports. -- var parentNode = p.ParentNode; var producerPort = GraphInfo.GetProducerPort(p); // -- Only valid for the producer port. -- if (producerPort != p) { return; } // -- Determine default port spec. -- if (parentNode.IsFunctionDefinition) { if (p.IsInDataOrControlPort) { GraphEditor.SetPortSpec(p, PortSpecification.Parameter); } } else if (parentNode.IsEventHandler) { if (p.IsFixDataPort) { GraphEditor.SetPortSpec(p, PortSpecification.Parameter); } else { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } } else if (parentNode.IsVariableDefinition) { if (p.IsOutDataOrControlPort) { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } else if (p.IsInDataOrControlPort) { GraphEditor.SetPortSpec(p, PortSpecification.Constant); } } else if (parentNode.IsConstructor) { if (p.IsInDataOrControlPort) { GraphEditor.SetPortSpec(p, PortSpecification.Constant); } else if (p.IsOutDataOrControlPort) { // -- Determine if this is a local variable of not. -- bool isLocal = false; parentNode.ForEachChildPort( cp => { if (cp.IsInDataOrControlPort) { if (cp.ProducerPort != null) { isLocal = true; } } } ); if (isLocal) { GraphEditor.SetPortSpec(p, PortSpecification.LocalVariable); } else { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } } } // TODO: Needs to be verified... else if (parentNode.IsKindOfFunction) { if (p.IsInDataOrControlPort) { var initialValue = p.Value; if (initialValue != null) { GraphEditor.SetPortSpec(p, PortSpecification.Constant); } else { var runtimeType = p.RuntimeType; if (p.IsTargetPort && (runtimeType == typeof(GameObject) || runtimeType == typeof(Transform) || GraphInfo.IsLocalType(p))) { GraphEditor.SetPortSpec(p, PortSpecification.Owner); p.Value = null; } else { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } } } else if (p.IsOutDataOrControlPort) { if (GraphInfo.MustBeATypeVariable(p)) { GraphEditor.SetPortSpec(p, PortSpecification.PrivateVariable); } else { GraphEditor.SetPortSpec(p, PortSpecification.LocalVariable); } } } else if (parentNode.IsInstanceNode) { if (p.IsInDataOrControlPort) { var runtimeType = p.RuntimeType; if (p.IsTargetPort && (runtimeType == typeof(GameObject) || runtimeType == typeof(Transform) || GraphInfo.IsLocalType(p))) { GraphEditor.SetPortSpec(p, PortSpecification.Owner); p.Value = null; } else { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } } } else if (parentNode.IsKindOfPackage) { if (p.IsInDataOrControlPort) { GraphEditor.SetPortSpec(p, PortSpecification.PublicVariable); } } else { GraphEditor.SetPortSpec(p, PortSpecification.LocalVariable); } }
// =================================================================== /// Refreshes the port specififcation of a connection. /// /// @param vsObject An object that is part of the connection. /// public static void RefreshPortSpec(iCS_EditorObject vsObject) { var producerPort = GraphInfo.GetProducerPort(vsObject); SetPortSpec(producerPort, producerPort.PortSpec); }