public override void SetParameter(MethodDef.Param param, object obj) { base.SetParameter(param, obj); _resetProperties = false; Behaviac.Design.Attachments.Attach evt = obj as Behaviac.Design.Attachments.Attach; Behaviac.Design.Nodes.BaseNode baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode; Behaviac.Design.Nodes.Behavior behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null; _agentType = (behavior != null) ? behavior.AgentType : null; if (!string.IsNullOrEmpty(_globalType)) { _agentType = Plugin.GetInstanceAgentType(_globalType); } string selectionName = string.Empty; VariableDef variable = param.Value as VariableDef; if (variable != null) { selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName; } else { RightValueDef variableRV = param.Value as RightValueDef; if (variableRV != null) { selectionName = variableRV.DisplayName; } } setComboBox(selectionName); }
public override object FromStringValue(List <Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str) { if (type != typeof(RightValueDef)) { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); } if (str.Length == 0 || str.Length == 2 && str == "\"\"") { return(null); } if (!str.StartsWith("const")) { int pos = str.IndexOf('('); if (pos < 0) { VariableDef var = DesignerPropertyEnum.parsePropertyVar(result, node, str); return(new RightValueDef(var)); } else { Behaviac.Design.Nodes.Behavior behavior = node.Behavior as Behaviac.Design.Nodes.Behavior; AgentType agentType = (behavior != null) ? behavior.AgentType : null; string valueClass = VariableDef.kSelfMethod; MethodDef method = DesignerMethodEnum.parseMethodString(result, node, agentType, this.MethodType, str); if (method == null) { string className = Plugin.GetClassName(str); method = DesignerMethodEnum.parseMethodString(result, node, Plugin.GetInstanceAgentType(className), this.MethodType, str); valueClass = className + VariableDef.kMethod; } string instanceName = Plugin.GetInstanceName(str); if (!string.IsNullOrEmpty(instanceName)) { valueClass = instanceName + VariableDef.kMethod; } return(new RightValueDef(method, valueClass)); } } else { VariableDef var = this.parseConstVar(result, node, parentObject, str); if (var != null) { return(new RightValueDef(var)); } } return(null); }
private List <MethodDef> getMethods() { List <MethodDef> methods = new List <MethodDef>(); Behaviac.Design.Attachments.Attach evt = _object as Behaviac.Design.Attachments.Attach; Behaviac.Design.Nodes.BaseNode baseNode = (evt != null) ? evt.Node : _object as Behaviac.Design.Nodes.BaseNode; if (baseNode == null) { baseNode = this._root; } Behaviac.Design.Nodes.Behavior behavior = null; if (baseNode != null) { behavior = baseNode.Behavior as Behaviac.Design.Nodes.Behavior; } AgentType agentType = null; if (behavior != null && behavior.AgentType != null) { agentType = behavior.AgentType; } object action = _property.Property.GetValue(_object, null); RightValueDef varRV = action as RightValueDef; if (varRV != null && Plugin.IsInstanceName(varRV.ValueClassReal)) { agentType = Plugin.GetInstanceAgentType(varRV.ValueClassReal); } if (agentType != null) { DesignerRightValueEnum enumAttRV = _property.Attribute as DesignerRightValueEnum; DesignerMethodEnum attrMethod = _property.Attribute as DesignerMethodEnum; MethodType methodType = attrMethod != null ? attrMethod.MethodType : MethodType.Getter; if (enumAttRV != null) { methodType = enumAttRV.MethodType; } IList <MethodDef> actions = agentType.GetMethods(methodType); foreach (MethodDef actionType in actions) { if (Plugin.IsCompatibleType(this.FilterType, actionType.ReturnType, false)) { methods.Add(actionType); } } } return(methods); }
public static VariableDef setParameter(List <Nodes.Node.ErrorCheck> result, DefaultObject node, string propertyName) { Behaviac.Design.Nodes.Behavior behavior = node.Behavior as Behaviac.Design.Nodes.Behavior; // Convert the Par to the Property if (!propertyName.Contains(".") && !propertyName.Contains(":")) { propertyName = "Self." + behavior.AgentType.AgentTypeName + "::" + propertyName; } VariableDef var = null; string instance = Plugin.GetInstanceName(propertyName); if (!string.IsNullOrEmpty(instance)) { propertyName = propertyName.Substring(instance.Length + 1, propertyName.Length - instance.Length - 1); var = createVariable(result, node, behavior.AgentType, instance, propertyName); if (var != null) { return(var); } } // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { instance = "Self"; var = createVariable(result, node, behavior.AgentType, instance, propertyName); if (var != null) { return(var); } } // Try to find the global property with the name. string instacneName = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(instacneName) && Plugin.GetInstanceAgentType(instacneName) != null) { var = createVariable(result, node, behavior.AgentType, instacneName, propertyName); if (var != null) { return(var); } } return(null); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); _resetMethods = false; DesignerMethodEnum enumAtt = property.Attribute as DesignerMethodEnum; if (enumAtt != null && property.Property.PropertyType == null) { throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name)); } Behaviac.Design.Attachments.Attach evt = obj as Behaviac.Design.Attachments.Attach; Behaviac.Design.Nodes.BaseNode baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode; Behaviac.Design.Nodes.Behavior behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null; if (behavior == null && this._root != null) { behavior = this._root.Behavior as Behaviac.Design.Nodes.Behavior; } _agentType = (behavior != null) ? behavior.AgentType : null; object action = property.Property.GetValue(obj, null); MethodDef method = action as MethodDef; int typeIndex = -1; if (method != null) { typeIndex = getTypeIndex(method.Owner); } if (typeIndex < 0) { typeIndex = 0; } // Keep only one type for efficiency. _currentNames.Clear(); _currentNames.Add(_names[typeIndex]); this.typeComboBox.Items.Clear(); this.typeComboBox.Items.Add(_types[typeIndex]); this.typeComboBox.SelectedIndex = 0; }
public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly) { base.SetParameter(param, obj, bReadonly); _resetProperties = false; Behaviac.Design.Attachments.Attach evt = obj as Behaviac.Design.Attachments.Attach; Behaviac.Design.Nodes.BaseNode baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode; Behaviac.Design.Nodes.Behavior behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null; string selectionName = string.Empty; VariableDef variable = param.Value as VariableDef; if (variable != null) { _valueOwner = variable.ValueClass; selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName; } else { RightValueDef variableRV = param.Value as RightValueDef; if (variableRV != null) { _valueOwner = variableRV.ValueClassReal; selectionName = variableRV.DisplayName; } } _agentType = (behavior != null) ? behavior.AgentType : null; if (_valueOwner != VariableDef.kSelf) { _agentType = Plugin.GetInstanceAgentType(_valueOwner); } setComboBox(selectionName); }
static public VariableDef setParameter(NodeTag.DefaultObject node, string propertyName) { Behaviac.Design.Nodes.Behavior behavior = node.Behavior as Behaviac.Design.Nodes.Behavior; string instance = Plugin.GetInstanceName(propertyName); if (!string.IsNullOrEmpty(instance)) { propertyName = propertyName.Substring(instance.Length + 1, propertyName.Length - instance.Length - 1); VariableDef var = createVariable(behavior.AgentType, instance, propertyName); if (var != null) { return(var); } } // Try to find the Par parameter with the name. List <ParInfo> allPars = new List <ParInfo>(); ((Nodes.Node)behavior).GetAllPars(ref allPars); if (allPars.Count > 0) { foreach (ParInfo p in allPars) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { VariableDef var = new VariableDef(p); var.SetValue(p, VariableDef.kPar); return(var); } } } // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { IList <PropertyDef> properties = behavior.AgentType.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(new VariableDef(p, VariableDef.kSelf)); } } } // Try to find the World property with the name. string instacneName = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(instacneName) && Plugin.GetInstanceAgentType(instacneName) != null) { IList <PropertyDef> properties = Plugin.GetInstanceAgentType(instacneName).GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(new VariableDef(p, instacneName)); } } } return(null); }
private string getValueType(MethodDef.Param param, string propertyName) { if (param.IsLocalVar) { Behaviac.Design.Nodes.Node node = _object as Behaviac.Design.Nodes.Node; if (node == null) { Attachments.Attachment attach = (_object as Attachments.Attachment); if (attach != null) { node = attach.Node; } } Behaviac.Design.Nodes.Behavior behavior = (node != null) ? node.Behavior as Behaviac.Design.Nodes.Behavior : null; // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { IList <PropertyDef> properties = behavior.AgentType.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kSelf); } } } // Try to find the global property with the name. string className = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(className)) { AgentType agent = Plugin.GetInstanceAgentType(className); if (agent != null) { IList <PropertyDef> properties = agent.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(className); } } } } } return(VariableDef.kConst); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); _resetProperties = false; Type enumtype = null; DesignerPropertyEnum enumAtt = property.Attribute as DesignerPropertyEnum; if (enumAtt != null) { enumtype = property.Property.PropertyType; } if (enumtype == null) { throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name)); } Behaviac.Design.Attachments.Attach evt = obj as Behaviac.Design.Attachments.Attach; Behaviac.Design.Nodes.BaseNode baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode; Behaviac.Design.Nodes.Behavior behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null; if (behavior == null && this._root != null) { behavior = this._root.Behavior as Behaviac.Design.Nodes.Behavior; } _agentType = null; if (behavior != null) { _agentType = behavior.AgentType; if (_agentType == null) { return; } } object propertyMember = property.Property.GetValue(obj, null); VariableDef variable = propertyMember as VariableDef; RightValueDef variableRV = propertyMember as RightValueDef; if (variable != null && variable.ValueClass != VariableDef.kSelf) { _agentType = Plugin.GetInstanceAgentType(variable.ValueClass); } if (variableRV != null && variableRV.ValueClassReal != VariableDef.kSelf) { string gloablClass = variableRV.ValueClassReal; _agentType = Plugin.GetInstanceAgentType(gloablClass); } string selectionName = string.Empty; if (variable != null && variable.Property != null) { selectionName = variable.Property.DisplayName; } else if (variableRV != null && variableRV.Var != null && variableRV.Var.Property != null) { selectionName = variableRV.Var.Property.DisplayName; } this.FilterType = null; if (enumAtt != null) { if (enumAtt.DependedProperty != "") { Type objType = _object.GetType(); PropertyInfo pi = objType.GetProperty(enumAtt.DependedProperty); object propMember = pi.GetValue(obj, null); VariableDef var = propMember as VariableDef; if (var != null) { this.FilterType = var.GetValueType(); } else { MethodDef method = propMember as MethodDef; if (method != null) { this.FilterType = method.ReturnType; } else { RightValueDef varRV = propMember as RightValueDef; if (varRV != null) { this.FilterType = varRV.ValueType; } } } } else { this.FilterType = enumAtt.FilterType; } } setComboBox(selectionName); //after the left is changed, the right might need to be invalidated if (this.comboBox.Text != selectionName) { property.Property.SetValue(_object, null, null); } }
private string getValueType(string propertyName) { Behaviac.Design.Nodes.Node node = _object as Behaviac.Design.Nodes.Node; Behaviac.Design.Nodes.Behavior behavior = (node != null) ? node.Behavior as Behaviac.Design.Nodes.Behavior : null; if (behavior != null) { // Try to find the Par parameter with the name. List <ParInfo> allPars = new List <ParInfo>(); ((Nodes.Node)behavior).GetAllPars(ref allPars); if (allPars.Count > 0) { foreach (ParInfo p in allPars) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kPar); } } } } // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { IList <PropertyDef> properties = behavior.AgentType.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kSelf); } } } // Try to find the World property with the name. string className = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(className)) { AgentType agent = Plugin.GetInstanceAgentType(className); if (agent != null) { IList <PropertyDef> properties = agent.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(className); } } } } return(VariableDef.kConst); }