/// <summary> /// Resolve the dependencies /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); MaterialComponent materialComponent = this.Owner.FindComponent <MaterialComponent>(); if (materialComponent == null) { MaterialsMap materialsMap = this.Owner.FindComponent <MaterialsMap>(); if (materialsMap != null) { materialsMap.OnComponentInitialized += (s, o) => { this.material = materialsMap.DefaultMaterial; }; } } else { materialComponent.OnComponentInitialized += (s, o) => { this.material = materialComponent.Material; }; } // If the entity is initialized, we need to update the current particle system if (this.isInitialized) { this.LoadParticleSystem(); } }
public void ApplyMaterial() { Owner.RemoveComponent<MaterialsMap>(); string content = "Content/SmokeParticle.wpk"; if (currentParticleSystemIndex == 2 || currentParticleSystemIndex == 3) { content = "Content/WhitePixel.wpk"; } var materials = new MaterialsMap(new BasicMaterial(content, DefaultLayers.Additive) { VertexColorEnabled = true }); Owner.AddComponent(materials); }