public static void Update() { int targetsPerFrame = DamageManager._targetsPerFrame; int index = 0; while (targetsPerFrame > 0 && DamageManager._hits.Count > 0 && index < DamageManager._hits.Count) { DamageHit hit = DamageManager._hits[index]; if (hit.thing.graphic.renderTexture == null) { hit.thing.graphic = hit.thing.GetEditorImage(0, 0, true, target: DamageManager.Get16x16Target()); ++index; --targetsPerFrame; } else { DamageManager._hits.RemoveAt(index); float num = (float)hit.thing.graphic.width / (float)hit.thing.graphic.width; Camera camera = new Camera(0.0f, 0.0f, (float)hit.thing.graphic.width, (float)hit.thing.graphic.height); camera.position = new Vec2(hit.thing.x - hit.thing.centerx * num, hit.thing.y - hit.thing.centery * num); DuckGame.Graphics.SetRenderTarget(hit.thing.graphic.renderTexture); DepthStencilState depthStencilState = new DepthStencilState() { StencilEnable = true, StencilFunction = CompareFunction.Equal, StencilPass = StencilOperation.Keep, ReferenceStencil = 1, DepthBufferEnable = false }; DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, DamageManager._blendState, SamplerState.PointClamp, depthStencilState, RasterizerState.CullNone, (MTEffect)null, camera.getMatrix()); foreach (Vec2 point in hit.points) { DamageManager._bulletHoles.depth = new Depth(1f); DamageManager._bulletHoles.x = point.x + Rando.Float(-1f, 1f); DamageManager._bulletHoles.y = point.y + Rando.Float(-1f, 1f); DamageManager._bulletHoles.imageIndex = Rando.Int(4); DamageManager._bulletHoles.Draw(); } DuckGame.Graphics.screen.End(); DuckGame.Graphics.device.SetRenderTarget((Microsoft.Xna.Framework.Graphics.RenderTarget2D)null); --targetsPerFrame; } } }