GameEntities.Influence.OnPostCreate2 C# (CSharp) Method

OnPostCreate2() protected method

Overridden from Engine.EntitySystem.Entity.OnPostCreate(Boolean).
protected OnPostCreate2 ( bool loaded ) : void
loaded bool
return void
        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.

            AddTimer();

            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 );
                }
            }
        }