Skip to content

Commit

Permalink
Merge pull request #190 from project-fika/dev-3.10
Browse files Browse the repository at this point in the history
dev > main
  • Loading branch information
Lacyway authored Nov 26, 2024
2 parents 124733c + bfe7b8d commit e9e5c38
Show file tree
Hide file tree
Showing 310 changed files with 16,893 additions and 10,316 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

# CS0618: Type or member is obsolete
dotnet_diagnostic.CS0618.severity = none

# Custom config
tab_width = 4
indent_size = 4
end_of_line = crlf
indent_style = tab
7 changes: 2 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.FIKA_GITMODULES }}

- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Install dependencies
run: dotnet restore --configfile Nuget.config
run: dotnet restore

- name: Build
run: dotnet build --nologo --no-restore --configuration Debug

- name: Test
run: dotnet test --nologo --no-restore --no-build --blame-hang-timeout 1min


Binary file added Fika.Core/Bundles/Files/mainmenuui.bundle
Binary file not shown.
Binary file modified Fika.Core/Bundles/Files/newmatchmakerui.bundle
Binary file not shown.
Binary file modified Fika.Core/Bundles/Files/ping.bundle
Binary file not shown.
Binary file modified Fika.Core/Bundles/Files/playerui.bundle
Binary file not shown.
Binary file modified Fika.Core/Bundles/Files/senditemmenu.bundle
Binary file not shown.
183 changes: 163 additions & 20 deletions Fika.Core/Console/FikaCommands.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using Comfort.Common;
using EFT;
using EFT.Console.Core;
using EFT.InventoryLogic;
using EFT.UI;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Players;
using Fika.Core.Coop.Utils;
using Fika.Core.Networking;
using HarmonyLib;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Fika.Core.Console
{
Expand All @@ -16,17 +21,8 @@ public class FikaCommands
[ConsoleCommand("bring", "", null, "Teleports all AI to yourself as the host", [])]
public static void Bring()
{
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;

if (coopGame == null)
if (!CheckForGame())
{
ConsoleScreen.LogWarning("You are not in a game.");
return;
}

if (coopGame.Status != GameStatus.Started)
{
ConsoleScreen.LogWarning("Game is not running.");
return;
}

Expand Down Expand Up @@ -60,17 +56,8 @@ public static void Bring()
[ConsoleCommand("god", "", null, "Set god mode on/off", [])]
public static void God([ConsoleArgument(false, "true or false to toggle god mode")] bool state)
{
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;

if (coopGame == null)
if (!CheckForGame())
{
ConsoleScreen.LogWarning("You are not in a game.");
return;
}

if (coopGame.Status != GameStatus.Started)
{
ConsoleScreen.LogWarning("Game is not running.");
return;
}

Expand Down Expand Up @@ -162,6 +149,143 @@ public static void StopTimer()
}
}

[ConsoleCommand("goToBTR", "", null, "Teleports you to the BTR if active", [])]
public static void GoToBTR()
{
if (Singleton<IFikaGame>.Instance is CoopGame game)
{
GameWorld gameWorld = game.GameWorld_0;
if (gameWorld != null)
{
if (gameWorld.BtrController != null)
{
Transform btrTransform = Traverse.Create(gameWorld.BtrController.BtrView).Field<Transform>("_cachedTransform").Value;
if (btrTransform != null)
{
Player myPlayer = gameWorld.MainPlayer;
if (myPlayer != null)
{
myPlayer.Teleport(btrTransform.position + (Vector3.forward * 3));
}
}
}
else
{
ConsoleScreen.LogWarning("There is no BTRController active!");
}
}
}
}

[ConsoleCommand("spawnItem", "", null, "Spawns an item from a templateId")]
public static void SpawnItem([ConsoleArgument("", "The templateId to spawn an item from")] string templateId,
[ConsoleArgument(1, "The amount to spawn if the item can stack")] int amount = 1)
{
if (!CheckForGame())
{
return;
}

GameWorld gameWorld = Singleton<GameWorld>.Instance;
CoopPlayer player = (CoopPlayer)gameWorld.MainPlayer;
if (!player.HealthController.IsAlive)
{
ConsoleScreen.LogError("You cannot spawn an item while dead!");
return;
}

ItemFactoryClass itemFactory = Singleton<ItemFactoryClass>.Instance;
if (itemFactory == null)
{
ConsoleScreen.LogError("ItemFactory was null!");
return;
}

Item item = itemFactory.GetPresetItem(templateId);
if (amount > 1 && item.StackMaxSize > 1)
{
item.StackObjectsCount = Mathf.Clamp(amount, 1, item.StackMaxSize);
}
else
{
item.StackObjectsCount = 1;
}
FikaGlobals.SpawnItemInWorld(item, player);

SpawnItemPacket packet = new()
{
NetId = player.NetId,
Item = item
};

if (FikaBackendUtils.IsServer)
{
Singleton<FikaServer>.Instance.SendDataToAll(ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
return;
}
Singleton<FikaClient>.Instance.SendData(ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
}

/// <summary>
/// Based on SSH's TarkyMenu command
/// </summary>
/// <param name="wildSpawnType"></param>
/// <param name="number"></param>
[ConsoleCommand("spawnNPC", "", null, "Spawn NPC with specified WildSpawnType")]
public static void SpawnNPC([ConsoleArgument("pmcBot", "The WildSpawnType to spawn (use help for a list)")] string wildSpawnType, [ConsoleArgument(1, "The amount of AI to spawn")] int amount)
{
if (!CheckForGame())
{
return;
}

if (!FikaBackendUtils.IsServer)
{
ConsoleScreen.LogWarning("You cannot spawn AI as a client!");
return;
}

if (string.IsNullOrEmpty(wildSpawnType) || wildSpawnType.ToLower() == "help")
{
foreach (object availableSpawnType in Enum.GetValues(typeof(WildSpawnType)))
{
ConsoleScreen.Log(availableSpawnType.ToString());
}
ConsoleScreen.Log("Available WildSpawnType options below");
return;
}

if (!Enum.TryParse(wildSpawnType, true, out WildSpawnType selectedSpawnType))
{
ConsoleScreen.Log($"Invalid WildSpawnType: {wildSpawnType}");
return;
}

if (amount <= 0)
{
ConsoleScreen.Log($"Invalid number: {amount}. Please enter a valid positive integer.");
return;
}

BotWaveDataClass newBotData = new()
{
BotsCount = amount,
Side = EPlayerSide.Savage,
SpawnAreaName = "",
Time = 0f,
WildSpawnType = selectedSpawnType,
IsPlayers = false,
Difficulty = BotDifficulty.easy,
ChanceGroup = 100f,
WithCheckMinMax = false
};


IBotGame botController = (IBotGame)Singleton<AbstractGame>.Instance;
botController.BotsController.BotSpawner.ActivateBotsByWave(newBotData);
ConsoleScreen.Log($"SpawnNPC completed. {amount} bots spawned.");
}

#endif

[ConsoleCommand("debug", "", null, "Toggle debug window", [])]
Expand Down Expand Up @@ -189,5 +313,24 @@ public static void Clear()
{
Singleton<PreloaderUI>.Instance.Console.Clear();
}

private static bool CheckForGame()
{
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;

if (coopGame == null)
{
ConsoleScreen.LogWarning("You are not in a game.");
return false;
}

if (coopGame.Status != GameStatus.Started)
{
ConsoleScreen.LogWarning("Game is not running.");
return false;
}

return true;
}
}
}
Loading

0 comments on commit e9e5c38

Please sign in to comment.