replace as with direct cast

This commit is contained in:
JohnCorby 2022-05-29 13:46:43 -07:00
parent 516c91dca9
commit ccaa7f89cf
3 changed files with 7 additions and 7 deletions

View File

@ -34,7 +34,7 @@ internal class GhostPartyDirectorPatches : QSBPatch
var index = Random.Range(0, __instance._ghostsWaitingToAmbush.Count);
DebugLog.DebugWrite($"Unlocking ghost {index} for ambush.");
var ghost = __instance._ghostsWaitingToAmbush[index].GetWorldObject<QSBGhostBrain>();
(ghost.GetAction(GhostAction.Name.PartyHouse) as QSBPartyHouseAction).AllowChasePlayer();
((QSBPartyHouseAction)ghost.GetAction(GhostAction.Name.PartyHouse)).AllowChasePlayer();
ghost.HintPlayerLocation(ghost._data.players.MinBy(x => x.Value.playerLocation.distance).Key);
if (firstAmbush)
{
@ -68,11 +68,11 @@ internal class GhostPartyDirectorPatches : QSBPatch
__instance._ambushTriggered = true;
__instance._waitingToAmbushInitial = true;
__instance._ambushTriggerTime = Time.time + (__instance._ambushTriggeredThisLoop ? __instance._secondaryAmbushDelay : __instance._initialAmbushDelay);
(__instance._fireplaceGhost.GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse) as QSBPartyHouseAction).LookAtPlayer(0f, TurnSpeed.MEDIUM);
((QSBPartyHouseAction)__instance._fireplaceGhost.GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse)).LookAtPlayer(0f, TurnSpeed.MEDIUM);
for (int i = 0; i < __instance._ambushGhosts.Length; i++)
{
float delay = (float)i;
(__instance._ambushGhosts[i].GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse) as QSBPartyHouseAction).LookAtPlayer(delay, TurnSpeed.SLOWEST);
((QSBPartyHouseAction)__instance._ambushGhosts[i].GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse)).LookAtPlayer(delay, TurnSpeed.SLOWEST);
}
}
@ -100,7 +100,7 @@ internal class GhostPartyDirectorPatches : QSBPatch
__instance._ghostsWaitingToAmbush.AddRange(__instance._ambushGhosts);
for (int i = 0; i < __instance._directedGhosts.Length; i++)
{
(__instance._directedGhosts[i].GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse) as QSBPartyHouseAction).ResetAllowChasePlayer();
((QSBPartyHouseAction)__instance._directedGhosts[i].GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.PartyHouse)).ResetAllowChasePlayer();
}
}

View File

@ -60,7 +60,7 @@ internal class GhostPartyPathDirectorPatches : QSBPatch
var ghostBrain = __instance._dispatchedGhosts[i].GetWorldObject<QSBGhostBrain>();
if (ghostBrain.GetCurrentActionName() == GhostAction.Name.PartyPath)
{
var partyPathAction = ghostBrain.GetCurrentAction() as QSBPartyPathAction;
var partyPathAction = (QSBPartyPathAction)ghostBrain.GetCurrentAction();
if (partyPathAction.hasReachedEndOfPath)
{
if (!partyPathAction.isMovingToFinalPosition)
@ -101,7 +101,7 @@ internal class GhostPartyPathDirectorPatches : QSBPatch
var num = Random.Range(0, __instance._ghostSpawns.Length);
ghostBrain2.AttachedObject.transform.position = __instance._ghostSpawns[num].spawnTransform.position;
ghostBrain2.AttachedObject.transform.eulerAngles = Vector3.up * __instance._ghostSpawns[num].spawnTransform.eulerAngles.y;
(ghostBrain2.GetCurrentAction() as QSBPartyPathAction).StartFollowPath();
((QSBPartyPathAction)ghostBrain2.GetCurrentAction()).StartFollowPath();
__instance._ghostSpawns[num].spawnDoor.Open();
__instance._ghostSpawns[num].spawnDoorTimer = Time.timeSinceLevelLoad + 4f;
__instance._waitingGhosts.RemoveAt(0);

View File

@ -200,7 +200,7 @@ internal class GhostZone2DirectorPatches : QSBPatch
DebugLog.DebugWrite($"- fade light down");
QSBGhostZone2Director.ElevatorsStatus[j].elevatorPair.elevator.topLight.FadeTo(0f, 0.2f);
DebugLog.DebugWrite($"- get action");
QSBGhostZone2Director.ElevatorsStatus[j].elevatorAction = __instance._elevators[j].ghost.GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.ElevatorWalk) as QSBElevatorWalkAction;
QSBGhostZone2Director.ElevatorsStatus[j].elevatorAction = (QSBElevatorWalkAction)__instance._elevators[j].ghost.GetWorldObject<QSBGhostBrain>().GetAction(GhostAction.Name.ElevatorWalk);
DebugLog.DebugWrite($"- CallToUseElevator on action");
QSBGhostZone2Director.ElevatorsStatus[j].elevatorAction.CallToUseElevator();
DebugLog.DebugWrite($"- get ghost controller");