Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow's build's changes #48

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
7 changes: 4 additions & 3 deletions CelesteArchipelago.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<!--Disable "Copy Local" for all references-->
<ItemDefinitionGroup>
<PackageReference PrivateAssets="all" ExcludeAssets="runtime" />
<!--<PackageReference PrivateAssets="all" ExcludeAssets="runtime" />-->
<Reference Private="false" />
</ItemDefinitionGroup>
<ItemGroup>
Expand All @@ -38,12 +38,12 @@
<None Remove="src\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Archipelago.MultiClient.Net.dll" />
<!--<None Remove="Archipelago.MultiClient.Net.dll" />-->
<None Remove="CelesteArchipelago.dll" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Archipelago.MultiClient.Net" Version="5.0.6" />
<PackageReference Include="Archipelago.MultiClient.Net" Version="6.2.0" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="22.01.04.03" PrivateAssets="all" ExcludeAssets="runtime" />
</ItemGroup>

Expand Down Expand Up @@ -81,6 +81,7 @@
</Choose>

<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="$(OutputPath)\Archipelago.MultiClient.Net.dll" DestinationFolder="bin" />
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll" DestinationFolder="bin" />
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).pdb" DestinationFolder="bin" />
</Target>
Expand Down
17 changes: 16 additions & 1 deletion CelesteArchipelagoModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@
namespace Celeste.Mod.CelesteArchipelago {
public class CelesteArchipelagoModuleSettings : EverestModuleSettings
{
[SettingMaxLength(30)]
public string Name { get; set; } = "Madeline";
public string Password { get; set; } = "";
public string Server { get; set; } = "";
[SettingMaxLength(30)]
public string Server { get; set; } = "archipelago.gg";
public string Port { get; set; } = "38281";
private bool _Chat = false;
public bool Chat {
get => _Chat;
set {
_Chat = value;
if (value) {
ArchipelagoController.Instance.Init();
} else {
ArchipelagoController.Instance.DeInit();
}
}
}


[DefaultButtonBinding(Buttons.Back, Keys.T)]
public ButtonBinding ToggleChat { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion Chat/ChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public void Init()
{
CelesteArchipelagoModule.Settings.ScrollChatDown.SetRepeat(0.15f);
CelesteArchipelagoModule.Settings.ScrollChatUp.SetRepeat(0.15f);
Enabled = true;
if (CelesteArchipelagoModule.Settings.Chat == true){
Enabled = true;
}
}

public void DeInit()
Expand Down
19 changes: 15 additions & 4 deletions Networking/ArchipelagoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private VictoryConditionOptions VictoryCondition
new PatchedOuiJournal(),
new PatchedSaveData(),
new PatchedStrawberry(),
new PatchedBerryCounter(),
};

public ArchipelagoController(Game game) : base(game)
Expand All @@ -101,6 +102,11 @@ public void Init()
ChatHandler.Init();
}

public void DeInit()
{
ChatHandler.DeInit();
}

public override void Update(GameTime gameTime)
{

Expand Down Expand Up @@ -130,7 +136,7 @@ public void StartSession(Action<LoginResult> onLogin)
port: CelesteArchipelagoModule.Settings.Port,
name: CelesteArchipelagoModule.Settings.Name,
flags: ItemsHandlingFlags.AllItems,
version: new Version(0, 4, 3),
version: new Version(0, 5, 0),
tags: null,
uuid: null,
password: CelesteArchipelagoModule.Settings.Password,
Expand Down Expand Up @@ -168,13 +174,18 @@ public void DisconnectSession()
Connection?.Dispose();
}

public void ReceiveItemCallback(ReceivedItemsHelper receivedItemsHelper)
public void ReceiveItemCallback(IReceivedItemsHelper receivedItemsHelper)
{
while(receivedItemsHelper.Any())
{
// Receive latest uncollected item
Logger.Log("CelesteArchipelago", $"Received item {receivedItemsHelper.PeekItemName()} with ID {receivedItemsHelper.PeekItem().Item}");
var itemID = receivedItemsHelper.PeekItem().Item;
Logger.Log("CelesteArchipelago", $"Received item {receivedItemsHelper.PeekItem().ItemName} with ID {receivedItemsHelper.PeekItem().ItemId}");
if (receivedItemsHelper.PeekItem().ItemName == "Victory (Celeste)")
{
receivedItemsHelper.DequeueItem();
continue;
}
var itemID = receivedItemsHelper.PeekItem().ItemId;
ArchipelagoNetworkItem item = new ArchipelagoNetworkItem(itemID);

// Collect received item via chosen progression system
Expand Down
3 changes: 2 additions & 1 deletion Networking/ArchipelagoSlotData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class ArchipelagoSlotData
{ "cassettes_required", typeof(ArchipelagoSlotData).GetProperty("CassettesRequired") },
{ "hearts_required", typeof(ArchipelagoSlotData).GetProperty("HeartsRequired") },
{ "levels_required", typeof(ArchipelagoSlotData).GetProperty("LevelsRequired") },
{ "goal_level", typeof(ArchipelagoSlotData).GetProperty("VictoryCondition") },
{ "victory_condition", typeof(ArchipelagoSlotData).GetProperty("VictoryCondition") },
{ "progression_system", typeof(ArchipelagoSlotData).GetProperty("ProgressionSystem") },
{ "goal_level", typeof(ArchipelagoSlotData).GetProperty("VictoryCondition") },
{ "disable_heart_gates", typeof(ArchipelagoSlotData).GetProperty("DisableHeartGates") },
};

Expand Down
4 changes: 2 additions & 2 deletions Networking/CheckpointState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public CheckpointItem(AreaKey area, string level)
}
}
private static List<CheckpointItem> Checkpoints;
private DataStorageHelper helper;
private IDataStorageHelper helper;

private static void InitCheckpoints()
{
Expand All @@ -45,7 +45,7 @@ private static int FindCheckpoint(AreaKey area, string level)
return Checkpoints.FindIndex((x) => x.Area == area && x.Level == level);
}

public CheckpointState(ulong current, DataStorageHelper helper)
public CheckpointState(ulong current, IDataStorageHelper helper)
{
runningTotal = current;
if(Checkpoints is null)
Expand Down
4 changes: 1 addition & 3 deletions Networking/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ protected override void Dispose(bool disposing)
if (Session.Socket.Connected)
{
Logger.Log("CelesteArchipelago", "Disconnecting socket.");
var rawSocket = DynamicData.For(Session.Socket).Get<ClientWebSocket>("webSocket");
rawSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Close requested by client", CancellationToken.None).Wait();
DynamicData.For(Session.Socket).Invoke("OnSocketClosed");
Session.Socket.DisconnectAsync().GetAwaiter().GetResult();
}
base.Dispose(disposing);
}
Expand Down
104 changes: 104 additions & 0 deletions PatchedObjects/PatchedBerryCounter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using Microsoft.Xna.Framework;
using Monocle;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Celeste.Mod.CelesteArchipelago
{
public class PatchedBerryCounter : IPatchable
{
public void Load()
{
On.Celeste.GameplayStats.Render += BerryCounter;

}

public void Unload()
{
On.Celeste.GameplayStats.Render -= BerryCounter;
}
public static void BerryCounter(On.Celeste.GameplayStats.orig_Render render, GameplayStats stats)
{

if (stats.DrawLerp <= 0f)
{
return;
}
float num = Ease.CubeOut(stats.DrawLerp);
Level level = stats.Scene as Level;
AreaKey area = level.Session.Area;
AreaModeStats areaModeStats = SaveData.Instance.Areas[area.ID].Modes[(int)area.Mode];
ModeProperties modeProperties = AreaData.Get(area).Mode[(int)area.Mode];
int totalStrawberries = modeProperties.TotalStrawberries;
int num2 = 32;
int num3 = (totalStrawberries - 1) * num2;
int num4 = ((totalStrawberries > 0 && modeProperties.Checkpoints != null) ? (modeProperties.Checkpoints.Length * num2) : 0);
Vector2 position = new Vector2((1920 - num3 - num4) / 2, 1016f + (1f - num) * 80f);
if (totalStrawberries <= 0)
{
return;
}
int num5 = ((modeProperties.Checkpoints == null) ? 1 : (modeProperties.Checkpoints.Length + 1));
for (int i = 0; i < num5; i++)
{
int num6 = ((i == 0) ? modeProperties.StartStrawberries : modeProperties.Checkpoints[i - 1].Strawberries);
for (int j = 0; j < num6; j++)
{
EntityData entityData = modeProperties.StrawberriesByCheckpoint[i, j];
if (entityData == null)
{
continue;
}
bool flag = false;
foreach (EntityID strawberry in level.Session.Strawberries)
{
if (entityData.ID == strawberry.ID && entityData.Level.Name == strawberry.Level)
{
flag = true;
}
}
MTexture mTexture = GFX.Gui["dot"];
if (flag)
{
if (area.Mode == AreaMode.CSide)
{
mTexture.DrawOutlineCentered(position, Calc.HexToColor("f2ff30"), 1.5f);
}
else
{
mTexture.DrawOutlineCentered(position, Calc.HexToColor("ff3040"), 1.5f);
}
}
else
{
bool flag2 = false;
foreach (EntityID strawberry2 in areaModeStats.Strawberries)
{
if (entityData.ID == strawberry2.ID && entityData.Level.Name == strawberry2.Level)
{
flag2 = true;
}
}
if (flag2)
{
mTexture.DrawOutlineCentered(position, Calc.HexToColor("4193ff"), 1f);
}
else
{
Draw.Rect(position.X - (float)mTexture.ClipRect.Width * 0.5f, position.Y - 4f, mTexture.ClipRect.Width, 8f, Color.DarkGray);
}
}
position.X += num2;
}
if (modeProperties.Checkpoints != null && i < modeProperties.Checkpoints.Length)
{
Draw.Rect(position.X - 3f, position.Y - 16f, 6f, 32f, Color.DarkGray);
position.X += num2;
}
}
}
}
}
11 changes: 6 additions & 5 deletions PatchedObjects/PatchedHeartGemDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ public void Unload()

private static void ctor(On.Celeste.HeartGemDoor.orig_ctor orig, HeartGemDoor self, EntityData data, Vector2 offset)
{
if (ArchipelagoController.Instance.SlotData.DisableHeartGates == 1)
{
(self.Scene as Level).Session.SetFlag("opened_heartgem_door_" + self.Requires);
}
//if (ArchipelagoController.Instance.SlotData.DisableHeartGates == 1)
//{
// (self.Scene as Level).Session.SetFlag("opened_heartgem_door_" + self.Requires);
//}
orig(self, data, offset);
}

private delegate int orig_HeartGemDoor_get_HeartGems(HeartGemDoor self);
private static int Get_HeartGems(orig_HeartGemDoor_get_HeartGems orig, HeartGemDoor self)
{
if (SaveData.Instance.CheatMode)
if (SaveData.Instance.CheatMode || ArchipelagoController.Instance.SlotData.DisableHeartGates == 1)
{
return self.Requires;
}

return ArchipelagoController.Instance.ProgressionSystem.GetTotalLogically(CollectableType.HEARTGEM);
}

Expand Down
6 changes: 3 additions & 3 deletions PatchedObjects/PatchedStrawberry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ private static void orig_OnCollect(orig_Strawberry_orig_OnCollect orig, Strawber
if (self.Follower.Leader != null)
{
Player obj = self.Follower.Leader.Entity as Player;
// collectIndex = obj.StrawberryCollectIndex;
// obj.StrawberryCollectIndex++;
collectIndex = obj.StrawberryCollectIndex;
obj.StrawberryCollectIndex++;
obj.StrawberryCollectResetTimer = 2.5f;
self.Follower.Leader.LoseFollower(self.Follower);
}
Expand All @@ -58,7 +58,7 @@ private static void orig_OnCollect(orig_Strawberry_orig_OnCollect orig, Strawber
ArchipelagoController.Instance.ProgressionSystem.OnCollectedClient(SaveData.Instance.CurrentSession_Safe.Area, CollectableType.STRAWBERRY, self.ID); // NEW
Session session = (self.Scene as Level).Session;
session.DoNotLoad.Add(self.ID);
// session.Strawberries.Add(self.ID);
session.Strawberries.Add(self.ID);
session.UpdateLevelStartDashes();
self.Add(new Coroutine(strawberry.Invoke<IEnumerator>("CollectRoutine", collectIndex)));
}
Expand Down
2 changes: 1 addition & 1 deletion Progression/DefaultProgression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void OnCollectedServer(AreaKey area, CollectableType collectable, EntityI
StrawberryCount += 1;
break;
default:
throw new ArgumentOutOfRangeException($"CollectableType {collectable} not implemented.");
throw new ArgumentOutOfRangeException($"CollectableType {area} {collectable} {entity} not implemented.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
DLL: bin/CelesteArchipelago.dll
Dependencies:
- Name: Everest
Version: 1.4465.0
Version: 1.4896.0