public static BaseComponent LoadFromDefinition(ContentManager content, string definitionPath, BaseEntity parent) { WaterComponentDefinition compDef = content.Load <WaterComponentDefinition>(definitionPath); WaterComponent newComponent = new WaterComponent(parent, compDef); return(newComponent); }
public WaterComponent(BaseEntity parent, WaterComponentDefinition compDef) : base(parent) { ActivateComponent(); this.width = compDef.Width; this.length = compDef.Length; SetupWaterVertices(); // The vertex declaration is static, so we only need to create it once, and all water planes can use it if (vertexDeclaration == null) { vertexDeclaration = VertexWater.VertexDeclaration; } if (compDef.MaterialPath.Length > 0) { this.material = this.parentEntity.Game.Content.Load <Material>(compDef.MaterialPath); } else { throw new Exception("A WaterComponentDefinition must contain a valid material file path"); } switch (this.parentEntity.Game.Graphics.Settings.GraphicsLevel) { case GraphicsLevel.Highest: case GraphicsLevel.High: this.material.CurrentTechnique = "Water"; break; case GraphicsLevel.Med: this.material.CurrentTechnique = "WaterReflectOnly"; break; case GraphicsLevel.Low: this.material.CurrentTechnique = "WaterReflectOnly"; break; } this.WaterColorLight = compDef.WaterColorLight; this.WaterColorDark = compDef.WaterColorDark; this.Reflectivity = compDef.Reflectivity; }