Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
TianMengLucky committed Aug 13, 2023
1 parent 480cdb0 commit 6eb911d
Show file tree
Hide file tree
Showing 89 changed files with 564 additions and 2,256 deletions.
18 changes: 8 additions & 10 deletions FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<student>
<Weavers>
<Costura>
<IncludeAssemblies>
Csv
Downloader
</IncludeAssemblies>
</Costura>
</Weavers>
</student>
<Weavers>
<Costura>
<IncludeAssemblies>
Csv
Downloader
</IncludeAssemblies>
</Costura>
</Weavers>
20 changes: 6 additions & 14 deletions NextShip/Buttons/ButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,26 @@ namespace NextShip.Buttons;

public class ButtonBase
{
public string name;
public Action Action;
public ActionButton ActionButton;
public GameObject ButtonGameObject;
public string name;
public string text;

public ButtonBase()
{
ButtonGameObject = new GameObject(base.ToString());
}

public ButtonBase Create(string name = "", GameObject clonetarget = null,ActionButton ActionButton = null, Action action = null)
public ButtonBase Create(string name = "", GameObject clonetarget = null, ActionButton ActionButton = null,
Action action = null)
{
this.name = name;
if (clonetarget != null)
{
ButtonGameObject = Object.Instantiate(clonetarget);
}
if (clonetarget != null) ButtonGameObject = Object.Instantiate(clonetarget);

if (action != null)
{
Action = action;
}
if (action != null) Action = action;

if (ActionButton != null)
{
this.ActionButton = ActionButton;
}
if (ActionButton != null) this.ActionButton = ActionButton;
return this;
}
}
4 changes: 2 additions & 2 deletions NextShip/Buttons/ButtonsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace NextShip.Buttons;

public class ButtonsManager
{
public static List<ButtonBase> _AllButtons = new List<ButtonBase>();
public static List<RoleButton> _AllRoleButton = new List<RoleButton>();
public static List<ButtonBase> _AllButtons = new();
public static List<RoleButton> _AllRoleButton = new();
}
1 change: 0 additions & 1 deletion NextShip/Buttons/RoleButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ protected RoleButton()
{
Create();
}

}
32 changes: 32 additions & 0 deletions NextShip/Chat/Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using HarmonyLib;

namespace NextShip.Chat;

[HarmonyPatch]
public static class Commands
{
[HarmonyPatch(typeof(ChatController), nameof(ChatController.SendChat))]
private static class SendChatPatch
{
public static bool Prefix(ChatController __instance)
{
__instance.timeSinceLastMessage = 3f;
var text = __instance.freeChatField.Text;
var args = text.Split(' ');
var canceled = false;
var cancelVal = "";
switch (args[0])
{

}

if (canceled)
{
__instance.freeChatField.Clear();
__instance.freeChatField.textArea.SetText(cancelVal);
}

return !canceled;
}
}
}
62 changes: 39 additions & 23 deletions NextShip/Cosmetics/Patches/HatManagerPatch.cs
Original file line number Diff line number Diff line change
@@ -1,69 +1,85 @@
using System;
using System.Collections.Generic;
using HarmonyLib;
using Exception = System.Exception;

namespace NextShip.Patches;

[HarmonyPatch(typeof(HatManager))]
public static class HatManagerPatch
{
public static List<HatViewData> AllCacheHatViewDatas = new();
public static List<NamePlateViewData> AllCacheNamePlateViewDatas = new();
public static List<SkinViewData> AllCacheSkinViewDatas = new();
public static List<VisorViewData> AllCacheVisorViewDatas = new();

public static bool initialized;
private static bool initialized = true;

[HarmonyPatch(nameof(HatManager.Initialize))]
[HarmonyPostfix]
public static void InitHatCache(HatManager __instance)
{
if (initialized) return;


TaskUtils.StartTask(() => initialized = AllCosmeticsCache.StartCache(__instance));
}
}

public static class AllCosmeticsCache
{
public static List<HatViewData> AllHatViewDatasCache = new();
public static List<NamePlateViewData> AllNamePlateViewDatasCache = new();
public static List<SkinViewData> AllSkinViewDatasCache = new();
public static List<VisorViewData> AllVisorViewDatasCache = new();
public static List<PetBehaviour> AllPetBehavioursCache = new();


public static bool StartCache(HatManager __instance)
{
try
{
__instance.allHats.Do(n => n.AddToChache());
__instance.allSkins.Do(n => n.AddToChache());
__instance.allVisors.Do(n => n.AddToChache());
__instance.allNamePlates.Do(n => n.AddToChache());
initialized = true;
__instance.allHats.Do(n => n.AddToCache());
__instance.allSkins.Do(n => n.AddToCache());
__instance.allVisors.Do(n => n.AddToCache());
__instance.allNamePlates.Do(n => n.AddToCache());
__instance.allPets.Do(n => n.AddToCache());
Info("缓存成功");
return true;
}
catch (Exception e)
{
Exception(e);
Error("缓存失败");
initialized = false;
return false;
}
}


public static void AddToChache(this HatData data)
private static void AddToCache(this HatData data)
{
var Asset = data.CreateAddressableAsset();
Asset.LoadAsync();
AllHatViewDatasCache.Add(Asset.GetAsset());
}

private static void AddToCache(this NamePlateData data)
{
var Asset = data.CreateAddressableAsset();
Asset.LoadAsync();
AllCacheHatViewDatas.Add(Asset.GetAsset());
AllNamePlateViewDatasCache.Add(Asset.GetAsset());
}

public static void AddToChache(this NamePlateData data)
private static void AddToCache(this VisorData data)
{
var Asset = data.CreateAddressableAsset();
Asset.LoadAsync();
AllCacheNamePlateViewDatas.Add(Asset.GetAsset());
AllVisorViewDatasCache.Add(Asset.GetAsset());
}

public static void AddToChache(this VisorData data)
private static void AddToCache(this SkinData data)
{
var Asset = data.CreateAddressableAsset();
Asset.LoadAsync();
AllCacheVisorViewDatas.Add(Asset.GetAsset());
AllSkinViewDatasCache.Add(Asset.GetAsset());
}

public static void AddToChache(this SkinData data)
private static void AddToCache(this PetData data)
{
var Asset = data.CreateAddressableAsset();
Asset.LoadAsync();
AllCacheSkinViewDatas.Add(Asset.GetAsset());
AllPetBehavioursCache.Add(Asset.GetAsset());
}
}
16 changes: 11 additions & 5 deletions NextShip/Game/GameEvents/GameEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ namespace NextShip.Game.GameEvents;
[HarmonyPatch]
public class GameEvent
{
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameEnd)), HarmonyPostfix]
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameEnd))]
[HarmonyPostfix]
public static void AmongUsClient_OnGameEnd(AmongUsClient __instance,
[HarmonyArgument(0)] EndGameResult endGameResult) =>
[HarmonyArgument(0)] EndGameResult endGameResult)
{
GameEventListener.Start(nameof(IGameEvent.OnGameEnd), __instance, endGameResult);

[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Start)), HarmonyPostfix]
public static void GameStartManager_OnGameStart(GameStartManager __instance) =>
}

[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Start))]
[HarmonyPostfix]
public static void GameStartManager_OnGameStart(GameStartManager __instance)
{
GameEventListener.Start(nameof(IGameEvent.OnGameStart), __instance);
}
}
39 changes: 26 additions & 13 deletions NextShip/Game/GameEvents/IGameEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@

public interface IGameEvent
{
public void OnPlayerJoined(AmongUsClient _amongUsClient) {}

public void OnPlayerLeft(AmongUsClient _amongUsClient) {}
public void OnPlayerJoined(AmongUsClient _amongUsClient)
{
}

public void OnGameStart(GameStartManager _gameStartManager) {}

public void OnCoBegin() {}

public void OnPlayerKill(PlayerControl murderer, PlayerControl target) {}

public void OnGameEnd(AmongUsClient __instance, EndGameResult endGameResult) {}

public void OnIntroCutscene(IntroCutscene _introCutscene) {}

public void OnPlayerLeft(AmongUsClient _amongUsClient)
{
}

public void OnGameStart(GameStartManager _gameStartManager)
{
}

public void OnCoBegin()
{
}

public void OnPlayerKill(PlayerControl murderer, PlayerControl target)
{
}

public void OnGameEnd(AmongUsClient __instance, EndGameResult endGameResult)
{
}

public void OnIntroCutscene(IntroCutscene _introCutscene)
{
}
}
7 changes: 1 addition & 6 deletions NextShip/Game/Info/HostInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ namespace NextShip.Game.Info;

public class HostInfo
{
public HostInfo()
{

}
}

}
4 changes: 0 additions & 4 deletions NextShip/Game/Info/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ namespace NextShip.Game.Info;

public class PlayerInfo
{
public PlayerInfo()
{

}
}

[HarmonyPatch(typeof(TaskPanelBehaviour), nameof(TaskPanelBehaviour.SetTaskText))]
Expand Down
Loading

0 comments on commit 6eb911d

Please sign in to comment.