private void DrawTagSelection(Constraint constraint, TagTarget target) { EditorGUILayout.BeginHorizontal(); constraint.RawTags = EditorGUILayout.TextField("Containing tag(s)", constraint.RawTags); if (GUILayout.Button(constraint.TagMethod.ToString(), GUILayout.Width(32))) { constraint.ToggleTagMethod(); } GUI.SetNextControlName("PlusButton"); if (GUILayout.Button("+", GUILayout.Width(20))) { GUI.FocusControl("PlusButton"); List <string> userTags = new List <string>(); string[] allUserTags = ChunkTags.GlobalUserTags(target); //Filtering all tags that are already used allUserTags.ToList() .Where(s => !constraint.ParsedTags.Contains(s)).ToList() .ForEach(s => userTags.Add(s)); TagContextMenu(userTags, constraint); //selectedTag = EditorGUILayout.GetControlRect(selectedTag, userTags); //constraint.RawTags += ";" + userTags[selectedTag]; } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField(" ", "(Separated by semicolons)"); }
private List <TagInstance> FindChunkTags() { ChunkTags chunkTags = chunk.GetComponent <ChunkTags> (); if (chunkTags != null) { return(chunkTags.Tags); } return(new List <TagInstance> (0)); }
public HallwayTemplateMeta(GameObject parent) { this.atMostConstraints = new List <Constraint> (); this.defaultSortingIndex = Random.value * .5f; this.parent = parent; this.child = Child; this.tags = child.GetComponent <ChunkTags> (); HallwayPrototype prototype = parent.GetComponent <HallwayPrototype> (); this.mask = prototype.Mask; }
private bool IsFuzzySatisfied(ChunkTags chunkTags) { if (chunkTags != null) { List <TagInstance> autoTags = chunkTags.autoGenerated; //Find the tag instance of the chunk with by the name defined in the GUI //It's value is then compared with min and max TagInstance toTest = autoTags.Find(ti => ti.Descriptor == fuzzyTagName); return(toTest.Value <= Max && toTest.Value >= Min); } return(true); }
private bool IsUserTagsSatisfied(ChunkTags chunkTags) { IEnumerable <string> userTags = chunkTags.userGenerated.Select(ct => ct.Name); if (tagMethod == TagComparisonMethod.And) { return(parsedTags.All(pt => userTags.Contains(pt))); } else { return(parsedTags.Any(pt => userTags.Contains(pt))); } }
//Returns, wether a constraint has beend satisfied. //Detects whether this is a user or fuzzy tag private bool ConstraintResult(ChunkTags chunkTags) { bool result; if (type == ConstraintType.FuzzyProperties) { result = IsFuzzySatisfied(chunkTags); } else { result = IsUserTagsSatisfied(chunkTags); } return(result); }
//Used only for Chunks by the ChunkHelper Class public bool IsConstraintSatisfied(ChunkMetadata meta, ChunkHelperProgress progress) { ChunkTags chunkTags = meta.Chunk.GetComponent <ChunkTags> (); bool result = ConstraintResult(chunkTags); if (amount == ConstraintAmount.None) { //Eventhough the amount is none, we don't want to return false //If the result was true, meaning the constraint applies to this chunk, we want to negate it to false //This will result in the chunk not being used. If the result was false before, this means that this constraint //Doesn't apply to the given chunk, meaning, that we don't want to affect it's creation by returning false, thus returning true result = !result; } else if (amount != ConstraintAmount.All) { result = HandleRoomAmount(meta, progress, result); } return(result); }
void OnEnable() { tags = target as ChunkTags; }
//Used to check for all masks that are effected by this constraint public bool IsAffectedByConstraints(ChunkTags tags) { return(ConstraintResult(tags)); }