Skip to content

Commit

Permalink
nightly v1.8.0.0 (1/14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipodtouch0218 committed Jan 15, 2024
1 parent 8488882 commit e2848fc
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 45 deletions.
6 changes: 3 additions & 3 deletions Assets/Photon/Fusion/Resources/NetworkProjectConfig.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"PeerMode": 0,
"LagCompensation": {
"Enabled": true,
"HitboxBufferLengthInMs": 200,
"HitboxDefaultCapacity": 512,
"HitboxBufferLengthInMs": 400,
"HitboxDefaultCapacity": 256,
"CachedStaticCollidersSize": 64
},
"EnqueueIncompleteSynchronousSpawns": true,
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"Heap": {
"PageShift": 14,
"PageCount": 128,
"PageCount": 256,
"GlobalsSize": 0
},
"AssembliesToWeave": [
Expand Down
3 changes: 2 additions & 1 deletion Assets/Resources/Prefabs/Static/GlobalController.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ MonoBehaviour:
m_fontSizeMin: 0
m_fontSizeMax: 28
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
Expand Down Expand Up @@ -44733,6 +44733,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
playerList: {fileID: 1394624252273630683}
statusText: {fileID: 3626728888328854889}
--- !u!1 &8962770090848600293
GameObject:
m_ObjectHideFlags: 0
Expand Down
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 = "1/14/2024 4:27:53 AM";}
public static class BuildInfo{public static string BUILD_TIME = "1/15/2024 1:46:53 AM";}
11 changes: 8 additions & 3 deletions Assets/Scripts/Camera/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ public override void Render() {
(fromVector, toVector) = currentPositionReader.Read(from, to);
}

Vector2 dest;
Utils.UnwrapLocations(fromVector, toVector, out var fromVectorRelative, out var toVectorRelative);
Vector2 lerped = Vector2.Lerp(fromVectorRelative, toVectorRelative, alpha);
Utils.WrapWorldLocation(ref lerped);
if (Vector2.Distance(fromVectorRelative, toVectorRelative) > 1f) {
dest = toVectorRelative;
} else {
dest = Vector2.Lerp(fromVectorRelative, toVectorRelative, alpha);
}
Utils.WrapWorldLocation(ref dest);

newPosition = lerped;
newPosition = dest;
newPosition.z = CurrentPosition.z;
} else {
newPosition = CurrentPosition;
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/DiscordController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using NSMB.Translation;

public class DiscordController : MonoBehaviour {
#pragma warning disable IDE0079
#pragma warning disable CS0162

//---Static Variables
Expand Down Expand Up @@ -164,4 +165,5 @@ public void AskToJoin(ref User user) {
//});
}
#pragma warning restore CS0162
#pragma warning restore IDE0079
}
8 changes: 5 additions & 3 deletions Assets/Scripts/Entity/Enemy/Koopa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ public void BlueBecomeItem(PlayerController player) {
BlueShellCollector = player;
powerupCollect.OnPowerupCollect(player, Enums.GetPowerupScriptable(Enums.PowerupState.BlueShell));
} else {
Runner.Spawn(PrefabList.Instance.Powerup_BlueShell, transform.position + Vector3.down * 0.15f, onBeforeSpawned: (runner, obj) => {
obj.GetComponent<Powerup>().OnBeforeSpawned(0.1f);
});
if (Runner.IsServer) {
Runner.Spawn(PrefabList.Instance.Powerup_BlueShell, transform.position + Vector3.down * 0.15f, onBeforeSpawned: (runner, obj) => {
obj.GetComponent<Powerup>().OnBeforeSpawned(0.1f);
});
}
}
DespawnEntity();
}
Expand Down
25 changes: 18 additions & 7 deletions Assets/Scripts/Entity/EntityMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Fusion;
using NSMB.Tiles;
using NSMB.Utils;
using NSMB.Entities.Player;

[SimulationBehaviour]
public class EntityMover : NetworkBehaviour, IBeforeTick, IAfterTick, IAfterAllTicks, IRemotePrefabCreated {
Expand Down Expand Up @@ -215,6 +216,8 @@ private Vector2 CollideAndSlide(Vector2 raycastPos, Vector2 raycastVel, bool gra
}
}

Vector2 alignedDirection;

bool isTilemap = hit.collider is CompositeCollider2D;
if (Mathf.Abs(angle) < maxFloorAngle) {
// Floor
Expand All @@ -232,6 +235,8 @@ private Vector2 CollideAndSlide(Vector2 raycastPos, Vector2 raycastVel, bool gra
AddTileContacts(lowerBound, upperBound, y, InteractionDirection.Down);
}

alignedDirection = Vector2.up;

} else if (Mathf.Abs(angle) > 180 - maxFloorAngle) {
// Roof
Data.HitRoof = true;
Expand All @@ -246,16 +251,20 @@ private Vector2 CollideAndSlide(Vector2 raycastPos, Vector2 raycastVel, bool gra
AddTileContacts(lowerBound, upperBound, y, InteractionDirection.Up);
}

alignedDirection = Vector2.down;

} else {
InteractionDirection interactionDirection;
if (angle > 0) {
// Left
Data.HitLeft = true;
interactionDirection = InteractionDirection.Left;
alignedDirection = Vector2.left;
} else {
// Right
Data.HitRight = true;
interactionDirection = InteractionDirection.Right;
alignedDirection = Vector2.right;
}

if (hit.collider.GetComponentInParent<NetworkObject>() is NetworkObject no) {
Expand All @@ -269,7 +278,11 @@ private Vector2 CollideAndSlide(Vector2 raycastPos, Vector2 raycastVel, bool gra
}
}

Vector2 positionToSurfacePoint = (direction * hit.distance) + (hit.normal * Skin);
Vector2 positionToSurfacePoint = (direction * hit.distance) + (alignedDirection * Skin);

if (TryGetComponent(out PlayerController _)) {
Debug.DrawRay(positionToSurfacePoint, hit.normal, Color.red);
}

// Started inside an object
if (hit.distance <= 0) {
Expand Down Expand Up @@ -305,12 +318,10 @@ private Vector2 CollideAndSlide(Vector2 raycastPos, Vector2 raycastVel, bool gra
offset.y = 0;
}

if (offset.sqrMagnitude >= Skin) {
Position += offset;
raycastPos += offset;
direction = ((Vector2) Vector3.ProjectOnPlane(direction, hit.normal)).normalized;
positionToSurfacePoint = direction * hit.distance;
}
Position += offset;
raycastPos += offset;
direction = ((Vector2) Vector3.ProjectOnPlane(direction, hit.normal)).normalized;
positionToSurfacePoint = direction * hit.distance;
}

if (Data.OnGround && gravityPass) {
Expand Down
21 changes: 12 additions & 9 deletions Assets/Scripts/Entity/Player/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public override void FixedUpdateNetwork() {
}

CheckForPowerupActions(input, PreviousInputs);
HandleMovement(heldButtons, pressedButtons);
HandleMovement(heldButtons, pressedButtons, input);
}

PreviousTickIsOnGround = IsOnGround;
Expand Down Expand Up @@ -653,7 +653,7 @@ private void CheckForEntityCollision() {
Quaternion.identity,
Object.InputAuthority,
LagCompensatedBuffer,
options: HitOptions.IgnoreInputAuthority | HitOptions.IncludeBox2D,
options: HitOptions.IgnoreInputAuthority | HitOptions.IncludeBox2D | HitOptions.SubtickAccuracy,
clearHits: false);
}

Expand Down Expand Up @@ -974,6 +974,7 @@ public void OnInput(NetworkRunner runner, NetworkInput input) {
}



Vector2 joystick = ControlSystem.controls.Player.Movement.ReadValue<Vector2>();
bool jump = ControlSystem.controls.Player.Jump.ReadValue<float>() >= 0.5f;
bool powerup = ControlSystem.controls.Player.PowerupAction.ReadValue<float>() >= 0.5f;
Expand All @@ -994,7 +995,7 @@ public void OnInput(NetworkRunner runner, NetworkInput input) {
newInput.buttons.Set(PlayerControls.Sprint, sprint ^ Settings.Instance.controlsAutoSprint);
newInput.buttons.Set(PlayerControls.PowerupAction, powerup);

// Powerup action counter avoids dropped inputs
// Powerup action counter to avoid dropped inputs
NetworkButtons pressed = newInput.buttons.GetPressed(onInputPreviousInputs.buttons);
if (pressed.IsSet(PlayerControls.PowerupAction)
|| (pressed.IsSet(PlayerControls.Sprint) && Settings.Instance.controlsFireballSprint && (State == Enums.PowerupState.FireFlower || State == Enums.PowerupState.IceFlower))
Expand All @@ -1003,6 +1004,11 @@ public void OnInput(NetworkRunner runner, NetworkInput input) {
newInput.powerupActionCounter++;
}

// Jump tick to avoid dropped inputs
if (pressed.IsSet(PlayerControls.Jump)) {
newInput.lastJumpPressTick = Runner.Tick;
}

input.Set(newInput);
onInputPreviousInputs = newInput;
}
Expand Down Expand Up @@ -2552,7 +2558,7 @@ public void HandleBlockSnapping() {
body.Position = newPosition;
}

private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedButtons) {
private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedButtons, PlayerNetworkInput input) {
float delta = Runner.DeltaTime;
IsFunctionallyRunning = heldButtons.IsSet(PlayerControls.Sprint) || State == Enums.PowerupState.MegaMushroom || IsPropellerFlying;

Expand Down Expand Up @@ -2645,7 +2651,7 @@ private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedBu
IsInShell = false;
body.Velocity -= body.Velocity * (delta * 2f);

float timeStunned = (Runner.Tick - KnockbackTick) * Runner.DeltaTime;
float timeStunned = (Runner.Tick - KnockbackTick) * delta;

if ((IsSwimming && timeStunned > 1.5f) || (!IsSwimming && IsOnGround && Mathf.Abs(body.Velocity.x) < 0.35f && timeStunned > 0.5f)) {
ResetKnockback();
Expand All @@ -2663,10 +2669,7 @@ private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedBu
bool powerupAction = heldButtons.IsSet(PlayerControls.PowerupAction);

// Jump Buffering
if (pressedButtons.IsSet(PlayerControls.Jump) && !IsOnGround) {
// 0.15s buffer time
JumpBufferTime = Runner.SimulationTime + 0.15f;
}
JumpBufferTime = (input.lastJumpPressTick * delta) + 0.15f;

bool jumpPressed = pressedButtons.IsSet(PlayerControls.Jump);
bool canJump = jumpPressed || (Runner.SimulationTime <= JumpBufferTime && (IsOnGround || WallSliding));
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/Entity/World Elements/FrozenCube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public override void FixedUpdateNetwork() {
return;
}

if (GameManager.Instance.GameEnded) {
body.Velocity = Vector2.zero;
return;
}

base.FixedUpdateNetwork();

if (!Object || IsDead) {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ private IEnumerator CallLoadingComplete(float seconds) {
}

private IEnumerator CallAllPlayersLoaded() {
yield return new WaitForSeconds(1f);
yield return new WaitForSeconds(2f);
if (!calledAllPlayersLoaded) {
OnAllPlayersLoaded?.Invoke();
}
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Networking/Fusion/PlayerNetworkInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public struct PlayerNetworkInput : INetworkInput {

public NetworkButtons buttons;
public int lastJumpPressTick;
public byte powerupActionCounter;

}
Expand Down
13 changes: 9 additions & 4 deletions Assets/Scripts/UI/Menu/Loading/LoadingCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public void OnDestroy() {
}

public void Initialize() {
if (initialized)
if (initialized) {
return;
}

initialized = true;

Expand All @@ -46,8 +47,10 @@ public void Initialize() {
audioSource.volume = 0;
audioSource.Play();

if (fadeCoroutine != null)
if (fadeCoroutine != null) {
StopCoroutine(fadeCoroutine);
}

fadeCoroutine = StartCoroutine(FadeVolume(0.1f, true));

//audioListener.enabled = true;
Expand All @@ -60,8 +63,9 @@ public void EndLoading() {

initialized = false;

if (fadeCoroutine != null)
if (fadeCoroutine != null) {
StopCoroutine(fadeCoroutine);
}

fadeCoroutine = StartCoroutine(FadeVolume(0.1f, false));
//audioListener.enabled = false;
Expand All @@ -88,8 +92,9 @@ private IEnumerator FadeVolume(float fadeTime, bool fadeIn) {
yield return null;
}

if (!fadeIn)
if (!fadeIn) {
audioSource.Stop();
}
}
}
}
28 changes: 16 additions & 12 deletions Assets/Scripts/UI/Menu/Loading/LoadingWaitingOn.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using TMPro;

Expand All @@ -14,15 +14,18 @@ public class LoadingWaitingOn : MonoBehaviour {

//---Serialized Variables
[SerializeField] private TMP_Text playerList;
[SerializeField] private TMP_Text statusText;

//---Private Variables
private TMP_Text text;
private GameObject playerListParent;

public void OnValidate() {
this.SetIfNull(ref statusText);
}

public void Awake() {
text = GetComponent<TMP_Text>();
playerListParent = playerList.transform.parent.gameObject;
text.text = GlobalController.Instance.translationManager.GetTranslation("ui.loading.loading");
statusText.text = GlobalController.Instance.translationManager.GetTranslation("ui.loading.loading");
}

public void OnEnable() {
Expand All @@ -36,26 +39,28 @@ public void Update() {

// Loading (as spectator)
if (!ourData || ourData.IsCurrentlySpectating) {
text.text = tm.GetTranslation("ui.loading.spectator");
statusText.text = tm.GetTranslation("ui.loading.spectator");
playerListParent.SetActive(false);
return;
}

// Still loading
if (!GameManager.Instance || !GameManager.Instance.Object) {
text.text = tm.GetTranslation("ui.loading.loading");
statusText.text = tm.GetTranslation("ui.loading.loading");
playerListParent.SetActive(false);
return;
}

// Game starting
if (GameManager.Instance.gameObject.activeSelf && GameManager.Instance.GameStartTimer.IsRunning) {
text.text = tm.GetTranslation("ui.loading.starting");
statusText.text = tm.GetTranslation("ui.loading.starting");
playerListParent.SetActive(false);
return;
}

HashSet<string> waitingFor = new();
// Waiting for others
StringBuilder waitingOnPlayers = new();

NetworkRunner runner = GameManager.Instance.Runner;
foreach (PlayerRef player in runner.ActivePlayers) {
PlayerData data = player.GetPlayerData(runner);
Expand All @@ -64,14 +69,13 @@ public void Update() {
}

if (!data.IsLoaded) {
waitingFor.Add(data.GetNickname());
waitingOnPlayers.AppendLine(data.GetNickname());
}
}

// Waiting for others
text.text = tm.GetTranslation("ui.loading.waiting");
statusText.text = tm.GetTranslation("ui.loading.waiting");
playerListParent.SetActive(true);
playerList.text = waitingFor.Count == 0 ? "" : "\n- " + string.Join("\n- ", waitingFor);
playerList.text = waitingOnPlayers.ToString();
}
}
}
Loading

0 comments on commit e2848fc

Please sign in to comment.