public static void AttachEditorComponents(Entity result, ListProperty<Entity.Handle> target) { Transform transform = result.Get<Transform>(); Property<bool> selected = result.GetOrMakeProperty<bool>("EditorSelected"); Command<Entity> toggleEntityConnected = new Command<Entity> { Action = delegate(Entity entity) { if (target.Contains(entity)) target.Remove(entity); else if (entity != result) target.Add(entity); } }; result.Add("ToggleEntityConnected", toggleEntityConnected); LineDrawer connectionLines = new LineDrawer { Serialize = false }; connectionLines.Add(new Binding<bool>(connectionLines.Enabled, selected)); Color connectionLineColor = new Color(1.0f, 1.0f, 1.0f, 0.5f); ListBinding<LineDrawer.Line, Entity.Handle> connectionBinding = new ListBinding<LineDrawer.Line, Entity.Handle>(connectionLines.Lines, target, delegate(Entity.Handle entity) { return new LineDrawer.Line { A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor), B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(entity.Target.Get<Transform>().Position, connectionLineColor) }; }, x => x.Target != null && x.Target.Active); result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, selected)); result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, () => selected, transform.Position)); connectionLines.Add(connectionBinding); result.Add(connectionLines); }