Skip to content

Commit

Permalink
Fix bug that with masturbation scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eusth committed Sep 22, 2016
1 parent 7412622 commit 767bb0d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 32 deletions.
14 changes: 8 additions & 6 deletions HoneySelectVR/HoneyActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@
using System.Text;
using UnityEngine;
using VRGIN.Core;
using static Config.VoiceSystem;

namespace HoneySelectVR
{
public class HoneyActor : DefaultActor<CharInfo>
{
private GameObject _HeadRoot;
private TransientHead _Head;
public TransientHead Head { get; private set; }

public HoneyActor(CharInfo nativeActor) : base(nativeActor)
{
_Head = nativeActor.gameObject.AddComponent<TransientHead>();
Head = nativeActor.gameObject.AddComponent<TransientHead>();
//nativeActor.chaBody.asVoice.spatialBlend = 1f;
//nativeActor.chaBody.asVoice.spatialize = true;
}

private Transform _Eyes;
public override Transform Eyes
{
get
{
return _Head.Eyes;
return Head.Eyes;
//return Actor.GetReferenceInfo(CharReference.RefObjKey.AP_Nose).transform;
}
}
Expand All @@ -31,11 +33,11 @@ public override bool HasHead
{
get
{
return _Head.Visible;
return Head.Visible;
}
set
{
_Head.Visible = value;
Head.Visible = value;
}
}
}
Expand Down
54 changes: 33 additions & 21 deletions HoneySelectVR/HoneyInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,60 @@ namespace HoneySelectVR
internal class HoneyInterpreter : GameInterpreter
{
public HScene Scene;
private IList<HoneyActor> _Actors = new List<HoneyActor>();
private FieldInfo _FemaleField = typeof(HScene).GetField("chaFemale", BindingFlags.NonPublic | BindingFlags.Instance);
private FieldInfo _MaleField = typeof(HScene).GetField("chaMale", BindingFlags.NonPublic | BindingFlags.Instance);
private HoneyActor _Female;
private HoneyActor _Male;


protected override void OnLevel(int level)
{
base.OnLevel(level);

Scene = GameObject.FindObjectOfType<HScene>();
StartCoroutine(DelayedInit());
}

protected override void OnUpdate()
{
base.OnUpdate();
if (Scene)
{
StartCoroutine(DelayedInit());
} else
{
_Male = null;
_Female = null;
}
}

IEnumerator DelayedInit()
private IEnumerator DelayedInit()
{
var scene = Singleton<Scene>.Instance;
if (!scene)
VRLog.Error("No scene");

while(scene.IsNowLoading)
while (_FemaleField.GetValue(Scene) == null)
{
yield return null;
}

foreach(var actor in GameObject.FindObjectsOfType<CharInfo>())
{
_Actors.Add(new HoneyActor(actor));
}

_Actors = _Actors.OrderBy(a => a.Actor.Sex).ToList();

VRLog.Info("Found {0} chars", _Actors.Count);
_Male = new HoneyActor(_MaleField.GetValue(Scene) as CharMale);
_Female = new HoneyActor(_FemaleField.GetValue(Scene) as CharFemale);
}

protected override void OnUpdate()
{
base.OnUpdate();
}

public override IEnumerable<IActor> Actors
{
get
{
return _Actors.Cast<IActor>();

foreach(var actor in new HoneyActor[] { _Male, _Female })
{
if(actor != null && actor.Actor && actor.Actor.chaBody.eyeLookCtrl)
{
if(!actor.Eyes)
{
actor.Head.Reinitialize();
}
yield return actor;
}
}
}
}

Expand Down
26 changes: 21 additions & 5 deletions HoneySelectVR/TransientHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using UnityEngine;
using VRGIN.Core;
using VRGIN.Helpers;

namespace HoneySelectVR
{
Expand Down Expand Up @@ -46,15 +47,20 @@ public bool Visible

protected override void OnStart()
{

avatar = GetComponent<CharInfo>();
Reinitialize();
}

public void Reinitialize()
{
headTransform = GetHead(avatar);
eyesTransform = GetEyes(avatar);

root = avatar.objRoot.transform;
m_tongues = root.GetComponentsInChildren<SkinnedMeshRenderer>().Where(renderer => renderer.name.StartsWith("cm_O_tang") || renderer.name == "cf_O_tang").Where(tongue => tongue.enabled).ToArray();

}

public static Transform GetHead(CharInfo human)
{
return human.chaBody.objHead.GetComponentsInParent<Transform>().First(t => t.name.StartsWith("c") && t.name.Contains("J_Head"));
Expand All @@ -63,12 +69,16 @@ public static Transform GetHead(CharInfo human)

public static Transform GetEyes(CharInfo human)
{
var eyes = human.chaBody.objHead.GetComponentsInChildren<Transform>().FirstOrDefault(t => t.name.StartsWith("c") && t.name.EndsWith("Eye_r_L"));
var eyes = human.chaBody.objHeadBone.transform.Descendants().FirstOrDefault(t => t.name.StartsWith("c") && t.name.EndsWith("J_Eye_r_L"));
if (!eyes)
{
VRLog.Info("Creating eyes");
eyes = new GameObject("cm_Eye_r_L").transform;
eyes.SetParent(GetHead(human), false);
eyes.transform.localPosition = new Vector3(0, 0.17f, 0.05f);
eyes.transform.localPosition = new Vector3(0, 0.07f, 0.05f);
} else
{
VRLog.Info("FOund eyes");
}
return eyes;
}
Expand All @@ -83,11 +93,17 @@ void SetVisibility(bool visible)
//Console.WriteLine("Enabling {0} renderers", rendererList.Count);
foreach (var renderer in rendererList)
{
renderer.enabled = true;
if (renderer)
{
renderer.enabled = true;
}
}
foreach (var renderer in m_tongues)
{
renderer.enabled = true;
if (renderer)
{
renderer.enabled = true;
}
}

}
Expand Down

0 comments on commit 767bb0d

Please sign in to comment.