Skip to content

Commit

Permalink
nightly v1.8.0.0 (1/1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipodtouch0218 committed Jan 2, 2024
1 parent e34b719 commit f425f2e
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
public static class BuildInfo{public static string BUILD_TIME = "12/31/2023 4:26:34 AM";}
public static class BuildInfo{public static string BUILD_TIME = "1/2/2024 2:12:46 AM";}
13 changes: 11 additions & 2 deletions Assets/Scripts/Entity/EntityMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Vector2 Position {
[SerializeField] private bool bounceOnImpacts;

//---Private Variables
private Vector2 previousInternalPosition;
private Vector2 previousRenderPosition;
private PropertyReader<Vector2> internalPositionPropertyReader;

Expand Down Expand Up @@ -79,9 +80,18 @@ public unsafe override void Render() {
if (Freeze) {
newPosition = Position;
} else if (TryGetSnapshotsBuffers(out var from, out var to, out float alpha)) {

// Snapshot interpolation with no smoothing:
Vector2 fromVector;
Vector2 toVector;

(Vector2 fromVector, Vector2 toVector) = internalPositionPropertyReader.Read(from, to);
if (ForceSnapshotInterpolation) {
fromVector = previousInternalPosition;
toVector = Position;
previousInternalPosition = Position;
} else {
(fromVector, toVector) = internalPositionPropertyReader.Read(from, to);
}

if (interpolationTeleportDistance > 0 && Utils.WrappedDistance(fromVector, toVector) > interpolationTeleportDistance) {
// Teleport over large distances
Expand All @@ -94,7 +104,6 @@ public unsafe override void Render() {
}
} else {
// Fallback interpolation with some smoothing:

if (interpolationTeleportDistance > 0 && Utils.WrappedDistance(previousRenderPosition, Position) > interpolationTeleportDistance) {
// Teleport over large distances
newPosition = Utils.WrapWorldLocation(Position);
Expand Down
8 changes: 6 additions & 2 deletions Assets/Scripts/Entity/World Elements/GenericMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using NSMB.Game;

//[OrderBefore(typeof(EntityMover))]
public class GenericMover : NetworkBehaviour, IBeforeTick, IWaitForGameStart {
public class GenericMover : NetworkBehaviour, IBeforeTick, IWaitForGameStart, IWaitForGameEnd {

//---Networked Variables
[Networked] private Vector3 Origin { get; set; }
Expand Down Expand Up @@ -61,10 +61,14 @@ public override void FixedUpdateNetwork() {
SetPosition(transform, Origin, Runner.SimulationTime - GameManager.Instance.GameStartTime);
}

public void Execute() {
void IWaitForGameStart.Execute() {
Enabled = true;
}

void IWaitForGameEnd.Execute() {
Enabled = false;
}

private void SetPosition(Transform target, Vector3 origin, float secondsElapsed) {
if (!target) {
target = transform;
Expand Down
35 changes: 35 additions & 0 deletions Assets/Scripts/Entity/World Elements/IWaitForGameEnd.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Fusion;

public interface IWaitForGameEnd {

public virtual FunctionTarget Target => FunctionTarget.All;

void AttemptExecute(NetworkObject obj) {
switch (Target) {
case FunctionTarget.All: {
Execute();
break;
}
case FunctionTarget.ServerHostOnly: {
if (obj.Runner.IsServer) {
Execute();
}

break;
}
case FunctionTarget.ObjectOwnerOnly: {
if (obj.HasInputAuthority) {
Execute();
}

break;
}
}
}

void Execute();

public enum FunctionTarget {
All, ServerHostOnly, ObjectOwnerOnly
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Entity/World Elements/IWaitForGameEnd.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ private IEnumerator EndGame(int winningTeam) {
PlaySounds = false;
endSoundPlayed = true;

// End "WaitForGameEnd" objects
foreach (var wfge in FindObjectsByType<NetworkBehaviour>(FindObjectsSortMode.None).Where(nb => nb is IWaitForGameEnd)) {
((IWaitForGameEnd) wfge).AttemptExecute(wfge.Object);
}

ForceUnpause();
musicManager.Stop();

Expand Down
22 changes: 12 additions & 10 deletions Assets/Scripts/Networking/Fusion/NetworkHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,17 +453,19 @@ public static async Task<StartGameResult> ConnectToRegion(string region = "") {
object communicator = cloudServices.GetType().GetProperty("Communicator", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(cloudServices);
object client = communicator.GetType().GetProperty("Client", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(communicator);
object regionHandler = client.GetType().GetField("RegionHandler", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(client);
IList regions = (IList) regionHandler.GetType().GetProperty("EnabledRegions", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(regionHandler);

var codeField = regions[0].GetType().GetProperty("Code", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
var pingField = regions[0].GetType().GetProperty("Ping", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
foreach (object item in regions) {
string code = (string) codeField.GetValue(item);
int ping = (int) pingField.GetValue(item);
RegionPings[code] = ping;
}
if (regionHandler != null) {
IList regions = (IList) regionHandler.GetType().GetProperty("EnabledRegions", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(regionHandler);

var codeField = regions[0].GetType().GetProperty("Code", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
var pingField = regions[0].GetType().GetProperty("Ping", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
foreach (object item in regions) {
string code = (string) codeField.GetValue(item);
int ping = (int) pingField.GetValue(item);
RegionPings[code] = ping;
}

OnRegionPingsUpdated?.Invoke();
OnRegionPingsUpdated?.Invoke();
}
} catch (Exception e) {
Debug.LogError(e);
}
Expand Down
24 changes: 16 additions & 8 deletions Assets/Scripts/UI/Menu/Chat/MainMenuChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ public void UpdatePlayerColors() {
}

public void SetTypingIndicator(PlayerRef player) {
if (!MainMenuManager.Instance)
if (!MainMenuManager.Instance) {
return;
}

PlayerData data;
if ((data = player.GetPlayerData(NetworkHandler.Runner)) && data.IsMuted)
if ((data = player.GetPlayerData(NetworkHandler.Runner)) && data.IsMuted) {
return;
}

PlayerListEntry ple = MainMenuManager.Instance.playerList.GetPlayerListEntry(player);
if (ple)
if (ple) {
ple.typingCounter = 4;
}
}

public void SendChat() {
Expand All @@ -61,8 +64,9 @@ public void SendChat() {
}

string text = chatbox.text.Replace("\n", " ").Trim();
if (string.IsNullOrWhiteSpace(text))
if (string.IsNullOrWhiteSpace(text)) {
return;
}

if (text.StartsWith('/')) {
ChatManager.Instance.AddSystemMessage("ui.inroom.chat.command");
Expand All @@ -73,8 +77,9 @@ public void SendChat() {
}

public void ClearChat() {
foreach (ChatMessage message in chatMessages)
foreach (ChatMessage message in chatMessages) {
Destroy(message.gameObject);
}

chatMessages.Clear();
}
Expand All @@ -94,18 +99,21 @@ public void OnChatMessage(ChatMessage.ChatMessageData data) {
}

public void OnTextboxChanged() {
if (!MainMenuManager.Instance)
if (!MainMenuManager.Instance) {
return;
}

int size = chatbox.text.Length;
if (size == previousTextLength)
if (size == previousTextLength) {
return;
}

previousTextLength = size;

PlayerListEntry ple = MainMenuManager.Instance.playerList.GetPlayerListEntry(NetworkHandler.Runner.LocalPlayer);
if (!ple || ple.typingCounter > 2)
if (!ple || ple.typingCounter > 2) {
return;
}

SessionData.Instance.Rpc_UpdateTypingCounter();
}
Expand Down
14 changes: 1 addition & 13 deletions Assets/Scripts/UI/Menu/MainMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,7 @@ public void UpdateStartGameButton() {
}

public bool IsRoomConfigurationValid() {
List<PlayerData> nonSpectators = Runner.ActivePlayers.Select(p => p.GetPlayerData(Runner)).Where(pd => !pd.IsManualSpectator).ToList();
bool validRoomConfig = true;

int realPlayers = nonSpectators.Count();
validRoomConfig &= realPlayers >= 1;

// Only do team checks if there's more than one player
if (SessionData.Instance && SessionData.Instance.Teams && realPlayers > 1) {
int teams = nonSpectators.Select(pd => pd.Team).Distinct().Count();
validRoomConfig &= teams > 1;
}

return validRoomConfig;
return Runner.ActivePlayers.Select(p => p.GetPlayerData(Runner)).Where(pd => !pd.IsManualSpectator).Count() >= 1;
}

public void Kick(PlayerData target) {
Expand Down
30 changes: 20 additions & 10 deletions Assets/Scripts/UI/Menu/PlayerListHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public class PlayerListHandler : MonoBehaviour {
private NetworkRunner Runner => NetworkHandler.Instance.runner;

public void OnEnable() {
if (!NetworkHandler.Instance.runner)
if (!NetworkHandler.Instance || !Runner) {
return;
}

if (NetworkHandler.Instance.runner.SessionInfo.IsValid)
if (NetworkHandler.Instance.runner.SessionInfo.IsValid) {
PopulatePlayerEntries(true);
}

NetworkHandler.OnPlayerJoined += OnPlayerJoined;
NetworkHandler.OnPlayerLeft += OnPlayerLeft;
Expand All @@ -39,8 +41,9 @@ public void PopulatePlayerEntries(bool addSelf) {
RemoveAllPlayerEntries();
try {
foreach (PlayerRef player in Runner.ActivePlayers) {
if (addSelf || Runner.LocalPlayer != player)
if (addSelf || Runner.LocalPlayer != player) {
AddPlayerEntry(player);
}
}
} catch {

Expand All @@ -49,8 +52,9 @@ public void PopulatePlayerEntries(bool addSelf) {

public void AddPlayerEntry(PlayerRef player) {
PlayerData data = player.GetPlayerData(Runner);
if (!data || !template)
if (!data || !template) {
return;
}

if (!playerListEntries.ContainsKey(player)) {
GameObject go = Instantiate(template, contentPane.transform);
Expand All @@ -71,20 +75,23 @@ public void RemoveAllPlayerEntries() {
}

public void RemovePlayerEntry(PlayerRef player) {
if (!playerListEntries.ContainsKey(player))
if (!playerListEntries.ContainsKey(player)) {
return;
}

Destroy(playerListEntries[player].gameObject);
playerListEntries.Remove(player);
UpdateAllPlayerEntries();
}

public void UpdateAllPlayerEntries() {
foreach (PlayerRef player in Runner.ActivePlayers)
foreach (PlayerRef player in Runner.ActivePlayers) {
UpdatePlayerEntry(player, false);
}

if (MainMenuManager.Instance)
if (MainMenuManager.Instance) {
MainMenuManager.Instance.chat.UpdatePlayerColors();
}
}

public void UpdatePlayerEntry(PlayerRef player, bool updateChat = true) {
Expand All @@ -96,23 +103,26 @@ public void UpdatePlayerEntry(PlayerRef player, bool updateChat = true) {
playerListEntries[player].UpdateText();
ReorderEntries();

if (updateChat && MainMenuManager.Instance)
if (updateChat && MainMenuManager.Instance) {
MainMenuManager.Instance.chat.UpdatePlayerColors();
}
}

public void ReorderEntries() {
foreach (PlayerRef player in Runner.ActivePlayers.OrderByDescending(pr => pr.GetPlayerData(NetworkHandler.Runner).JoinTick)) {

if (!playerListEntries.ContainsKey(player))
if (!playerListEntries.ContainsKey(player)) {
continue;
}

playerListEntries[player].transform.SetAsFirstSibling();
}
}

public PlayerListEntry GetPlayerListEntry(PlayerRef player) {
if (playerListEntries.ContainsKey(player))
if (playerListEntries.ContainsKey(player)) {
return playerListEntries[player];
}

return null;
}
Expand Down

0 comments on commit f425f2e

Please sign in to comment.