public override IObject2D CreateObject2D(World2D world2D, ALayer2D layer2D, IObject obj) { if (obj is CurvedStarLinkEntity) { CurvedStarLinkEntity entity = obj as CurvedStarLinkEntity; return(new CurvedStarLinkEntity2D(layer2D, this, entity)); } return(null); }
public CurvedStarLinkEntity2D(ALayer2D layer2D, IObject2DFactory factory, CurvedStarLinkEntity entity) : base(layer2D, entity) { this.starEntityFrom = layer2D.GetEntity2DFromEntity(entity.StarFrom) as StarEntity2D; this.starEntityTo = layer2D.GetEntity2DFromEntity(entity.StarTo) as StarEntity2D; this.ObjectSprite.Color = Color.Blue; //this.ObjectSprite.Texture = factory.GetTextureByIndex(0); this.radius = (int)entity.Radius; this.center = new Vector2f(entity.Center.X, entity.Center.Y); Shader shader = new Shader(null, null, @"Assets\Graphics\Shaders\LinkCurvedFrag.frag"); Texture distortionMap = factory.GetTextureById("distorsionTexture"); this.ObjectSprite.Texture = factory.GetTextureById("distorsionTexture"); this.ObjectSprite.Texture.Repeated = true; distortionMap.Repeated = true; distortionMap.Smooth = true; shader.SetUniform("currentTexture", new Shader.CurrentTextureType()); shader.SetUniform("distTexture", distortionMap); render = new RenderStates(BlendMode.Alpha); render.Shader = shader; shader.SetUniform("radius", (float)(this.radius)); shader.SetUniform("margin", (float)(StarLinkEntity2D.WIDTH_LINK / 2)); shader.SetUniform("sideMainTexture", (int)this.ObjectSprite.Texture.Size.X); this.UpdateScaling(); this.Priority = 9; this.InitializeState(entity); }