-
Notifications
You must be signed in to change notification settings - Fork 0
Landscape Objects
Details about the design process can be found on this page.
Landscape objects are Entities
that implement EnvironmentalComponent
. They may also implement CollisionEffectComponent
. They are generated in the ObstacleFactory, and placed on the map in the ForestGameArea file. They are removable by the player.
The Environmental Component
is the base component/class that holds the information releated to obstacles on the map and is used by ObstacleFactory
to create Environmental Obstacles. It consists only of getters to allow functions to get either the Obstacle as an enum, the ResourceType
and ResourceValue
. The ResourceType
is the type of resource this obstacle would return when destroyed while ResourceValue
returns the number of resources. E.g. Tree
would return WOOD
with the value 20
.
These values are stored via the use of ENUMS
allowing for easy change of values depending on future teams and saves extensive abstraction/inheristance by creating a individiual class for every resource type.
CollisionEffectComponent
s allow EnvironmentalObject
s to enact various effects on the player/npcs. These effects include:
-
SLOW
(although this is a misnomer as they can also be used to increase speed - simply give the EnvironmentalComponent a speed aspect > 1) DAMAGE
KNOCKBACK
- and basic collision effects (
DIVERT
&NONE
)
Entities implementing CollisionEffectComponent
should also implement ColliderComponent
, PhysicsComponent
, and EnvironmentalComponent
. If you want the effect to extend past the bounds of the collider (i.e. in an area of effect), HitboxComponent
should also be implemented and given a size
Effects can be configured to effect either the player, npcs, or both. By default, effects work on all entities that collide with them, but this can be changed using SetEffectTarget()
and the EffectTarget
enum.
The effects work using the engine's collision handler, and effects are applied on collision and, if necessary, removed when the collision ends.
The SLOW
effect is implemented by accessing a method added to player & NPC movement components (SetPlayerSpeed()
in PlayerActions.java
and SetMaxSpeed()
in PhysicsMovementComponent.java
respectively. Speed is changed by multiplying the entity's current speed by the speedModifier
, and this debuff is removed on collision end by multiplying the speed by 1/speedModifier
. We have tried to test to ensure floating point errors don't end up with the entity moving at a drastically different speed after many collisions, but this is still possible. the ResetSpeed()
functions can be implemented to fix this if necessary.
Initially, we tried to implement the SLOW
effect using the engine's physics library & applying friction / linear damping. If you are considering refactoring this effect to be used in this way, tread carefully! It will (we think) require some tinkering with the engine's PreSolve
function in the PhysicsContactListener
to add additional friction between colliding bodies regardless of the friction on individual bodies.
By default DAMAGE
also knocks back the entity. This behaviour can be changed by using SetKnockback()
and setting knockback to 0f
To place environmental obstacles the ForestGameArea
must be used specifically with the function SpawnEnvironmentalObstacles
. SpawnEnvironmnetalObstacles
, as the name implies, spawns all of the obstacles on the map using semi random amounts of TREES
, ROCKS
etc. It calls SpawnEnvironmentalObstacle
which will spawn the given obstacle at a random X,Y pos. It does this by creating an Entity
via calling ObstacleFactory
and if the spawn position is valid via the environmentalCollision
class.