Fixed treasure room event for bedroom Fixed painting's interaction with MattyFixes Fixed critical damage bug introduced by v62 Increased lights spawn for all presets by a lot Added Coroner compatibility Added Scarlet Devil Mansion (moon) to the interior's spawn list Lights now have a chance of flickering and dying
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using DunGen;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace ScarletMansion.GamePatch.Components.TreasureRoom {
|
|
public class TreasureRoomBookPullEvent : TreasureRoom {
|
|
|
|
[Header("References")]
|
|
public TreasureRoomBookSwitch[] switches;
|
|
|
|
[Header("Prefabs")]
|
|
public GameObject bookPrefab;
|
|
|
|
public override bool CanOpen() {
|
|
var ready = GetDoorStatusValue() == switches.Length;
|
|
if (ready) {
|
|
Plugin.logger.LogDebug($"Opening cause all books pulled");
|
|
return ready;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override int GetDoorStatusValue() {
|
|
return switches.Count(s => s.pulled);
|
|
}
|
|
|
|
protected override void LockTreasureDoor(List<Doorway> doorways) {
|
|
base.LockTreasureDoor(doorways);
|
|
|
|
if (StartOfRound.Instance.IsHost) {
|
|
|
|
Plugin.logger.LogDebug("HOST: Creating book switches");
|
|
|
|
switches = new TreasureRoomBookSwitch[3];
|
|
var zones = GetComponentInParent<Tile>().GetComponentsInChildren<TreasureRoomBookZone>();
|
|
var switchOrdered = zones.Where(z => z != null && z.gameObject.activeInHierarchy).OrderBy(s => systemRandom.NextDouble());
|
|
var mapPropsContainer = GetMapPropsContainer();
|
|
for(var i = 0; i < 3; ++i) {
|
|
var result = switchOrdered.ElementAt(i).GetRandomPosition(systemRandom);
|
|
var bookGameObject = GameObject.Instantiate(bookPrefab, result.position, result.rotation, mapPropsContainer.transform);
|
|
var networkObject = bookGameObject.GetComponent<NetworkObject>();
|
|
|
|
var bookScript = bookGameObject.GetComponentInChildren<TreasureRoomBookSwitch>();
|
|
bookScript.treasureRoom = this;
|
|
switches[i] = bookScript;
|
|
|
|
networkObject.Spawn(true);
|
|
}
|
|
|
|
CreateDoorStatuses(doorways);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|