Fixed inventory, spawn and settings

This commit is contained in:
erik 2025-05-15 21:34:20 +02:00
parent 0c539bc023
commit f4ec57a44d
5 changed files with 51 additions and 37 deletions

View file

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Timers;
using Decal.Adapter;
using Decal.Adapter.Wrappers;
@ -30,7 +32,6 @@ namespace MosswartMassacre
public static bool TelemetryEnabled { get; set; } = false;
public bool WebSocketEnabled { get; set; } = false;
public bool InventoryLogEnabled { get; set; } = false;
private MossyInventory _inventoryLogger;
private static Queue<string> rareMessageQueue = new Queue<string>();
@ -44,7 +45,6 @@ namespace MosswartMassacre
MyHost = Host;
WriteToChat("Mosswart Massacre has started!");
// Subscribe to chat message event
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
@ -53,6 +53,7 @@ namespace MosswartMassacre
CoreManager.Current.WorldFilter.CreateObject += OnSpawn;
CoreManager.Current.WorldFilter.ReleaseObject += OnDespawn;
// Initialize the timer
updateTimer = new Timer(1000); // Update every second
updateTimer.Elapsed += UpdateStats;
@ -94,6 +95,7 @@ namespace MosswartMassacre
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
CoreManager.Current.WorldFilter.CreateObject -= OnSpawn;
CoreManager.Current.WorldFilter.ReleaseObject -= OnDespawn;
// Stop and dispose of the timer
if (updateTimer != null)
@ -138,10 +140,11 @@ namespace MosswartMassacre
Telemetry.Start();
if (WebSocketEnabled)
WebSocket.Start();
}
private async void OnSpawn(object sender, CreateObjectEventArgs e)
{
var mob = e.New;
@ -235,29 +238,7 @@ namespace MosswartMassacre
DelayedCommandManager.AddDelayedCommand($"/a {rareText}", 3000);
}
// if (e.Text.EndsWith("!testrare\""))
// {
// string simulatedText = $"{CoreManager.Current.CharacterFilter.Name} has discovered the Ancient Pickle!";
//
// if (IsRareDiscoveryMessage(simulatedText, out string simulatedRareText))
// {
// rareCount++;
// MainView.UpdateRareCount(rareCount);
//
// if (RareMetaEnabled)
// {
// Decal_DispatchOnChatCommand("/vt setmetastate loot_rare");
// }
//
// DelayedCommandManager.AddDelayedCommand($"/a {simulatedRareText}", 3000);
// }
// else
// {
// WriteToChat("[Test] Simulated rare message didn't match the regex.");
// }
//
// return;
// }
if (e.Color == 18 && e.Text.EndsWith("!report\""))
{
TimeSpan elapsed = DateTime.Now - statsStartTime;
@ -540,6 +521,7 @@ namespace MosswartMassacre
WriteToChat("/mm http - Local http-command server enable|disable");
WriteToChat("/mm remotecommand - Listen to allegiance !do/!dot enable|disable");
WriteToChat("/mm getmetastate - Gets the current metastate");
break;
case "report":