-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraMapConfigUpdatePatch.cs
More file actions
72 lines (68 loc) · 2.81 KB
/
CameraMapConfigUpdatePatch.cs
File metadata and controls
72 lines (68 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using UnityEngine;
using Verse;
using HarmonyLib;
using RimWorld;
using System.Collections.Generic;
namespace SimpleCameraSetting
{
//CameraFollowing 기능 관련
//메시지 띄우기, 다른 림 Follow 시 부드럽게 이동 등
[HarmonyPatch]
public static class CameraMapConfigUpdatePatch
{
static List<Pawn> lastSelectedPawns=new List<Pawn>();
[HarmonyPatch(typeof(CameraMapConfig), nameof(CameraMapConfig.ConfigFixedUpdate_60))]
[HarmonyPrefix]
public static bool Prefix(ref CameraMapConfig __instance, ref Vector3 rootPos, ref Vector3 velocity)
{
if (__instance.followSelected)
{
List<Pawn> selectedPawns = Find.Selector.SelectedPawns;
//added code
if (selectedPawns.Empty())
{
if (SimpleCameraModSetting.modSetting.autoOffFollow)
{
Current.CameraDriver.config.followSelected = false;
Messages.Message("Camera Following " + (Current.CameraDriver.config.followSelected ? "On" : "Off"), new MessageTypeDef(),false);
}
else
{
selectedPawns = lastSelectedPawns;
}
}else lastSelectedPawns = new List<Pawn>(selectedPawns);
//code end
if (selectedPawns.Count > 0)
{
Vector3 zero = Vector3.zero;
int num = 0;
foreach (Pawn t in selectedPawns)
{
if (t.MapHeld == Find.CurrentMap)
{
zero += t.TrueCenter();
++num;
}
}
if (num > 0)
{
Vector3 target = zero / (float)num;
target.y = rootPos.y;
//original code
//rootPos = Vector3.MoveTowards(rootPos, target, 0.02f * Mathf.Max(Find.TickManager.TickRateMultiplier, 1f) * this.moveSpeedScale);
//Messages.Message("" + target, new MessageTypeDef());
//added code
Find.CameraDriver.JumpToCurrentMapLoc(target);
//code end
}
}
}
if ((double)__instance.autoPanSpeed <= 0.0 || Find.TickManager.CurTimeSpeed == TimeSpeed.Paused && !__instance.autoPanWhilePaused)
return false;
velocity.x = Mathf.Cos(__instance.autoPanAngle) * __instance.autoPanSpeed;
velocity.z = Mathf.Sin(__instance.autoPanAngle) * __instance.autoPanSpeed;
return false;
}
}
}