コード例 #1
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);
        }