Skip to content

Commit

Permalink
Add Repair Zone Notifications
Browse files Browse the repository at this point in the history
- Adds preference "RepairFacility_ChatNotifications" [default: false], if enabled this will send a chat message to the player when they enter/exit a vehicle repair zone with an eligible vehicle that can be repaired
  • Loading branch information
data-bomb committed Sep 14, 2024
1 parent 28ac08b commit 9b4afc9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Si_RepairFacility/Si_RepairFacility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class RepairFacility : MelonMod
static MelonPreferences_Entry<float> _Pref_Aliens_Structure_HealRate = null!;
static MelonPreferences_Entry<float> _Pref_Aliens_Queen_HealRate = null!;
static MelonPreferences_Entry<float> _Pref_Humans_Infantry_HealRate = null!;
static MelonPreferences_Entry<bool> _Pref_Repair_Notification = null!;

public override void OnInitializeMelon()
{
Expand All @@ -70,6 +71,8 @@ public override void OnInitializeMelon()

_Pref_Aliens_Structure_HealRate ??= _modCategory.CreateEntry<float>("RepairFacility_Alien_Structure_HealRate", 0.01f);

_Pref_Repair_Notification ??= _modCategory.CreateEntry<bool>("RepairFacility_ChatNotifications", false);

vehiclesAtRepairShop = new List<Unit>();
}

Expand Down Expand Up @@ -145,6 +148,11 @@ public static void Postfix(OpenableBase __instance, Zone __0, Unit __1)
MelonLogger.Msg("Found player's " + (__1.IsFlyingType ? "aircraft" : "vehicle") + " entering LVF repair zone: " + __1.ControlledBy.PlayerName + " with vehicle " + __1.ToString());

vehiclesAtRepairShop.Add(__1);

if (_Pref_Repair_Notification.Value)
{
HelperMethods.SendChatMessageToPlayer(__1.ControlledBy, HelperMethods.chatPrefix, " Entered vehicle repair zone.");
}
}
catch (Exception error)
{
Expand Down Expand Up @@ -196,7 +204,12 @@ public static void Postfix(OpenableBase __instance, Zone __0, Unit __1)
MelonLogger.Msg("Found player's " + (__1.IsFlyingType ? "aircraft" : "vehicle") + " exiting LVF repair zone: " + __1.ControlledBy.PlayerName + " with vehicle " + __1.ToString());
}

vehiclesAtRepairShop.RemoveAll(vehicleDM => vehicleDM == __1);
vehiclesAtRepairShop.RemoveAll(vehicle => vehicle == __1);

if (_Pref_Repair_Notification.Value)
{
HelperMethods.SendChatMessageToPlayer(__1.ControlledBy, HelperMethods.chatPrefix, " Left vehicle repair zone.");
}
}
catch (Exception error)
{
Expand Down

0 comments on commit 9b4afc9

Please sign in to comment.