2024-01-08 08:53:35 +00:00
|
|
|
|
using Aki.Debugging.BTR.Utils;
|
2024-01-15 09:09:31 +00:00
|
|
|
|
using Aki.SinglePlayer.Utils.TraderServices;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using Comfort.Common;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
using EFT;
|
2024-01-12 08:54:12 +00:00
|
|
|
|
using EFT.InventoryLogic;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
using EFT.Vehicle;
|
|
|
|
|
using HarmonyLib;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using System;
|
2024-01-12 08:54:12 +00:00
|
|
|
|
using System.Collections;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
using System.Linq;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using System.Reflection;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Aki.Debugging.BTR
|
|
|
|
|
{
|
|
|
|
|
public class BTRManager : MonoBehaviour
|
|
|
|
|
{
|
2024-01-04 08:51:06 +00:00
|
|
|
|
private GameWorld gameWorld;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
private BotsController botsController;
|
|
|
|
|
|
|
|
|
|
private BotBTRService btrBotService;
|
2024-01-05 09:27:59 +00:00
|
|
|
|
private BTRControllerClass btrController;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
private BTRVehicle btrServerSide;
|
|
|
|
|
private BTRView btrClientSide;
|
2024-01-12 08:54:12 +00:00
|
|
|
|
private BotOwner btrBotShooter;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
private BTRDataPacket btrDataPacket = default;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
private bool btrBotShooterInitialized = false;
|
|
|
|
|
|
2024-01-04 08:51:06 +00:00
|
|
|
|
private EPlayerBtrState previousPlayerBtrState;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
private BTRSide lastInteractedBtrSide;
|
|
|
|
|
public BTRSide LastInteractedBtrSide => lastInteractedBtrSide;
|
2024-01-12 08:54:12 +00:00
|
|
|
|
|
|
|
|
|
private BTRTurretServer btrTurretServer;
|
|
|
|
|
private Transform btrTurretDefaultTargetTransform;
|
|
|
|
|
private Coroutine _shootingTargetCoroutine;
|
|
|
|
|
private bool isShooting = false;
|
|
|
|
|
private BulletClass btrMachineGunAmmo;
|
|
|
|
|
private Item btrMachineGunWeapon;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
|
2024-01-08 08:53:35 +00:00
|
|
|
|
private MethodInfo _updateTaxiPriceMethod;
|
|
|
|
|
|
|
|
|
|
private Dictionary<ETraderServiceType, Dictionary<string, bool>> ServicePurchasedDict { get; set; }
|
|
|
|
|
|
|
|
|
|
BTRManager()
|
|
|
|
|
{
|
|
|
|
|
Type btrControllerType = typeof(BTRControllerClass);
|
|
|
|
|
_updateTaxiPriceMethod = AccessTools.GetDeclaredMethods(btrControllerType).Single(IsUpdateTaxiPriceMethod);
|
|
|
|
|
ServicePurchasedDict = new Dictionary<ETraderServiceType, Dictionary<string, bool>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find `BTRControllerClass.method_9(PathDestination currentDestinationPoint, bool lastRoutePoint)`
|
|
|
|
|
private bool IsUpdateTaxiPriceMethod(MethodInfo method)
|
|
|
|
|
{
|
|
|
|
|
return (method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsServicePurchased(ETraderServiceType serviceType, string traderId)
|
|
|
|
|
{
|
|
|
|
|
if (ServicePurchasedDict.TryGetValue(serviceType, out var traderDict))
|
|
|
|
|
{
|
|
|
|
|
if (traderDict.TryGetValue(traderId, out var result))
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetServicePurchased(ETraderServiceType serviceType, string traderId)
|
|
|
|
|
{
|
|
|
|
|
if (ServicePurchasedDict.TryGetValue(serviceType, out var traderDict))
|
|
|
|
|
{
|
|
|
|
|
traderDict[traderId] = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ServicePurchasedDict[serviceType] = new Dictionary<string, bool>();
|
|
|
|
|
ServicePurchasedDict[serviceType][traderId] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-03 16:06:50 +00:00
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-04 08:51:06 +00:00
|
|
|
|
gameWorld = Singleton<GameWorld>.Instance;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
|
|
|
|
|
if (gameWorld == null)
|
|
|
|
|
{
|
|
|
|
|
Destroy(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gameWorld.BtrController == null)
|
|
|
|
|
{
|
2024-01-05 09:27:59 +00:00
|
|
|
|
if (!Singleton<BTRControllerClass>.Instantiated)
|
2024-01-03 16:06:50 +00:00
|
|
|
|
{
|
2024-01-05 09:27:59 +00:00
|
|
|
|
Singleton<BTRControllerClass>.Create(new BTRControllerClass());
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 09:27:59 +00:00
|
|
|
|
gameWorld.BtrController = btrController = Singleton<BTRControllerClass>.Instance;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
InitBTR();
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("[AKI-BTR]: Unable to spawn BTR");
|
|
|
|
|
DestroyGameObjects();
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
btrController.SyncBTRVehicleFromServer(UpdateDataPacket());
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|
|
|
|
|
// BotShooterBtr doesn't get assigned to BtrController immediately so we nullcheck this in Update
|
|
|
|
|
if (btrController.BotShooterBtr != null && !btrBotShooterInitialized)
|
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
btrBotShooter = btrController.BotShooterBtr;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
btrBotService.Reset(); // Player will be added to Neutrals list and removed from Enemies list
|
|
|
|
|
btrBotShooterInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
if (btrController.BotShooterBtr == null) return;
|
|
|
|
|
|
|
|
|
|
if (IsAimingAtTarget() && !isShooting)
|
|
|
|
|
{
|
|
|
|
|
_shootingTargetCoroutine = StaticManager.BeginCoroutine(ShootTarget());
|
|
|
|
|
}
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 08:51:06 +00:00
|
|
|
|
public void HandleBtrDoorState(EPlayerBtrState playerBtrState)
|
|
|
|
|
{
|
|
|
|
|
if (previousPlayerBtrState == EPlayerBtrState.Approach && playerBtrState == EPlayerBtrState.GoIn
|
|
|
|
|
|| previousPlayerBtrState == EPlayerBtrState.Inside && playerBtrState == EPlayerBtrState.GoOut)
|
|
|
|
|
{
|
|
|
|
|
// Open Door
|
|
|
|
|
UpdateBTRSideDoorState(1);
|
|
|
|
|
}
|
|
|
|
|
else if (previousPlayerBtrState == EPlayerBtrState.GoIn && playerBtrState == EPlayerBtrState.Inside
|
|
|
|
|
|| previousPlayerBtrState == EPlayerBtrState.GoOut && playerBtrState == EPlayerBtrState.Outside)
|
|
|
|
|
{
|
|
|
|
|
// Close Door
|
|
|
|
|
UpdateBTRSideDoorState(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousPlayerBtrState = playerBtrState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Please tell me there's a better way than this xd
|
|
|
|
|
public void OnPlayerInteractDoor(PlayerInteractPacket interactPacket)
|
|
|
|
|
{
|
|
|
|
|
var playerGoIn = interactPacket.InteractionType == EInteractionType.GoIn;
|
|
|
|
|
var playerGoOut = interactPacket.InteractionType == EInteractionType.GoOut;
|
|
|
|
|
|
|
|
|
|
if (interactPacket.SideId == 0)
|
|
|
|
|
{
|
|
|
|
|
if (interactPacket.SlotId == 0)
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (playerGoIn) btrServerSide.LeftSlot0State = 1;
|
|
|
|
|
else if (playerGoOut) btrServerSide.LeftSlot0State = 0;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
else if (interactPacket.SlotId == 1)
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (playerGoIn) btrServerSide.LeftSlot1State = 1;
|
|
|
|
|
else if (playerGoOut) btrServerSide.LeftSlot1State = 0;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (interactPacket.SideId == 1)
|
|
|
|
|
{
|
|
|
|
|
if (interactPacket.SlotId == 0)
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (playerGoIn) btrServerSide.RightSlot0State = 1;
|
|
|
|
|
else if (playerGoOut) btrServerSide.RightSlot0State = 0;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
else if (interactPacket.SlotId == 1)
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (playerGoIn) btrServerSide.RightSlot1State = 1;
|
|
|
|
|
else if (playerGoOut) btrServerSide.RightSlot1State = 0;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
private void InitBTR()
|
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
// Initial setup
|
|
|
|
|
botsController = Singleton<IBotGame>.Instance.BotsController;
|
|
|
|
|
btrBotService = botsController.BotTradersServices.BTRServices;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
var btrControllerType = btrController.GetType();
|
|
|
|
|
AccessTools.Method(btrControllerType, "method_3").Invoke(btrController, null); // spawns server-side BTR game object
|
|
|
|
|
botsController.BotSpawner.SpawnBotBTR(); // spawns the scav bot which controls the BTR's turret
|
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
// Initial BTR configuration
|
2024-01-05 08:58:15 +00:00
|
|
|
|
btrServerSide = btrController.BtrVehicle;
|
|
|
|
|
btrServerSide.moveSpeed = 20f;
|
|
|
|
|
var btrMapConfig = btrController.MapPathsConfiguration;
|
|
|
|
|
btrServerSide.CurrentPathConfig = btrMapConfig.PathsConfiguration.pathsConfigurations.RandomElement();
|
|
|
|
|
btrServerSide.Initialization(btrMapConfig);
|
|
|
|
|
AccessTools.Method(btrControllerType, "method_14").Invoke(btrController, null); // creates and assigns the BTR a fake stash
|
|
|
|
|
|
|
|
|
|
DisableServerSideRenderers();
|
|
|
|
|
|
|
|
|
|
gameWorld.MainPlayer.OnBtrStateChanged += HandleBtrDoorState;
|
|
|
|
|
|
|
|
|
|
btrServerSide.MoveEnable();
|
2024-01-08 08:53:35 +00:00
|
|
|
|
btrServerSide.IncomingToDestinationEvent += ToDestinationEvent;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
// Sync initial position and rotation
|
2024-01-05 08:58:15 +00:00
|
|
|
|
UpdateDataPacket();
|
|
|
|
|
btrClientSide = btrController.BtrView;
|
|
|
|
|
btrClientSide.transform.position = btrDataPacket.position;
|
|
|
|
|
btrClientSide.transform.rotation = btrDataPacket.rotation;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
// Initialise turret variables
|
|
|
|
|
btrTurretServer = btrServerSide.BTRTurret;
|
|
|
|
|
btrTurretDefaultTargetTransform = (Transform)AccessTools.Field(btrTurretServer.GetType(), "defaultTargetTransform").GetValue(btrTurretServer);
|
|
|
|
|
btrMachineGunAmmo = (BulletClass)BTRUtil.CreateItem(BTRUtil.BTRMachineGunAmmoTplId);
|
|
|
|
|
btrMachineGunWeapon = BTRUtil.CreateItem(BTRUtil.BTRMachineGunWeaponTplId);
|
|
|
|
|
|
2024-01-08 08:53:35 +00:00
|
|
|
|
// Pull services data for the BTR from the server
|
2024-01-15 09:09:31 +00:00
|
|
|
|
TraderServicesManager.Instance.GetTraderServicesDataFromServer(BTRUtil.BTRTraderId);
|
2024-01-08 08:53:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* BTR has arrived at a destination, re-calculate taxi prices
|
|
|
|
|
*/
|
|
|
|
|
private void ToDestinationEvent(PathDestination destinationPoint, bool isFirst, bool isFinal, bool isLastRoutePoint)
|
|
|
|
|
{
|
|
|
|
|
// Update the prices for the taxi service
|
|
|
|
|
_updateTaxiPriceMethod.Invoke(btrController, new object[] { destinationPoint, isFinal });
|
2024-01-05 08:58:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 08:51:06 +00:00
|
|
|
|
private void UpdateBTRSideDoorState(byte state)
|
|
|
|
|
{
|
|
|
|
|
var player = gameWorld.MainPlayer;
|
|
|
|
|
var btrSides = (BTRSide[])AccessTools.Field(typeof(BTRView), "_btrSides").GetValue(btrController.BtrView);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < btrSides.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (player.BtrInteractionSide != null && btrSides[i] == player.BtrInteractionSide
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|| lastInteractedBtrSide != null && btrSides[i] == lastInteractedBtrSide)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (i == 0) btrServerSide.LeftSideState = state;
|
|
|
|
|
else if (i == 1) btrServerSide.RightSideState = state;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (lastInteractedBtrSide != player.BtrInteractionSide)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
lastInteractedBtrSide = player.BtrInteractionSide;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 16:06:50 +00:00
|
|
|
|
private BTRDataPacket UpdateDataPacket()
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
btrDataPacket.position = btrServerSide.transform.position;
|
|
|
|
|
btrDataPacket.rotation = btrServerSide.transform.rotation;
|
2024-01-12 08:54:12 +00:00
|
|
|
|
if (btrTurretServer?.gunsBlockRoot != null)
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
btrDataPacket.turretRotation = btrTurretServer.transform.rotation;
|
|
|
|
|
btrDataPacket.gunsBlockRotation = btrTurretServer.gunsBlockRoot.rotation;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
}
|
|
|
|
|
btrDataPacket.State = (byte)btrServerSide.BtrState;
|
|
|
|
|
btrDataPacket.RouteState = (byte)btrServerSide.VehicleRouteState;
|
|
|
|
|
btrDataPacket.LeftSideState = btrServerSide.LeftSideState;
|
|
|
|
|
btrDataPacket.LeftSlot0State = btrServerSide.LeftSlot0State;
|
|
|
|
|
btrDataPacket.LeftSlot1State = btrServerSide.LeftSlot1State;
|
|
|
|
|
btrDataPacket.RightSideState = btrServerSide.RightSideState;
|
|
|
|
|
btrDataPacket.RightSlot0State = btrServerSide.RightSlot0State;
|
|
|
|
|
btrDataPacket.RightSlot1State = btrServerSide.RightSlot1State;
|
|
|
|
|
btrDataPacket.currentSpeed = btrServerSide.currentSpeed;
|
|
|
|
|
btrDataPacket.timeToEndPause = btrServerSide.timeToEndPause;
|
|
|
|
|
btrDataPacket.moveDirection = (byte)btrServerSide.VehicleMoveDirection;
|
|
|
|
|
btrDataPacket.MoveSpeed = btrServerSide.moveSpeed;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
if (btrController.BotShooterBtr != null)
|
|
|
|
|
{
|
|
|
|
|
btrDataPacket.BtrBotId = btrController.BotShooterBtr.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return btrDataPacket;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisableServerSideRenderers()
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
var meshRenderers = btrServerSide.transform.GetComponentsInChildren<MeshRenderer>();
|
2024-01-03 16:06:50 +00:00
|
|
|
|
foreach (var renderer in meshRenderers)
|
|
|
|
|
{
|
|
|
|
|
renderer.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
private bool IsAimingAtTarget()
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
var turretInDefaultRotation = btrTurretServer.targetTransform == btrTurretDefaultTargetTransform
|
|
|
|
|
&& btrTurretServer.targetPosition == btrTurretServer.defaultAimingPosition;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|
2024-01-12 08:54:12 +00:00
|
|
|
|
var enemies = btrBotShooter.BotsGroup.Enemies;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (enemies.Any())
|
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
IPlayer currentTarget = enemies.First().Key;
|
|
|
|
|
Transform currentTargetTransform = currentTarget.Transform.Original;
|
|
|
|
|
Vector3 currentTargetPosition = currentTargetTransform.position;
|
|
|
|
|
var currentTargetInfo = btrBotShooter.EnemiesController.EnemyInfos[currentTarget];
|
|
|
|
|
|
|
|
|
|
if (!currentTarget.HealthController.IsAlive)
|
|
|
|
|
{
|
|
|
|
|
enemies.Remove(currentTarget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentTargetInfo.IsVisible)
|
|
|
|
|
{
|
|
|
|
|
if (btrTurretServer.CheckPositionInAimingZone(currentTargetPosition))
|
|
|
|
|
{
|
|
|
|
|
btrTurretServer.EnableAimingObject(currentTargetTransform);
|
|
|
|
|
}
|
|
|
|
|
// If turret machine gun aim is close enough to target and has line of sight
|
|
|
|
|
if (btrBotShooter.BotBtrData.CanShoot())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!currentTargetInfo.IsVisible)
|
|
|
|
|
{
|
|
|
|
|
// Turret will hold the angle where target was last seen for 3 seconds before resetting its rotation
|
|
|
|
|
if (btrTurretServer.targetPosition != currentTargetInfo.EnemyLastPosition && btrTurretServer.targetTransform != null)
|
|
|
|
|
{
|
|
|
|
|
btrTurretServer.EnableAimingPosition(currentTargetInfo.EnemyLastPosition);
|
|
|
|
|
}
|
|
|
|
|
else if (currentTargetInfo.TimeLastSeen >= 3f && !turretInDefaultRotation)
|
|
|
|
|
{
|
|
|
|
|
btrTurretServer.DisableAiming();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-05 08:58:15 +00:00
|
|
|
|
}
|
2024-01-12 08:54:12 +00:00
|
|
|
|
else if (!enemies.Any() && !turretInDefaultRotation)
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
2024-01-12 08:54:12 +00:00
|
|
|
|
btrTurretServer.DisableAiming();
|
2024-01-05 08:58:15 +00:00
|
|
|
|
}
|
2024-01-12 08:54:12 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Custom method to make the BTR coaxial machine gun shoot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IEnumerator ShootTarget()
|
|
|
|
|
{
|
|
|
|
|
isShooting = true;
|
|
|
|
|
|
|
|
|
|
Transform machineGunMuzzle = btrTurretServer.machineGunLaunchPoint;
|
|
|
|
|
Player btrBotPlayer = btrBotShooter.GetPlayer;
|
|
|
|
|
|
|
|
|
|
gameWorld.SharedBallisticsCalculator.Shoot(btrMachineGunAmmo, machineGunMuzzle.position, machineGunMuzzle.forward, btrBotPlayer.ProfileId, btrMachineGunWeapon, 1f, 0);
|
|
|
|
|
|
|
|
|
|
Player.FirearmController firearmController = btrBotShooter.GetComponent<Player.FirearmController>();
|
|
|
|
|
WeaponPrefab weaponPrefab = (WeaponPrefab)AccessTools.Field(firearmController.GetType(), "weaponPrefab_0").GetValue(firearmController);
|
|
|
|
|
WeaponSoundPlayer weaponSoundPlayer = weaponPrefab.GetComponent<WeaponSoundPlayer>();
|
|
|
|
|
AccessTools.Method(firearmController.GetType(), "method_54").Invoke(firearmController, new object[] { weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, machineGunMuzzle.forward, false });
|
|
|
|
|
|
|
|
|
|
yield return new WaitForSecondsRealtime(0.092308f); // 650 RPM
|
|
|
|
|
isShooting = false;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 16:06:50 +00:00
|
|
|
|
private void DestroyGameObjects()
|
|
|
|
|
{
|
|
|
|
|
if (btrController != null)
|
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (btrServerSide != null)
|
2024-01-03 16:06:50 +00:00
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
Destroy(btrServerSide.gameObject);
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (btrClientSide != null)
|
2024-01-03 16:06:50 +00:00
|
|
|
|
{
|
2024-01-05 08:58:15 +00:00
|
|
|
|
Destroy(btrClientSide.gameObject);
|
2024-01-03 16:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btrController.Dispose();
|
|
|
|
|
}
|
2024-01-04 08:51:06 +00:00
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (gameWorld?.MainPlayer != null)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
|
|
|
|
gameWorld.MainPlayer.OnBtrStateChanged -= HandleBtrDoorState;
|
|
|
|
|
}
|
2024-01-12 08:54:12 +00:00
|
|
|
|
|
|
|
|
|
StaticManager.KillCoroutine(ref _shootingTargetCoroutine);
|
2024-01-03 16:06:50 +00:00
|
|
|
|
Destroy(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|