Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
TianMengLucky committed Oct 16, 2023
1 parent 877aca5 commit 1e44d1a
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 123 deletions.
Empty file added NextShip.Api/APIReadme.md
Empty file.
5 changes: 0 additions & 5 deletions NextShip.Api/Class1.cs

This file was deleted.

10 changes: 10 additions & 0 deletions NextShip.Api/NextShip.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>NextShip.Api</RootNamespace>
<PackageVersion>0.1.0</PackageVersion>
<PackageProjectUrl></PackageProjectUrl>
<PackageReadmeFile>APIReadme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="APIReadme.md" Pack="true" PackagePath="\" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.672" Private="false" ExcludeAssets="runtime;native"/>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.7.11" PrivateAssets="all"/>
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" PrivatPeAssets="all" ExcludeAssets="runtime"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public enum CompatibilityLevel
[AttributeUsage(AttributeTargets.Class)]
public sealed class ShipPluginInfo : Attribute
{
public ShipPluginInfo(string Id, Version Version, string Name)
public ShipPluginInfo(string Id, ShipVersion Version, string Name)
{
this.Id = Id;
this.Version = Version;
this.Name = Name;
}

public string Id { get; }
public Version Version { get; }
public ShipVersion Version { get; }
public string Name { get; }
}
File renamed without changes.
7 changes: 4 additions & 3 deletions NextShip/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ private static void SendToFile(string tag, string filename, string text, LogLeve
public static void OutputTISLog()
{
var logName = FilesManager.TIS_DataPath +
$"/log/TISLog_{DateTime.Now.ToString(CultureInfo.InvariantCulture)}.ShipLog";
$"/log/{GetNowTime()}.log";
FilesManager.CreateDirectory(FilesManager.TIS_DataPath + "/log");
if (!File.Exists(logName)) File.Create(logName);
File.WriteAllText(logName, stringB.ToString());
File.WriteAllText(logName.Replace("/", "\\"), stringB.ToString(), Encoding.UTF8);
Msg("输出日志成功", "LogOutToData", "Log");
}

public static string GetNowTime() => DateTime.Now.ToString("g").Replace("/", "-").Replace(":", "-");



Expand Down
5 changes: 5 additions & 0 deletions NextShip/Manager/BanManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace NextShip.Manager;

public class BanManager : Manager<BanManager>
{
}
95 changes: 3 additions & 92 deletions NextShip/Manager/HistoryInfoManager.cs
Original file line number Diff line number Diff line change
@@ -1,99 +1,10 @@
using System;
using System.Collections.Generic;
using NextShip.RPC;
using NextShip.Utilities;

/* using static NextShip.Roles.RoleInfo; */
namespace NextShip.Manager;

namespace NextShip.HistoryManager;

public static class HistoryInfoManager
{
public static Dictionary<byte, List<HistoryInfo>> HistoryInfoDc = new();
public static Dictionary<byte, int> SerialNumber = new();

public static void Add(this PlayerControl player, RoleTeam team, RoleId roleId, bool isRpc, int number = 0)
{
if (!HistoryInfoDc.ContainsKey(player.PlayerId) && number != 0) SerialNumber[player.PlayerId] = 0;
if (number != 0) SerialNumber[player.PlayerId] = number;
if (!isRpc)
RPCUtils.Create((byte)CustomRPC.HistorySynchronization,
new[] { player.PlayerId, (byte)roleId, (byte)team }, new[] { SerialNumber[player.PlayerId] });
var info = new HistoryInfo(SerialNumber[player.PlayerId], team, roleId, DateTime.Now);
HistoryInfoDc[player.PlayerId].Add(info);
SerialNumber[player.PlayerId]++;
}

public class HistoryInfo
{
public static int Number;
public static RoleTeam Team;
public static RoleId Role;
public static DateTime Time;

public HistoryInfo(int number, RoleTeam team, RoleId role, DateTime time)
{
Number = number;
Team = team;
Role = role;
Time = time;
}
}
}

public class TeamHistoryManager
{
public static RoleTeam OldTeam;
public static RoleTeam NewTeam;

/* public static void Start()
{
OldTeam = RoleHelpers.GetRoleInfo(CachedPlayer.LocalPlayer.PlayerControl).team;
NewTeam = OldTeam;
} */

public static void Update()
{
if (NewTeam != OldTeam) CachedPlayer.LocalPlayer.PlayerControl.Add(NewTeam, RoleHistoryManager.NewRole, false);
}
}

public class RoleHistoryManager
public class HistoryInfoManager : Manager<HistoryInfoManager>
{
public static RoleId OldRole;
public static RoleId NewRole;

/* public static void Start()
{
OldRole = RoleHelpers.GetRoleInfo(CachedPlayer.LocalPlayer.PlayerControl).roleId;
NewRole = OldRole;
} */

public static void Update()
{
if (NewRole != OldRole) CachedPlayer.LocalPlayer.PlayerControl.Add(TeamHistoryManager.NewTeam, NewRole, false);
}

}

public class DeathInfoManager
{
public class DeadPlayer
{
public DeathReason DeathReason;
public PlayerControl Murderer;
public PlayerControl player;
public DateTime TimeOfDeath;

public DeadPlayer(PlayerControl player, DateTime TimeOfDeath, DeathReason DeathReason, PlayerControl Murderer)
{
this.player = player;
this.TimeOfDeath = TimeOfDeath;
this.DeathReason = DeathReason;
this.Murderer = Murderer;
}

private enum CustomDeathReason
{
}
}
}
6 changes: 6 additions & 0 deletions NextShip/Manager/HistoryManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace NextShip.Manager;

public class HistoryManager : Manager<HistoryManager>
{

}
10 changes: 10 additions & 0 deletions NextShip/Manager/Manager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace NextShip.Manager;

public class Manager<T> where T : new()
{
protected static T _instance;

public static T Instance => Get();

public static T Get() => _instance ??= new T();
}
5 changes: 5 additions & 0 deletions NextShip/Manager/VersionManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace NextShip.Manager;

public class VersionManager : Manager<VersionManager>
{
}
1 change: 1 addition & 0 deletions NextShip/NextShip.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@




<Target Name="Copy" AfterTargets="Build" Condition="$(NextShipLast) != ''">
<Copy SourceFiles="$(OutputPath)/$(AssemblyName).dll" DestinationFolder="$(NextShipLast)/BepInEx/plugins/" UseSymboliclinksIfPossible="true"/>
</Target>
Expand Down
2 changes: 1 addition & 1 deletion NextShip/Patches/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static void Postfix(VersionShower __instance)
stringText += " " + $"{ThisAssembly.Git.Branch} {ThisAssembly.Git.Commit}";
#endif

stringText += "" + $"作者:天寸梦初 ver{Main.AmongUsVersion}";
stringText += "" + $"作者:天寸梦初 ver{Main.SupportVersion}";

__instance.text.text = stringText;
}
Expand Down
76 changes: 76 additions & 0 deletions NextShip/ShipVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using UnityEngine;

namespace NextShip;

public class ShipVersion
{
public int Major { get; protected set; }
public int Minor { get; protected set; }
public int Info { get; protected set; }

public string StringText { get; protected set; }

internal ShipVersion() { }

public ShipVersion(int major, int minor, int info)
{
Major = major;
Minor = minor;
Info = info;
}

public void set(int major, int minor, int info)
{
Major = major;
Minor = minor;
Info = info;
}
}

public class AmongUsVersion : ShipVersion
{
public int Year { get; protected set; }
public int Month { get; protected set; }
public int Day { get; protected set; }
public int Revision { get; protected set; }

public AmongUsVersion(int major, int minor, int info) : base(major, minor, info)
{
}

internal AmongUsVersion() {}

internal AmongUsVersion Form()
{
return new AmongUsVersion();
}

public AmongUsVersion AmongUsSet(int year, int month, int day, int revision = 0)
{
Year = year;
Month = month;
Day = day;
Revision = revision;
return this;
}

internal static AmongUsVersion GetFormConstants() =>
new AmongUsVersion().AmongUsSet(Constants.Year, Constants.Month, Constants.Day, Constants.Revision);

internal static string GetBuildVersion() => Application.version;

public static int GetVersion(int year, int month, int day, int rev) =>
year * 25000 + month * 1800 + day * 50 + rev;

public static explicit operator string(AmongUsVersion Ver)
{
if (Ver.Major == 0 || Ver.Minor == 0 || Ver.Info == 0) return string.Empty;
return $"{Ver.Major}.{Ver.Minor}.{Ver.Day}";
}

public static explicit operator int(AmongUsVersion Ver)
{
if (Ver.Year == 0 || Ver.Month == 0 || Ver.Day == 0) return 0;
return GetVersion(Ver.Year, Ver.Month, Ver.Day, Ver.Revision);
}
}
1 change: 0 additions & 1 deletion NextShip/UI/Components/OnClickButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace NextShip.UI.Components;

[Il2CppRegister]
public class OnClickButton : MonoBehaviour, INextUI
{
public BoxCollider2D[] BoxCollider2Ds;
Expand Down
47 changes: 42 additions & 5 deletions NextShip/UI/Components/ShipOptionBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using NextShip.Options;
using NextShip.UI.Interface;
using NextShip.Utilities.Attributes;
Expand All @@ -14,8 +15,15 @@ public class ShipOptionBehaviour : MonoBehaviour, INextUI
public TextMeshPro TitleText;
public PassiveButton PreviousButton;
public PassiveButton NextButton;
public OptionBase OptionBase;
public OptionBase OptionBase { private set; get; }

public Action<ShipOptionBehaviour> OnOptionValueChanged;

public void SetOptionBase(OptionBase optionBase)
{
OptionBase = optionBase;
}

public void FixedUpdate()
{
}
Expand All @@ -27,21 +35,50 @@ public void OnEnable()
ValueText.text = OptionBase.GetValueString();
}

internal static GameObject GenerateOption(Transform Parent, Sprite sprite, string Name = "Temp")
internal static GameObject GenerateOption(Transform Parent, string Name = "Temp")
{
var Option = new GameObject(Name);
Option.transform.SetParent(Parent);
Option.transform.localPosition = new Vector3(0, 0, -5);
var behaviour = Option.AddComponent<ShipOptionBehaviour>();

var BackGround = behaviour.BackGround_Sprite = new GameObject("BackGround").AddComponent<SpriteRenderer>();
BackGround.sprite = sprite;

var BackGroundObj = new GameObject("BackGround");
var BackGround = behaviour.BackGround_Sprite = BackGroundObj.AddComponent<SpriteRenderer>();
BackGround.sprite = ObjetUtils.Find<Sprite>("smallButtonBorder");

var ValueText = behaviour.ValueText = new GameObject("ValueText").AddComponent<TextMeshPro>();
var TitleText = behaviour.TitleText = new GameObject("TitleText").AddComponent<TextMeshPro>();

ValueText.text = "ValueText";
TitleText.text = "TitleText";

ValueText.transform.SetParent(Option.transform);
TitleText.transform.SetParent(Option.transform);
BackGround.transform.SetParent(Option.transform);

var leftButtonSprite = SpriteUtils.LoadSpriteFromResources("left.png");
var rightButtonSprite = SpriteUtils.LoadSpriteFromResources("right.png");

var LeftButton = new GameObject("LeftButton");
LeftButton.transform.SetParent(Option.transform);
var LeftButton_Sprite = LeftButton.AddComponent<SpriteRenderer>();
LeftButton_Sprite.sprite = leftButtonSprite;
LeftButton.CreatePassiveButton(() =>
{
behaviour.OptionBase.Decrease();
behaviour.OnOptionValueChanged(behaviour);
});

var RightButton = new GameObject("RightButton");
RightButton.transform.SetParent(Option.transform);
var RightButton_Sprite = RightButton.AddComponent<SpriteRenderer>();
RightButton_Sprite.sprite = rightButtonSprite;
RightButton.CreatePassiveButton(() =>
{
behaviour.OptionBase.Increase();
behaviour.OnOptionValueChanged(behaviour);
});

return Option;
}

Expand Down
1 change: 0 additions & 1 deletion NextShip/UI/Components/UpdateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace NextShip.UI.Components;

[Il2CppRegister]
public class UpdateTask : MonoBehaviour
{
public static List<ShipTask> Tasks;
Expand Down
Loading

0 comments on commit 1e44d1a

Please sign in to comment.