Skip to content

Touch Components

Jonoym edited this page Sep 9, 2021 · 5 revisions

Touch Components

Entities need to interact once they are within proximity of each other. Currently the only way this occurs is once an attack between two entities occurs but does not cover triggers for events to occur or collection of items.

TouchAttackComponent class is a part of the base engine but has been changed to extend TouchComponent which is a base class for any Touch interactions.

How To Use

This component needs a subclass to extend it and provide the functionality for the collisions. The collisions that take place are reliant on the hitboxes of those entities and the onCollisionStart needs to be implemented. onCollisionStart will take in the entities that are in the collision and this method is where any changes due to collision will be called.

The onCollisionStart method will require some error checking before any functionality is carried out to ensure that the entities that are involved with the collision are correct.

Simplified UML Diagram

image

Sequence Diagram

The sequence diagram below shows the event when the player entity collides a Cutscene and Movement trigger entity. The main steps of this sequence are:

  1. The entities in the collision are verified to see if the collision is valid.
  2. If the entities are valid, movement and input from the player will pause and a text box will be displayed.
  3. While the player is moving, there will be repeated checks (loop) to determine if the player has reached the desired destinations.
  4. The inputcomponent will no longer be locked and will now accept input.

image

TouchComponent

This is an abstract class that has been made for the basis of all functionality regarding entity interaction.

The TouchComponent class contains the protected variables:

  • targetLayer: the group of entities the owner of the component can interact with
  • hitboxComponent: the component of the hitbox of the owner entity

The TouchComponent class contains these methods:

  • Constructor TouchComponent(short targetLayer): takes in a targetLayer, which is the group of entities that the owner of this entity can interact with.
  • create(): adds the event listener to the entity which will call onCollisionStart(), an abstract method that will be in the classes that extend TouchComponent as well as the hitbox of that entity.

TouchAttackComponent

This component will be added to any entity that can target and damage another entity. Along with the base requirements, the component will need the knockback force as well as the CombatStatsComponent to determine how much damage the collision will do to either player.

The onCollisionStart method will attempt to attack the target by altering the health of the entity within the collision, then it will apply the knockback on the entity.

TouchCutsceneComponent

This component will be used to trigger any cutscenes within the game once the player has interacted with the entity. The entity that triggers the cutscene could be both a visible entity in the game or an invisible hook once the player walks within a certain vicinity.

This component will access the dialogue component within the UI and set the dialogue to whatever message is to be displayed. Since the character will usually trigger this by walking, the player will stop moving or potentially by involuntarily moved once triggered since the dialogue boxes have higher priority input.

TouchMoveComponent

This component is used to move the player in any direction after triggering it until a certain position has been passed. This component can be used in addition to the TouchCutsceneComponent allowing for the text box to appear as well as control the character simultaneously.

Chaining of entity triggers containing TouchMoveComponent allow the game to control the player through a complicated set of movements. Skipping cutscenes has been considered but teleporting the player to the final position can cause issues with the stuttering of the camera.

Table of Contents

Home

Design Document

Design Document

Design Document

Game Engine

Getting Started

Entities and Components

Item Drops from Entities

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Map Generation

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally