Esempio n. 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);
            }
        }