Esempio n. 1
0
        private void PlaceItem(PlaceObject po)
        {
            if (Content.Items.ContainsKey(po.Depth))
            {
                return;
            }

            var         character     = Context.GetCharacter(po.Character, _sprite);
            var         itemTransform = CreateTransform(po);
            DisplayItem displayItem   = character switch
            {
                Playable _ => new SpriteItem(),
                Button _ => new ButtonItem(),
                        _ => new RenderItem(),
            };

            displayItem.Transform = itemTransform;
            displayItem.Create(character, Context, this);

            //add this object as an AS property
            if (po.Flags.HasFlag(PlaceObjectFlags.HasName))
            {
                ScriptObject.Variables[po.Name] = Value.FromObject(displayItem.ScriptObject);
                displayItem.Name = po.Name;
            }

            if (po.Flags.HasFlag(PlaceObjectFlags.HasClipAction))
            {
                if (po.ClipEvents != null)
                {
                    foreach (var clipEvent in po.ClipEvents)
                    {
                        if (clipEvent.Flags.HasFlag(ClipEventFlags.Initialize))
                        {
                            Context.Avm.Execute(clipEvent.Instructions, displayItem.ScriptObject,
                                                Character.Container.Constants.Entries);
                        }
                    }
                }
            }

            if (po.Flags.HasFlag(PlaceObjectFlags.HasClipDepth))
            {
                displayItem.ClipDepth = po.ClipDepth;
                displayItem.ClipMask  = new RenderTarget(Context.Window.ContentManager.GraphicsDevice);
            }

            Content.AddItem(po.Depth, displayItem);
        }