Exemplo n.º 1
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary>
        protected override void OnPostCreate2(bool loaded)
        {
            base.OnPostCreate2(loaded);

            //We has initialization into OnPostCreate2, because we need to intialize after
            //parent entity initialized (Dynamic.OnPostCreate). It's need for world serialization.

            SubscribeToTickEvent();

            Dynamic parent = (Dynamic)Parent;

            bool existsAttachedObjects = false;

            //show attached objects for this influence
            foreach (MapObjectAttachedObject attachedObject in parent.AttachedObjects)
            {
                if (attachedObject.Alias == Type.Name)
                {
                    attachedObject.Visible = true;
                    existsAttachedObjects  = true;
                }
            }

            if (!existsAttachedObjects)
            {
                //create default particle system
                if (!string.IsNullOrEmpty(Type.DefaultParticleName))
                {
                    defaultAttachedParticle = new MapObjectAttachedParticle();
                    defaultAttachedParticle.ParticleName = Type.DefaultParticleName;
                    parent.Attach(defaultAttachedParticle);
                }
            }
        }