1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef TWINE_SCENE_COLLISION_H
24 #define TWINE_SCENE_COLLISION_H
25 
26 #include "common/scummsys.h"
27 #include "twine/shared.h"
28 
29 namespace TwinE {
30 
31 class ActorStruct;
32 struct ExtraListStruct;
33 class TwinEEngine;
34 
35 class Collision {
36 private:
37 	TwinEEngine *_engine;
38 
39 	void handlePushing(const IVec3 &minsTest, const IVec3 &maxsTest, const ActorStruct *actor, ActorStruct *actorTest);
40 public:
41 	Collision(TwinEEngine *engine);
42 	/** Actor collision coordinate */
43 	IVec3 _collision;
44 
45 	/** Actor collision coordinate */
46 	IVec3 _processCollision;
47 
48 	/** Cause damage in current processed actor */
49 	int32 _causeActorDamage = 0; //fieldCauseDamage
50 
51 	/**
52 	 * Check if actor 1 is standing in actor 2
53 	 * @param actorIdx1 Actor 1 index
54 	 * @param actorIdx2 Actor 2 index
55 	 */
56 	bool standingOnActor(int32 actorIdx1, int32 actorIdx2) const;
57 
58 	int32 getAverageValue(int32 start, int32 end, int32 maxDelay, int32 delay) const;
59 
60 	/**
61 	 * Reajust actor position in scene according with brick shape bellow actor
62 	 * @param brickShape Shape of brick bellow the actor
63 	 */
64 	void reajustActorPosition(ShapeType brickShape);
65 
66 	/**
67 	 * Check collision with actors
68 	 * @param actorIx Current process actor index
69 	 */
70 	int32 checkCollisionWithActors(int32 actorIdx);
71 
72 	/**
73 	 * Check Hero collision with bricks
74 	 * @param x Hero X coordinate
75 	 * @param y Hero Y coordinate
76 	 * @param z Hero Z coordinate
77 	 * @param damageMask Cause damage mask
78 	 */
79 	void checkHeroCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask);
80 
81 	/**
82 	 * Check other actor collision with bricks
83 	 * @param x Actor X coordinate
84 	 * @param y Actor Y coordinate
85 	 * @param z Actor Z coordinate
86 	 * @param damageMask Cause damage mask
87 	 */
88 	void checkActorCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask);
89 
90 	/** Make actor to stop falling */
91 	void stopFalling();
92 
93 	/**
94 	 * Check extra collision with actors
95 	 * @param extra to process
96 	 * @param actorIdx actor to check collision
97 	 */
98 	int32 checkExtraCollisionWithActors(ExtraListStruct *extra, int32 actorIdx);
99 
100 	/** Check extra collision with bricks */
101 	bool checkExtraCollisionWithBricks(int32 x, int32 y, int32 z, const IVec3 &oldPos);
102 
103 	/**
104 	 * Check extra collision with another extra
105 	 * @param extra to process
106 	 * @param extraIdx extra index to check collision
107 	 */
108 	int32 checkExtraCollisionWithExtra(ExtraListStruct *extra, int32 extraIdx) const;
109 };
110 
111 } // namespace TwinE
112 #endif
113