public void DrawLayer(Rectangle viewport, IGraphics graphics) { foreach (var entity in _entities) { var location = entity.GetComponent <LocationComponent>(); if (!viewport.Contains(location.Location)) { continue; } var isDetected = _sensorHandler.IsDetected(Constants.PlayerTeam, entity); if (!entity.BelongsTo(Constants.PlayerTeam) && !isDetected) { continue; } // Rotate image to movement / facing angle var texture = entity.Texture(); var rotated = texture.Image.Rotate(location.FacingAngle); // Translate against camera movement var area = rotated.Area(location.Location); area.Translate(viewport.X, viewport.Y); graphics.DrawImage(rotated, area); } }
public void DrawLayer(Rectangle viewport, IGraphics graphics) { foreach (var entity in _entities) { var location = entity.GetComponent <LocationComponent>(); if (!viewport.Contains(location.Location)) { continue; } var isDetected = _sensorHandler.IsDetected(Constants.PlayerTeam, entity); if (!entity.BelongsTo(Constants.PlayerTeam) && !isDetected) { continue; } var model = entity.Model(); model.Location = new Vector3(0, 0, 2); // Note: the tiny offset on the Y axis prevents clipping through the plane var radians = (Math.PI / 180) * location.FacingAngle; model.Rotation = new Vector3(0, 0.001f, (float)radians); var texture = entity.Texture(); var render = _3dEngine.Render(model, texture); var area = render.Area(location.Location); area.Translate(viewport.X, viewport.Y); graphics.DrawBytes(render.Buffer, area); } }