Skip to content

Commit

Permalink
1055 tb2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsFabTest committed Sep 30, 2023
1 parent 050cc7b commit 02605ba
Show file tree
Hide file tree
Showing 63 changed files with 1,100 additions and 111 deletions.
5 changes: 5 additions & 0 deletions Nebula/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public static CustomOption GetCurrentGameModeOption()
public static CustomOption BattleShotEffectiveRangeOption;
public static CustomOption BattleNoticeRangeOption;


//public static CustomOption ConnectCacheTimeOption;

public static void AddExclusiveAssignment(ref List<ExclusiveAssignment> exclusiveAssignments)
{
if (!exclusiveAssignmentParent.getBool()) return;
Expand Down Expand Up @@ -823,5 +826,7 @@ MetaScreenContent[][] AddKillCoolDownProceedIgnoringOptions(Action refresher,par
BattleShotEffectiveRangeOption.suffix = "cross";
BattleNoticeRangeOption = CustomOption.Create(Color.white, "option.battleOption.noticeRangeOption", 20f, 2f, 50f, 2f,BattleOption,false,false,"",CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleNoticeRangeOption.suffix = "cross";

//ConnectCacheTimeOption = CustomOption.Create(Color.white, "option.connectCacheTime", 10f, 1f, 100f, 1f, roleCountOption, false, false, "", CustomOptionTab.Settings).HiddenOnDisplay(true).SetGameMode(CustomGameMode.ActuallyAll);
}
}
1 change: 1 addition & 0 deletions Nebula/Events/GlobalEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static public bool IsActive(Type type)

static public void Update()
{
if(Game.GameData.data.IsTimeStopped) return;
foreach (GlobalEvent globalEvent in Events)
{
globalEvent.duration -= Time.deltaTime;
Expand Down
2 changes: 2 additions & 0 deletions Nebula/Events/LocalEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class LocalEvent

public float duration { get; private set; }
public bool SpreadOverMeeting { get; protected set; }
public bool WillStop = true;

public bool CheckTerminal()
{
Expand Down Expand Up @@ -41,6 +42,7 @@ static public void Update()
{
foreach (LocalEvent localEvent in Events)
{
if(Game.GameData.data.IsTimeStopped && localEvent.WillStop) continue;
localEvent.LocalUpdate();
localEvent.duration -= Time.deltaTime;
}
Expand Down
13 changes: 13 additions & 0 deletions Nebula/Events/StandardEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Nebula.Events;

public class StandardEvent : LocalEvent{
Action action;
public StandardEvent(Action action,float time,bool isCrossMeeting,bool WillStop) : base(time) { this.action = action; SpreadOverMeeting = isCrossMeeting; this.WillStop = WillStop; }
public override void OnTerminal(){
action.Invoke();
}

public static void SetEvent(Action action,float time = 0f,bool isCrossMeeting = false,bool WillStop = true){
LocalEvent.Activate(new StandardEvent(action,time,isCrossMeeting,WillStop));
}
}
8 changes: 8 additions & 0 deletions Nebula/Game/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,11 @@ public class GameData

public bool IsLockedKill;

public bool IsTimeStopped;
public bool IsLocked;

//public bool isFlashed;

public GameData()
{

Expand Down Expand Up @@ -1383,12 +1388,15 @@ public GameData()
Timer = 300f;

IsCanceled = false;
IsLocked = false;

//Reporter = null;
//Dead = null;

IsLockedKill = false;

IsTimeStopped = false;

Roles.Perk.PerkHolder.PerkData.InitializePerkData();
}

Expand Down
15 changes: 9 additions & 6 deletions Nebula/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ public static MurderAttemptResult checkMuderAttemptAndKill(PlayerControl killer,
return murder;
}

public static void PlayCustomFlash(Color color, float fadeIn, float fadeOut, float maxAlpha = 0.5f)
public static void PlayCustomFlash(Color color, float fadeIn, float fadeOut, float maxAlpha = 0.5f, float flashDuring = 0f)
{
float duration = fadeIn + fadeOut;
float duration = fadeIn + fadeOut + flashDuring;

var flash = GameObject.Instantiate(HudManager.Instance.FullScreen, HudManager.Instance.transform);
flash.color = color;
Expand All @@ -513,14 +513,17 @@ public static void PlayCustomFlash(Color color, float fadeIn, float fadeOut, flo
if (p < (fadeIn / duration))
{
if (flash != null)
flash.color = new Color(color.r, color.g, color.b, Mathf.Clamp01(maxAlpha * p / (fadeIn / duration)));
flash.color = new Color(color.r, color.g, color.b, Mathf.Clamp01((PlayerControl.LocalPlayer.Data.IsDead ? Mathf.Min(maxAlpha,0.2f) : maxAlpha) * p / (fadeIn / duration)));
}
else
else if(1 - p < (fadeOut / duration))
{
if (flash != null)
flash.color = new Color(color.r, color.g, color.b, Mathf.Clamp01(maxAlpha * (1 - p) / (fadeOut / duration)));
flash.color = new Color(color.r, color.g, color.b, Mathf.Clamp01((PlayerControl.LocalPlayer.Data.IsDead ? Mathf.Min(maxAlpha,0.2f) : maxAlpha) * (1 - p) / (fadeOut / duration)));
}else{
if (flash != null)
flash.color = new Color(color.r,color.g,color.b,PlayerControl.LocalPlayer.Data.IsDead ? Mathf.Min(maxAlpha,0.2f) : maxAlpha);
}
if (p == 1f && flash != null)
if ((p == 1f || MeetingHud.Instance) && flash != null)
{
flash.enabled = false;
GameObject.Destroy(flash.gameObject);
Expand Down
13 changes: 12 additions & 1 deletion Nebula/Module/AssetLoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nebula.Roles.NeutralRoles;
using Mono.Cecil;
using Nebula.Roles.NeutralRoles;
using Nebula.Tasks;
using System.Reflection;
using UnityEngine;
Expand Down Expand Up @@ -60,6 +61,8 @@ public static class AssetLoader

public static GameObject MetaObjectPrefab;

//public static AudioSource audioSource;

static public void Load()
{
var resourceStream = assembly.GetManifestResourceStream("Nebula.Resources.Assets.nebula_asset");
Expand Down Expand Up @@ -102,6 +105,14 @@ static public void Load()

PuppeteerLaugh = AssetBundle.LoadFromMemory(assembly.GetManifestResourceStream("Nebula.Resources.Assets.audiobundle").ReadFully()).LoadAsset<AudioClip>("PuppeteerLaugh.mp3").DontUnload();
Uskneko = AssetBundle.LoadFromMemory(assembly.GetManifestResourceStream("Nebula.Resources.Assets.haomingassets").ReadFully()).LoadAsset<AudioClip>("Uskneko.mp3").DontUnload();

/*
audioSource = new();
AudioClip clip = Resources.Load<AudioClip>("Sounds/background.mp3");
audioSource.clip = clip;
audioSource.DontUnload();
audioSource.loop = true;
*/
}

public static Sprite GetMapSprite(byte mapId,Vector2 size,Int32 mask)
Expand Down
14 changes: 12 additions & 2 deletions Nebula/Module/CustomOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void UpdateSelectionProcess(Tuple<int,int> param)
int sent = 0;
while (num > 0)
{
int length = num > 8 ? 8 : num;
int length = num > 128 ? 128 : num;
var options = new Tuple<int, int>[length];
for (int i = 0; i < length; i++)
{
Expand Down Expand Up @@ -1293,7 +1293,17 @@ public class PlayerJoinedPatch
{
public static void Postfix()
{
if(AmongUsClient.Instance.AmHost)CustomOption.ShareAllOptions.Invoke(CustomOption.AllOptions);
if(AmongUsClient.Instance.AmHost) CustomOption.ShareAllOptions.Invoke(CustomOption.AllOptions);
/*
int randomInt = NebulaPlugin.rnd.Next(10000);
TMPro.TMP_Text message = new();
message.text = "Wait for " + (randomInt / 1000).ToString() + " seconds.";
message.color = Color.red;
message.transform.position = new Vector3(0f,0f,5f);
Thread.Sleep(randomInt);
UnityEngine.GameObject.Destroy(message);
*/
//if(AmongUsClient.Instance.AmHost)CustomOption.ShareAllOptions.Invoke(CustomOption.AllOptions);
}
}

Expand Down
10 changes: 5 additions & 5 deletions Nebula/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public class NebulaPlugin : BasePlugin
public const string AmongUsVersion = "2023.3.28";
public const string PluginGuid = "cn.zsfabtest.amongus.nebular";
public const string PluginName = "TheNebula-R-LTS";
public const string PluginVersion = "1.0.5.2";
public const bool IsSnapshot = false;
public const string PluginVersion = "1.0.5.5";
public const bool IsSnapshot = true;

public static string PluginVisualVersion = (IsSnapshot ? ("23.09.14" + " - ") : "") + PluginVersion;
public static string PluginVisualVersion = (IsSnapshot ? ("23.09.30" + " - ") : "") + PluginVersion;
public static string PluginStage = IsSnapshot ? "Snapshot" : "";

public const string PluginVersionForFetch = "1.0.5.2";
public byte[] PluginVersionData = new byte[] { 1, 0, 5, 2 };
public const string PluginVersionForFetch = "1.0.5.5";
public byte[] PluginVersionData = new byte[] { 1, 0, 5, 5 };

public static NebulaPlugin Instance;

Expand Down
19 changes: 15 additions & 4 deletions Nebula/Objects/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public class CustomButton

public bool IsValid { get { return activeFlag; } }
public bool IsShown { get { return activeFlag && !hideFlag; } }
public bool timeInVent = false;

public SpriteRenderer lockRenderer;

private static Sprite spriteKeyBindBackGround;
private static Sprite spriteKeyBindOption;
Expand Down Expand Up @@ -211,6 +212,8 @@ public CustomButton(Action OnClick, Func<bool> HasButton, Func<bool> CouldUse, A
Expansion.GridArrangeExpansion.AddGridArrangeContent(button.gameObject,GridParam);

setActive(true);

this.lockRenderer = null;
}

public CustomButton(Action OnClick, Func<bool> HasButton, Func<bool> CouldUse, Action OnMeetingEnds, Sprite Sprite, Expansion.GridArrangeExpansion.GridArrangeParameter GridParam, HudManager hudManager, KeyCode? hotkey, string buttonText = "", ImageNames labelType = ImageNames.UseButton)
Expand Down Expand Up @@ -315,7 +318,7 @@ public CustomButton SetTimer(float timer)

public void onClickEvent()
{
if (HasButton() && CouldUse())
if (HasButton() && CouldUse() && !Game.GameData.data.IsTimeStopped && !Game.GameData.data.IsLocked)
{
if (this.Timer < 0f)
{
Expand Down Expand Up @@ -462,15 +465,23 @@ private bool MouseClicked()

public void Update()
{
if(Game.GameData.data.IsLocked && !lockRenderer){
lockRenderer = this.AddOverlay(lockedButtonSprite.GetSprite(),0f);
}
if(!Game.GameData.data.IsLocked && lockRenderer != null){
lockRenderer.gameObject.SetActive(false);
lockRenderer = null;
}

if (actionButton.cooldownTimerText.color.a != 1f)
{
Color c = actionButton.cooldownTimerText.color;
actionButton.cooldownTimerText.color = new Color(c.r, c.g, c.b, 1f);
}

if (Timer >= 0)
if (Timer >= 0 && !Game.GameData.data.IsTimeStopped)
{
if ((HasEffect && isEffectActive) || (timeInVent && !MeetingHud.Instance))
if (HasEffect && isEffectActive)
Timer -= Time.deltaTime;
else if (Helpers.ProceedTimer(isImpostorKillButton))
Timer -= Time.deltaTime;
Expand Down
4 changes: 3 additions & 1 deletion Nebula/Objects/CustomObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ static UsableCustomObjectBehaviour()

public float UsableDistance { get => 0.8f; }
public float PercentCool { get => 0f; }
public bool hasOutLine = true;

public ImageNames UseIcon { get => ImageNames.UseButton; }

public void SetOutline(bool on, bool mainTarget)
{
if (this.CustomObject.Renderer)
if (this.CustomObject.Renderer && hasOutLine)
{
CustomObject.Renderer.material.SetFloat("_Outline", (float)(on ? 1 : 0));
CustomObject.Renderer.material.SetColor("_OutlineColor", Color.white);
Expand Down Expand Up @@ -119,6 +120,7 @@ protected static void VisibleObjectUpdate(CustomObject obj)
public static ObjectTypes.Footprint Footprint = new ObjectTypes.Footprint();
public static ObjectTypes.TeleportEvidence TeleportEvidence = new ObjectTypes.TeleportEvidence();
public static ObjectTypes.Leaves Leaves = new ObjectTypes.Leaves();
public static ObjectTypes.TeleportField TeleportField = new ObjectTypes.TeleportField();

public byte Id { get; }
public string ObjectName { get; }
Expand Down
81 changes: 81 additions & 0 deletions Nebula/Objects/ObjectTypes/TeleportField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Nebula.Module;

namespace Nebula.Objects.ObjectTypes;

public class TeleportField : TypeWithImage{
public float[] LastTeleport;
public static SpriteLoader ActivePortal = new("Nebula.Resources.ActivePortal.png",125f);
public static SpriteLoader InactivePortal = new("Nebula.Resources.InactivePortal.png",125f);
public static SpriteLoader UnusablePortal = new("Nebula.Resources.UnusablePortal.png",125f);
public TeleportField() : base(232, "TeleportField", new SpriteLoader("Nebula.Resources.PerkFrame.png",100f)){
LastTeleport = new float[100];
}

public override bool CanSeeInShadow(CustomObject? obj) => true;
public override bool IsUsable => true;
public override bool RequireMonoBehaviour => true;
public override bool CanUse(CustomObject obj, PlayerControl player)
{
if(LastTeleport[obj.Data[0]] > 0f) return false;
/*
//int cnt = 0;
foreach(var oj in CustomObject.Objects){
if(oj.Value.ObjectType == CustomObject.Type.TeleportField && oj.Value != obj){
}
}
*/
if(CustomObject.Objects.Values.FirstOrDefault((oj) => { return oj.ObjectType == CustomObject.Type.TeleportField && oj != obj && oj.Data[0] == obj.Data[0]; }) == null) return false;
return true;
}
public override void Use(CustomObject obj)
{
foreach(var oj in CustomObject.Objects.Values){
if(oj.ObjectType == CustomObject.Type.TeleportField && oj != obj && oj.Data[0] == obj.Data[0]){
PlayerControl.LocalPlayer.transform.position = oj.GameObject.transform.position;
RPCEventInvoker.ResetTeleportField(obj.Data[0]);
}
}
}
public override void Initialize(CustomObject obj){
base.Initialize(obj);
obj.Data = new int[2];
obj.Data[0] = CustomObject.Objects.Values.Count((oj) => { return oj.ObjectType == CustomObject.Type.TeleportField; }) / 2;
LastTeleport[obj.Data[0]] = 0f;
obj.Renderer.sprite = UnusablePortal.GetSprite();
//obj.Renderer.size = new(2f,2f);
obj.Renderer.enabled = true;
obj.UsableBehaviour.hasOutLine = false;
}

public override void Update(CustomObject obj)
{
base.Update(obj);
FixZPosition(obj);
LastTeleport[obj.Data[0]] -= Time.deltaTime / 2;
if(CustomObject.Objects.Values.FirstOrDefault((oj) => { return oj.ObjectType == CustomObject.Type.TeleportField && oj != obj && oj.Data[0] == obj.Data[0]; }) != null){
if(LastTeleport[obj.Data[0]] <= 0f) obj.Renderer.sprite = ActivePortal.GetSprite();
else obj.Renderer.sprite = InactivePortal.GetSprite();
//base.Initialize(obj);
}
}

public override void Update(CustomObject obj,int command){
if(command == 1){
LastTeleport[obj.Data[0]] = Roles.Roles.Enchanter.getCooldown();
}
}

public static void ResetTime(int idx){
/*
foreach(var oj in CustomObject.Objects){
if(oj.Value.ObjectType == CustomObject.Type.TeleportField && oj.Value.Data[0] == idx) oj.Value.Data[1] = Roles.Roles.Enchanter.getCooldown();
}
*/
//LastTeleport = Roles.Roles.Enchanter.getCooldown();
//List<TeleportField> teleportFields;
foreach(var oj in CustomObject.Objects.Values){
if(oj.ObjectType == CustomObject.Type.TeleportField && oj.Data[0] == idx) oj.Update(1);
}
}
}
17 changes: 17 additions & 0 deletions Nebula/Patches/EmergencyPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ static void Postfix(EmergencyMinigame __instance)
return;
}

if (Game.GameData.data.IsTimeStopped){
__instance.StatusText.text = Language.Language.GetString("meeting.timeIsStopped");
__instance.NumberText.text = string.Empty;
__instance.ClosedLid.gameObject.SetActive(true);
__instance.OpenLid.gameObject.SetActive(false);
__instance.ButtonActive = false;
return;
}

if (Game.GameData.data.IsLocked){
__instance.StatusText.text = Language.Language.GetString("meeting.isLocked");
__instance.NumberText.text = string.Empty;
__instance.ClosedLid.gameObject.SetActive(true);
__instance.OpenLid.gameObject.SetActive(false);
__instance.ButtonActive = false;
return;
}

int score = 0, require = 0;
if (Game.GameData.data.GameRule.canUseEmergencyWithoutDeath)
Expand Down
Loading

0 comments on commit 02605ba

Please sign in to comment.