Skip to content

Commit

Permalink
#6: Basic inventory system with network sync, but still cannot gurant…
Browse files Browse the repository at this point in the history
…ee inventory always sync (include items + ammos). And will cause initial slowness in sync
  • Loading branch information
Danil Ko committed Mar 7, 2021
1 parent 763678b commit 2e575b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ai/TeamMapAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,26 @@ public bool ChargeAmount(int chargeAmount)
{
_currentUnitUsageAmount = _currentUnitUsageAmount - chargeAmount;
EmitSignal(nameof(TeamUnitUsageAmountChangeSignal), _currentUnitUsageAmount);

if (GetTree().NetworkPeer != null && GetTree().IsNetworkServer())
{
Rpc(nameof(_clientSetAmount), _currentUnitUsageAmount);
}

return true;
}
}

[Remote]
private void _clientSetAmount(int amount)
{
if (!GetTree().IsNetworkServer())
{
_currentUnitUsageAmount = amount;
EmitSignal(nameof(TeamUnitUsageAmountChangeSignal), _currentUnitUsageAmount);
}
}

public bool isUnitUsageAmountAllowed()
{
if (_currentUnitUsageAmount < _unitCost || _currentUnitUsageAmount < 0)
Expand Down
1 change: 1 addition & 0 deletions inventory/InventoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private void _createPickUp(ItemResource itemResource, Vector2 itemPosition)
pickup.GlobalPosition = itemPosition;
}

[Remote]
private void _clientCreatePickUp(String info)
{
if (!GetTree().IsNetworkServer())
Expand Down
Binary file removed mono_crash.mem.21892.1.blob
Binary file not shown.
2 changes: 1 addition & 1 deletion ui/TitleScreen.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ margin_left = 168.411
margin_top = 111.168
margin_right = 242.411
margin_bottom = 135.168
value = 10.0
value = 5.0
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down

0 comments on commit 2e575b3

Please sign in to comment.