Skip to content

Commit 7549466

Browse files
authored
Merge pull request #334 from project-fika/1.2.8-dev
1.2.8
2 parents a68a45a + 8021b18 commit 7549466

File tree

5 files changed

+90
-28
lines changed

5 files changed

+90
-28
lines changed

Fika.Core/Coop/Custom/FikaHealthBar.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private void CreateHealthBar()
222222
playerPlate.SetNameText(currentPlayer.Profile.Info.MainProfileNickname);
223223
if (FikaPlugin.DevelopersList.ContainsKey(currentPlayer.Profile.Nickname.ToLower()))
224224
{
225-
playerPlate.playerNameScreen.color = new Color(0, 0.6091f, 1, 1);
225+
playerPlate.playerNameScreen.color = new Color(0, 6f, 1, 1);
226226
ChatSpecialIconSettings specialIcons = Resources.Load<ChatSpecialIconSettings>("ChatSpecialIconSettings");
227227
playerPlate.bearPlateScreen.GetComponent<Image>().sprite = specialIcons.IconsSettings[1].IconSprite;
228228
playerPlate.bearPlateScreen.transform.localPosition = new Vector3(0f, 24.9f, 0);
@@ -238,6 +238,10 @@ private void CreateHealthBar()
238238
playerPlate.usecPlateScreen.GetComponent<Image>().sprite = specialIcons.IconsSettings[2].IconSprite;
239239
playerPlate.usecPlateScreen.transform.localPosition = new Vector3(0f, 24.9f, 0);
240240
}
241+
else
242+
{
243+
playerPlate.playerNameScreen.color = FikaPlugin.NamePlateTextColor.Value;
244+
}
241245
// Start the plates both disabled, the visibility will be set in the update loop
242246
playerPlate.usecPlateScreen.gameObject.SetActive(false);
243247
playerPlate.bearPlateScreen.gameObject.SetActive(false);
@@ -343,7 +347,7 @@ private void ShowEffects_SettingChanged(object sender, EventArgs e)
343347
currentPlayer.HealthController.EffectAddedEvent -= HealthController_EffectAddedEvent;
344348
currentPlayer.HealthController.EffectRemovedEvent -= HealthController_EffectRemovedEvent;
345349

346-
List<HealthBarEffect> tempList = new(effects);
350+
List<HealthBarEffect> tempList = [.. effects];
347351
foreach (HealthBarEffect effect in tempList)
348352
{
349353
effect.Remove();
@@ -430,7 +434,8 @@ private void UpdateHealth()
430434

431435
private void UpdateHealthBarColor(float normalizedHealth)
432436
{
433-
Color color = Color.Lerp(Color.red, Color.green, normalizedHealth);
437+
Color color = Color.Lerp(FikaPlugin.LowHealthColor.Value,
438+
FikaPlugin.FullHealthColor.Value, normalizedHealth);
434439
color.a = playerPlate.healthBarScreen.color.a; // Keep the alpha value unchanged
435440
playerPlate.healthBarScreen.color = color;
436441
}
@@ -445,7 +450,7 @@ private void UpdateColorImage(Image screenObject, float alpha)
445450
}
446451
}
447452

448-
private void UpdateColorTextMeshProUGUI(TMPro.TextMeshProUGUI screenObject, float alpha)
453+
private void UpdateColorTextMeshProUGUI(TextMeshProUGUI screenObject, float alpha)
449454
{
450455
if (screenObject.gameObject.activeInHierarchy)
451456
{

Fika.Core/Coop/ObservedClasses/Snapshotting/ObservedState.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ internal ObservedState(Vector3 position, Vector2 rotation)
99
{
1010
Position = position;
1111
Rotation = rotation;
12+
PoseLevel = 1f;
13+
IsGrounded = true;
14+
HasGround = true;
1215
}
1316

1417
public Vector3 Position;

Fika.Core/FikaPlugin.cs

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BepInEx.Configuration;
33
using BepInEx.Logging;
44
using Comfort.Common;
5+
using Diz.Utils;
56
using EFT.UI;
67
using Fika.Core.Bundles;
78
using Fika.Core.Console;
@@ -48,7 +49,7 @@ namespace Fika.Core
4849
[BepInDependency("com.SPT.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after spt-debugging, that way we can disable its patches
4950
public class FikaPlugin : BaseUnityPlugin
5051
{
51-
public const string FikaVersion = "1.2.7";
52+
public const string FikaVersion = "1.2.8";
5253
public static FikaPlugin Instance;
5354
public static string EFTVersionMajor { get; internal set; }
5455
public static string ServerModVersion { get; private set; }
@@ -136,6 +137,9 @@ public ManualLogSource FikaLogger
136137
public static ConfigEntry<float> MinimumNamePlateScale { get; set; }
137138
public static ConfigEntry<bool> ShowEffects { get; set; }
138139
public static ConfigEntry<bool> UseOcclusion { get; set; }
140+
public static ConfigEntry<Color> FullHealthColor { get; set; }
141+
public static ConfigEntry<Color> LowHealthColor { get; set; }
142+
public static ConfigEntry<Color> NamePlateTextColor { get; set; }
139143

140144
// Coop | Quest Sharing
141145
public static ConfigEntry<EQuestSharingTypes> QuestTypesToShareAndReceive { get; set; }
@@ -281,16 +285,21 @@ private void VerifyServerVersion()
281285
if (failed)
282286
{
283287
FikaLogger.LogError($"Server version check failed. Expected: >{RequiredServerVersion}, received: {serverVersion}");
284-
MessageBoxHelper.Show($"Failed to verify server mod version.\nMake sure that the server mod is installed and up-to-date!\nRequired Server Version: {RequiredServerVersion}",
285-
"FIKA ERROR", MessageBoxHelper.MessageBoxType.OK);
286-
Application.Quit();
288+
AsyncWorker.RunInMainTread(ShowServerCheckFailMessage);
287289
}
288290
else
289291
{
290292
FikaLogger.LogInfo($"Server version check passed. Expected: >{RequiredServerVersion}, received: {serverVersion}");
291293
}
292294
}
293295

296+
private void ShowServerCheckFailMessage()
297+
{
298+
MessageBoxHelper.Show($"Failed to verify server mod version.\nMake sure that the server mod is installed and up-to-date!\nRequired Server Version: {RequiredServerVersion}",
299+
"FIKA ERROR", MessageBoxHelper.MessageBoxType.OK);
300+
Application.Quit();
301+
}
302+
294303
/// <summary>
295304
/// Coroutine to ensure all mods are loaded by waiting 5 seconds
296305
/// </summary>
@@ -552,7 +561,7 @@ private void SetupConfig()
552561
{
553562
Category = coopNameplatesHeader,
554563
DispName = LocaleUtils.BEPINEX_USE_NAME_PLATES_T.Localized(),
555-
Order = 13
564+
Order = 16
556565
}),
557566
"Show Player Name Plates", ref failed, headers);
558567

@@ -561,7 +570,7 @@ private void SetupConfig()
561570
{
562571
Category = coopNameplatesHeader,
563572
DispName = LocaleUtils.BEPINEX_HIDE_HEALTH_BAR_T.Localized(),
564-
Order = 12
573+
Order = 15
565574
}),
566575
"Hide Health Bar", ref failed, headers);
567576

@@ -570,7 +579,7 @@ private void SetupConfig()
570579
{
571580
Category = coopNameplatesHeader,
572581
DispName = LocaleUtils.BEPINEX_USE_PERCENT_T.Localized(),
573-
Order = 11
582+
Order = 14
574583
}),
575584
"Show HP% instead of bar", ref failed, headers);
576585

@@ -579,7 +588,7 @@ private void SetupConfig()
579588
{
580589
Category = coopNameplatesHeader,
581590
DispName = LocaleUtils.BEPINEX_SHOW_EFFECTS_T.Localized(),
582-
Order = 10
591+
Order = 13
583592
}),
584593
"Show Effects", ref failed, headers);
585594

@@ -588,7 +597,7 @@ private void SetupConfig()
588597
{
589598
Category = coopNameplatesHeader,
590599
DispName = LocaleUtils.BEPINEX_SHOW_FACTION_ICON_T.Localized(),
591-
Order = 9
600+
Order = 12
592601
}),
593602
"Show Player Faction Icon", ref failed, headers);
594603

@@ -597,7 +606,7 @@ private void SetupConfig()
597606
{
598607
Category = coopNameplatesHeader,
599608
DispName = LocaleUtils.BEPINEX_HIDE_IN_OPTIC_T.Localized(),
600-
Order = 8
609+
Order = 11
601610
}),
602611
"Hide Name Plate in Optic", ref failed, headers);
603612

@@ -606,7 +615,7 @@ private void SetupConfig()
606615
{
607616
Category = coopNameplatesHeader,
608617
DispName = LocaleUtils.BEPINEX_OPTIC_USE_ZOOM_T.Localized(),
609-
Order = 7,
618+
Order = 10,
610619
IsAdvanced = true
611620
}),
612621
"Name Plates Use Optic Zoom", ref failed, headers);
@@ -616,7 +625,7 @@ private void SetupConfig()
616625
{
617626
Category = coopNameplatesHeader,
618627
DispName = LocaleUtils.BEPINEX_DEC_OPAC_PERI_T.Localized(),
619-
Order = 6
628+
Order = 9
620629
}),
621630
"Decrease Opacity In Peripheral", ref failed, headers);
622631

@@ -626,7 +635,7 @@ private void SetupConfig()
626635
{
627636
Category = coopNameplatesHeader,
628637
DispName = LocaleUtils.BEPINEX_NAME_PLATE_SCALE_T.Localized(),
629-
Order = 5
638+
Order = 8
630639
}),
631640
"Name Plate Scale", ref failed, headers);
632641

@@ -636,7 +645,7 @@ private void SetupConfig()
636645
{
637646
Category = coopNameplatesHeader,
638647
DispName = LocaleUtils.BEPINEX_ADS_OPAC_T.Localized(),
639-
Order = 4
648+
Order = 7
640649
}),
641650
"Opacity in ADS", ref failed, headers);
642651

@@ -646,7 +655,7 @@ private void SetupConfig()
646655
{
647656
Category = coopNameplatesHeader,
648657
DispName = LocaleUtils.BEPINEX_MAX_DISTANCE_T.Localized(),
649-
Order = 3
658+
Order = 6
650659
}),
651660
"Max Distance to Show", ref failed, headers);
652661

@@ -656,7 +665,7 @@ private void SetupConfig()
656665
{
657666
Category = coopNameplatesHeader,
658667
DispName = LocaleUtils.BEPINEX_MIN_OPAC_T.Localized(),
659-
Order = 2
668+
Order = 5
660669
}),
661670
"Minimum Opacity", ref failed, headers);
662671

@@ -666,7 +675,7 @@ private void SetupConfig()
666675
{
667676
Category = coopNameplatesHeader,
668677
DispName = LocaleUtils.BEPINEX_MIN_PLATE_SCALE_T.Localized(),
669-
Order = 1
678+
Order = 4
670679
}),
671680
"Minimum Name Plate Scale", ref failed, headers);
672681

@@ -675,10 +684,37 @@ private void SetupConfig()
675684
{
676685
Category = coopNameplatesHeader,
677686
DispName = LocaleUtils.BEPINEX_USE_OCCLUSION_T.Localized(),
678-
Order = 0
687+
Order = 3
679688
}),
680689
"Use Occlusion", ref failed, headers);
681690

691+
FullHealthColor = SetupSetting(coopDefaultNamePlatesHeader, "Full Health Color", Color.green,
692+
new ConfigDescription(LocaleUtils.BEPINEX_HEALTHCOLOR_FULL_D.Localized(), tags: new ConfigurationManagerAttributes()
693+
{
694+
Category = coopNameplatesHeader,
695+
DispName = LocaleUtils.BEPINEX_HEALTHCOLOR_FULL_T.Localized(),
696+
Order = 2
697+
}),
698+
"Full Health Color", ref failed, headers);
699+
700+
LowHealthColor = SetupSetting(coopDefaultNamePlatesHeader, "Low Health Color", Color.red,
701+
new ConfigDescription(LocaleUtils.BEPINEX_HEALTHCOLOR_LOW_D.Localized(), tags: new ConfigurationManagerAttributes()
702+
{
703+
Category = coopNameplatesHeader,
704+
DispName = LocaleUtils.BEPINEX_HEALTHCOLOR_LOW_T.Localized(),
705+
Order = 1
706+
}),
707+
"Low Health Color", ref failed, headers);
708+
709+
NamePlateTextColor = SetupSetting(coopDefaultNamePlatesHeader, "Name Plate Text Color", Color.white,
710+
new ConfigDescription(LocaleUtils.BEPINEX_NAMEPLATECOLOR_D.Localized(), tags: new ConfigurationManagerAttributes()
711+
{
712+
Category = coopNameplatesHeader,
713+
DispName = LocaleUtils.BEPINEX_NAMEPLATECOLOR_T.Localized(),
714+
Order = 0
715+
}),
716+
"Name Plate Text Color", ref failed, headers);
717+
682718
// Coop | Quest Sharing
683719

684720
string coopQuestSharingHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_QUEST_SHARING.Localized());

Fika.Core/Utils/FikaModHandler.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BepInEx.Bootstrap;
33
using BepInEx.Logging;
44
using Comfort.Common;
5+
using Diz.Utils;
56
using EFT;
67
using EFT.UI;
78
using Fika.Core.Coop.Patches;
@@ -15,6 +16,7 @@
1516
using System.Collections;
1617
using System.Collections.Generic;
1718
using System.IO;
19+
using System.Threading.Tasks;
1820
using UnityEngine;
1921
using Logger = BepInEx.Logging.Logger;
2022

@@ -72,7 +74,7 @@ public void VerifyMods(PatchManager manager)
7274
{
7375
FikaPlugin.Instance.FikaLogger.LogError("FikaModHandler::VerifyMods: Response was invalid!");
7476
MessageBoxHelper.Show($"Failed to verify mods with server.\nMake sure that the server mod is installed!", "FIKA ERROR", MessageBoxHelper.MessageBoxType.OK);
75-
Application.Quit();
77+
AsyncWorker.RunInMainTread(Application.Quit);
7678
return;
7779
}
7880

@@ -99,7 +101,7 @@ public void VerifyMods(PatchManager manager)
99101

100102
if (installationError)
101103
{
102-
StaticManager.BeginCoroutine(InformInstallationError());
104+
_ = Task.Run(InformInstallationError);
103105
}
104106

105107
HandleModSpecificPatches(manager);
@@ -115,19 +117,29 @@ private void HandleModSpecificPatches(PatchManager manager)
115117
}
116118
}
117119

118-
private IEnumerator InformInstallationError()
120+
private async Task InformInstallationError()
119121
{
120122
while (!Singleton<PreloaderUI>.Instantiated)
121123
{
122-
yield return null;
123-
}
124+
await Task.Delay(250);
125+
}
126+
127+
AsyncWorker.RunInMainTread(ShowModErrorMessage);
128+
}
124129

130+
private void ShowModErrorMessage()
131+
{
125132
string message = "Your client doesn't meet server requirements, check logs for more details";
126133

127134
// -1f time makes the message permanent
128135
GClass3547 errorScreen = Singleton<PreloaderUI>.Instance.ShowCriticalErrorScreen("INSTALLATION ERROR", message,
129136
ErrorScreen.EButtonType.QuitButton, -1f);
130-
errorScreen.OnAccept += Application.Quit;
137+
138+
Action quitAction = Application.Quit;
139+
errorScreen.OnAccept += quitAction;
140+
errorScreen.OnDecline += quitAction;
141+
errorScreen.OnClose += quitAction;
142+
errorScreen.OnCloseSilent += quitAction;
131143
}
132144

133145
private void CheckSpecialMods(string key)

Fika.Core/Utils/LocaleUtils.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ public static bool IsBoss(WildSpawnType wildSpawnType, out string name)
274274
public const string BEPINEX_MIN_PLATE_SCALE_D = "F_BepInEx_MinPlateScale_D";
275275
public const string BEPINEX_USE_OCCLUSION_T = "F_BepInEx_UseOcclusion_T";
276276
public const string BEPINEX_USE_OCCLUSION_D = "F_BepInEx_UseOcclusion_D";
277+
public const string BEPINEX_HEALTHCOLOR_FULL_T = "F_BepInEx_HealthColorFull_T";
278+
public const string BEPINEX_HEALTHCOLOR_FULL_D = "F_BepInEx_HealthColorFull_D";
279+
public const string BEPINEX_HEALTHCOLOR_LOW_T = "F_BepInEx_HealthColorLow_T";
280+
public const string BEPINEX_HEALTHCOLOR_LOW_D = "F_BepInEx_HealthColorLow_D";
281+
public const string BEPINEX_NAMEPLATECOLOR_T = "F_BepInEx_NamePlateColor_T";
282+
public const string BEPINEX_NAMEPLATECOLOR_D = "F_BepInEx_NamePlateColor_D";
277283

278284
public const string BEPINEX_QUEST_TYPES_T = "F_BepInEx_QuestTypes_T";
279285
public const string BEPINEX_QUEST_TYPES_D = "F_BepInEx_QuestTypes_D";

0 commit comments

Comments
 (0)