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
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using DunGen;
|
|
|
|
namespace ScarletMansion.GamePatch.Props {
|
|
public abstract class RandomPrefabBase : RandomProp {
|
|
|
|
public List<GameObject> props = new List<GameObject>();
|
|
|
|
[Header("Randomizer")]
|
|
public bool randomizePosition = false;
|
|
public float randomPositionRange = 0f;
|
|
public bool randomizeRotation = true;
|
|
public FloatRange randomRotationRange = new FloatRange(0f, 360f);
|
|
|
|
[Header("Special Logic")]
|
|
public bool skipNextSpawn;
|
|
|
|
public void SpawnGameObject(RandomStream randomStream, GameObject prefab){
|
|
// I really hate that I have to do this
|
|
// but DungeonGenerator.ProcessProps() goes through every RandomProp regardless if the gameobject is active or not
|
|
// I cannot escape it
|
|
if (skipNextSpawn) {
|
|
skipNextSpawn = false;
|
|
return;
|
|
}
|
|
|
|
var gameObject = GameObject.Instantiate(prefab);
|
|
var gameObjectTransform = gameObject.transform;
|
|
gameObjectTransform.parent = transform;
|
|
|
|
if (randomizePosition){
|
|
var x = (float)randomStream.NextDouble() * randomPositionRange;
|
|
var z = (float)randomStream.NextDouble() * randomPositionRange;
|
|
gameObjectTransform.localPosition = new Vector3(x, 0f, z);
|
|
} else {
|
|
gameObjectTransform.localPosition = Vector3.zero;
|
|
}
|
|
|
|
if (randomizeRotation){
|
|
var y = randomRotationRange.GetRandom(randomStream);
|
|
gameObjectTransform.localEulerAngles = new Vector3(0f, y, 0f);
|
|
} else {
|
|
gameObjectTransform.localRotation = Quaternion.identity;
|
|
}
|
|
}
|
|
|
|
|
|
public void OnDrawGizmosSelected(){
|
|
if (randomizePosition) {
|
|
Utility.DrawGizmoCircle(transform, randomPositionRange, Color.green);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|