Rust
This commit is contained in:
@@ -80,6 +80,9 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
private Timer _doubleExpTimer;
|
||||
|
||||
private Timer _rustTimer;
|
||||
private Timer _rustDurationTimer;
|
||||
|
||||
[Signal] private delegate void OnLoadLevelRequestEventHandler();
|
||||
|
||||
public event Action<string> InventoryEventNotification;
|
||||
@@ -191,6 +194,19 @@ public partial class Game : Node3D, IGame
|
||||
_doubleExpTimer.Timeout += EndDoubleExpTimer;
|
||||
AddChild(_doubleExpTimer);
|
||||
|
||||
_player.StatusEffectComponent.Rust.Changed += RustStatusChanged;
|
||||
|
||||
_rustTimer = new Timer();
|
||||
_rustTimer.WaitTime = 2f;
|
||||
_rustTimer.Timeout += RustTimeout;
|
||||
|
||||
_rustDurationTimer = new Timer();
|
||||
_rustDurationTimer.WaitTime = _player.StatusEffectComponent.RustDuration;
|
||||
_rustDurationTimer.Timeout += RustWoreOff;
|
||||
|
||||
AddChild(_rustTimer);
|
||||
AddChild(_rustDurationTimer);
|
||||
|
||||
GameRepo.IsPaused.Sync += IsPaused_Sync;
|
||||
InGameUI.PlayerInfoUI.Activate();
|
||||
InGameUI.Show();
|
||||
@@ -414,16 +430,16 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
|
||||
var restorative = restorativeScene.Instantiate<Restorative>();
|
||||
restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
|
||||
AddChild(restorative);
|
||||
restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
|
||||
}
|
||||
|
||||
private void DropItem(Vector3 vector)
|
||||
{
|
||||
var randomItem = ItemDatabase.Instance.PickItem<IBaseInventoryItem>() as Node3D;
|
||||
var duplicated = randomItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
|
||||
AddChild(duplicated);
|
||||
duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
|
||||
}
|
||||
|
||||
private void UseTeleportPrompt_CloseTeleportPrompt()
|
||||
@@ -576,6 +592,12 @@ public partial class Game : Node3D, IGame
|
||||
SfxDatabase.Instance.Play(SoundEffect.HealVT);
|
||||
InventoryEventNotification.Invoke($"Restored {consumableItem.HealVTAmount} VT.");
|
||||
}
|
||||
|
||||
if (consumableItem.Stats.HealsStatusAilments)
|
||||
{
|
||||
_player.StatusEffectComponent.Reset();
|
||||
InventoryEventNotification.Invoke($"All status afflictments have faded.");
|
||||
}
|
||||
}
|
||||
|
||||
private void EnactEffectItemEffects(EffectItem effectItem)
|
||||
@@ -809,6 +831,29 @@ public partial class Game : Node3D, IGame
|
||||
_player.Activate();
|
||||
}
|
||||
|
||||
private void RustStatusChanged(bool rustStatus)
|
||||
{
|
||||
if (rustStatus)
|
||||
{
|
||||
_rustTimer.Start();
|
||||
_rustDurationTimer.Start();
|
||||
GameRepo.AnnounceMessageOnMainScreen("Afflicted with Rust.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_rustTimer.Stop();
|
||||
GameRepo.AnnounceMessageOnMainScreen("Rust affliction has faded.");
|
||||
}
|
||||
}
|
||||
|
||||
private void RustTimeout()
|
||||
{
|
||||
_player.HealthComponent.Damage(3);
|
||||
}
|
||||
|
||||
private void RustWoreOff() => _player.StatusEffectComponent.Rust.OnNext(false);
|
||||
|
||||
|
||||
public void NotifyInventory(string message) => InventoryEventNotification?.Invoke(message);
|
||||
|
||||
private void OnQuit() => GameExitRequested?.Invoke();
|
||||
|
||||
Reference in New Issue
Block a user