Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
NEO
  • Loading branch information
Keelhauled authored Jun 17, 2017
1 parent 7247eba commit d2cad17
Show file tree
Hide file tree
Showing 12 changed files with 1,184 additions and 0 deletions.
31 changes: 31 additions & 0 deletions LockOnNeoPlugin/LockOnPluginNeo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using IllusionPlugin;
using UnityEngine;
using LockOnPluginUtilities;

namespace LockOnPlugin
{
public class LockOnPluginNeo : IEnhancedPlugin
{
public string Name => GetType().Name;
public string Version => "2.0.0";

public string[] Filter => new string[]
{
"StudioNEO_32",
"StudioNEO_64",
};

public void OnLevelWasLoaded(int level)
{
if(level == 3 && !GameObject.Find("NeoMono") && FileManager.TargetSettingsExist())
new GameObject("NeoMono").AddComponent<NeoMono>();
}

public void OnUpdate(){}
public void OnLateUpdate(){}
public void OnApplicationStart(){}
public void OnApplicationQuit(){}
public void OnLevelWasInitialized(int level){}
public void OnFixedUpdate(){}
}
}
162 changes: 162 additions & 0 deletions LockOnNeoPlugin/NeoMono.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Studio;

namespace LockOnPlugin
{
internal partial class NeoMono : LockOnBase
{
private Studio.CameraControl camera;
private Studio.CameraControl.CameraData cameraData;
private OCIChar currentCharaOCI;

protected override void Start()
{
camera = Singleton<Studio.Studio>.Instance.cameraCtrl;
cameraData = GetSecureField<Studio.CameraControl, Studio.CameraControl.CameraData>("cameraData");
Singleton<Studio.Studio>.Instance.treeNodeCtrl.onSelect += new Action<TreeNodeObject>(OnSelectWork);
Singleton<Studio.Studio>.Instance.onDelete += new Action<ObjectCtrlInfo>(OnDeleteWork);

base.Start();

manageCursorVisibility = false;
}

protected override void Update()
{
base.Update();

prevCharaHotkey.KeyDownAction(() => CharaSwitch(false, scrollThroughMalesToo));
nextCharaHotkey.KeyDownAction(() => CharaSwitch(true, scrollThroughMalesToo));
}

protected override void OnGUI()
{
base.OnGUI();

if(showInfoMsg && guiTimeInfo > 0.0f)
{
DebugGUI(1.0f, 0.0f, 200f, 50f, infoMsg);
guiTimeInfo -= Time.deltaTime;
}
}

private void OnSelectWork(TreeNodeObject _node)
{
ObjectCtrlInfo objectCtrlInfo = null;
if(Singleton<Studio.Studio>.Instance.dicInfo.TryGetValue(_node, out objectCtrlInfo))
{
if(objectCtrlInfo.kind == 0)
{
OCIChar ocichar = objectCtrlInfo as OCIChar;

if(ocichar != currentCharaOCI)
{
currentCharaOCI = ocichar;
currentCharaInfo = ocichar.charInfo;
targetManager.UpdateAllTargets(ocichar.charInfo);

if(lockOnTarget)
{
if(!LockOn(lockOnTarget.name, true))
{
LockOnRelease();
}
}
}
else
{
currentCharaOCI = ocichar;
currentCharaInfo = ocichar.charInfo;
}

return;
}
}

showLockOnTargets = false;
currentCharaOCI = null;
currentCharaInfo = null;
targetManager.UpdateAllTargets(null);
LockOnRelease();
}

private void OnDeleteWork(ObjectCtrlInfo _info)
{
ObjectCtrlInfo objectCtrlInfo = _info;

if(objectCtrlInfo.kind == 0)
{
OCIChar ocichar = objectCtrlInfo as OCIChar;

if(ocichar == currentCharaOCI)
{
showLockOnTargets = false;
currentCharaOCI = null;
currentCharaInfo = null;
targetManager.UpdateAllTargets(null);
LockOnRelease();
}
}
}

protected override void LockOn()
{
TreeNodeCtrl nodeCtrl = Singleton<Studio.Studio>.Instance.treeNodeCtrl;

if(!nodeCtrl.selectNode)
{
List<TreeNodeObject> femaleNodes = GetCharaNodes<OCICharFemale>();
if(femaleNodes.Count > 0) nodeCtrl.SelectSingle(femaleNodes[0]);
}

base.LockOn();
}

private void CharaSwitch(bool scrollDown, bool malesToo)
{
TreeNodeCtrl nodeCtrl = Singleton<Studio.Studio>.Instance.treeNodeCtrl;
List<TreeNodeObject> charaNodes = malesToo ? GetCharaNodes<OCIChar>() : GetCharaNodes<OCICharFemale>();

if(!nodeCtrl.selectNode && charaNodes.Count > 0)
{
nodeCtrl.SelectSingle(charaNodes[0]);
}
else
{
for(int i = 0; i < charaNodes.Count; i++)
{
if(charaNodes[i] == nodeCtrl.selectNode)
{
int next = i + 1 > charaNodes.Count - 1 ? 0 : i + 1;
if(!scrollDown) next = i - 1 < 0 ? charaNodes.Count - 1 : i - 1;
nodeCtrl.SelectSingle(charaNodes[next]);
break;
}
}
}
}

private List<TreeNodeObject> GetCharaNodes<CharaType>()
{
List<TreeNodeObject> charaNodes = new List<TreeNodeObject>();

int n = 0; TreeNodeObject nthNode;
while(nthNode = Singleton<Studio.Studio>.Instance.treeNodeCtrl.GetNode(n))
{
ObjectCtrlInfo objectCtrlInfo = null;
if(Singleton<Studio.Studio>.Instance.dicInfo.TryGetValue(nthNode, out objectCtrlInfo))
{
if(objectCtrlInfo is CharaType)
{
charaNodes.Add(nthNode);
}
}
n++;
}

return charaNodes;
}
}
}
47 changes: 47 additions & 0 deletions LockOnNeoPlugin/NeoProperties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using UnityEngine;

namespace LockOnPlugin
{
internal partial class NeoMono : LockOnBase
{
protected override float CameraMoveSpeed
{
get { return camera.moveSpeed; }
set { camera.moveSpeed = value; }
}

protected override Vector3 CameraTargetPos
{
get { return camera.targetPos; }
set { camera.targetPos = value; }
}

protected override Vector3 LockOnTargetPos
{
get { return lockOnTarget.transform.position; }
}

protected override Vector3 CameraAngle
{
get { return camera.cameraAngle; }
set { camera.cameraAngle = value; }
}

protected override float CameraFov
{
get { return Camera.main.fieldOfView; }
set { Camera.main.fieldOfView = value; }
}

protected override Vector3 CameraDir
{
get { return cameraData.distance; }
set { cameraData.distance = value; }
}

protected override bool CameraTargetTex
{
set { camera.isConfigTargetTex = value; }
}
}
}
139 changes: 139 additions & 0 deletions LockOnPluginParty/HSceneMono.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using IllusionUtility.GetUtility;
using System.Linq;
using System.Collections.Generic;
using IllusionPlugin;
using UnityEngine;
using Manager;

namespace LockOnPlugin
{
internal partial class HSceneMono : LockOnBase
{
private HSceneManager instance;
private CameraControl_Ver2 camera;
private HSceneSprite sprite;

protected override void Start()
{
instance = Singleton<HSceneManager>.Instance;
currentCharaInfo = instance.females[0];
camera = Singleton<CameraControl_Ver2>.Instance;
sprite = Singleton<HScene>.Instance.sprite;
camera.isOutsideTargetTex = ModPrefs.GetString("LockOnPlugin", "HideCameraTarget", "True", true).ToLower() == "true" ? false : true;

base.Start();
}

protected override void Update()
{
base.Update();

nextCharaHotkey.KeyDownAction(CharaSwitch);
}

protected override void OnGUI()
{
if(guiTimeAngle > 0.0f)
{
DebugGUI(0.5f, 0.5f, 100f, 50f, "Camera tilt\n" + CameraAngle.z.ToString("0.0"));
guiTimeAngle -= Time.deltaTime;
}

if(guiTimeFov > 0.0f)
{
DebugGUI(0.5f, 0.5f, 100f, 50f, "Field of view\n" + CameraFov.ToString("0.0"));
guiTimeFov -= Time.deltaTime;
}

if(showInfoMsg && guiTimeInfo > 0.0f && sprite.categoryToggleOption.isActiveAndEnabled)
{
DebugGUI(0.5f, 0.0f, 200f, 50f, infoMsg);
guiTimeInfo -= Time.deltaTime;
}

if(showLockOnTargets)
{
foreach(GameObject target in targetManager.GetAllTargetsMultiple())
{
if(target)
{
Vector3 pos = Camera.main.WorldToScreenPoint(target.transform.position);
if(pos.z >= 0.0f && GUI.Button(new Rect(pos.x - targetSize / 2, Screen.height - pos.y - targetSize / 2, targetSize, targetSize), "L"))
{
LockOn(target);
}
}
else
{
showLockOnTargets = false;
targetManager.UpdateAllTargetsMultiple(null);
}
}
}
}

protected override void ToggleLockOnGUI()
{
if(showLockOnTargets)
{
showLockOnTargets = false;
}
else
{
List<CharInfo> females = new List<CharInfo>();
foreach(CharInfo character in FindObjectsOfType<CharInfo>().ToList())
{
if(character is CharFemale)
{
females.Add(character);
}
}

targetManager.UpdateAllTargetsMultiple(females);
showLockOnTargets = true;
}
}

private void CharaSwitch()
{
if(lockOnTarget && currentCharaInfo)
{
string targetName = lockOnTarget.name;
CharFemale[] females = FindObjectsOfType<CharFemale>();
int activeFemCount = 0;

foreach(CharFemale female in females)
{
if(female.chaBody.objBone)
{
activeFemCount++;
}
}

if(activeFemCount == 2)
{
if(currentCharaInfo == females[0])
{
currentCharaInfo = females[1];
LockOn(currentCharaInfo.chaBody.objBone.transform.FindLoop(targetName));
}
else if(currentCharaInfo == females[1])
{
currentCharaInfo = females[0];
LockOn(currentCharaInfo.chaBody.objBone.transform.FindLoop(targetName));
}
}
else
{
currentCharaInfo = instance.females[0];
LockOn(currentCharaInfo.chaBody.objBone.transform.FindLoop(targetName));
}
}
else
{
currentCharaInfo = instance.females[0];
LockOn();
}
}
}
}
Loading

0 comments on commit d2cad17

Please sign in to comment.