Skip to content

Commit

Permalink
Merge pull request #95 from project-fika/dev
Browse files Browse the repository at this point in the history
Dev > main
  • Loading branch information
Lacyway authored Jul 15, 2024
2 parents b7389e0 + f1b8567 commit eab6989
Show file tree
Hide file tree
Showing 23 changed files with 369 additions and 375 deletions.
31 changes: 31 additions & 0 deletions Fika.Core/Console/FikaCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Players;
using Fika.Core.Coop.Utils;
using System.Collections.Generic;

namespace Fika.Core.Console
{
Expand Down Expand Up @@ -113,6 +114,36 @@ public static void Extract()

coopGame.Extract(localPlayer, null);
}

[ConsoleCommand("despawnallai", "", null, "Despawns all AI Bots", [])]
public static void DespawnAllAI()
{
if (Singleton<IFikaGame>.Instance is CoopGame game)
{
if (!FikaBackendUtils.IsServer)
{
ConsoleScreen.LogWarning("You are not the host.");
return;
}

CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler);

List<IPlayer> Bots = new List<IPlayer>(game.BotsController.Players);

foreach (Player bot in Bots)
{
if (bot.AIData.BotOwner == null)
{
continue;
}

ConsoleScreen.Log($"Despawning: {bot.Profile.Nickname}");

game.DespawnBot(coopHandler, bot);
}
}
}

#endif

[ConsoleCommand("debug", "", null, "Toggle debug window", [])]
Expand Down
260 changes: 0 additions & 260 deletions Fika.Core/Coop/Airdrops/FikaAirdropBox.cs

This file was deleted.

35 changes: 18 additions & 17 deletions Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Fika.Core.Networking;
using LiteNetLib;
using LiteNetLib.Utils;
using SPT.Custom.Airdrops;
using System;
using System.Collections;
using UnityEngine;
Expand All @@ -25,7 +26,7 @@ namespace Coop.Airdrops
public class FikaAirdropsManager : MonoBehaviour
{
private FikaAirdropPlane airdropPlane;
private FikaAirdropBox AirdropBox;
private AirdropBox AirdropBox;
private FikaItemFactoryUtil factory;
public bool isFlareDrop;
public FikaAirdropParametersModel AirdropParameters { get; set; }
Expand Down Expand Up @@ -111,7 +112,7 @@ protected async void Start()
airdropPlane = await FikaAirdropPlane.Init(AirdropParameters.RandomAirdropPoint,
AirdropParameters.DropHeight, AirdropParameters.Config.PlaneVolume,
AirdropParameters.Config.PlaneSpeed);
AirdropBox = await FikaAirdropBox.Init(AirdropParameters.Config.CrateFallSpeed);
AirdropBox = await AirdropBox.Init(AirdropParameters.Config.CrateFallSpeed);
factory = new FikaItemFactoryUtil();
}
catch
Expand Down Expand Up @@ -177,18 +178,18 @@ protected async void FixedUpdate()
airdropPlane = await FikaAirdropPlane.Init(AirdropParameters.SpawnPoint, AirdropParameters.DropHeight, AirdropParameters.Config.PlaneVolume,
AirdropParameters.Config.PlaneSpeed, true, AirdropParameters.LookPoint);

AirdropBox = await FikaAirdropBox.Init(AirdropParameters.Config.CrateFallSpeed);
AirdropBox = await AirdropBox.Init(AirdropParameters.Config.CrateFallSpeed);
factory = new FikaItemFactoryUtil();

factory.BuildClientContainer(AirdropBox.Container, rootItem);
factory.BuildClientContainer(AirdropBox.container, rootItem);

if (AirdropBox.Container != null && CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
if (AirdropBox.container != null && CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
if (!string.IsNullOrEmpty(ContainerId))
{
AirdropBox.Container.Id = ContainerId;
coopHandler.ListOfInteractiveObjects.Add(ContainerId, AirdropBox.Container);
Logger.LogInfo($"Adding AirdropBox {AirdropBox.Container.Id} to interactive objects.");
AirdropBox.container.Id = ContainerId;
coopHandler.ListOfInteractiveObjects.Add(ContainerId, AirdropBox.container);
Logger.LogInfo($"Adding AirdropBox {AirdropBox.container.Id} to interactive objects.");
}
else
{
Expand Down Expand Up @@ -281,19 +282,19 @@ private void BuildLootContainer(FikaAirdropConfigModel config)
throw new Exception("Airdrops. Tried to BuildLootContainer without any Loot.");
}

factory.BuildContainer(AirdropBox.Container, config, lootData.DropType);
factory.AddLoot(AirdropBox.Container, lootData);
factory.BuildContainer(AirdropBox.container, config, lootData.DropType);
factory.AddLoot(AirdropBox.container, lootData);

if (AirdropBox.Container != null && CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
if (AirdropBox.container != null && CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
if (coopHandler.GetInteractiveObject(AirdropBox.Container.Id, out _))
if (coopHandler.GetInteractiveObject(AirdropBox.container.Id, out _))
{
Logger.LogInfo("Existing crate already exists, setting value to " + ContainerCount);
AirdropBox.Container.Id = AirdropBox.Container.Id + $"_{ContainerCount}";
AirdropBox.container.Id = AirdropBox.container.Id + $"_{ContainerCount}";
ContainerCount++;
}
coopHandler.ListOfInteractiveObjects.Add(AirdropBox.Container.Id, AirdropBox.Container);
Logger.LogInfo($"Adding AirdropBox {AirdropBox.Container.Id} to interactive objects.");
coopHandler.ListOfInteractiveObjects.Add(AirdropBox.container.Id, AirdropBox.container);
Logger.LogInfo($"Adding AirdropBox {AirdropBox.container.Id} to interactive objects.");
}

// Get the lootData. Send to clients.
Expand Down Expand Up @@ -343,12 +344,12 @@ private IEnumerator SendLootToClients(bool isFlare = false)

Logger.LogInfo("Sending Airdrop Loot to clients.");

Item rootItem = AirdropBox.Container.ItemOwner.RootItem;
Item rootItem = AirdropBox.container.ItemOwner.RootItem;

AirdropLootPacket lootPacket = new()
{
RootItem = rootItem,
ContainerId = AirdropBox.Container.Id
ContainerId = AirdropBox.container.Id
};

NetDataWriter writer = new();
Expand Down
Loading

0 comments on commit eab6989

Please sign in to comment.