Exemplo n.º 1
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            ModelAlpha model = new ModelAlpha();

            model.Filename.Value = "AlphaModels\\light";
            model.Color.Value    = this.Color;
            model.Serialize      = false;
            model.Scale.Value    = new Vector3(1, 1, -1);
            model.Add(new Binding <Matrix>(model.Transform, entity.Get <Transform>().Matrix));
            entity.Add("EditorModel", model);
            model.Add(new Binding <bool>(model.Enabled, Editor.EditorModelsVisible));

            VoxelAttachable.AttachEditorComponents(entity, main);

            ModelAlpha offsetModel = new ModelAlpha();

            offsetModel.Filename.Value = "AlphaModels\\cone";
            offsetModel.Add(new Binding <Vector3>(offsetModel.Color, model.Color));

            CameraStop cameraStop = entity.Get <CameraStop>();

            offsetModel.Add(new Binding <bool>(offsetModel.Enabled, () => entity.EditorSelected && cameraStop.Offset != 0 && Editor.EditorModelsVisible, entity.EditorSelected, cameraStop.Offset, Editor.EditorModelsVisible));
            offsetModel.Add(new Binding <Vector3, float>(offsetModel.Scale, x => new Vector3(1, 1, x), cameraStop.Offset));
            offsetModel.Add(new Binding <Matrix>(offsetModel.Transform, model.Transform));
            offsetModel.Serialize = false;
            entity.Add("EditorModel3", offsetModel);

            EntityConnectable.AttachEditorComponents(entity, "Next", cameraStop.Next);
        }
Exemplo n.º 2
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);

            VoxelAttachable.AttachEditorComponents(entity, main, entity.Get <Model>().Color);
            PlayerTrigger.AttachEditorComponents(entity, main, entity.Get <Model>().Color);
        }
Exemplo n.º 3
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            MapExit mapExit = entity.GetOrCreate <MapExit>("MapExit");

            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding(trigger.PlayerEntered, (Action)mapExit.Go));

            trigger.EditorProperties();
            entity.Add("OnEnter", trigger.PlayerEntered);
            entity.Add("Enable", trigger.Enable);
            entity.Add("Enabled", trigger.Enabled);
            entity.Add("Disable", trigger.Disable);
            entity.Add("NextMap", mapExit.NextMap, new PropertyEntry.EditorData
            {
                Options = FileFilter.Get(main, main.MapDirectory, null, MapLoader.MapExtension, delegate()
                {
                    return(new[] { Main.MenuMap });
                }),
            });
            entity.Add("StartSpawnPoint", mapExit.StartSpawnPoint);
        }
Exemplo n.º 4
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            ParticleEmitter emitter = entity.GetOrCreate <ParticleEmitter>("ParticleEmitter");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            this.SetMain(entity, main);

            attachable.EditorProperties();

            emitter.Add(new Binding <Vector3>(emitter.Position, transform.Position));
            emitter.EditorProperties();

            entity.Add("Enabled", emitter.Enabled);
            entity.Add("Enable", emitter.Enable);
            entity.Add("Disable", emitter.Disable);
            entity.Add("Burst", new Command
            {
                Action = delegate()
                {
                    entity.Add(new Animation
                               (
                                   new Animation.Execute(emitter.Enable),
                                   new Animation.Delay(0.3f),
                                   new Animation.Execute(emitter.Disable)
                               ));
                }
            });
        }
Exemplo n.º 5
0
        public static VoxelAttachable MakeAttachable(Entity entity, Main main, bool detachIfRemoved = true, bool detachIfMoved = false, Command detachCommand = null)
        {
            VoxelAttachable attachable = entity.GetOrCreate <VoxelAttachable>("VoxelAttachable");

            attachable.detachIfRemoved = detachIfRemoved;
            attachable.detachIfMoved   = detachIfMoved;

            if (main.EditorEnabled)
            {
                return(attachable);
            }

            Transform transform = entity.Get <Transform>();

            if (detachCommand == null)
            {
                detachCommand = new Command
                {
                    Action = delegate()
                    {
                        entity.Add(new Animation(new Animation.Execute(entity.Delete)));
                    }
                };
            }

            attachable.Add(new CommandBinding(attachable.Detach, detachCommand));
            attachable.Add(new TwoWayBinding <Matrix>(transform.Matrix, attachable.Transform));

            return(attachable);
        }
Exemplo n.º 6
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            CameraStop cameraStop = entity.GetOrCreate <CameraStop>("CameraStop");

            entity.CannotSuspendByDistance = true;

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            if (main.EditorEnabled)
            {
                entity.Add("Preview", new Command
                {
                    Action = delegate()
                    {
                        ulong id = entity.GUID;

                        Action go = delegate()
                        {
                            main.EditorEnabled.Value = false;
                            IO.MapLoader.Load(main, main.MapFile);

                            main.Spawner.CanSpawn             = false;
                            main.Renderer.Brightness.Value    = 0.0f;
                            main.Renderer.InternalGamma.Value = 0.0f;
                            main.UI.IsMouseVisible.Value      = false;

                            main.AddComponent(new PostInitialization
                            {
                                delegate()
                                {
                                    // We have to squirrel away the ID and get a new entity
                                    // because OUR entity got wiped out by the MapLoader.
                                    main.GetByGUID(id).Get <CameraStop>().Go.Execute();
                                }
                            });
                        };

                        Editor editor = main.Get("Editor").First().Get <Editor>();
                        if (editor.NeedsSave)
                        {
                            editor.SaveWithCallback(go);
                        }
                        else
                        {
                            go();
                        }
                    },
                }, Command.Perms.Executable);
            }

            entity.Add("Go", cameraStop.Go);
            entity.Add("OnDone", cameraStop.OnDone);
            entity.Add("Offset", cameraStop.Offset);
            entity.Add("Blend", cameraStop.Blend);
            entity.Add("Duration", cameraStop.Duration);
        }
Exemplo n.º 7
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");
            Rift      rift      = entity.GetOrCreate <Rift>("Rift");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, false, false, null);

            attachable.Enabled.Value = true;
            VoxelAttachable.BindTarget(entity, rift.Position);

            this.SetMain(entity, main);

            PointLight light = entity.GetOrCreate <PointLight>();

            light.Color.Value = new Vector3(1.2f, 1.4f, 1.6f);
            light.Add(new Binding <Vector3>(light.Position, rift.Position));
            light.Add(new Binding <bool>(light.Enabled, () => rift.Type == Rift.Style.In && rift.Enabled, rift.Type, rift.Enabled));
            light.Add(new Binding <float>(light.Attenuation, x => x * 2.0f, rift.CurrentRadius));

            rift.Add(new Binding <Entity.Handle>(rift.Voxel, attachable.AttachedVoxel));
            rift.Add(new Binding <Voxel.Coord>(rift.Coordinate, attachable.Coord));

            entity.Add("Enable", rift.Enable);
            entity.Add("Disable", rift.Disable);
            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("Enabled", rift.Enabled);
            entity.Add("Radius", rift.Radius);
            entity.Add("Style", rift.Type);
        }
Exemplo n.º 8
0
        public static void BindTarget(Entity entity, Property <Matrix> target)
        {
            VoxelAttachable attachable = entity.Get <VoxelAttachable>();
            Transform       transform  = entity.Get <Transform>();

            entity.Add(new Binding <Matrix>(target, () => Matrix.CreateTranslation(0, 0, attachable.Offset) * transform.Matrix, attachable.Offset, transform.Matrix));
        }
Exemplo n.º 9
0
        public static void BindTarget(Entity entity, Property <Vector3> target)
        {
            VoxelAttachable attachable = entity.Get <VoxelAttachable>();
            Transform       transform  = entity.Get <Transform>();

            entity.Add(new Binding <Vector3>(target, () => Vector3.Transform(new Vector3(0, 0, attachable.Offset), transform.Matrix), attachable.Offset, transform.Matrix));
        }
Exemplo n.º 10
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;

            Transform transform = entity.GetOrCreate <Transform>("Transform");

            PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("Trigger");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            base.Bind(entity, main, creating);

            TargetFactory.Positions.Add(transform);
            entity.Add(new CommandBinding(entity.Delete, delegate()
            {
                TargetFactory.Positions.Remove(transform);
            }));

            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                entity.Add(new Animation(new Animation.Execute(entity.Delete)));
            }));
            trigger.Add(new Binding <bool>(trigger.Enabled, transform.Enabled));
            trigger.EditorProperties();
            attachable.EditorProperties();

            entity.Add("Enabled", transform.Enabled);

            entity.Add("Enable", transform.Enable);
            entity.Add("Disable", transform.Disable);
            entity.Add("Reached", trigger.PlayerEntered);
        }
Exemplo n.º 11
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspendByDistance = true;

            PointLight light     = entity.GetOrCreate <PointLight>("PointLight");
            Transform  transform = entity.GetOrCreate <Transform>("Transform");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            light.Add(new Binding <Vector3>(light.Position, () => Vector3.Transform(new Vector3(0, 0, attachable.Offset), transform.Matrix), attachable.Offset, transform.Matrix));

            Switch sw = entity.GetOrCreate <Switch>("Switch");

            if (main.EditorEnabled)
            {
                light.Enabled.Value = true;
            }
            else
            {
                light.Add(new Binding <bool>(light.Enabled, sw.On));
                CommandBinding <IEnumerable <Voxel.Coord>, Voxel> cellFilledBinding = null;

                entity.Add(new NotifyBinding(delegate()
                {
                    Voxel m = attachable.AttachedVoxel.Value.Target.Get <Voxel>();
                    if (cellFilledBinding != null)
                    {
                        entity.Remove(cellFilledBinding);
                    }

                    cellFilledBinding = new CommandBinding <IEnumerable <Voxel.Coord>, Voxel>(m.CellsFilled, delegate(IEnumerable <Voxel.Coord> coords, Voxel newMap)
                    {
                        foreach (Voxel.Coord c in coords)
                        {
                            if (c.Equivalent(attachable.Coord))
                            {
                                sw.On.Value = c.Data == Voxel.States.PoweredSwitch;
                                break;
                            }
                        }
                    });
                    entity.Add(cellFilledBinding);

                    sw.On.Value = m[attachable.Coord] == Voxel.States.PoweredSwitch;
                }, attachable.AttachedVoxel));
            }

            sw.Add(new Binding <Entity.Handle>(sw.AttachedVoxel, attachable.AttachedVoxel));
            sw.Add(new Binding <Voxel.Coord>(sw.Coord, attachable.Coord));

            this.SetMain(entity, main);

            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("OnPowerOn", sw.OnPowerOn);
            entity.Add("OnPowerOff", sw.OnPowerOff);
            entity.Add("On", sw.On, null, true);
        }
Exemplo n.º 12
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);

            VoxelAttachable.AttachEditorComponents(entity, main, entity.Get <Model>().Color);

            EntityConnectable.AttachEditorComponents(entity, "Target", entity.Get <VoxelFill>().Target);
        }
Exemplo n.º 13
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);

            Rift.AttachEditorComponents(entity, main, this.Color);

            VoxelAttachable.AttachEditorComponents(entity, main, entity.Get <Model>().Color);
        }
Exemplo n.º 14
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);
            Model editorModel = entity.Get <Model>("EditorModel");

            editorModel.Add(new Binding <bool>(editorModel.Enabled, () => Editor.EditorModelsVisible && !entity.EditorSelected, Editor.EditorModelsVisible, entity.EditorSelected));
            VoxelAttachable.AttachEditorComponents(entity, main, editorModel.Color);
        }
Exemplo n.º 15
0
        public override Entity Create(Main main)
        {
            Entity          entity     = new Entity(main, "Note");
            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Vector.Value = Direction.NegativeY;
            return(entity);
        }
Exemplo n.º 16
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, true, false);

            attachable.Enabled.Value = true;

            if (!main.EditorEnabled)
            {
                // -1 means we're currently submerged, anything above 0 is the timestamp of the last time we were submerged
                float submerged                  = -1.0f;
                float lastEmit                   = 0.0f;
                Water submergedWater             = null;
                Property <Vector3> coordinatePos = new Property <Vector3>();
                VoxelAttachable.BindTarget(entity, coordinatePos);
                Action check = delegate()
                {
                    Water nowSubmerged = Water.Get(coordinatePos);
                    if (nowSubmerged == null && main.TotalTime - submerged < 1.0f)
                    {
                        Entity ve = attachable.AttachedVoxel.Value.Target;
                        if (ve != null)
                        {
                            Voxel       v   = ve.Get <Voxel>();
                            Voxel.Box   b   = v.GetBox(attachable.Coord);
                            BoundingBox box = new BoundingBox(v.GetRelativePosition(b.X, b.Y, b.Z), v.GetRelativePosition(b.X + b.Width, b.Y + b.Height, b.Z + b.Depth));
                            if (submergedWater != null && main.TotalTime - lastEmit > 0.1f)
                            {
                                Water.SplashParticles(main, box.Transform(v.Transform), v, submergedWater.Position.Value.Y);
                                lastEmit = main.TotalTime;
                            }
                        }
                    }

                    if (nowSubmerged != null)
                    {
                        submerged      = -1.0f;
                        submergedWater = nowSubmerged;
                    }
                    else if (submerged == -1.0f && nowSubmerged == null)
                    {
                        Sound.PostEvent(AK.EVENTS.PLAY_WATER_SPLASH_OUT_BIG, transform.Position);
                        submerged = main.TotalTime;
                    }
                };
                transform.Add(new NotifyBinding(check, coordinatePos));
                entity.Add(new PostInitialization(delegate()
                {
                    submerged = Water.Get(coordinatePos) != null ? -1.0f : -2.0f;
                }));
            }

            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("AttachVector", attachable.Vector);
        }
Exemplo n.º 17
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main, true, false).EditorProperties();
            transform.EditorProperties();
        }
Exemplo n.º 18
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);
            Model           editorModel = entity.Get <Model>("EditorModel");
            ParticleEmitter emitter     = entity.Get <ParticleEmitter>();

            editorModel.Add(new Binding <bool>(editorModel.Enabled, () => Editor.EditorModelsVisible && (!entity.EditorSelected || emitter.ParticleType.Value == null), entity.EditorSelected, emitter.ParticleType, Editor.EditorModelsVisible));

            VoxelAttachable.AttachEditorComponents(entity, main, editorModel.Color);
        }
Exemplo n.º 19
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            entity.CannotSuspendByDistance = true;

            PlayerTrigger   trigger    = entity.GetOrCreate <PlayerTrigger>("Trigger");
            PlayerSpawn     spawn      = entity.GetOrCreate <PlayerSpawn>("PlayerSpawn");
            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            this.SetMain(entity, main);

            attachable.EditorProperties();

            if (main.EditorEnabled)
            {
                entity.Add("Spawn Here", new Command
                {
                    Action = delegate()
                    {
                        main.Spawner.StartSpawnPointGUID.Value = entity.GUID;
                        Action go = delegate()
                        {
                            main.EditorEnabled.Value = false;
                            IO.MapLoader.Load(main, main.MapFile);
                        };

                        Editor editor = main.Get("Editor").First().Get <Editor>();
                        if (editor.NeedsSave)
                        {
                            editor.SaveWithCallback(go);
                        }
                        else
                        {
                            go();
                        }
                    },
                }, Command.Perms.Executable);
            }

            spawn.Add(new TwoWayBinding <Vector3>(transform.Position, spawn.Position));
            spawn.Add(new Binding <float, Quaternion>(spawn.Rotation, delegate(Quaternion value)
            {
                Vector3 x = Vector3.Transform(Vector3.Forward, value);
                return(((float)Math.PI * -0.5f) - (float)Math.Atan2(x.Z, x.X));
            }, transform.Quaternion));
            spawn.EditorProperties();

            trigger.Enabled.Value = true;
            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding(trigger.PlayerEntered, spawn.Activate));

            trigger.EditorProperties();
        }
Exemplo n.º 20
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);
            Model model = entity.Get <Model>("EditorModel");

            Property <Vector3> color = entity.Get <PointLight>().Color;

            model.Add(new Binding <Vector3>(model.Color, color));
            model.Add(new Binding <bool>(model.Enabled, Editor.EditorModelsVisible));

            VoxelAttachable.AttachEditorComponents(entity, main, color);
        }
Exemplo n.º 21
0
        public static void AttachEditorComponents(Entity entity, Main main, Property <Vector3> color = null)
        {
            ModelAlpha model = new ModelAlpha();

            model.Filename.Value = "AlphaModels\\cone";
            if (color != null)
            {
                model.Add(new Binding <Vector3>(model.Color, color));
            }

            VoxelAttachable attachable = entity.GetOrCreate <VoxelAttachable>("VoxelAttachable");

            Model editorModel = entity.Get <Model>("EditorModel");

            model.Add(new Binding <bool>(model.Enabled, () => Editor.EditorModelsVisible && (entity.EditorSelected && attachable.Offset != 0), entity.EditorSelected, attachable.Offset, Editor.EditorModelsVisible));
            model.Add(new Binding <Vector3, float>(model.Scale, x => new Vector3(1.0f, 1.0f, x), attachable.Offset));
            model.Serialize = false;
            entity.Add("EditorModel2", model);

            Property <Matrix> transform = entity.Get <Transform>().Matrix;

            model.Add(new Binding <Matrix>(model.Transform, delegate()
            {
                Direction dir = attachable.Vector;
                Matrix m      = Matrix.Identity;
                m.Translation = transform.Value.Translation;
                if (dir == Direction.None)
                {
                    m.Forward = m.Right = m.Up = Vector3.Zero;
                }
                else
                {
                    Vector3 normal = Vector3.TransformNormal(dir.GetVector(), transform);

                    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, attachable.Vector));
        }
Exemplo n.º 22
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            trigger.Serialize = false;

            VoxelAttachable attachable  = VoxelAttachable.MakeAttachable(entity, main);
            Collectible     collectible = entity.GetOrCreate <Collectible>("Collectible");

            trigger.Radius.Value = 3;
            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));
            trigger.Add(new Binding <bool>(trigger.Enabled, x => !x, collectible.PickedUp));

            collectible.Add(new CommandBinding(trigger.PlayerEntered, collectible.PlayerTouched));

            Sound.AttachTracker(entity, trigger.Position);

            PointLight light = entity.Create <PointLight>();

            light.Serialize         = false;
            light.Attenuation.Value = 10.0f;
            light.Color.Value       = new Vector3(1.25f, 1.75f, 2.0f);
            light.Add(new Binding <Vector3>(light.Position, transform.Position));
            light.Add(new Binding <bool>(light.Enabled, x => !x, collectible.PickedUp));

            ParticleEmitter distortionEmitter = entity.GetOrCreate <ParticleEmitter>("DistortionEmitter");

            distortionEmitter.Serialize = false;
            distortionEmitter.Add(new Binding <Vector3>(distortionEmitter.Position, trigger.Position));
            distortionEmitter.ParticleType.Value       = "Distortion";
            distortionEmitter.ParticlesPerSecond.Value = 4;
            distortionEmitter.Jitter.Value             = new Vector3(0.5f);
            distortionEmitter.Add(new Binding <bool>(distortionEmitter.Enabled, x => !x, collectible.PickedUp));

            Model model = entity.GetOrCreate <Model>("Model");

            model.Filename.Value = "Models\\sphere";
            model.Serialize      = false;
            model.Scale.Value    = new Vector3(0.5f);
            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));
            model.Add(new Binding <bool>(model.Enabled, x => !x, collectible.PickedUp));

            this.SetMain(entity, main);

            attachable.EditorProperties();
            entity.Add("Collected", collectible.PlayerTouched);
        }
Exemplo n.º 23
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            ModelAlpha model = new ModelAlpha();

            model.Filename.Value = "AlphaModels\\light";
            model.Color.Value    = this.Color;
            model.Serialize      = false;

            entity.Add("EditorModel", model);

            model.Add(new Binding <Matrix>(model.Transform, entity.Get <Transform>().Matrix));
            model.Add(new Binding <bool>(model.Enabled, Editor.EditorModelsVisible));

            PlayerTrigger.AttachEditorComponents(entity, main, this.Color);
            VoxelAttachable.AttachEditorComponents(entity, main);
        }
Exemplo n.º 24
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main, true, false).EditorProperties();

            Explosion explosion = entity.GetOrCreate <Explosion>("Explosion");

            entity.Add(new CommandBinding(explosion.Delete, entity.Delete));

            explosion.Add(new Binding <Vector3>(explosion.Position, transform.Position));

            entity.Add("Explode", explosion.Go);
            entity.Add("DeleteAfter", explosion.DeleteAfter);
        }
Exemplo n.º 25
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");
            Trigger   trigger   = entity.GetOrCreate <Trigger>("Trigger");

            VoxelAttachable.MakeAttachable(entity, main);

            this.SetMain(entity, main);

            trigger.EditorProperties();
            entity.Add("Enable", trigger.Enable);
            entity.Add("Disable", trigger.Disable);
            entity.Add("Entered", trigger.Entered);
            entity.Add("Exited", trigger.Exited);

            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
        }
Exemplo n.º 26
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            Model model = entity.GetOrCreate <Model>("Model");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            model.EditorProperties();

            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));

            entity.Add("Enabled", model.Enabled);
            entity.Add("Enable", model.Enable);
            entity.Add("Disable", model.Disable);
        }
Exemplo n.º 27
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            AmbientSound ambientSound = entity.GetOrCreate <AmbientSound>("AmbientSound");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();
            VoxelAttachable.BindTarget(entity, ambientSound.Position);

            entity.Add("PlayCue", ambientSound.PlayCue);
            entity.Add("StopCue", ambientSound.StopCue);

            entity.Add("Play", ambientSound.Enable);
            entity.Add("Stop", ambientSound.Disable);
            entity.Add("Playing", ambientSound.Enabled);
        }
Exemplo n.º 28
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspendByDistance = true;

            PointLight light     = entity.GetOrCreate <PointLight>("PointLight");
            Transform  transform = entity.GetOrCreate <Transform>("Transform");

            light.Add(new TwoWayBinding <Vector3>(light.Position, transform.Position));

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            entity.Add("Enable", light.Enable);
            entity.Add("Disable", light.Disable);
            entity.Add("Enabled", light.Enabled);
            entity.Add("Color", light.Color);
            entity.Add("Attenuation", light.Attenuation);
        }
Exemplo n.º 29
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            AnimatedModel model = entity.GetOrCreate <AnimatedModel>("Model");

            model.MapContent.Value = true;

            AnimatedProp prop = entity.GetOrCreate <AnimatedProp>("AnimatedProp");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            model.EditorProperties();

            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));

            entity.Add("Visible", model.Enabled);
            ListProperty <string> clips = null;

            if (main.EditorEnabled)
            {
                clips = new ListProperty <string>();
                model.Add(new ChangeBinding <string>(model.Filename, delegate(string old, string value)
                {
                    if (model.IsValid)
                    {
                        clips.Clear();
                        clips.AddAll(model.Clips.Keys);
                    }
                }));
            }
            entity.Add("Clip", prop.Clip, new PropertyEntry.EditorData {
                Options = clips,
            });
            entity.Add("Loop", prop.Loop);
            entity.Add("Enabled", prop.Enabled);
            entity.Add("Enable", prop.Enable);
            entity.Add("Disable", prop.Disable);
        }
Exemplo n.º 30
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            entity.Add("AttachOffset", attachable.Offset);

            if (!main.EditorEnabled)
            {
                Property <Vector3> soundPosition = new Property <Vector3>();
                VoxelAttachable.BindTarget(entity, soundPosition);
                Sound.AttachTracker(entity, soundPosition);
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WHITE_LIGHT, entity);
                SoundKiller.Add(entity, AK.EVENTS.STOP_WHITE_LIGHT);
            }
        }