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

Loot dropping upon death #529

Merged
merged 6 commits into from
Jul 21, 2020

Conversation

IsaacLic
Copy link
Contributor

@IsaacLic IsaacLic commented Jul 10, 2020

Description

This PR adds a system for creating Loot objects when an entity with a DropsLoot component dies. Loot is the DS object that is created when certain SolObjects (e.g. ships) are destroyed. The logic was pulled from Asteroid, although SolShip uses a similar structure.

This is built upon PRs #519 and #522. It makes use of the DestroyEvent from 519, as well as Position and Velocity from 522.

Testing

First, copy/paste the following three fields to SolApplication:

private boolean madeLootEntity = false;
    private int counter = 0;
    EntityRef entity;

Next, add the following code after line 231 (inside the if statement that confims that solGame isn't null):

            if (!madeLootEntity) {

            entity = entitySystemManager.getEntityManager().createEntity(new DropsLootOnDeath(), new Position(), new Velocity(), new Size());

            Position position = entity.getComponent(Position.class).get();
            position.position = solGame.getHero().getPosition().cpy();
            position.position.x += 1;
            position.position.y += 3;
            entity.setComponent(position);

            Size size = new Size();
            size.size = 20;
            entity.setComponent(size);

            madeLootEntity = true;
        }
        counter++;
        if (counter == 500) {
            entitySystemManager.sendEvent(new DestroyEvent(), entity);
        }

That code does a few things:

  • Creates an entity with the requisite components to drop loot upon dying
  • Moves the entity one unit down and three to the right, so that the loot won't be absorbed by the station
  • After several seconds, the EntitySystemManager will send a DestroyEvent to the entity, causing loot to appear on screen

@skaldarnar
Copy link
Member

I read "loot dropping" I post links:

These are basically two resources I found while briefly looking into loot tables for Terasology. Maybe they are helpful, maybe not - I honestly didn't look at the PR 🙈

Copy link
Member

@NicholasBatesNZ NicholasBatesNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this, seems to work 👍

@NicholasBatesNZ NicholasBatesNZ merged commit bf6d24f into MovingBlocks:develop Jul 21, 2020
@NicholasBatesNZ NicholasBatesNZ added this to the v2.1.0 milestone Jul 21, 2020
@IsaacLic IsaacLic deleted the lootStructure branch October 11, 2021 16:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants