protected override void FilterAddObjectTree(MyPrefabSnapPoint myPrefabSnapPoint) { if (IsFilterChanged(myPrefabSnapPoint)) { FilterAddObjectTreePrivate(myPrefabSnapPoint); } }
private bool IsFilterChanged(MyPrefabSnapPoint myPrefabSnapPoint) { return(myPrefabSnapPoint != m_activeSnapPointFilter || m_filterTextbox.Text != m_activeTextFilter || m_checkboxOnlyItemsOnWhichHasBlueprints.Checked != m_activeItemsOnWhichHasBlueprintsFilter || m_checkboxOnlyItemsOnWhichHasOre.Checked != m_activeItemsOnWhichHasOreFilter || m_checkboxOnlyItemsWhichHasBuild.Checked != m_activeItemsWhichHasBuildFilter); }
private void FilterAddObjectTreePrivate(MyPrefabSnapPoint myPrefabSnapPoint) { m_activeSnapPointFilter = myPrefabSnapPoint; m_activeTextFilter = m_filterTextbox.Text; m_activeItemsOnWhichHasBlueprintsFilter = m_checkboxOnlyItemsOnWhichHasBlueprints.Checked; m_activeItemsOnWhichHasOreFilter = m_checkboxOnlyItemsOnWhichHasOre.Checked; m_activeItemsWhichHasBuildFilter = m_checkboxOnlyItemsWhichHasBuild.Checked; m_addObjectTreeView.FilterTree(item => { return(FilterResultByText(item) && FilterResultByItemAndPrefabSnapPoint(item) && FilterResultByItemOnWhichHasBlueprints(item) && FilterResultByItemOnWhichHasOre(item) && FilterResultByBuildItem(item)); }); }
public MySnapPointLink(MyPrefabSnapPoint snapPoint) { SnapPoint = snapPoint; LinkTransformation = snapPoint.Prefab.WorldMatrix; }
protected abstract void FilterAddObjectTree(MyPrefabSnapPoint myPrefabSnapPoint);
protected override void FilterAddObjectTree(MyPrefabSnapPoint myPrefabSnapPoint) { if (myPrefabSnapPoint != m_activeSnapPointFilter || m_filterTextbox.Text != m_activeTextFilter || MyEditor.Static.SnapPointFilter != m_savedSnapPointFilter/* || MyEditor.GetCurrentState() == MyEditorStateEnum.SELECTED_WAYPOINT*/) { m_activeSnapPointFilter = myPrefabSnapPoint; m_activeTextFilter = m_filterTextbox.Text; m_savedSnapPointFilter = MyEditor.Static.SnapPointFilter; m_addObjectTreeView.FilterTree(item => { /* // filter by waypoint if(MyEditor.GetCurrentState() == MyEditorStateEnum.SELECTED_WAYPOINT){ if( string.Compare(item.Text.ToString(), "WayPoint") == 0) return true; else return false; } */ // Filter by text if (!string.IsNullOrEmpty(m_activeTextFilter)) { if (item.ToolTip == null) { return false; } var toolTips = item.ToolTip.GetToolTips(); if (toolTips.Count == 0 || toolTips[0].Text.ToString().IndexOf(m_activeTextFilter, StringComparison.InvariantCultureIgnoreCase) == -1) { return false; } } // Filter by snap point if (!MyEditor.Static.SnapPointFilter || myPrefabSnapPoint == null) { // Always pass if snap point filter is disabled or no snap point selected return true; } var tag = item.Tag as PrefabTag; if (tag != null) { var snapPoints = MyEditor.GetPrefabSnapPoints(tag.PrefabModule, tag.PrefabId); return snapPoints.Exists(a => myPrefabSnapPoint.CanAttachTo(a)); } return false; }); } }
public static List<MyPrefabSnapPoint> GetSnapPoints(MyModel model, MyPrefabBase prefab) { List<MyPrefabSnapPoint> snapPoints = new List<MyPrefabSnapPoint>(); foreach (var dummy in model.Dummies) { if (dummy.Key.StartsWith("SNAPPOINT", StringComparison.InvariantCultureIgnoreCase)) { var customData = dummy.Value.CustomData; var snapPoint = new MyPrefabSnapPoint(prefab); // Get rid of scale in rotation part snapPoint.Matrix = Matrix.CreateWorld(dummy.Value.Matrix.Translation, dummy.Value.Matrix.Forward, dummy.Value.Matrix.Up); snapPoint.SnapType = new MyPrefabSnapPoint.MyPrefabSnapPointType("OBJECT_", "", dummy.Value.CustomData); snapPoint.Name = dummy.Key; snapPoints.Add(snapPoint); string targetPostfix = "TARGET_BUILD_TYPE"; foreach (var target in customData) { if (target.Key.StartsWith(targetPostfix)) { string postfix = target.Key.Substring(targetPostfix.Length); snapPoint.SnapTargets.Add(new MyPrefabSnapPoint.MyPrefabSnapPointType( "TARGET_", postfix, dummy.Value.CustomData)); } } } } return snapPoints; }