Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle inventory on death #83

Merged
merged 4 commits into from Jun 9, 2019

Conversation

4 participants
@darshan3
Copy link
Member

commented Jun 1, 2019

Project Card:
Handle respawn on death

How to test:

  1. Host a Light and Shadow game
  2. Join the game using one more client instance
  3. Choose one team with each of the players
  4. Give "player one" items and blocks through cheat "give item"
  5. Collect opposition flag using 'player one'.
  6. Kill "player one" by repeatedly attacking it through "player two".
  7. Try to collect dropped items and flag using "player two".

Expected outcome:
The killed player should get respawned at its home base with full health restored. All the items held by them should get dropped at the same location except the magic staff. Trying to collect the dropped flag sends it directly to home base.

@iaronaraujo
Copy link
Contributor

left a comment

The code seems pretty good! I haven't tested it out in game but since e_a have tested it I think it is ok to approve this PR! I would ask you to add the javadoc, but since the classes are the same as the other PR, I think that you only need to change there

Prefab staffPrefab = assetManager.getAsset(LASUtils.MAGIC_STAFF_URI, Prefab.class).orElse(null);

Vector3f startPosition = new Vector3f(player.getComponent(LocationComponent.class).getLocalPosition());
Vector3f impulse = Vector3f.zero();

This comment has been minimized.

Copy link
@iaronaraujo

iaronaraujo Jun 1, 2019

Contributor

Just out of curiosity, what would happen if the impulse wasn't 0?

This comment has been minimized.

Copy link
@darshan3

darshan3 Jun 1, 2019

Author Member

Impulse 0 drops the items at the same place. If we increasing its value, items will be thrown in that direction.

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

which might be a nice effect later (to scatter them in a small radius around the player). Could even use the direction of killing impact … 🤔

@nihal111
Copy link
Member

left a comment

Looks good overall, few nits. Let's fix it soon and merge!

Show resolved Hide resolved ...sology/ligthandshadow/componentsystem/controllers/PlayerDeathSystem.java

Prefab staffPrefab = assetManager.getAsset(LASUtils.MAGIC_STAFF_URI, Prefab.class).orElse(null);

Vector3f startPosition = new Vector3f(player.getComponent(LocationComponent.class).getLocalPosition());

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 2, 2019

Member

Why do we call this the startPosition? If anything, it should be the endPosition 😆 or better, deathPosition.

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

deathPosition sounds about right …


Prefab staffPrefab = assetManager.getAsset(LASUtils.MAGIC_STAFF_URI, Prefab.class).orElse(null);

Vector3f startPosition = new Vector3f(player.getComponent(LocationComponent.class).getLocalPosition());

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

deathPosition sounds about right …

Prefab staffPrefab = assetManager.getAsset(LASUtils.MAGIC_STAFF_URI, Prefab.class).orElse(null);

Vector3f startPosition = new Vector3f(player.getComponent(LocationComponent.class).getLocalPosition());
Vector3f impulse = Vector3f.zero();

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

which might be a nice effect later (to scatter them in a small radius around the player). Could even use the direction of killing impact … 🤔

int count = inventoryManager.getStackSize(slot);
player.send(new DropItemRequest(slot, player, impulse, startPosition, count));
}
}

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

Could you please introduce a new method to keep the inventory handling in a concise spot. The beforeDestroy method should read as close to the following as possible (i.e., a high-level description of the semantics):

public void beforeDestroy(…) {
    event.consume();
    dropItemsFromInventory(player, …);
    healPlayer(player);
    respawnPlayerAtBase(player);
}

healPlayer and respawnPlayerAtBase are already single lines of code, but for inventory a new method will help.

@skaldarnar skaldarnar added this to In progress in GSOC 2019: Light & Shadows via automation Jun 4, 2019

@darshan3 darshan3 force-pushed the HandleInventoryOnDeath branch from 69cce4c to ba8d110 Jun 6, 2019

@nihal111 nihal111 merged commit 1da6656 into master Jun 9, 2019

@nihal111 nihal111 deleted the HandleInventoryOnDeath branch Jun 9, 2019

@darshan3 darshan3 moved this from In progress to Done in GSOC 2019: Light & Shadows Jun 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.