private bool DetermineIfShouldShowStates(NamedObjectSave instance) { IElement referencedEntitySave = instance.GetReferencedElement(); bool shouldRemove = referencedEntitySave == null; if (referencedEntitySave != null) { shouldRemove = true; IElement element = referencedEntitySave; while (element != null) { if (element.States.Count != 0) { shouldRemove = false; break; } else { element = ObjectFinder.Self.GetIElement(element.BaseElement); } } } return(!shouldRemove); }
public static void WriteSetStateOnNamedObject(NamedObjectSave namedObject, ICodeBlock codeBlock) { if (!string.IsNullOrEmpty(namedObject.CurrentState)) { IElement referencedElement = namedObject.GetReferencedElement(); if (referencedElement != null && referencedElement.GetUncategorizedStatesRecursively().Count != 0) { string qualifiedName = NamedObjectSaveCodeGenerator.GetQualifiedTypeName(namedObject); string lineToAdd = namedObject.FieldName + ".CurrentState = " + qualifiedName + ".VariableState." + namedObject.CurrentState + ";"; codeBlock.Line(lineToAdd); } } }
public static bool GetIfCanBeReferencedByRelationship(NamedObjectSave nos) { if (nos == null) { throw new ArgumentNullException(nameof(nos)); } var nosElement = nos.GetReferencedElement(); var nosAti = nos.GetAssetTypeInfo(); var entity = nosElement as EntitySave; var shouldConsider = false; if (entity?.ImplementsICollidable == true) { shouldConsider = true; } if (!shouldConsider) { // See if it's a list of ICollidables shouldConsider = nos != null && nos.SourceType == SourceType.FlatRedBallType && nos.SourceClassType == "PositionedObjectList<T>" && !string.IsNullOrEmpty(nos.SourceClassGenericType) && ObjectFinder.Self.GetEntitySave(nos.SourceClassGenericType)?.ImplementsICollidable == true; } if (!shouldConsider) { shouldConsider = nosAti?.QualifiedRuntimeTypeName.QualifiedType == "FlatRedBall.TileCollisions.TileShapeCollection"; } if (!shouldConsider) { shouldConsider = nosAti?.QualifiedRuntimeTypeName.QualifiedType == "FlatRedBall.Math.Geometry.ShapeCollection"; } return(shouldConsider); }
public static void FillPossibleStatesFor(List <string> listToFill, string selectedItemName, NamedObjectSave currentNamedObject) { IElement element = currentNamedObject.GetReferencedElement(); while (element != null) { IEnumerable <StateSave> stateList = element.States; // Let's see if this element has a variable by this name CustomVariable foundVariable = element.GetCustomVariableRecursively(selectedItemName); if (foundVariable != null) { FillPossibleStatesFor(listToFill, element, foundVariable); break; } else { listToFill.Add("<NONE>"); bool useDefaultStateList = selectedItemName == "CurrentVariableState" || (foundVariable == null && selectedItemName == "CurrentState"); if (useDefaultStateList) { foreach (StateSave state in element.States) { listToFill.Add(state.Name); } foreach (StateSaveCategory ssc in element.StateCategoryList) { if (ssc.SharesVariablesWithOtherCategories) { foreach (StateSave state in ssc.States) { listToFill.Add(state.Name); } } } } else { if (!useDefaultStateList) { string stateCategory = ""; if (foundVariable != null) { stateCategory = foundVariable.Type; } else { stateCategory = StateSaveExtensionMethods.GetStateTypeFromCurrentVariableName(selectedItemName); } StateSaveCategory category = element.GetStateCategory(stateCategory); if (category != null) { stateList = category.States; } } foreach (StateSave state in stateList) { listToFill.Add(state.Name); } } element = ObjectFinder.Self.GetIElement(element.BaseElement); } } }