Upload from upload_mods.ps1
This commit is contained in:
290
Scripts/Manager/Inactive/EventsManagerRebirth.cs
Normal file
290
Scripts/Manager/Inactive/EventsManagerRebirth.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Audio;
|
||||
using static UIPopupList;
|
||||
|
||||
public class EventsManagerRebirth
|
||||
{
|
||||
private static EventsManagerRebirth instance = null;
|
||||
|
||||
public static List<eventInfo> playerEvents = new List<eventInfo>();
|
||||
|
||||
private static bool loadedEvents = false;
|
||||
|
||||
public static int nextFeralSenseDay = 0;
|
||||
public static int nextFeralSensePeriod = 0;
|
||||
private static int nextScreamerNight = 0;
|
||||
private static bool isScreamerEventActivated = false;
|
||||
private static float updateCheck = 0f;
|
||||
private static float updateTick = 30f;
|
||||
|
||||
private static float updateTickCheckScreamer = 60f;
|
||||
|
||||
public static bool HasInstance => instance != null;
|
||||
|
||||
public class eventInfo
|
||||
{
|
||||
public int playerID;
|
||||
public float eventCheckScreamer;
|
||||
public float eventCheckEntity;
|
||||
public float eventCheckEvent;
|
||||
|
||||
public eventInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public eventInfo(int _playerID,
|
||||
float _eventCheckScreamer,
|
||||
float _eventCheckEntity,
|
||||
float _eventCheckEvent
|
||||
)
|
||||
{
|
||||
this.playerID = _playerID;
|
||||
this.eventCheckScreamer = _eventCheckScreamer;
|
||||
this.eventCheckEntity = _eventCheckEntity;
|
||||
this.eventCheckEvent = _eventCheckEvent;
|
||||
}
|
||||
}
|
||||
|
||||
public static EventsManagerRebirth Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
EventsManagerRebirth.instance = new EventsManagerRebirth();
|
||||
//Log.Out("Starting Events Manager");
|
||||
//Load();
|
||||
//Log.Out("EventsManagerRebirth-Init LOADED EVENTS");
|
||||
loadedEvents = true;
|
||||
|
||||
int minimum = 2;
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
minimum = 3;
|
||||
}
|
||||
|
||||
if (nextScreamerNight == 0)
|
||||
{
|
||||
nextScreamerNight = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(minimum, 7);
|
||||
|
||||
//Log.Out("EventsManagerRebirth-Init nextScreamerNight: " + nextScreamerNight);
|
||||
}
|
||||
|
||||
if (nextFeralSenseDay == 0)
|
||||
{
|
||||
nextFeralSenseDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(minimum, 7);
|
||||
nextFeralSensePeriod = Manager.random.RandomRange(0, 3);
|
||||
}
|
||||
|
||||
ModEvents.GameUpdate.RegisterHandler(Update);
|
||||
}
|
||||
|
||||
public static void AddEvent(int _playerID,
|
||||
float _eventCheckScreamer,
|
||||
float _eventCheckEntity,
|
||||
float _eventCheckEvent
|
||||
)
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-AddEvent START");
|
||||
bool foundEvent = false;
|
||||
|
||||
foreach (eventInfo eventData in playerEvents)
|
||||
{
|
||||
if (eventData.playerID == _playerID)
|
||||
{
|
||||
foundEvent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundEvent)
|
||||
{
|
||||
eventInfo newEvent = new eventInfo();
|
||||
newEvent.playerID = _playerID;
|
||||
newEvent.eventCheckScreamer = _eventCheckScreamer;
|
||||
newEvent.eventCheckEntity = _eventCheckEntity;
|
||||
newEvent.eventCheckEvent = _eventCheckEvent;
|
||||
|
||||
playerEvents.Add(newEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (RebirthVariables.noHit && (Time.time - RebirthVariables.noHitCheck) > RebirthVariables.noHitTick)
|
||||
{
|
||||
RebirthVariables.noHit = false;
|
||||
//Log.Out("============================== NO HIT LOGGING ENDED ==============================");
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight() && (Time.time - updateCheck) > updateTick)
|
||||
{
|
||||
updateCheck = Time.time;
|
||||
//Log.Out("EventsManagerRebirth-Update TICK");
|
||||
|
||||
if (nextFeralSenseDay < GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime))
|
||||
{
|
||||
nextFeralSenseDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(0, 3);
|
||||
nextFeralSensePeriod = Manager.random.RandomRange(0, 3);
|
||||
}
|
||||
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
|
||||
if (!isClient)
|
||||
{
|
||||
DictionaryList<int, AIDirectorPlayerState> trackedPlayers = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorPlayerManagementComponent>().trackedPlayers;
|
||||
for (int i = 0; i < trackedPlayers.list.Count; i++)
|
||||
{
|
||||
AIDirectorPlayerState aidirectorPlayerState = trackedPlayers.list[i];
|
||||
if (!aidirectorPlayerState.Player.IsDead())
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update player: " + aidirectorPlayerState.Player.entityId);
|
||||
|
||||
bool foundPlayer = false;
|
||||
|
||||
foreach (eventInfo eventData in playerEvents)
|
||||
{
|
||||
if (eventData.playerID == aidirectorPlayerState.Player.entityId)
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update FOUND PLAYER");
|
||||
foundPlayer = true;
|
||||
|
||||
string optionScreamerNights = RebirthVariables.customScreamerNights;
|
||||
|
||||
if (optionScreamerNights != "none")
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update SCREAMER NIGHTS TURNED ON nextScreamerNight: " + nextScreamerNight);
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update isScreamerEventActivated: " + isScreamerEventActivated);
|
||||
|
||||
if (!isScreamerEventActivated && (nextScreamerNight == GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime)))
|
||||
{
|
||||
isScreamerEventActivated = true;
|
||||
//Log.Out("EventsManagerRebirth-Update isScreamerEventActivated: " + isScreamerEventActivated);
|
||||
}
|
||||
//Log.Out("EventsManagerRebirth-Update IS NIGHT");
|
||||
if (isScreamerEventActivated && (Time.time - eventData.eventCheckScreamer) > updateTickCheckScreamer)
|
||||
{
|
||||
eventData.eventCheckScreamer = Time.time;
|
||||
|
||||
//Log.Out("EventsManagerRebirth-Update SCREAMER TICK");
|
||||
|
||||
int playerLevel = aidirectorPlayerState.Player.Progression.Level;
|
||||
|
||||
int topLevel = 150;
|
||||
|
||||
if (optionScreamerNights == "higher")
|
||||
{
|
||||
topLevel = 75;
|
||||
}
|
||||
else if (optionScreamerNights == "lower")
|
||||
{
|
||||
topLevel = 225;
|
||||
}
|
||||
|
||||
if (playerLevel >= 20)
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update CAN SPAWN SCREAMER");
|
||||
|
||||
int playerLevelDifference = topLevel - playerLevel;
|
||||
|
||||
if (playerLevelDifference < 0)
|
||||
{
|
||||
playerLevelDifference = 0;
|
||||
}
|
||||
|
||||
int baseChance = topLevel - playerLevelDifference;
|
||||
|
||||
int randomInt = aidirectorPlayerState.Player.rand.RandomRange(0, topLevel);
|
||||
|
||||
//Log.Out("EventsManagerRebirth-Update playerLevel: " + playerLevel);
|
||||
//Log.Out("EventsManagerRebirth-Update topLevel: " + topLevel);
|
||||
//Log.Out("EventsManagerRebirth-Update playerLevelDifference: " + playerLevelDifference);
|
||||
//Log.Out("EventsManagerRebirth-Update randomInt: " + randomInt);
|
||||
//Log.Out("EventsManagerRebirth-Update baseChance: " + baseChance);
|
||||
|
||||
if (randomInt < baseChance)
|
||||
{
|
||||
int searchDistance = 150;
|
||||
|
||||
List<Entity> entitiesInBounds = aidirectorPlayerState.Player.world.GetEntitiesInBounds(typeof(EntityZombieScreamerRebirth), BoundsUtils.BoundsForMinMax(aidirectorPlayerState.Player.position.x - searchDistance, aidirectorPlayerState.Player.position.y - 50, aidirectorPlayerState.Player.position.z - searchDistance, aidirectorPlayerState.Player.position.x + searchDistance, aidirectorPlayerState.Player.position.y + 50, aidirectorPlayerState.Player.position.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("EventsManagerRebirth-Update NUM Screamers: " + entitiesInBounds.Count);
|
||||
|
||||
if (entitiesInBounds.Count < RebirthVariables.customScreamerMax)
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update randomInt < baseChance SPAWNED SCREAMER");
|
||||
RebirthUtilities.SpawnScreamer(aidirectorPlayerState.Player.position, (int)(playerLevel / 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update TOO MANY SCREAMERS ALREADY");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update randomInt >= baseChance NO SPAWN");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update CAN'T SPAWN SCREAMER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update NEED TO WAIT A BIT");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isScreamerEventActivated)
|
||||
{
|
||||
isScreamerEventActivated = false;
|
||||
|
||||
if (optionScreamerNights == "higher")
|
||||
{
|
||||
nextScreamerNight = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(1, 2);
|
||||
}
|
||||
else if (optionScreamerNights == "lower")
|
||||
{
|
||||
nextScreamerNight = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(4, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextScreamerNight = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(2, 4);
|
||||
}
|
||||
|
||||
//Log.Out("EventsManagerRebirth-Update IS DAY, nextScreamerNight: " + nextScreamerNight);
|
||||
}
|
||||
//Log.Out("EventsManagerRebirth-Update IS DAY");
|
||||
if (nextScreamerNight < GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime))
|
||||
{
|
||||
nextScreamerNight = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) + Manager.random.RandomRange(0, 3);
|
||||
isScreamerEventActivated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update SCREAMER NIGHTS TURNED OFF");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPlayer)
|
||||
{
|
||||
//Log.Out("EventsManagerRebirth-Update DIDN'T FIND PLAYER");
|
||||
AddEvent(aidirectorPlayerState.Player.entityId, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user