Moved dungen code to DunGenPlus

Added critical damage as a mechanic
Maid knife feed deals critical damage, then kills on second time
Added concept of treasure room with kitchen
Frames now only start at the player when not being looked
New attempt at snowglobe animations, it broke though
Added concept of indoor weathers
LethalConfig compability now changes the color of configs that my presets touch
Added jukebox
Changed modGUID
Removed AC compability
Falling into void deals critical damage and teleports, then kills on second time
Maid spawns revenant ghost on death
This commit is contained in:
LadyAliceMargatroid 2024-08-02 08:56:09 -07:00
parent faa391c309
commit 056cac8df1
63 changed files with 976 additions and 2061 deletions

View file

@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.Netcode;
using UnityEngine;
namespace ScarletMansion.GamePatch.Components {
public class ScarletRadio : NetworkBehaviour{
[Header("Networked Values")]
public int volume;
public bool playing;
public int audioIndex;
[Header("Songs")]
public AudioClip[] audioClips;
[Header("References")]
public AudioSource audioSource;
public float maxVolume = 1f;
public Transform onOffSwitchTransform;
public Transform volumeSwitchTransform;
public Transform volumeDialTransform;
public Transform tuneSwitchTransform;
private float onOffSwitchTransformX;
private float volumeSwitchTransformX;
private float volumeDialTransformX;
private float onOffSwitchTransforX;
[Header("Switch Values")]
public Vector2 onOffSwitchRotation;
public Vector2 volumeSwitchRotation;
public Vector2 volumeDialRotation;
public Vector2 tuneSwitchRotation;
void Start() {
audioSource.volume = maxVolume * (volume * 0.1f);
}
void RotateTransformTo(Transform dial, ref float current, float towards){
current = Mathf.Lerp(current, towards, Time.deltaTime * 2f);
var v = new Vector3(current, 0f, 0f);
dial.localEulerAngles = v;
}
void RotateTransformTo(Transform dial, ref float current, Vector2 lerpVector, float lerp){
RotateTransformTo(dial, ref current, Mathf.Lerp(lerpVector.x, lerpVector.y, lerp));
}
void Update(){
RotateTransformTo(onOffSwitchTransform, ref onOffSwitchTransformX, playing ? onOffSwitchRotation.y : onOffSwitchRotation.x);
RotateTransformTo(volumeSwitchTransform, ref volumeSwitchTransformX, volumeSwitchRotation, volume * 0.1f);
RotateTransformTo(volumeDialTransform, ref volumeDialTransformX, volumeDialRotation, volume * 0.1f);
RotateTransformTo(tuneSwitchTransform, ref onOffSwitchTransforX, tuneSwitchRotation, (float)audioIndex / (audioClips.Length - 1));
}
public void ToggleOnOffSwitch(){
ToggleOnOffSwitchServerRpc();
}
public void ToggleVolumeSwitchLeft() {
ToggleVolumeSwitchServerRpc(-1);
}
public void ToggleVolumeSwitchRight() {
ToggleVolumeSwitchServerRpc(1);
}
public void ToggleSongSwitch(){
ToggleSongSwitchServerRpc();
}
[ServerRpc(RequireOwnership = false)]
public void ToggleOnOffSwitchServerRpc(){
ToggleOnOffSwitchClientRpc(!playing);
}
[ClientRpc]
public void ToggleOnOffSwitchClientRpc(bool playing){
this.playing = playing;
if (playing) AttemptTurnOn();
else AttemptTurnOff();
}
[ServerRpc(RequireOwnership = false)]
public void ToggleVolumeSwitchServerRpc(int count){
ToggleVolumeSwitchClientRpc(Mathf.Clamp(volume + count, 0, 10));
}
[ClientRpc]
public void ToggleVolumeSwitchClientRpc(int volume){
this.volume = volume;
audioSource.volume = maxVolume * (volume * 0.1f);
}
[ServerRpc(RequireOwnership = false)]
public void ToggleSongSwitchServerRpc(){
ToggleSongSwitchClientRpc((audioIndex + 1) % audioClips.Length);
}
[ClientRpc]
public void ToggleSongSwitchClientRpc(int audioIndex){
this.audioIndex = audioIndex;
if (playing && audioSource.isPlaying) audioSource.Stop();
audioSource.clip = audioClips[audioIndex];
AttemptTurnOn();
}
public void AttemptTurnOff(){
if (!playing && audioSource.isPlaying) audioSource.Stop();
}
public void AttemptTurnOn(){
if (playing && !audioSource.isPlaying) audioSource.Play();
}
}
}