public override void OnSetup() { if (ConfigUtil.TryGetLocalConfig <DoorWaveDataDTO>("DoorWaves.json", out var cfg)) { foreach (var data in cfg.Datas) { if (CurrentExpeditionTier != data.TargetExpeditionTier) { continue; } if (CurrentExpeditionIndex != data.TargetExpeditionIndex) { continue; } DataContext = data.Datas; } } if (DataContext == null) { ConfigUtil.SaveLocalConfig <DoorWaveDataDTO>("DoorWaves.json"); Logger.Error("UNLOAD SELF!"); UnloadSelf(); return; } }
public override void OnBuildDone() { foreach (var doorData in DataContext) { var doorZone = Builder.GetZone(doorData.DoorZoneLayer, doorData.DoorZoneIndex); var door = Builder.GetSpawnedDoorInZone(doorZone); if (door == null) { continue; } var doorWaveManager = new LG_DoorMultiWave(); doorWaveManager.Door = door; doorWaveManager.MessageData = doorData.Messages; RegisterUpdateEvent(doorWaveManager.OnUpdate); Replicators.Add(doorWaveManager); doorWaveManager.Setup(ReplicatorType.LevelInstance, ReplicatorCHType.GameOrderCritical, new DoorWaveState() { WaveCount = 0, PhaseStatus = PhaseType.Initialized }); var initPuzzle = ChainedPuzzleUtil.SetupDoor(doorData.ChainedPuzzleToActive, door); initPuzzle.SolvedMessageDuration = 0.0f; initPuzzle.Solved = () => { doorWaveManager.TriggerDoor(); }; var doorLock = door.m_locks.Cast <LG_SecurityDoor_Locks>(); doorLock.m_intOpenDoor.InteractionMessage = doorData.StartMessage; doorLock.m_intCustomMessage.m_message = doorData.LockdownMessage; doorLock.ChainedPuzzleToSolve = initPuzzle.Instance; var waveCount = doorData.WaveDatas.Length; doorWaveManager.WaveInfos = new WaveInfo[waveCount]; for (int i = 0; i < waveCount; i++) { var waveData = doorData.WaveDatas[i]; var waveInfo = new WaveInfo { RawData = waveData }; doorWaveManager.WaveInfos[i] = waveInfo; //Setup ChainedPuzzle ChainedPuzzleContext puzzle = null; if (ChainedPuzzleUtil.IsValidID(waveData.PuzzleID)) { puzzle = ChainedPuzzleUtil.SetupDoor(waveData.PuzzleID, door); } else if (i == 0) { puzzle = ChainedPuzzleUtil.SetupDoor(4, door); Logger.Warning("ChainedPuzzleToActive should always have ValidPuzzle ID!, Replaced with id: 4"); } //Assign Puzzle Instance if (puzzle != null) { puzzle.SolvedMessage = string.Empty; puzzle.SolvedMessageDuration = 0.0f; waveInfo.PuzzleToStart = puzzle; } else { Logger.Warning("ChainedPuzzle was null!, Wave: {0}", i + 1); } //Setup Verification Terminal if (waveData.SearchPhaseType == SearchType.SearchTerminal && Builder.TryGetZone(waveData.TerminalZoneLayer, waveData.TerminalZoneIndex, out var terminalZone)) { var terminal = Builder.GetSpawnedTerminalInZone(terminalZone, waveData.TerminalPickMode); if (terminal == null) { Logger.Warning("Unable to find Terminal Instance for Search Phase!, Wave: {0}", i + 1); continue; } //Add Local Log waveInfo.VerifyTerminal = terminal; waveInfo.ValidFileName = waveData.GeneratedFileName; terminal.AddLocalLog(new TerminalLogFileData() { FileName = waveData.GeneratedFileName, FileContent = waveData.GeneratedFileContent }); //Add Controller Command TerminalUtil.AddCommand(terminal, doorData.PushKeyCommand, doorData.PushKeyCommandDesc, (eTerm, arg1, arg2) => { DoorCommandHandler(doorWaveManager, doorData.PushKeyCommand, eTerm, arg1, arg2); }); //Has Valid ChainedPuzzle Setting for Terminal var verifyPuzzleID = waveData.TerminalChainedPuzzleToVerify; if (ChainedPuzzleUtil.TryGetBlock(verifyPuzzleID, out var block)) { var terminalPuzzle = ChainedPuzzleUtil.SetupTerminal(block, terminal); waveInfo.PuzzleToVerify = terminalPuzzle; } } } } }