SDM_LethalCompany_Mod/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletPlayerControllerB.cs
LadyAliceMargatroid fd731baf2f Added configs for items and enemies
Critical damage renamed to marked for death and all share the same mechanic now
Revelant now slows down to speed over a fixed short amount instead the nonworking jank before
Moved item/enemy injection to DunGenPlus
2024-12-15 09:23:53 -08:00

72 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using GameNetcodeStuff;
namespace ScarletMansion.GamePatch.Components {
public class ScarletPlayerControllerB : MonoBehaviour {
public static Dictionary<PlayerControllerB, ScarletPlayerControllerB> playerControllers;
public PlayerControllerB player;
public bool markedForDeath;
public static ScarletPlayerControllerB GetScarletPlayerScript(PlayerControllerB player) {
if (!playerControllers.TryGetValue(player, out var scarlet)) {
scarlet = player.GetComponent<ScarletPlayerControllerB>();
if (scarlet == null) {
Plugin.logger.LogError($"Couldn't find scarlet player script for {player}. Kinda bad");
return null;
}
Plugin.logger.LogMessage($"Scarlet player script for {player} was not initially registered. We good now but like why?");
playerControllers.Add(player, scarlet);
}
return scarlet;
}
public static void InitializeScarletScripts() {
playerControllers = new Dictionary<PlayerControllerB, ScarletPlayerControllerB>();
}
public void Initialize(PlayerControllerB player){
this.player = player;
CreateHelmetForFlashlight(player, Assets.flashlight, 0);
CreateHelmetForFlashlight(player, Assets.flashlightBB, 1);
}
public void Register(){
if (!playerControllers.ContainsKey(player))
playerControllers.Add(player, this);
}
public static void CreateHelmetForFlashlight(PlayerControllerB player, Assets.Flashlight flashlight, int index){
try {
var helmetLights = player.allHelmetLights.ToList();
var light = helmetLights[index];
var parent = light.transform.parent;
var gameObj = GameObject.Instantiate(light.gameObject, parent);
gameObj.name = $"scarletlight{index}";
var newFlashlightHelmetIndex = helmetLights.Count;
if (flashlight.scarletHelmetIndex != newFlashlightHelmetIndex)
Plugin.logger.LogDebug($"Created helmet light for scarlet flashlight {index}. Updated index from {flashlight.scarletHelmetIndex} to {newFlashlightHelmetIndex}");
flashlight.scarletHelmetIndex = newFlashlightHelmetIndex;
helmetLights.Add(gameObj.GetComponent<Light>());
player.allHelmetLights = helmetLights.ToArray();
} catch (Exception e) {
Plugin.logger.LogError("Failed to create helmet light for scarlet flashlight");
Plugin.logger.LogError(e.ToString());
flashlight.scarletHelmetIndex = index;
}
}
}
}