public static bool RenderPortrait(PortraitRenderer __instance, Pawn pawn, RenderTexture renderTexture, Vector3 cameraOffset, float cameraZoom) { int tID = Thread.CurrentThread.ManagedThreadId; if (RimThreaded.mainRequestWaits.TryGetValue(tID, out EventWaitHandle eventWaitStart)) { Camera portraitCamera = Find.PortraitCamera; //portraitCamera.targetTexture = renderTexture; set_targetTexture(portraitCamera, renderTexture); Vector3 position = portraitCamera.transform.position; float orthographicSize = portraitCamera.orthographicSize; portraitCamera.transform.position += cameraOffset; portraitCamera.orthographicSize = 1f / cameraZoom; pawnFR(__instance) = pawn; //portraitCamera.Render(); Render(portraitCamera); pawnFR(__instance) = null; portraitCamera.transform.position = position; portraitCamera.orthographicSize = orthographicSize; //portraitCamera.targetTexture = null; set_targetTexture(portraitCamera, null); return(false); } return(true); }
public void SetPortraitRenderer(PortraitRenderer newPortraitRenderer) { if (currentPortraitRenderer != null) { currentPortraitRenderer.Stop(); } currentPortraitRenderer = newPortraitRenderer; newPortraitRenderer.Play(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (previousValue != sceneAsset.serializedObject) { PortraitRenderer rend = (PortraitRenderer)target; var newValue = sceneAsset.objectReferenceValue as SceneAsset; if (newValue != null) { rend.sceneName = newValue.name; } } }
public static bool RenderPortrait(PortraitRenderer __instance, Pawn pawn, RenderTexture renderTexture, Vector3 cameraOffset, float cameraZoom) { if (allThreads2.TryGetValue(CurrentThread, out ThreadInfo threadInfo)) { Camera portraitCamera = Find.PortraitCamera; //portraitCamera.targetTexture = renderTexture; set_targetTexture(portraitCamera, renderTexture); Vector3 position = portraitCamera.transform.position; float orthographicSize = portraitCamera.orthographicSize; portraitCamera.transform.position += cameraOffset; portraitCamera.orthographicSize = 1f / cameraZoom; pawnFR(__instance) = pawn; //portraitCamera.Render(); Render(portraitCamera); pawnFR(__instance) = null; portraitCamera.transform.position = position; portraitCamera.orthographicSize = orthographicSize; //portraitCamera.targetTexture = null; set_targetTexture(portraitCamera, null); return(false); } return(true); }
/// <summary> /// Entry point for re-drawing based on updated portrait. /// </summary> private void drawPortrait() { pbPortrait.Image?.Dispose(); try { var steps = PortraitBuilder.Engine.PortraitBuilder.BuildCharacter(character, loader.ActivePortraitData.Sprites) .Where(step => step != null) .Select(step => { step.Tile = loader.Cache.Get(step.Def)[step.TileIndex]; return(step); }); var rendered = PortraitRenderer.DrawPortrait(steps); previewImage = SKImage.FromBitmap(rendered); } catch (Exception e) { logger.LogError("Error encountered rendering portrait", e); return; } pbPortrait.Image = Image.FromStream(previewImage.Encode().AsStream(true)); if (!this.Visible) { return; } var fullUrl = GetOnlinePortraitUrl(); logger.LogInformation("Rendering remote portrait: " + fullUrl); lnkLblRemotePortrait.Text = fullUrl; pbPortraitOnline.ImageLocation = fullUrl; }