当前位置: 首页>>代码示例>>C#>>正文


C# MapObjects.MapObject类代码示例

本文整理汇总了C#中Sledge.DataStructures.MapObjects.MapObject的典型用法代码示例。如果您正苦于以下问题:C# MapObject类的具体用法?C# MapObject怎么用?C# MapObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MapObject类属于Sledge.DataStructures.MapObjects命名空间,在下文中一共展示了MapObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformOperation

        public void PerformOperation(MapObject mo)
        {
            mo.Transform(_transformation, _transformFlags);

            if (ClearVisgroups)
            {
                foreach (var o in mo.FindAll()) o.Visgroups.Clear();
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:9,代码来源:TransformEditOperation.cs

示例2: Unclone

 public override void Unclone(MapObject o)
 {
     PasteBase(o, null, true);
     var e = o as World;
     if (e == null) return;
     EntityData = e.EntityData.Clone();
     Paths.Clear();
     Paths.AddRange(e.Paths.Select(x => x.Clone()));
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:9,代码来源:World.cs

示例3: PerformOperation

 public void PerformOperation(MapObject mo)
 {
     var current = Extractor(mo.BoundingBox);
     var target = Extractor(_alignBox);
     var value = target - current;
     var translate = Creator(value);
     var transform = new UnitTranslate(translate);
     mo.Transform(transform, _transformFlags);
 }
开发者ID:silky,项目名称:sledge,代码行数:9,代码来源:AlignObjectsEditOperation.cs

示例4: Paste

 public override void Paste(MapObject o, IDGenerator generator)
 {
     PasteBase(o, generator);
     var e = o as World;
     if (e == null) return;
     EntityData = e.EntityData.Clone();
     Paths.Clear();
     Paths.AddRange(e.Paths.Select(x => x.Clone()));
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:9,代码来源:World.cs

示例5: UpdateModels

 private static void UpdateModels(Document document, MapObject mo)
 {
     mo.Children.ForEach(x => UpdateModels(document, x));
     var e = mo as Entity;
     if (e == null || !ShouldHaveModel(e)) return;
     var model = GetModelName(e);
     var file = document.Environment.Root.TraversePath(model);
     if (file == null) return;
     SetModel(e, ModelProvider.CreateModelReference(file));
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:10,代码来源:ModelExtensions.cs

示例6: Render2D

 public void Render2D(Viewport2D viewport, MapObject o)
 {
     if (Sledge.Settings.Select.CenterHandlesActiveViewportOnly && !viewport.IsFocused) return;
     var center = viewport.Flatten(o.BoundingBox.Center);
     double a = 192;
     if (Sledge.Settings.Select.CenterHandlesFollowCursor)
     {
         var dist = (double) (center - _mousePos).VectorMagnitude();
         if (dist >= _fadeDistance) return;
         a = 192 * ((_fadeDistance - dist) / _fadeDistance);
     }
     GL.Color4(Color.FromArgb((int) a, o.Colour));
     GL.Vertex2(center.DX - _offset, center.DY - _offset);
     GL.Vertex2(center.DX + _offset, center.DY + _offset);
     GL.Vertex2(center.DX - _offset, center.DY + _offset);
     GL.Vertex2(center.DX + _offset, center.DY - _offset);
 }
开发者ID:ChristopherHaws,项目名称:sledge,代码行数:17,代码来源:CenterHandlesHelper.cs

示例7: Render3D

        public void Render3D(Viewport3D vp, MapObject o)
        {
            var right = vp.Camera.GetRight();
            var up = Vector3.Cross(right, (vp.Camera.LookAt - vp.Camera.Location).Normalized());
            var entity = (Entity) o;

            var orig = new Vector3((float)entity.Origin.X, (float)entity.Origin.Y, (float)entity.Origin.Z);
            if (entity.IsSelected)
            {
                orig = Vector3.TransformPosition(orig, Document.SelectListTransform);
            }
            var normal = Vector3.Subtract(vp.Camera.Location, orig);

            var tex = entity.Sprite;
            GL.Color3(Color.White);
            tex.Bind();

            if (entity.GameData != null)
            {
                var col = entity.GameData.Properties.FirstOrDefault(x => x.VariableType == VariableType.Color255);
                if (col != null)
                {
                    var val = entity.EntityData.Properties.FirstOrDefault(x => x.Key == col.Name);
                    if (val != null)
                    {
                        GL.Color3(val.GetColour(Color.White));
                    }
                }
            }

            var tup = Vector3.Multiply(up, (float)entity.BoundingBox.Height / 2f);
            var tright = Vector3.Multiply(right, (float)entity.BoundingBox.Width / 2f);

            GL.Begin(PrimitiveType.Quads);

            GL.Normal3(normal); GL.TexCoord2(1, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(1, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Subtract(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Subtract(tup, tright)));

            GL.End();
        }
开发者ID:074769,项目名称:sledge,代码行数:42,代码来源:EntitySpriteHelper.cs

示例8: Render3D

        public void Render3D(Viewport3D vp, MapObject o)
        {
            // These billboards aren't perfect but they'll do (they rotate with the lookat vector rather than the location vector)

            var right = vp.Camera.GetRight();
            var up = vp.Camera.GetUp();
            var entity = (Entity) o;

            var orig = new Vector3((float)entity.Origin.X, (float)entity.Origin.Y, (float)entity.Origin.Z);
            var normal = Vector3.Subtract(vp.Camera.Location, orig);

            var tex = entity.Sprite;
            TextureHelper.EnableTexturing();
            GL.Color3(Color.White);
            tex.Bind();

            if (entity.GameData != null)
            {
                var col = entity.GameData.Properties.FirstOrDefault(x => x.VariableType == VariableType.Color255);
                if (col != null)
                {
                    var val = entity.EntityData.Properties.FirstOrDefault(x => x.Key == col.Name);
                    if (val != null)
                    {
                        GL.Color3(val.GetColour(Color.White));
                    }
                }
            }

            var tup = Vector3.Multiply(up, (float)entity.BoundingBox.Height / 2f);
            var tright = Vector3.Multiply(right, (float)entity.BoundingBox.Width / 2f);

            GL.Begin(BeginMode.Quads);

            GL.Normal3(normal); GL.TexCoord2(1, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(1, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Subtract(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Subtract(tup, tright)));

            GL.End();
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:41,代码来源:EntitySpriteHelper.cs

示例9: IsValidFor

 public bool IsValidFor(MapObject o)
 {
     return false;
 }
开发者ID:ChristopherHaws,项目名称:sledge,代码行数:4,代码来源:CordonHelper.cs

示例10: SetSelected

        /// <summary>
        /// Deselect (first) a list of objects and then select (second) another list.
        /// </summary>
        /// <param name="objectsToDeselect">The objects to deselect</param>
        /// <param name="objectsToSelect">The objects to select</param>
        /// <param name="deselectAll">If true, this will ignore the objectToDeselect parameter and just deselect everything</param>
        /// <param name="ignoreGrouping">If true, object groups will be ignored</param>
        private void SetSelected(IEnumerable<MapObject> objectsToDeselect, IEnumerable<MapObject> objectsToSelect, bool deselectAll, bool ignoreGrouping)
        {
            if (objectsToDeselect == null) objectsToDeselect = new MapObject[0];
            if (objectsToSelect == null) objectsToSelect = new MapObject[0];

            if (deselectAll)
            {
                objectsToDeselect = Document.Selection.GetSelectedObjects();
                _lastTool = null;
            }

            // Normalise selections
            objectsToDeselect = NormaliseSelection(objectsToDeselect.Where(x => x != null), ignoreGrouping);
            objectsToSelect = NormaliseSelection(objectsToSelect.Where(x => x != null), ignoreGrouping);

            // Don't bother deselecting the objects we're about to select
            objectsToDeselect = objectsToDeselect.Where(x => !objectsToSelect.Contains(x));

            // Perform selections
            var deselected = objectsToDeselect.ToList();
            var selected = objectsToSelect.ToList();

            Document.PerformAction("Selection changed", new ChangeSelection(selected, deselected));
        }
开发者ID:074769,项目名称:sledge,代码行数:31,代码来源:SelectTool.cs

示例11: Paste

 public override void Paste(MapObject o, IDGenerator generator)
 {
     PasteBase(o, generator);
     var e = o as Solid;
     if (e == null) return;
     Faces.Clear();
     foreach (var f in e.Faces.Select(x => x.Copy(generator)))
     {
         f.Parent = this;
         Faces.Add(f);
         f.UpdateBoundingBox();
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:13,代码来源:Solid.cs

示例12: IsValidFor

 public bool IsValidFor(MapObject o)
 {
     return o is Entity;
 }
开发者ID:074769,项目名称:sledge,代码行数:4,代码来源:EntityTextHelper.cs

示例13: Paste

 public override void Paste(MapObject o, IDGenerator generator)
 {
     PasteBase(o, generator);
     var e = o as Entity;
     if (e == null) return;
     GameData = e.GameData;
     Origin = e.Origin.Clone();
     EntityData = e.EntityData.Clone();
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:9,代码来源:Entity.cs

示例14: MouseDown

        private void MouseDown(Viewport3D vp, ViewportEvent e)
        {
            if (!_currentTool.NoSelection())
            {
                var vtxs = _currentTool.GetVerticesAtPoint(e.X, vp.Height - e.Y, vp);

                if (vtxs.Any())
                {
                    // Use the topmost vertex as the control point
                    var vtx = vtxs.First();

                    // Mouse down on a point
                    if (vtx.IsSelected && KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs))
                    {
                        // If the vertex is selected and ctrl is down, deselect the vertices
                        vtxs.ForEach(x => x.IsSelected = false);
                    }
                    else
                    {
                        if (!vtx.IsSelected && !KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs))
                        {
                            // If we aren't clicking on a selected point and ctrl is not down, deselect the others
                            Points.ForEach(x => x.IsSelected = false);
                            // If this point is already selected, don't deselect others. This is the same behaviour as 2D selection.
                        }
                        vtxs.ForEach(x => x.IsSelected = true);
                    }
                    VertexSelectionChanged();

                    // Don't do other click operations
                    return;
                }

                // Nothing clicked
                if (!KeyboardState.Ctrl)
                {
                    // Deselect all the points if not ctrl-ing
                    Points.ForEach(x => x.IsSelected = false);
                }
            }
            if (!_currentTool.No3DSelection())
            {
                // Do selection
                var ray = vp.CastRayFromScreen(e.X, e.Y);
                var hits = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray, true);
                var solid = hits
                    .OfType<Solid>()
                    .Select(x => new { Item = x, Intersection = x.GetIntersectionPoint(ray) })
                    .Where(x => x.Intersection != null)
                    .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                    .Select(x => x.Item)
                    .FirstOrDefault();

                if (solid != null)
                {
                    if (solid.IsSelected && KeyboardState.Ctrl)
                    {
                        // deselect solid
                        var select = new MapObject[0];
                        var deselect = new[] {solid};
                        Document.PerformAction("Deselect VM solid", new ChangeSelection(select, deselect));
                    }
                    else if (!solid.IsSelected)
                    {
                        // select solid
                        var select = new[] {solid};
                        var deselect = !KeyboardState.Ctrl ? Document.Selection.GetSelectedObjects() : new MapObject[0];
                        Document.PerformAction("Select VM solid", new ChangeSelection(select, deselect));
                    }

                    // Don't do other click operations
                    return;
                }
            }

            base.MouseDown(vp, e);
        }
开发者ID:074769,项目名称:sledge,代码行数:77,代码来源:VMTool.cs

示例15: Edit

 protected void Edit(MapObject before, Action<Document, MapObject> action)
 {
     _editObjects.Add(new EditReference(before, action));
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:4,代码来源:CreateEditDelete.cs


注:本文中的Sledge.DataStructures.MapObjects.MapObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。