2023-03-03 18:52:31 +00:00
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Aki.SinglePlayer.Models.Progression
|
|
|
|
|
{
|
|
|
|
|
public class LighthouseProgressionClass : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private bool _isScav;
|
|
|
|
|
private GameWorld _gameWorld;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private Player _player;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
private float _timer;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private bool _playerFlaggedAsEnemyToBosses;
|
|
|
|
|
private List<MineDirectionalColliders> _bridgeMines;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
private RecodableItemClass _transmitter;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private List<IAIDetails> _zryachiyAndFollowers = new List<IAIDetails>();
|
2023-03-03 18:52:31 +00:00
|
|
|
|
private bool _aggressor;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private bool _isDoorDisabled;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
private readonly string _transmitterId = "62e910aaf957f2915e0a5e36";
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private readonly string _lightKeeperTid = "638f541a29ffd1183d187f57";
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
_gameWorld = Singleton<GameWorld>.Instance;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
_player = _gameWorld?.MainPlayer;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Exit if not on lighthouse
|
|
|
|
|
if (_gameWorld == null || !string.Equals(_player.Location, "lighthouse", System.StringComparison.OrdinalIgnoreCase))
|
2023-07-07 10:37:47 +01:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Expensive, run after gameworld / lighthouse checks above
|
|
|
|
|
_bridgeMines = FindObjectsOfType<MineDirectionalColliders>().ToList();
|
|
|
|
|
|
|
|
|
|
// Player is a scav, exit
|
|
|
|
|
if (_player.Side == EPlayerSide.Savage)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
_isScav = true;
|
2023-07-30 10:04:35 +01:00
|
|
|
|
|
2023-03-03 18:52:31 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
_transmitter = GetTransmitterFromInventory();
|
|
|
|
|
if (PlayerHasTransmitterInInventory())
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
GameObject.Find("Attack").SetActive(false);
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Zone was added in a newer version and the gameObject actually has a \
|
2023-03-03 18:52:31 +00:00
|
|
|
|
GameObject.Find("CloseZone\\").SetActive(false);
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Give access to Lightkeepers door
|
|
|
|
|
_gameWorld.BufferZoneController.SetPlayerAccessStatus(_player.ProfileId, true);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
IncrementLastUpdateTimer();
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Exit early if last update() run time was < 10 secs ago
|
2023-07-07 10:37:47 +01:00
|
|
|
|
if (_timer < 10f)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Skip if:
|
|
|
|
|
// GameWorld missing
|
|
|
|
|
// Player not an enemy to Zryachiy
|
|
|
|
|
// Lk door not accessible
|
|
|
|
|
// Player has no transmitter on thier person
|
|
|
|
|
if (_gameWorld == null || _playerFlaggedAsEnemyToBosses || _isDoorDisabled || _transmitter == null)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find Zryachiy and prep him
|
|
|
|
|
if (_zryachiyAndFollowers.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetupZryachiyAndFollowerHostility();
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_isScav)
|
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
MakeZryachiyAndFollowersHostileToPlayer();
|
|
|
|
|
|
2023-03-03 18:52:31 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// (active/green)
|
|
|
|
|
if (PlayerHasActiveTransmitterInHands())
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
SetBridgeMinesStatus(false);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
SetBridgeMinesStatus(true);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_aggressor)
|
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
DisableAccessToLightKeeper();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RecodableItemClass GetTransmitterFromInventory()
|
|
|
|
|
{
|
|
|
|
|
return (RecodableItemClass)_player.Profile.Inventory.AllRealPlayerItems.FirstOrDefault(x => x.TemplateId == _transmitterId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool PlayerHasTransmitterInInventory()
|
|
|
|
|
{
|
|
|
|
|
return _transmitter != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Update _time to diff from last run of update()
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void IncrementLastUpdateTimer()
|
|
|
|
|
{
|
|
|
|
|
_timer += Time.deltaTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool PlayerHasActiveTransmitterInHands()
|
|
|
|
|
{
|
|
|
|
|
return _gameWorld?.MainPlayer?.HandsController?.Item?.TemplateId == _transmitterId
|
|
|
|
|
&& _transmitter?.RecodableComponent?.Status == RadioTransmitterStatus.Green;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set all brdige mines to desire state
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="active">What state mines should be</param>
|
|
|
|
|
private void SetBridgeMinesStatus(bool active)
|
|
|
|
|
{
|
|
|
|
|
// Find mines with opposite state of what we want
|
|
|
|
|
foreach (var mine in _bridgeMines.Where(mine => mine.gameObject.activeSelf == !active))
|
|
|
|
|
{
|
|
|
|
|
mine.gameObject.SetActive(active);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
private void SetupZryachiyAndFollowerHostility()
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// only process non-players (ai)
|
|
|
|
|
foreach (var aiBot in _gameWorld.AllAlivePlayersList.Where(x => !x.IsYourPlayer))
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Edge case of bossZryachiy not being hostile to player
|
|
|
|
|
if (aiBot.AIData.BotOwner.IsRole(WildSpawnType.bossZryachiy) || aiBot.AIData.BotOwner.IsRole(WildSpawnType.followerZryachiy))
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Subscribe to bots OnDeath event
|
|
|
|
|
aiBot.OnPlayerDeadOrUnspawn += player1 =>
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// If player kills zryachiy or follower, force aggressor state
|
|
|
|
|
// Also set players Lk standing to negative (allows access to quest chain (Making Amends))
|
|
|
|
|
if (player1?.KillerId == _player.ProfileId)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
_aggressor = true;
|
|
|
|
|
_player.Profile.TradersInfo[_lightKeeperTid].SetStanding(-0.01);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Save bot to list for later access
|
|
|
|
|
_zryachiyAndFollowers.Add(aiBot);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Iterate over bots gathered from SetupZryachiyHostility()
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void MakeZryachiyAndFollowersHostileToPlayer()
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
// If player is a scav, they must be added to the bosses enemy list otherwise they wont kill them
|
2023-07-30 10:04:35 +01:00
|
|
|
|
foreach (var bot in _zryachiyAndFollowers)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-07-30 10:04:35 +01:00
|
|
|
|
bot.AIData.BotOwner.BotsGroup.AddEnemy(_player);
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
// Flag player was added to enemy list
|
|
|
|
|
_playerFlaggedAsEnemyToBosses = true;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:04:35 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Disable door + set transmitter to 'red'
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void DisableAccessToLightKeeper()
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
// Disable access to Lightkeepers door for the player
|
|
|
|
|
_gameWorld.BufferZoneController.SetPlayerAccessStatus(_gameWorld.MainPlayer.ProfileId, false);
|
|
|
|
|
_transmitter?.RecodableComponent?.SetStatus(RadioTransmitterStatus.Yellow);
|
|
|
|
|
_transmitter?.RecodableComponent?.SetEncoded(false);
|
2023-07-30 10:04:35 +01:00
|
|
|
|
_isDoorDisabled = true;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|