Skip to content

Commit

Permalink
Make changes based on latest utils update
Browse files Browse the repository at this point in the history
  • Loading branch information
valkyrienyanko committed Apr 17, 2023
1 parent 242d388 commit dbfc4d6
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 287 deletions.
27 changes: 1 addition & 26 deletions Scenes/Levels/Level A1.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=58 format=3]
[gd_scene load_steps=56 format=3 uid="uid://b78omwmk68h1k"]

[ext_resource type="Script" path="res://Scripts/Entities/Enemy/Spawner.cs" id="1"]
[ext_resource type="PackedScene" uid="uid://bfeednkyjlv1t" path="res://Scenes/Prefabs/Player.tscn" id="2"]
Expand Down Expand Up @@ -26,7 +26,6 @@
[ext_resource type="Texture2D" uid="uid://da35q1i260s8q" path="res://Sprites/Level/Parallax Backgrounds/Grass/2_trees.png" id="15"]
[ext_resource type="Texture2D" uid="uid://vg4rwpcnjqwo" path="res://Sprites/Level/Parallax Backgrounds/Grass/1_trees.png" id="16"]
[ext_resource type="Script" path="res://Scripts/Entities/Level/Trigger.cs" id="21"]
[ext_resource type="Shader" path="res://GodotUtils/Shaders/2D/GodRays.gdshader" id="27_eeclp"]

[sub_resource type="Shader" id="Shader_2y4hf"]
code = "// original wind shader from https://github.com/Maujoe/godot-simple-wind-shader-2d/tree/master/assets/maujoe.simple_wind_shader_2d
Expand Down Expand Up @@ -1263,22 +1262,6 @@ size = Vector2(68, 73.5)
[sub_resource type="RectangleShape2D" id="5"]
size = Vector2(10468, 98)

[sub_resource type="ShaderMaterial" id="ShaderMaterial_d6hg7"]
shader = ExtResource("27_eeclp")
shader_parameter/angle = 0.219
shader_parameter/position = 0.187
shader_parameter/spread = 0.537
shader_parameter/cutoff = -0.046
shader_parameter/falloff = 0.365
shader_parameter/edge_fade = 0.15
shader_parameter/speed = 5.0
shader_parameter/ray1_density = 12.0
shader_parameter/ray2_density = 40.0
shader_parameter/ray2_intensity = 0.3
shader_parameter/color = Color(0.698039, 1, 0.956863, 0.45098)
shader_parameter/hdr = false
shader_parameter/seed = 5.0

[node name="Level A1" type="Node2D"]
script = ExtResource("3")

Expand Down Expand Up @@ -1839,13 +1822,5 @@ limit_bottom = 651
editor_draw_limits = true
script = ExtResource("14_1qxvw")

[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_d6hg7")
offset_left = 2197.0
offset_top = -629.0
offset_right = 2652.0
offset_bottom = -129.0
scale = Vector2(1.62479, 1.62479)

[connection signal="area_entered" from="Level Finish" to="Level Finish" method="_on_level_finish_area_entered"]
[connection signal="area_entered" from="Bottom" to="Bottom" method="_on_Bottom_area_entered"]
4 changes: 2 additions & 2 deletions Scripts/Entities/Enemy/Bird.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public override void Init()
{
TimerChangeDirection = new GTimer(this, 1000);
TimerFlap = new GTimer(this, OnTimerFlap, 1000) { Loop = true };
TimerFlap.Start();
TimerFlap.StartMs();
AnimatedSprite.Play("fly");
MoveDir = Vector2.Left;
}
Expand All @@ -22,7 +22,7 @@ public override void UpdatePhysics()
{
if (IsOnWall() && !TimerChangeDirection.IsActive())
{
TimerChangeDirection.Start();
TimerChangeDirection.StartMs();
MoveDir = new Vector2(-MoveDir.X, MoveDir.Y);
AnimatedSprite.FlipH = MoveDir.X == 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public override void HandleTransitions()
{
Entity.StartedPreJump = true;
Entity.AnimatedSprite.Play("pre_jump_start");
Entity.PreJumpTimer.Start();
Entity.PreJumpTimer.StartMs();
SwitchState(EntityAnimationType.PreJumpStart);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Entities/Enemy/Slime/Slime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void UpdatePhysics()
Label.Text = "" + CurrentAnimation; // this shouldnt be set every frame
}

public override void TouchedGround() => IdleTimer.Start();
public override void TouchedGround() => IdleTimer.StartMs();

private void OnPreJumpTimer()
{
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Entities/Enemy/Spawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public override void _Ready()
Timer = new GTimer(this, OnTimer, RespawnInterval) { Loop = true };
}

public void Activate() => Timer.Start();
public void Activate() => Timer.StartMs();
public void Deactivate() => Timer.Stop();
public void Destroy() => QueueFree();

Expand Down
4 changes: 2 additions & 2 deletions Scripts/Entities/Enemy/Trapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void _on_detection_area_entered(Area2D area)
Revealed = true;
AnimatedSprite.Play("reveal");
AreaDamage.SetDeferred("monitoring", true);
TimerReveal.Start();
TimerReveal.StartMs();
}
}

Expand All @@ -52,6 +52,6 @@ private void OnTimerReveal()
Revealed = false;
AreaDamage.SetDeferred("monitoring", false);
AnimatedSprite.Play("hide");
TimerRevealCooldown.Start();
TimerRevealCooldown.StartMs();
}
}
2 changes: 1 addition & 1 deletion Scripts/Entities/Level/APlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Init()

public void TemporarilyDisablePlatform()
{
Timer.Start();
Timer.StartMs();
Collision.Disabled = true;
}

Expand Down
19 changes: 0 additions & 19 deletions Scripts/Entities/Level/LevelScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@ public override void _Ready()

CreateLevelBounds();

if (Net.IsMultiplayer())
{
var players = GameManager.UIPlayerList.Players;

foreach (var player in players)
{
// WARN: Should not access Client.PeerId directly from another thread
// Should not effect anything because this is only executed players.Count times once
if (player.Key == Net.Client.PeerId)
continue;

var otherPlayer = Prefabs.OtherPlayer.Instantiate<OtherPlayer>();

OtherPlayers.Add(player.Key, otherPlayer);

AddChild(otherPlayer);
}
}

Events.Generic.AddListener<byte>(EventGeneric.OnGameClientLeft, (id) =>
{
OtherPlayers[id].QueueFree();
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Entities/Level/MovingPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public partial class MovingPlatform : APlatform
[Export] public Tween.TransitionType TransitionType { get; set; } = Tween.TransitionType.Cubic;
[Export] public Tween.EaseType EaseType { get; set; } = Tween.EaseType.InOut;

public override async void _Ready()
public override void _Ready()
{
Init();

var tween = new GTween(this);
/*var tween = new GTween(this);
await tween.AnimatePlatform
(
Expand All @@ -22,6 +22,6 @@ await tween.AnimatePlatform
StartDelay,
TransitionType,
EaseType
);
);*/
}
}
6 changes: 3 additions & 3 deletions Scripts/Entities/Level/PlatformDisappear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public override void _PhysicsProcess(double d)
private void OnTimerFlash1Up()
{
Phase2 = true;
TimerFlash2.Start();
TimerFlash2.StartMs();
}

private void OnTimerFlash2Up()
{
Visible = false;
Collision.Disabled = true;
TimerReappear.Start();
TimerReappear.StartMs();
}

private void OnTimerReappear()
Expand All @@ -71,7 +71,7 @@ private void _on_Area2D_area_entered(Area2D area)
if (AreaIsPlayer(area))
{
PlayerOnPlatform = true;
TimerFlash1.Start();
TimerFlash1.StartMs();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Entities/MovingEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public virtual void RemoveHealth(int v)
HalfHearts = HalfHearts - Mathf.Min(HalfHearts, v); // do not take away more than what the entity does not have

// Player has taken damage so start the immunity timer
ImmunityTimer.Start();
ImmunityTimer.StartMs();

// If player has no health left, kill them
if (HalfHearts == 0)
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Entities/Player/Commands/PlayerCommandDash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public override void Start()
DashCount++;
DashReady = false;
CurrentlyDashing = true;
TimerDashDuration.Start();
TimerDashCooldown.Start();
TimerDashDuration.StartMs();
TimerDashCooldown.StartMs();
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions Scripts/Entities/Player/Commands/PlayerCommandDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,35 @@ public override void Start()
var dieStartPos = Entity.Position.Y;
var goUpDuration = 1.25f;

Entity.DieTween.Create();

// animate y position
Entity.DieTween.InterpolateProperty
Entity.DieTween.Animate
(
"position:y",
dieStartPos - 80,
goUpDuration,
0 // delay
goUpDuration
);

Entity.DieTween.InterpolateProperty
Entity.DieTween.Animate
(
"position:y",
dieStartPos + 400,
1.5f,
goUpDuration, // delay
true
)
.From(dieStartPos - 80);

// animate rotation
Entity.DieTween.InterpolateProperty
Entity.DieTween.Animate
(
"rotation",
Mathf.Pi,
1.5f,
goUpDuration, // delay
true
);

Entity.DieTween.Start();
Entity.DieTween.Callback(nameof(Entity.OnDieTweenCompleted));
//Entity.DieTween.Start();
Entity.DieTween.Callback(Entity.OnDieTweenCompleted);
}
}
20 changes: 2 additions & 18 deletions Scripts/Entities/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public override void Init()
if (GameManager.PlayerManager.ActiveCheckpoint)
Position = GameManager.PlayerManager.RespawnPosition;

TimerNetSend = new GTimer(this, NetUpdate, NetIntervals.HEARTBEAT) { Loop = true };

if (Net.IsMultiplayer())
TimerNetSend.Start();

DieTween = new GTween(this);

// dont go under platform at the end of a dash for X ms
Expand Down Expand Up @@ -165,15 +160,15 @@ public override void UpdatePhysicsAir()
/// <summary>
/// Called when a Dash Command finishes as Dash
/// </summary>
public void OnDashDone(object _, EventArgs _2) => DontCheckPlatformAfterDashDuration.Start();
public void OnDashDone(object _, EventArgs _2) => DontCheckPlatformAfterDashDuration.StartMs();

public void OnWallJump(object _, EventArgs _2)
{
Events.Player.Notify(EventPlayer.OnJump);

// Lock movement
PreventMovement = true;
PreventMovementTimer.Start();
PreventMovementTimer.StartMs();
}

public void PreventMovementFinished()
Expand All @@ -189,17 +184,6 @@ private float MoveDeadZone(float horzVelocity, int deadzone)
return horzVelocity;
}

private void NetUpdate()
{
if (Position != PrevNetPos)
Net.Client.Send(ClientPacketOpcode.PlayerPosition, new CPacketPlayerPosition
{
Position = Position
});

PrevNetPos = Position;
}

private async void UpdateUnderPlatform(MovementInput input)
{
var collision = RaycastsGround[0].GetCollider();
Expand Down
25 changes: 1 addition & 24 deletions Scripts/Linker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public partial class Linker : Node
[Export] public bool LoadTestLevel { get; set; }
[Export] public bool InstantlyLoadLevel { get; set; }

// net
[Export] public Godot.Collections.Array<ServerPacketOpcode> IgnoreOpcodesFromServer { get; set; }
[Export] public Godot.Collections.Array<ClientPacketOpcode> IgnoreOpcodesFromClient { get; set; }

[Export] public NodePath NodePathTransition;

Expand Down Expand Up @@ -60,31 +57,12 @@ public override async void _Ready()
LevelManager.CurrentLevel = "Test Level";
await LevelManager.LoadLevel(InstantlyLoadLevel);
}

if (AutoHostJoin)
{
if (GOS.IsExportedRelease())
{
// running in an exported build
GOS.SetWindowTitle("OtherClient");
GameManager.UIMapMenu.OnlineUsername = "OtherClient";
GameManager.UIMapMenu.Join();
}
else
{
// running in the editor
GOS.SetWindowTitle("ImHost");
GameManager.UIMapMenu.OnlineUsername = "ImHost";
await GameManager.UIMapMenu.HostGame();
}
}
}
}

public override async void _Process(double delta)
public override void _Process(double delta)
{
Logger.Update();
await GameManager.Update();
}

public override void _Input(InputEvent @event)
Expand Down Expand Up @@ -125,7 +103,6 @@ public async Task Cleanup()

//ModLoader.SaveEnabled();
//Options.SaveOptions();
await Net.Cleanup();
Tokens.Cleanup();
GetTree().Quit();
}
Expand Down
9 changes: 0 additions & 9 deletions Scripts/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
global using System.Text.RegularExpressions;
global using System.Threading.Tasks;
global using System.Linq;
global using Sankari.Netcode;
global using Sankari.Netcode.Client;
global using Sankari.Netcode.Server;

namespace Sankari;

Expand Down Expand Up @@ -47,7 +44,6 @@ public GameManager(Linker linker)
UIPlayerList = linker.UIPlayerList;
LevelManager.Init(linker.GetNode<Node>("Level"));
Popups.Init(linker);
Net.Init();
PlayerManager = new PlayerManager(2, 6); //this numbers are for testing purposes!
LevelUI.SetLabelLives(2); //required for the arbitrary lives count
PlayerManager.SetLevelCoins();
Expand All @@ -56,11 +52,6 @@ public GameManager(Linker linker)
LevelUI.Hide();
}

public static async Task Update()
{
await Net.Update();
}

public static void ShowMenu() => Menu.Show();

public static void LoadMap()
Expand Down
Loading

0 comments on commit dbfc4d6

Please sign in to comment.