Skip to content

Commit

Permalink
v0.1.1 HMD option only works in no fail mode, built for BS v0.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PureDark committed Aug 22, 2018
1 parent a999eb5 commit b5d688a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
18 changes: 13 additions & 5 deletions TransparentWall/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ namespace TransparentWall
class Plugin : IEnhancedPlugin, IPlugin
{
public static string PluginName = "TransparentWall";
public const string VersionNum = "0.1.0";
public const string VersionNum = "0.1.1";

public string Name => PluginName;
public string Version => VersionNum;
public string[] Filter { get; }


private static AsyncScenesLoader loader;

public const string KeyTranparentWall = "TransparentWall";
public const string KeyHMD = "HMD";
public const string KeyCameraPlus = "CameraPlus";
Expand Down Expand Up @@ -111,13 +113,19 @@ public void OnApplicationQuit()

private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
{
if (scene.buildIndex == 5)
if (scene.name == "StandardLevelLoader")
{
new GameObject("TransparentWall").AddComponent<TransparentWall>();
if (!loader)
loader = Resources.FindObjectsOfTypeAll<AsyncScenesLoader>().FirstOrDefault();
loader.loadingDidFinishEvent += OnLoadingDidFinish;
}
}
public void OnLoadingDidFinish()
{
new GameObject("TransparentWall").AddComponent<TransparentWall>();
}

public void OnLateUpdate()
public void OnLateUpdate()
{
}

Expand Down
62 changes: 33 additions & 29 deletions TransparentWall/TransparentWall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class TransparentWall : MonoBehaviour

private void Start()
{
if (!Plugin.IsTranparentWall)
return;
try
{
this._beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll<BeatmapObjectSpawnController>().First();
Expand Down Expand Up @@ -53,8 +55,11 @@ private void setupCams()
private IEnumerator<WaitForEndOfFrame> setupCamerasCoroutine()
{
yield return new WaitForEndOfFrame();

var mainGameSceneSetupData = Resources.FindObjectsOfTypeAll<MainGameSceneSetupData>().FirstOrDefault();

Camera mainCamera = FindObjectsOfType<Camera>().FirstOrDefault(x => x.CompareTag("MainCamera"));
if (Plugin.IsHMDOn)
if (Plugin.IsHMDOn && !mainGameSceneSetupData.gameplayOptions.validForScoreUse)
mainCamera.cullingMask &= ~(1 << WallLayer);
else
mainCamera.cullingMask |= (1 << WallLayer);
Expand All @@ -63,25 +68,27 @@ private IEnumerator<WaitForEndOfFrame> setupCamerasCoroutine()
{
if (plugin.Name == "CameraPlus" || plugin.Name == "CameraPlusOrbitEdition" || plugin.Name == "DynamicCamera")
{
var _cameraPlus = ReflectionUtil.GetPrivateField<MonoBehaviour>(plugin, "_cameraPlus");
if (_cameraPlus != null)
MonoBehaviour _cameraPlus = ReflectionUtil.GetPrivateField<MonoBehaviour>(plugin, "_cameraPlus");
while (_cameraPlus == null)
{
yield return new WaitForEndOfFrame();
_cameraPlus = ReflectionUtil.GetPrivateField<MonoBehaviour>(plugin, "_cameraPlus");
}
Camera cam = ReflectionUtil.GetPrivateField<Camera>(_cameraPlus, "_cam");
if (cam != null)
{
Camera cam = ReflectionUtil.GetPrivateField<Camera>(_cameraPlus, "_cam");
if (cam !=null)
{
if (((plugin.Name == "CameraPlus" || plugin.Name == "CameraPlusOrbitEdition") && Plugin.IsCameraPlusOn) || (plugin.Name == "DynamicCamera" && Plugin.IsDynamicCameraOn))
cam.cullingMask &= ~(1 << WallLayer);
else
cam.cullingMask |= (1 << WallLayer);
}
Camera multi = ReflectionUtil.GetPrivateField<Camera>(_cameraPlus, "multi");
if (multi != null)
{
if (Plugin.IsMutiViewFirstPersonOn)
multi.cullingMask &= ~(1 << WallLayer);
else
multi.cullingMask |= (1 << WallLayer);
}
if (((plugin.Name == "CameraPlus" || plugin.Name == "CameraPlusOrbitEdition") && Plugin.IsCameraPlusOn) || (plugin.Name == "DynamicCamera" && Plugin.IsDynamicCameraOn))
cam.cullingMask &= ~(1 << WallLayer);
else
cam.cullingMask |= (1 << WallLayer);
}
Camera multi = ReflectionUtil.GetPrivateField<Camera>(_cameraPlus, "multi");
if (multi != null)
{
if (Plugin.IsMutiViewFirstPersonOn)
multi.cullingMask &= ~(1 << WallLayer);
else
multi.cullingMask |= (1 << WallLayer);
}
break;
}
Expand All @@ -92,16 +99,13 @@ public virtual void HandleObstacleDiStartMovementEvent(BeatmapObjectSpawnControl
{
try
{
if (Plugin.IsTranparentWall)
{
StretchableObstacle _stretchableObstacle = ReflectionUtil.GetPrivateField<StretchableObstacle>(obstacleController, "_stretchableObstacle");
StretchableCube _stretchableCoreOutside = ReflectionUtil.GetPrivateField<StretchableCube>(_stretchableObstacle, "_stretchableCoreOutside");
StretchableCube _stretchableCoreInside = ReflectionUtil.GetPrivateField<StretchableCube>(_stretchableObstacle, "_stretchableCoreInside");
MeshRenderer _meshRenderer = ReflectionUtil.GetPrivateField<MeshRenderer>(_stretchableCoreOutside, "_meshRenderer");
MeshRenderer _meshRenderer2 = ReflectionUtil.GetPrivateField<MeshRenderer>(_stretchableCoreInside, "_meshRenderer");
_stretchableCoreOutside.gameObject.layer = WallLayer;
_stretchableCoreInside.gameObject.layer = WallLayer;
}
StretchableObstacle _stretchableObstacle = ReflectionUtil.GetPrivateField<StretchableObstacle>(obstacleController, "_stretchableObstacle");
StretchableCube _stretchableCoreOutside = ReflectionUtil.GetPrivateField<StretchableCube>(_stretchableObstacle, "_stretchableCoreOutside");
StretchableCube _stretchableCoreInside = ReflectionUtil.GetPrivateField<StretchableCube>(_stretchableObstacle, "_stretchableCoreInside");
//MeshRenderer _meshRenderer = ReflectionUtil.GetPrivateField<MeshRenderer>(_stretchableCoreOutside, "_meshRenderer");
//MeshRenderer _meshRenderer2 = ReflectionUtil.GetPrivateField<MeshRenderer>(_stretchableCoreInside, "_meshRenderer");
_stretchableCoreOutside.gameObject.layer = WallLayer;
_stretchableCoreInside.gameObject.layer = WallLayer;
}
catch (Exception ex)
{
Expand Down

0 comments on commit b5d688a

Please sign in to comment.