Skip to content

Commit

Permalink
Change scanning of actors, move input checks to OnUpdate, update VRGI…
Browse files Browse the repository at this point in the history
…N, fix gazes.
  • Loading branch information
Eusth committed Sep 26, 2016
1 parent a45bc6b commit 059c776
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
41 changes: 41 additions & 0 deletions HoneySelectVR/HoneyActor.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;
using static Config.VoiceSystem;

namespace HoneySelectVR
Expand All @@ -16,6 +17,13 @@ public class HoneyActor : DefaultActor<CharInfo>
public HoneyActor(CharInfo nativeActor) : base(nativeActor)
{
Head = nativeActor.gameObject.AddComponent<TransientHead>();

if (Actor.Sex == 1) // Only females!
{
var lookAtMe = nativeActor.gameObject.AddComponent<LookAtMeYouCuteLittleThing>();
lookAtMe.Actor = this;
}

//nativeActor.chaBody.asVoice.spatialBlend = 1f;
//nativeActor.chaBody.asVoice.spatialize = true;
}
Expand All @@ -40,5 +48,38 @@ public override bool HasHead
Head.Visible = value;
}
}

private class LookAtMeYouCuteLittleThing : ProtectedBehaviour
{
public HoneyActor Actor;

private LookTargetController _TargetController;
private Transform _MainCamera;

protected override void OnStart()
{
base.OnStart();
_TargetController = LookTargetController.Attach(Actor);
_MainCamera = Camera.main.transform;
}

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

var eyeLook = Actor.Actor.chaBody.eyeLookCtrl;
var neckLook = Actor.Actor.chaBody.neckLookCtrl;

if(eyeLook && eyeLook.target == _MainCamera)
{
eyeLook.target = _TargetController.Target;
}

if(neckLook && neckLook.target == _MainCamera)
{
neckLook.target = _TargetController.Target;
}
}
}
}
}
49 changes: 18 additions & 31 deletions HoneySelectVR/HoneyInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,36 @@ protected override void OnLevel(int level)
if (Scene)
{
StartCoroutine(DelayedInit());
} else
{
_Male = null;
_Female = null;
}

_Male = null;
_Female = null;

}

private IEnumerator DelayedInit()
{
var scene = Singleton<Scene>.Instance;
while (_FemaleField.GetValue(Scene) == null)
yield return null;
yield return null;

var characterController = Character.Instance;
if(characterController)
{
yield return null;
}
var male = characterController.dictMale.Values.FirstOrDefault();
var female = characterController.dictFemale.Values.FirstOrDefault();

_Male = new HoneyActor(_MaleField.GetValue(Scene) as CharMale);
_Female = new HoneyActor(_FemaleField.GetValue(Scene) as CharFemale);
if(male)
_Male = new HoneyActor(male);
if(female)
_Female = new HoneyActor(female);
}
}

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

bool _ExitSceneDetected = false;
/// <summary>
/// Workaround because ExitScene sets the timeScale to zero, which causes a number of issues with the input.
/// </summary>
protected override void OnLateUpdate()
{
base.OnLateUpdate();

bool exitScene = Singleton<Scene>.Instance.AddSceneName == SceneNames.Exit;
if (exitScene != _ExitSceneDetected)
{
if (exitScene)
{
Time.timeScale = 1.0f;
}
_ExitSceneDetected = exitScene;
}
}


public override IEnumerable<IActor> Actors
{
get
Expand Down
4 changes: 3 additions & 1 deletion HoneySelectVR/PlayTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ protected override void OnLevel(int level)
UpdateVisibility();
}

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

PlayButton selectedButton = null;
if (IsTracking && IsVisible)
{
Expand Down

0 comments on commit 059c776

Please sign in to comment.