Beispiel #1
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspendByDistance = true;
            Transform transform    = entity.GetOrCreate <Transform>("Transform");
            Transform mapTransform = entity.GetOrCreate <Transform>("MapTransform");

            mapTransform.Selectable.Value = false;
            StaticSlider slider = entity.GetOrCreate <StaticSlider>("StaticSlider");

            Factory.Get <VoxelFactory>().InternalBind(entity, main, creating, mapTransform);
            slider.Add(new TwoWayBinding <Matrix>(slider.Transform, mapTransform.Matrix));
            slider.Add(new Binding <Matrix>(slider.EditorTransform, transform.Matrix));

            Voxel voxel = entity.Get <Voxel>();

            slider.Add(new Binding <Vector3>(voxel.LinearVelocity, slider.LinearVelocity));

            AkGameObjectTracker.Attach(entity, voxel.Transform);
            SoundKiller.Add(entity, AK.EVENTS.STOP_ALL_OBJECT);

            if (main.EditorEnabled)
            {
                entity.Add(new Binding <Matrix>(entity.GetOrCreate <SliderCommon>("SliderCommon").OriginalTransform, voxel.Transform));
            }

            entity.Add("Forward", slider.Forward);
            entity.Add("Backward", slider.Backward);
            entity.Add("OnHitMax", slider.OnHitMax);
            entity.Add("OnHitMin", slider.OnHitMin);

            entity.Add("Direction", slider.Direction);
            entity.Add("Minimum", slider.Minimum);
            entity.Add("Maximum", slider.Maximum);
            entity.Add("Speed", slider.Speed);
            entity.Add("Goal", slider.Goal);
            entity.Add("StartAtMinimum", slider.StartAtMinimum);
            entity.Add("EnablePhysics", voxel.EnablePhysics);
            entity.Add("Position", slider.Position, new PropertyEntry.EditorData {
                Readonly = true
            });
            entity.Add("MovementLoop", slider.MovementLoop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("MovementStop", slider.MovementStop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });

            entity.Add("UVRotation", voxel.UVRotation);
            entity.Add("UVOffset", voxel.UVOffset);

            if (main.EditorEnabled)
            {
                this.attachEditorComponents(entity, main);
            }
        }
Beispiel #2
0
 public void EditorProperties()
 {
     this.Entity.Add("Play", this.Play);
     this.Entity.Add("PlayCue", this.PlayCue, new PropertyEntry.EditorData {
         Options = WwisePicker.Get(main)
     });
     this.Entity.Add("StopCue", this.StopCue, new PropertyEntry.EditorData {
         Options = WwisePicker.Get(main)
     });
     this.Entity.Add("Is3D", this.Is3D);
 }
Beispiel #3
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Slider slider = entity.GetOrCreate <Slider>("Slider");

            JointFactory.Bind(entity, main, slider.CreateJoint, false, creating);

            Components.Joint joint = entity.GetOrCreate <Components.Joint>("Joint");
            slider.Add(new Binding <Direction>(slider.Direction, joint.Direction));

            DynamicVoxel voxel = entity.Get <DynamicVoxel>();

            voxel.KineticFriction.Value = voxel.StaticFriction.Value = 0;
            AkGameObjectTracker.Attach(entity, voxel.Transform);
            SoundKiller.Add(entity, AK.EVENTS.STOP_ALL_OBJECT);

            if (main.EditorEnabled)
            {
                entity.Add(new Binding <Matrix>(entity.GetOrCreate <SliderCommon>("SliderCommon").OriginalTransform, voxel.Transform));
            }

            entity.Add("Forward", slider.Forward);
            entity.Add("Backward", slider.Backward);
            entity.Add("OnHitMax", slider.OnHitMax);
            entity.Add("OnHitMin", slider.OnHitMin);

            entity.Add("MovementLoop", slider.MovementLoop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("MovementStop", slider.MovementStop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("Direction", joint.Direction);
            entity.Add("Minimum", slider.Minimum);
            entity.Add("Maximum", slider.Maximum);
            entity.Add("Locked", slider.Locked);
            entity.Add("Speed", slider.Speed);
            entity.Add("Goal", slider.Goal);
            entity.Add("Servo", slider.Servo);
            entity.Add("StartAtMinimum", slider.StartAtMinimum);
            entity.Add("MaxForce", slider.MaxForce);

            entity.Add("UVRotation", voxel.UVRotation);
            entity.Add("UVOffset", voxel.UVOffset);
            entity.Add("CannotSuspendByDistance", voxel.CannotSuspendByDistance);
        }
Beispiel #4
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, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("StopCue", ambientSound.StopCue, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });

            entity.Add("Play", ambientSound.Enable);
            entity.Add("Stop", ambientSound.Disable);
            entity.Add("Enabled", ambientSound.Enabled);
        }
Beispiel #5
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Components.Joint joint   = entity.GetOrCreate <Components.Joint>("Joint");
            Spinner          spinner = entity.GetOrCreate <Spinner>("Spinner");

            spinner.Add(new Binding <Direction>(spinner.Direction, joint.Direction));

            JointFactory.Bind(entity, main, spinner.CreateJoint, true, creating);
            DynamicVoxel voxel = entity.Get <DynamicVoxel>();

            voxel.KineticFriction.Value = voxel.StaticFriction.Value = 0;

            if (main.EditorEnabled)
            {
                spinner.Add(new Binding <Quaternion, Matrix>(spinner.OriginalRotation, x => Quaternion.CreateFromRotationMatrix(x), voxel.Transform));
            }

            entity.Add("Forward", spinner.Forward);
            entity.Add("Backward", spinner.Backward);
            entity.Add("HitMax", spinner.HitMax);
            entity.Add("HitMin", spinner.HitMin);
            entity.Add("MovementLoop", spinner.MovementLoop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("MovementStop", spinner.MovementStop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });

            entity.Add("Direction", joint.Direction);
            entity.Add("Minimum", spinner.Minimum);
            entity.Add("Maximum", spinner.Maximum);
            entity.Add("Locked", spinner.Locked);
            entity.Add("Speed", spinner.Speed);
            entity.Add("Goal", spinner.Goal);
            entity.Add("Servo", spinner.Servo);
            entity.Add("CannotSuspendByDistance", entity.Get <DynamicVoxel>().CannotSuspendByDistance);
        }
Beispiel #6
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);
            entity.Add("PowerOnCue", sw.PowerOnCue, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
        }