LadyAliceMargatroid 4413d12ea3 Added new treasure room spawn (servant's quarters)
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
2024-09-01 18:45:16 -07:00

62 lines
2.4 KiB
C#

using DunGen;
using ScarletMansion.GamePatch.Items;
using ScarletMansion.GamePatch.Managers;
using System;
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 TreasureRoomPaintingGrabEvent : TreasureRoom {
public ScarletPainting paintingTarget;
public override bool CanOpen() {
var ready = paintingTarget && !paintingTarget.isAttached;
if (ready) {
Plugin.logger.LogDebug($"Opening cause painting grabbed");
return ready;
}
return false;
}
protected override void LockTreasureDoor(List<Doorway> doorways) {
base.LockTreasureDoor(doorways);
var bedroomEvent = GetComponentInParent<Tile>().GetComponentInChildren<ScarletBedroom>();
var globalProp = bedroomEvent.GetComponentInChildren<GlobalProp>(true);
globalProp.gameObject.SetActive(true);
Plugin.logger.LogDebug("Moving vent to inside of the treasure room");
var firstDoorway = doorways.FirstOrDefault();
var treasureRoomCenterTransform = firstDoorway.ConnectedDoorway.Tile.transform;
var bedroomEventVent = bedroomEvent.vent.transform;
Plugin.logger.LogDebug($"{bedroomEventVent.position} -> {treasureRoomCenterTransform.position}");
bedroomEventVent.position = treasureRoomCenterTransform.position;
bedroomEventVent.rotation = treasureRoomCenterTransform.rotation;
if (StartOfRound.Instance.IsHost) {
Plugin.logger.LogDebug("HOST: Translocating an avaiable painting");
// grab random painting to use
var paintingTransform = bedroomEvent.paintingSpawnTransform;
var allPaintings = ScarletGenericManager.Instance.paintings;
var firstAvailablePainting = allPaintings.Where(p => !p.grabbedByEvent)
.OrderBy(p => Vector3.SqrMagnitude(paintingTransform.position - p.transform.position))
.FirstOrDefault();
if (firstAvailablePainting) {
paintingTarget = firstAvailablePainting;
paintingTarget.RepositionClientRpc(paintingTransform.position, paintingTransform.rotation);
} else {
Plugin.logger.LogWarning($"Bedroom treasure room failed since there's no available paintings to grab");
}
}
}
}
}