/// <summary> /// A query selector for a specific entity. /// </summary> static public int QuerySelector(Rect inPosition, int inCurrentId, IRSEntity inEntity, RSTypeInfo inReturnType, bool inbNoParams, RSLibrary inLibrary) { RSEditorUtility.s_QueryElements.Clear(); inLibrary.GetAllQueriesForEntity(inEntity, RSEditorUtility.s_QueryElements, inReturnType, inbNoParams); return(RSGUI.RSElementSelector(inPosition, inCurrentId, RSEditorUtility.s_QueryElements)); }
/// <summary> /// A action selector for a specific entity. /// </summary> static public int ActionSelector(Rect inPosition, int inCurrentId, IRSEntity inEntity, RSLibrary inLibrary) { RSEditorUtility.s_ActionElements.Clear(); inLibrary.GetAllActionsForEntity(inEntity, RSEditorUtility.s_ActionElements); return(RSGUI.RSElementSelector(inPosition, inCurrentId, RSEditorUtility.s_ActionElements)); }
/// <summary> /// A query selector for a specific entity. /// </summary> static public int QuerySelector(GUIContent inLabel, int inCurrentId, IRSEntity inEntity, bool inbNoParams, RSLibrary inLibrary) { RSEditorUtility.s_QueryElements.Clear(); inLibrary.GetAllQueriesForEntity(inEntity, RSEditorUtility.s_QueryElements, null, inbNoParams); return(RSGUILayout.RSElementSelector(inLabel, inCurrentId, RSEditorUtility.s_QueryElements)); }
internal RSValidationContext(RSLibrary inLibrary, IRSEntityMgr inManager, IRSEntity inEntity, RSTriggerInfo inTrigger, RSParameterInfo inParameterInfo) { Library = inLibrary; Manager = inManager; Entity = inEntity; Trigger = inTrigger; Parameter = inParameterInfo; }
/// <summary> /// A trigger selector for a specific entity. /// </summary> static public RSTriggerId TriggerSelector(RSTriggerId inCurrentId, IRSEntity inEntity, RSTypeInfo inParameterType, RSLibrary inLibrary) { RSEditorUtility.s_TriggerElements.Clear(); inLibrary.GetAllTriggersForEntity(inEntity, RSEditorUtility.s_TriggerElements, inParameterType ?? RSBuiltInTypes.Void); inLibrary.GetAllGlobalTriggers(RSEditorUtility.s_TriggerElements, inParameterType ?? RSBuiltInTypes.Void); int trigger = RSGUILayout.RSElementSelector((int)inCurrentId, RSEditorUtility.s_TriggerElements); return(new RSTriggerId(trigger)); }
/// <summary> /// Outputs to a collection of queries directly associated with the given entity. /// </summary> public void GetAllQueriesForEntity(IRSEntity inEntity, ICollection <RSQueryInfo> outQueries, RSTypeInfo inReturnType = null, bool inbNoParams = false) { Assert.True(outQueries != null, "Cannot output queries to null collection"); Assert.True(inEntity != null, "Cannot get queries for null entity"); GetAllQueriesForType(m_EntityType, outQueries, inReturnType, inbNoParams); foreach (var component in inEntity.GetRSComponentTypes(this)) { Assert.True(component != null, "Null component"); GetAllQueriesForType(component, outQueries, inReturnType, inbNoParams); } }
/// <summary> /// Outputs to a collection of triggers directly associated with the given entity. /// </summary> public void GetAllTriggersForEntity(IRSEntity inEntity, ICollection <RSTriggerInfo> outTriggers, RSTypeInfo inParameterType = null) { Assert.True(outTriggers != null, "Cannot output triggers to null collection"); Assert.True(inEntity != null, "Cannot get triggers for null entity data"); GetAllTriggersForType(m_EntityType, outTriggers, inParameterType); foreach (var componentType in inEntity.GetRSComponentTypes(this)) { Assert.True(componentType != null, "Null component data"); GetAllTriggersForType(componentType, outTriggers, inParameterType); } }
/// <summary> /// Outputs to a collection of actions directly associated with the given entity. /// </summary> public void GetAllActionsForEntity(IRSEntity inEntity, ICollection <RSActionInfo> outActions) { Assert.True(outActions != null, "Cannot output actions to null collection"); Assert.True(inEntity != null, "Cannot get actions for null entity"); GetAllActionsForType(m_EntityType, outActions); foreach (var component in inEntity.GetRSComponentTypes(this)) { Assert.True(component != null, "Null component"); GetAllActionsForType(component, outActions); } }
static private EntityScopedIdentifier DoActionField(GUIContent inLabel, EntityScopedIdentifier inIdentifier, RSValidationFlags inFlags, RSValidationContext inContext) { EntityScopeData scope = inIdentifier.Scope; int actionId = inIdentifier.Id; using (new EditorGUILayout.VerticalScope()) { scope = EntityScopeField(inLabel, scope, inFlags.ForMethodScope(), inContext); using (new EditorGUI.IndentLevelScope()) { switch (scope.Type) { case EntityScopeType.Global: actionId = LibraryGUILayout.ActionSelectorGlobal(Content.ActionIdLabel, actionId, inContext.Library); break; case EntityScopeType.Null: EditorGUILayout.HelpBox("Cannot perform action on null entity", MessageType.Error); break; case EntityScopeType.Invalid: EditorGUILayout.HelpBox("Cannot perform action on missing entity", MessageType.Error); break; case EntityScopeType.Self: { if (inFlags.Has(RSValidationFlags.FilterSelection) && !scope.HasLinks() && inContext.Entity != null) { actionId = LibraryGUILayout.ActionSelector(Content.ActionIdLabel, actionId, inContext.Entity, inContext.Library); } else { actionId = LibraryGUILayout.ActionSelectorUnknown(Content.ActionIdLabel, actionId, inContext.Library); } break; } case EntityScopeType.ObjectById: { RSEntityId entityId = scope.IdArg; IRSEntity entity = null; if (inFlags.Has(RSValidationFlags.FilterSelection) && entityId != RSEntityId.Null && !scope.HasLinks() && inContext.Manager != null && (entity = inContext.Manager.Lookup.EntityWithId(entityId)) != null) { actionId = LibraryGUILayout.ActionSelector(Content.ActionIdLabel, actionId, entity, inContext.Library); } else { actionId = LibraryGUILayout.ActionSelectorUnknown(Content.ActionIdLabel, actionId, inContext.Library); } break; } default: actionId = LibraryGUILayout.ActionSelectorUnknown(Content.ActionIdLabel, actionId, inContext.Library); break; } if (actionId == 0) { EditorGUILayout.HelpBox("Cannot perform null action", MessageType.Error); } } } return(new EntityScopedIdentifier(scope, actionId)); }
/// <summary> /// A trigger selector for a specific entity. /// </summary> static public RSTriggerId TriggerSelector(Rect inPosition, GUIContent inLabel, RSTriggerId inCurrentId, IRSEntity inEntity, RSLibrary inLibrary) { RSEditorUtility.s_TriggerElements.Clear(); inLibrary.GetAllTriggersForEntity(inEntity, RSEditorUtility.s_TriggerElements); inLibrary.GetAllGlobalTriggers(RSEditorUtility.s_TriggerElements); int trigger = RSGUI.RSElementSelector(inPosition, inLabel, (int)inCurrentId, RSEditorUtility.s_TriggerElements); return(new RSTriggerId(trigger)); }
/// <summary> /// Converts a C# object to an RSValue. /// </summary> static public RSValue ToRSValue(object inObject) { if (inObject == null) { return(RSValue.Null); } Type objType = inObject.GetType(); if (objType == typeof(RSValue)) { return((RSValue)inObject); } if (objType.IsEnum) { return(RSValue.FromEnum((Enum)inObject)); } switch (Type.GetTypeCode(objType)) { case TypeCode.Boolean: return(RSValue.FromBool((bool)inObject)); case TypeCode.Byte: return(RSValue.FromInt((byte)inObject)); case TypeCode.Char: return(RSValue.FromInt((char)inObject)); case TypeCode.Double: Log.Warn("[RSInterop] Truncation from Double to Single"); return(RSValue.FromFloat((float)(double)inObject)); case TypeCode.Int16: return(RSValue.FromInt((Int16)inObject)); case TypeCode.Int32: return(RSValue.FromInt((Int32)inObject)); case TypeCode.SByte: return(RSValue.FromInt((sbyte)inObject)); case TypeCode.Single: return(RSValue.FromFloat((float)inObject)); case TypeCode.String: return(RSValue.FromString((string)inObject)); case TypeCode.UInt16: return(RSValue.FromInt((UInt16)inObject)); case TypeCode.UInt32: Log.Warn("[RSInterop] Truncation from UInt32 to Int32"); return(RSValue.FromInt((int)(UInt32)inObject)); case TypeCode.UInt64: Log.Warn("[RSInterop] Truncation from UInt64 to Int32"); return(RSValue.FromInt((int)(UInt64)inObject)); case TypeCode.Object: { if (objType == typeof(Color)) { return(RSValue.FromColor((Color)inObject)); } if (objType == typeof(Vector2)) { return(RSValue.FromVector2((Vector2)inObject)); } if (objType == typeof(Vector3)) { return(RSValue.FromVector3((Vector3)inObject)); } if (objType == typeof(Vector4)) { return(RSValue.FromVector4((Vector4)inObject)); } if (objType == typeof(RSGroupId)) { return(RSValue.FromGroupId((RSGroupId)inObject)); } if (objType == typeof(RSTriggerId)) { return(RSValue.FromTriggerId((RSTriggerId)inObject)); } if (typeof(IRSEntity).IsAssignableFrom(objType)) { IRSEntity entity = (IRSEntity)inObject; EntityScopeData scope = EntityScopeData.Entity(entity.Id); return(RSValue.FromEntity(scope)); } break; } } throw new ArgumentException(string.Format("Unable to convert object of type {0} to RSValue", objType.Name), "inObject"); }
static public EntityRef FromEntity(IRSEntity inEntity) { return(new EntityRef(inEntity == null ? RSEntityId.Null : inEntity.Id, null, null)); }
private void RegenContext(bool inbForce = false) { if (!inbForce && Event.current.type != EventType.Layout) { return; } m_SelfUndoTarget = new UndoTarget(this, "RuleTableEditor"); m_TargetState.Refresh(); if (m_TargetState.SelectedObject == null) { m_TargetState.Clear(); m_SelectionState.ClearAll(); return; } if (m_TargetState.SelectedObject != null && m_SelectionState.Source == null) { IRSRuleTableSource tableSource; if (!RSEditorUtility.EditorPlugin.TryGetRuleTable(m_TargetState.SelectedObject, out tableSource)) { m_TargetState.Clear(); m_SelectionState.ClearAll(); return; } if (tableSource.TableData == null) { m_TargetState.Clear(); m_SelectionState.ClearAll(); return; } m_SelectionState.Source = tableSource; m_SelectionState.Table = tableSource.TableData; bool bCleanUpChanged = TableUtils.CleanUp(tableSource.TableData); if (bCleanUpChanged) { m_TargetState.UndoTarget.MarkDirtyWithoutUndo("Cleaned up Rule Table data"); } } m_SelectionState.Refresh(); m_Context = m_Context.WithLibrary(RSEditorUtility.EditorPlugin.Library); IRSEntity entity = null; if (m_TargetState.SelectedObject) { RSEditorUtility.EditorPlugin.TryGetEntity(m_TargetState.SelectedObject, out entity); } m_Context = m_Context.WithEntity(entity); IRSEntityMgr manager = null; if (manager == null || m_TargetState.SelectedObject) { RSEditorUtility.EditorPlugin.TryGetEntityManager(m_TargetState.SelectedObject, out manager); } m_Context = m_Context.WithManager(manager); }
public bool TryGetEntity(Object inObject, out IRSEntity outEntity) { outEntity = null; return(false); }
public RSValidationContext WithEntity(IRSEntity inEntity) { return(new RSValidationContext(Library, Manager, inEntity, Trigger, Parameter)); }