Exemple #1
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;
            ModelInstance model        = entity.GetOrCreate <ModelInstance>("Model");
            ImplodeBlock  implodeBlock = entity.GetOrCreate <ImplodeBlock>("ImplodeBlock");

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

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

            this.SetMain(entity, main);

            IBinding offsetBinding = null;

            model.Add(new NotifyBinding(delegate()
            {
                if (offsetBinding != null)
                {
                    model.Remove(offsetBinding);
                }
                offsetBinding = new Binding <Vector3>(model.GetVector3Parameter("Offset"), implodeBlock.Offset);
                model.Add(offsetBinding);
            }, model.FullInstanceKey));
            if (implodeBlock.StateId != Voxel.t.Empty)
            {
                Voxel.States.All[implodeBlock.StateId].ApplyToEffectBlock(model);
            }
        }
Exemple #2
0
        public void Implode(Main main, Voxel v, Voxel.Coord coord, Voxel.State state, Vector3 target)
        {
            Entity       block        = this.CreateAndBind(main);
            ImplodeBlock implodeBlock = block.Get <ImplodeBlock>();

            state.ApplyToEffectBlock(block.Get <ModelInstance>());
            implodeBlock.Offset.Value = v.GetRelativePosition(coord);

            implodeBlock.StateId          = state.ID;
            implodeBlock.StartPosition    = v.GetAbsolutePosition(coord);
            implodeBlock.Type             = Rift.Style.In;
            implodeBlock.StartOrientation = Quaternion.CreateFromRotationMatrix(v.Transform);
            implodeBlock.EndOrientation   = Quaternion.CreateFromYawPitchRoll((float)this.random.NextDouble() * (float)Math.PI * 2.0f, (float)this.random.NextDouble() * (float)Math.PI * 2.0f, 0.0f);
            implodeBlock.EndPosition      = target;
            main.Add(block);
        }