Skip to content

Commit

Permalink
Update multiclient version
Browse files Browse the repository at this point in the history
  • Loading branch information
TRPG0 committed Jun 2, 2024
1 parent 383558c commit dab19ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions mod/ArchipelagoHylics2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<TargetFramework>net35</TargetFramework>
<AssemblyName>ArchipelagoHylics2</AssemblyName>
<Description>Connect to an Archipelago server to play Hylics 2 Randomizer.</Description>
<Version>1.0.8</Version>
<Version>1.0.9</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Archipelago.MultiClient.Net" Version="5.0.6" />
<PackageReference Include="Archipelago.MultiClient.Net" Version="6.0.0-rc5" />
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.1.0" />
Expand Down
17 changes: 8 additions & 9 deletions mod/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Archipelago.MultiClient.Net.Packets;
using Archipelago.MultiClient.Net.BounceFeatures.DeathLink;
using System;
using Archipelago.MultiClient.Net.Models;
using Color = UnityEngine.Color;

namespace ArchipelagoHylics2
{
Expand All @@ -18,7 +20,7 @@ public class APH2Plugin : BaseUnityPlugin
{
public const string PluginGUID = "com.trpg.ArchipelagoHylics2";
public const string PluginName = "ArchipelagoHylics2";
public const string PluginVersion = "1.0.8";
public const string PluginVersion = "1.0.9";

public static Harmony harmony = new("mod.ArchipelagoHylics2");

Expand Down Expand Up @@ -551,7 +553,7 @@ void OnGUI()
else
{
APState.ServerData.death_link = !APState.ServerData.death_link;
APState.set_deathlink();
APState.SetDeathlink();

if (APState.ServerData.death_link) APState.message_log.Add("DeathLink is now <color=#00FF7FFF>enabled.</color>");
else APState.message_log.Add("DeathLink is now <color=#FA8072FF>disabled.</color>");
Expand Down Expand Up @@ -888,10 +890,7 @@ void OnGUI()
}
else
{
string text = consoleCommand;
var packet = new SayPacket();
packet.Text = text;
APState.Session.Socket.SendPacket(packet);
APState.Session.Say(consoleCommand);
consoleCommand = "";
}
}
Expand Down Expand Up @@ -940,7 +939,7 @@ void OnSceneLoaded(Scene scene, LoadSceneMode mode)
// send victory to server after defeating Gibby
if (scene.name == "HylemxylemExplode_Cutscene" && APState.Authenticated)
{
APState.send_completion();
APState.SendCompletion();
}

// find and modify all necessary GameObjects
Expand Down Expand Up @@ -1216,8 +1215,8 @@ public static IEnumerator LoadItems()
yield return new WaitForSecondsRealtime(2f);
while (APState.ServerData.index < APState.Session.Items.Index)
{
var item = APState.Session.Items.AllItemsReceived[Convert.ToInt32(APState.ServerData.index)];
string name = APState.Session.Items.GetItemName(item.Item);
ItemInfo item = APState.Session.Items.AllItemsReceived[Convert.ToInt32(APState.ServerData.index)];
string name = item.ItemName;
string type = APState.IdentifyItemGetType(name);
string player = APState.Session.Players.GetPlayerName(item.Player);
bool self = false;
Expand Down
24 changes: 14 additions & 10 deletions mod/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using UnityEngine.SceneManagement;
using System.Linq;
using ORKFramework.Behaviours;
using Archipelago.MultiClient.Net.Models;

namespace ArchipelagoHylics2
{
Expand Down Expand Up @@ -122,7 +123,7 @@ public static bool Connect()
}
}
if (loginSuccess.SlotData["death_link"].ToString() == "1") ServerData.death_link = true;
set_deathlink();
SetDeathlink();

// send any location checks that may have been completed while disconnected
if (ServerData.@checked != null)
Expand All @@ -148,9 +149,10 @@ public static void Session_ItemRecieved(ReceivedItemsHelper helper)

if (helper.Index !> ServerData.index)
{
string type = IdentifyItemGetType(helper.PeekItemName());
string name = helper.PeekItemName();
string player = Session.Players.GetPlayerName(helper.PeekItem().Player);
ItemInfo info = helper.PeekItem();
string type = IdentifyItemGetType(info.ItemName);
string name = info.ItemName;
string player = Session.Players.GetPlayerName(info.Player);
bool self = false;

if (player == ServerData.slot_name) self = true;
Expand Down Expand Up @@ -241,7 +243,11 @@ public static void Session_PacketReceived(ArchipelagoPacketBase packet)
// setup in-game message if a location has an item for a different player
if (p.Data[0].Type == JsonMessagePartType.PlayerId && Session.Players.GetPlayerName(int.Parse(p.Data[0].Text)) == ServerData.slot_name && p.Data[1].Text == " sent " && APH2Plugin.showPopups)
{
APH2Plugin.queueMessage.Add("Found " + Session.Items.GetItemName(long.Parse(p.Data[2].Text)) + " for " + Session.Players.GetPlayerAlias(int.Parse(p.Data[4].Text)) + ".");
APH2Plugin.queueMessage.Add("Found "
+ Session.Items.GetItemName(long.Parse(p.Data[2].Text), Session.Players.GetPlayerInfo(p.Data[2].Player.Value).Game)
+ " for "
+ Session.Players.GetPlayerAlias(int.Parse(p.Data[4].Text))
+ ".");
}

foreach (var messagePart in p.Data)
Expand Down Expand Up @@ -293,7 +299,7 @@ public static string ItemFlagsToRGBA(ItemFlags? flags)
}
}

public static void set_deathlink()
public static void SetDeathlink()
{
if (DeathLinkService == null)
{
Expand All @@ -310,11 +316,9 @@ public static void set_deathlink()
}
}

public static void send_completion()
public static void SendCompletion()
{
var statusUpdatePacket = new StatusUpdatePacket();
statusUpdatePacket.Status = ArchipelagoClientState.ClientGoal;
Session.Socket.SendPacket(statusUpdatePacket);
Session.SetGoalAchieved();
}

// get IDs for server locations based on the activated ItemCollector's scene and ID
Expand Down

0 comments on commit dab19ee

Please sign in to comment.