public override void AttachEditorComponents(Entity result, Main main) { Model model = new Model(); model.Filename.Value = "Models\\light"; model.Add(new Binding<Vector3>(model.Color, result.Get<DirectionalLight>().Color)); model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); }
public override Entity Create(Main main) { Entity result = new Entity(main, "Skybox"); Transform transform = new Transform(); result.Add("Transform", transform); Model skybox = new Model(); skybox.Filename.Value = "Models\\skybox"; skybox.CullBoundingBox.Value = false; result.Add("Skybox", skybox); return result; }
public override void AttachEditorComponents(Entity result, Main main) { Model model = new Model(); model.Filename.Value = "Models\\sphere"; model.IsInstanced.Value = false; model.Add(new Binding<Vector3>(model.Color, result.Get<AmbientLight>().Color)); model.Scale.Value = new Vector3(0.5f); model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); }
public static void AttachEditorComponents(Entity result, Main main, Property<Vector3> color = null) { Model model = new Model(); model.Filename.Value = "Models\\cone"; if (color != null) model.Add(new Binding<Vector3>(model.Color, color)); model.Add(new Binding<bool>(model.Enabled, result.GetOrMakeProperty<bool>("EditorSelected"))); model.Add(new Binding<Vector3, float>(model.Scale, x => new Vector3(1.0f, 1.0f, x), result.GetOrMakeProperty<float>("AttachmentOffset", true))); model.Editable = false; model.Serialize = false; result.Add("EditorModel2", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); }
public override void AttachEditorComponents(Entity result, Main main) { Model model = new Model(); model.Filename.Value = "Models\\light"; model.Color.Value = this.Color; model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); PlayerTrigger.AttachEditorComponents(result, main, this.Color); MapAttachable.AttachEditorComponents(result, main); }
public override void AttachEditorComponents(Entity result, Main main) { base.AttachEditorComponents(result, main); Model model = new Model(); model.Filename.Value = "Models\\cone"; model.Color.Value = this.Color; model.IsInstanced.Value = false; model.Editable = false; model.Serialize = false; result.Add("EditorModel2", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); }
public override void AttachEditorComponents(Entity result, Main main) { Model model = new Model(); model.Filename.Value = "Models\\light"; model.Color.Value = this.Color; model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); Transform transform = result.Get<Transform>(); Property<Direction> dir = result.GetProperty<Direction>("Direction"); model.Add(new Binding<Matrix>(model.Transform, delegate() { Vector3 pos = transform.Position; return PlatformFactory.rotationMatrices[(int)dir.Value] * Matrix.CreateTranslation(pos); }, transform.Position, dir)); }
public override void AttachEditorComponents(Entity result, Main main) { Model model = new Model(); model.Filename.Value = "Models\\light"; Property<Vector3> color = result.Get<SpotLight>().Color; model.Add(new Binding<Vector3>(model.Color, color)); model.Add(new Binding<Matrix>(model.Transform, result.Get<Transform>().Matrix)); model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); model.Add(new Binding<Matrix>(model.Transform, delegate(Matrix x) { x.Forward *= -1.0f; return x; }, result.Get<Transform>().Matrix)); MapAttachable.AttachEditorComponents(result, main, color); }
public override Entity Create(Main main) { Entity result = new Entity(main, "Editor"); result.Serialize = false; Editor editor = new Editor(); EditorUI ui = new EditorUI { Editable = false }; Model model = new Model { Editable = false, Filename = new Property<string> { Value = "Models\\selector" }, Scale = new Property<Vector3> { Value = new Vector3(0.5f) } }; UIRenderer uiRenderer = new UIRenderer { Editable = false }; FPSInput input = new FPSInput { Editable = false }; input.EnabledWhenPaused.Value = true; AudioListener audioListener = new AudioListener { Editable = false }; Scroller scroller = new Scroller(); scroller.Position.Value = new Vector2(10, 10); scroller.AnchorPoint.Value = new Vector2(0, 0); scroller.ResizeHorizontal.Value = true; scroller.Name.Value = "Scroller"; uiRenderer.Root.Children.Add(scroller); ListContainer uiList = new ListContainer(); uiList.Name.Value = "PropertyList"; uiList.AnchorPoint.Value = new Vector2(0, 0); scroller.Children.Add(uiList); Container popup = new Container(); popup.Name.Value = "Popup"; popup.Opacity.Value = 0.5f; popup.Tint.Value = Microsoft.Xna.Framework.Color.Black; uiRenderer.Root.Children.Add(popup); ListContainer popupLayout = new ListContainer(); popup.Children.Add(popupLayout); Container popupSearchContainer = new Container(); popupSearchContainer.Tint.Value = Microsoft.Xna.Framework.Color.Black; popupLayout.Children.Add(popupSearchContainer); TextElement popupSearch = new TextElement(); popupSearch.Name.Value = "PopupSearch"; popupSearch.FontFile.Value = "Font"; popupSearchContainer.Children.Add(popupSearch); Scroller popupScroller = new Scroller(); popupScroller.Size.Value = new Vector2(200.0f, 300.0f); popupLayout.Children.Add(popupScroller); ListContainer popupList = new ListContainer(); popupList.Name.Value = "PopupList"; popupScroller.Children.Add(popupList); result.Add("Editor", editor); result.Add("UI", ui); result.Add("UIRenderer", uiRenderer); result.Add("Model", model); result.Add("Input", input); result.Add("AudioListener", audioListener); result.Add("StartSpawnPoint", new Property<string>()); result.Add("ProceduralGenerator", new ProceduralGenerator()); return result; }
private static void attachEditorComponents(Entity result, Main main) { Transform transform = result.Get<Transform>(); Property<bool> selected = new Property<bool> { Value = false, Editable = false, Serialize = false }; result.Add("EditorSelected", selected); Property<Entity.Handle> parentMap = result.GetOrMakeProperty<Entity.Handle>("Parent"); Command<Entity> toggleEntityConnected = new Command<Entity> { Action = delegate(Entity entity) { parentMap.Value = 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); Action recalculateLine = delegate() { connectionLines.Lines.Clear(); Entity parent = parentMap.Value.Target; if (parent != null) { connectionLines.Lines.Add(new LineDrawer.Line { A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor), B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(parent.Get<Transform>().Position, connectionLineColor) }); } }; Model model = new Model(); model.Filename.Value = "Models\\cone"; model.Editable = false; model.Serialize = false; result.Add("DirectionModel", model); Property<Direction> dir = result.GetProperty<Direction>("Direction"); Transform mapTransform = result.Get<Transform>("MapTransform"); model.Add(new Binding<Matrix>(model.Transform, delegate() { Matrix m = Matrix.Identity; m.Translation = transform.Position; if (dir == Direction.None) m.Forward = m.Right = m.Up = Vector3.Zero; else { Vector3 normal = Vector3.TransformNormal(dir.Value.GetVector(), mapTransform.Matrix); m.Forward = -normal; if (normal.Equals(Vector3.Up)) m.Right = Vector3.Left; else if (normal.Equals(Vector3.Down)) m.Right = Vector3.Right; else m.Right = Vector3.Normalize(Vector3.Cross(normal, Vector3.Down)); m.Up = Vector3.Cross(normal, m.Left); } return m; }, transform.Matrix, mapTransform.Matrix)); NotifyBinding recalculateBinding = null; Action rebuildBinding = delegate() { if (recalculateBinding != null) { connectionLines.Remove(recalculateBinding); recalculateBinding = null; } if (parentMap.Value.Target != null) { recalculateBinding = new NotifyBinding(recalculateLine, parentMap.Value.Target.Get<Transform>().Matrix); connectionLines.Add(recalculateBinding); } recalculateLine(); }; connectionLines.Add(new NotifyBinding(rebuildBinding, parentMap)); connectionLines.Add(new NotifyBinding(recalculateLine, selected)); connectionLines.Add(new NotifyBinding(recalculateLine, () => selected, transform.Position)); result.Add(connectionLines); }
public static void AttachEditorComponents(Entity result, Main main, Vector3 color) { Property<float> offset = result.Get<EnemyBase>().Offset; Model model = new Model(); model.Filename.Value = "Models\\cone"; model.Color.Value = color; model.IsInstanced.Value = false; model.Add(new Binding<Vector3, float>(model.Scale, x => new Vector3(1.0f, 1.0f, x), offset)); model.Editable = false; model.Serialize = false; result.Add("EditorModel2", model); model.Add(new Binding<Matrix>(model.Transform, result.Get<EnemyBase>().Transform)); }
public override Entity Create(Main main) { Entity result = new Entity(main, "Blast"); Transform transform = new Transform(); result.Add("Transform", transform); PhysicsBlock physics = new PhysicsBlock(); result.Add("Physics", physics); Model model = new Model(); result.Add("Model", model); model.Filename.Value = "Models\\blast"; model.Color.Value = new Vector3(0.75f, 2.0f, 0.75f); PointLight light = new PointLight(); light.Shadowed.Value = true; light.Color.Value = new Vector3(model.Color.Value.X, model.Color.Value.Y, model.Color.Value.Z); light.Attenuation.Value = 10.0f; result.Add("Light", light); if (ParticleSystem.Get(main, "Sparks") == null) { ParticleSystem.Add(main, "Sparks", new ParticleSystem.ParticleSettings { TextureName = "Particles\\spark", MaxParticles = 1000, Duration = TimeSpan.FromSeconds(1.0f), MinHorizontalVelocity = 0.0f, MaxHorizontalVelocity = 0.0f, MinVerticalVelocity = 0.0f, MaxVerticalVelocity = 0.0f, Gravity = new Vector3(0.0f, 0.0f, 0.0f), EndVelocity = 0.0f, MinRotateSpeed = -20.0f, MaxRotateSpeed = 20.0f, MinStartSize = 0.5f, MaxStartSize = 0.4f, MinEndSize = 0.2f, MaxEndSize = 0.1f, BlendState = Microsoft.Xna.Framework.Graphics.BlendState.Additive, MinColor = new Vector4(0.75f, 2.0f, 0.75f, 1.0f), MaxColor = new Vector4(0.75f, 2.0f, 0.75f, 1.0f), }); } ParticleEmitter emitter = new ParticleEmitter(); emitter.ParticleType.Value = "Sparks"; emitter.ParticlesPerSecond.Value = 200; emitter.Jitter.Value = new Vector3(0.25f); result.Add("Particles", emitter); Sound loopSound = new Sound(); result.Add("LoopSound", loopSound); loopSound.Cue.Value = "Blast Loop"; return result; }
public override void AttachEditorComponents(Entity result, Main main) { Transform transform = result.Get<Transform>(); Zone zone = result.Get<Zone>(); Property<bool> selected = new Property<bool> { Value = false, Editable = false, Serialize = false }; result.Add("EditorSelected", selected); Command<Entity> toggleEntityConnected = new Command<Entity> { Action = delegate(Entity entity) { if (zone.ConnectedEntities.Contains(entity)) { zone.ConnectedEntities.Remove(entity); Zone z = entity.Get<Zone>(); if (z != null) z.Parent.Value = null; } else { zone.ConnectedEntities.Add(entity); Zone z = entity.Get<Zone>(); if (z != null) z.Parent.Value = result; } } }; 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, zone.ConnectedEntities, delegate(Entity.Handle entity) { if (entity.Target == null) return new LineDrawer.Line[] { }; else { return new[] { 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) } }; } }); 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); Model model = new Model(); model.Filename.Value = "Models\\sphere"; model.Color.Value = this.Color; model.IsInstanced.Value = false; model.Scale.Value = new Vector3(0.5f); model.Editable = false; model.Serialize = false; result.Add("EditorModel", model); model.Add(new Binding<Matrix, Vector3>(model.Transform, x => Matrix.CreateTranslation(x), transform.Position)); Property<Vector3> corner1 = new Property<Vector3> { Editable = false, Serialize = false, Value = zone.BoundingBox.Value.Min }; Property<Vector3> corner2 = new Property<Vector3> { Editable = false, Serialize = false, Value = zone.BoundingBox.Value.Max }; result.Add(new Binding<BoundingBox>(zone.BoundingBox, delegate() { Vector3 a = corner1, b = corner2; return new BoundingBox(new Vector3(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z)), new Vector3(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z))); }, corner1, corner2)); Transform cornerTransform1 = this.addCornerModel(result, selected); cornerTransform1.Add(new TwoWayBinding<Vector3, Vector3> ( corner1, x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)), new[] { transform.Matrix }, cornerTransform1.Position, x => Vector3.Transform(x, transform.Matrix), new[] { transform.Matrix } )); Transform cornerTransform2 = this.addCornerModel(result, selected); cornerTransform2.Add(new TwoWayBinding<Vector3, Vector3> ( corner2, x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)), new[] { transform.Matrix }, cornerTransform2.Position, x => Vector3.Transform(x, transform.Matrix), new[] { transform.Matrix } )); ModelAlpha box = new ModelAlpha(); box.Filename.Value = "Models\\alpha-box"; box.Color.Value = new Vector3(this.Color.X, this.Color.Y, this.Color.Z); box.Alpha.Value = 0.125f; box.IsInstanced.Value = false; box.Editable = false; box.Serialize = false; box.DrawOrder.Value = 11; // In front of water box.DisableCulling.Value = true; result.Add(box); box.Add(new Binding<Matrix>(box.Transform, delegate() { BoundingBox b = zone.BoundingBox; return Matrix.CreateScale(b.Max - b.Min) * Matrix.CreateTranslation((b.Min + b.Max) * 0.5f) * transform.Matrix; }, zone.BoundingBox, transform.Matrix)); box.Add(new Binding<bool>(box.Enabled, selected)); box.Add(new Binding<BoundingBox>(box.BoundingBox, zone.BoundingBox)); box.CullBoundingBox.Value = false; }
private Transform addCornerModel(Entity entity, Property<bool> selected) { Transform transform = new Transform { Serialize = false, Editable = false }; entity.AddWithoutOverwriting(transform); Model cornerModel1 = new Model(); cornerModel1.Filename.Value = "Models\\sphere"; cornerModel1.Color.Value = this.Color; cornerModel1.IsInstanced.Value = false; cornerModel1.Scale.Value = new Vector3(0.5f); cornerModel1.Editable = false; cornerModel1.Serialize = false; entity.Add(cornerModel1); cornerModel1.Add(new Binding<Matrix, Vector3>(cornerModel1.Transform, x => Matrix.CreateTranslation(x), transform.Position)); cornerModel1.Add(new Binding<bool>(cornerModel1.Enabled, selected)); return transform; }
private static void attachEditorComponents(Entity result, Main main) { Transform transform = result.Get<Transform>(); Property<Entity.Handle> parentMap = result.GetOrMakeProperty<Entity.Handle>("Parent"); EntityConnectable.AttachEditorComponents(result, parentMap); Model model = new Model(); model.Filename.Value = "Models\\cone"; model.Editable = false; model.Serialize = false; result.Add("DirectionModel", model); Property<Direction> dir = result.GetProperty<Direction>("Direction"); Transform mapTransform = result.Get<Transform>("MapTransform"); model.Add(new Binding<Matrix>(model.Transform, delegate() { Matrix m = Matrix.Identity; m.Translation = transform.Position; if (dir == Direction.None) m.Forward = m.Right = m.Up = Vector3.Zero; else { Vector3 normal = Vector3.TransformNormal(dir.Value.GetVector(), mapTransform.Matrix); m.Forward = -normal; if (normal.Equals(Vector3.Up)) m.Right = Vector3.Left; else if (normal.Equals(Vector3.Down)) m.Right = Vector3.Right; else m.Right = Vector3.Normalize(Vector3.Cross(normal, Vector3.Down)); m.Up = Vector3.Cross(normal, m.Left); } return m; }, transform.Matrix, mapTransform.Matrix)); }