Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 12 additions & 41 deletions Assets/Scripts/Game/Automap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ public void UpdateAutomapStateOnWindowPush()
// since new teleporters could have been discovered by pc since last time map was open this must be checked here
CreateTeleporterMarkers();

SetActivationStateOfMapObjects(true);

gameobjectPlayerMarkerArrow.transform.position = gameObjectPlayerAdvanced.transform.position;
gameobjectPlayerMarkerArrow.transform.rotation = gameObjectPlayerAdvanced.transform.rotation;

Expand All @@ -429,12 +427,6 @@ public void UpdateAutomapStateOnWindowPush()
/// </summary>
public void UpdateAutomapStateOnWindowPop()
{
// about SetActivationStateOfMapObjects(false):
// this will not be enough if we will eventually allow gui windows to be opened while exploring the world
// then it will be necessary to either only disable the colliders on the automap level geometry or
// make player collision ignore colliders of objects in automap layer - I would clearly prefer this option
SetActivationStateOfMapObjects(false);

if ((GameManager.Instance.PlayerEnterExit.IsPlayerInside) && ((GameManager.Instance.PlayerEnterExit.IsPlayerInsideBuilding) || (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon) || (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle)))
{
// and get rid of lights used to light the automap level geometry
Expand Down Expand Up @@ -1154,9 +1146,6 @@ void CheckForNewlyDiscoveredMeshes()

if ((gameobjectGeometry != null) && ((GameManager.Instance.IsPlayerInsideBuilding) || (GameManager.Instance.IsPlayerInsideDungeon) || (GameManager.Instance.IsPlayerInsideCastle)))
{
// enable automap level geometry for revealing (so raycasts can hit colliders of automap level geometry)
gameobjectGeometry.SetActive(true);

// reveal geometry right below player - raycast down from player head position
Vector3 rayStartPos = gameObjectPlayerAdvanced.transform.position + Camera.main.transform.localPosition;
Vector3 rayDirection = Vector3.down;
Expand Down Expand Up @@ -1189,9 +1178,6 @@ void CheckForNewlyDiscoveredMeshes()
ScanWithRaycastInDirectionAndUpdateMeshesAndMaterials(rayStartPos + stepVector, rayDirection, rayDistance, offsetSecondProtectionRaycast);
}
}

// disable gameobjectGeometry so player movement won't be affected by geometry colliders of automap level geometry
gameobjectGeometry.SetActive(false);
}

// entrance marker discovery check - only do as long as undiscovered
Expand Down Expand Up @@ -1281,7 +1267,7 @@ IEnumerator CoroutineCheckForNewlyDiscoveredMeshes()
{
while (true)
{
// only proceed if automap is not opened (otherwise command gameobjectGeometry.SetActive(false); will mess with automap rendering when scheduling is a bitch and overwrites changes from UpdateAutomapStateOnWindowPush()
// only update discovery while automap is closed
if (!isOpenAutomap)
{
CheckForNewlyDiscoveredMeshes();
Expand Down Expand Up @@ -1315,25 +1301,6 @@ private void UpdateSlicingPositionY()
// material.renderQueue = 3000;
//}

/// <summary>
/// sets active state of map GameObjects like geometry, beacons, user note markers and teleporter markers
/// used on automap open to enable (show) objects and hide them on automap close
/// it is important to set them inactive when closing the map - so that ingame raycasts won't hit colliders of map objects
/// </summary>
/// <param name="active">the desired activation state for the map objects to be set</param>
private void SetActivationStateOfMapObjects(bool active)
{
gameobjectGeometry.SetActive(active);

gameobjectBeacons.SetActive(active);

if (gameObjectUserNoteMarkers != null)
gameObjectUserNoteMarkers.SetActive(active);

if (gameobjectTeleporterMarkers != null)
gameobjectTeleporterMarkers.SetActive(active);
}

/// <summary>
/// setup beacons: lazy creation of player marker arrow and beacons including
/// player position beacon, dungeon entrance position beacon and rotation pivot axis position beacon
Expand Down Expand Up @@ -1622,8 +1589,6 @@ private void AddTeleporterMarkerOnMap(TeleporterTransform startPoint, Teleporter
gameobjectTeleporterMarkers.layer = layerAutomap;
}

gameobjectTeleporterMarkers.SetActive(false);

string teleporterEntranceName = NameGameobjectTeleporterSubStringStart + dictkey + NameGameobjectTeleporterEntranceSubStringEnd;
if (gameobjectTeleporterMarkers.transform.Find(teleporterEntranceName) == null)
{
Expand Down Expand Up @@ -2484,16 +2449,12 @@ void InitWhenInInteriorOrDungeon(StaticDoor? door = null, bool initFromLoadingSa
CreateIndoorGeometryForAutomap(door.Value);
RestoreStateAutomapDungeon(true);
resetAutomapSettingsFromExternalScript = true; // set flag so external script (DaggerfallAutomapWindow) can pull flag and reset automap values on next window push

SetActivationStateOfMapObjects(false);
}
else if ((GameManager.Instance.IsPlayerInsideDungeon) || (GameManager.Instance.IsPlayerInsideCastle))
{
CreateDungeonGeometryForAutomap();
RestoreStateAutomapDungeon(!initFromLoadingSave); // if a save game was loaded, do not reset the revisited state (don't set parameter forceNotVisitedInThisRun to true)
resetAutomapSettingsFromExternalScript = true; // set flag so external script (DaggerfallAutomapWindow) can pull flag and reset automap values on next window push

SetActivationStateOfMapObjects(false);
}
else
{
Expand Down Expand Up @@ -2525,12 +2486,22 @@ private void OnTransitionToExterior(PlayerEnterExit.TransitionEventArgs args)
{
SaveStateAutomapInterior();
DestroyBeacons();
if (gameobjectGeometry != null)
{
UnityEngine.Object.Destroy(gameobjectGeometry);
gameobjectGeometry = null;
}
}

private void OnTransitionToDungeonExterior(PlayerEnterExit.TransitionEventArgs args)
{
SaveStateAutomapDungeon(true);
DestroyBeacons();
if (gameobjectGeometry != null)
{
UnityEngine.Object.Destroy(gameobjectGeometry);
gameobjectGeometry = null;
}
}

void OnLoadEvent(SaveData_v1 saveData)
Expand Down Expand Up @@ -2731,4 +2702,4 @@ public static int AddNext<T>(this SortedList<int, T> sortedList, T item)
}

#endregion
}
}
2 changes: 1 addition & 1 deletion ProjectSettings/DynamicsManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: fffffefffffffeffffbffefffffffffffffffefffffffefffffffffffffffffffffffefffffffefffffffefffffffefffffffefffffffefffbbffefffffffeffc800fe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffefffffffefffffffeff
m_LayerCollisionMatrix: fffbfefffffbfeffffbbfefffffffffffffbfefffffbfefffffffffffffffffffffbfefffffbfeffc804fe0ffffbfefffffbfefffffbfefffbbbfefffffbfeffc800fe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfefffffbfefffffbfefffffbfeff
m_AutoSimulation: 1
m_AutoSyncTransforms: 1
m_ReuseCollisionCallbacks: 0
Expand Down