Skip to content

Commit

Permalink
Modding API 1.6a (for Update v1.09)
Browse files Browse the repository at this point in the history
  • Loading branch information
zealottormunds committed Jan 3, 2021
1 parent d57ca91 commit 968b753
Show file tree
Hide file tree
Showing 38 changed files with 1,830 additions and 214 deletions.
37 changes: 37 additions & 0 deletions d3dcompiler_47_og/BoxCollider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "BoxCollider.h"
#include "GameObject.h"

using namespace std;
using namespace moddingApi;

bool BoxCollider::isColliding(BoxCollider a, BoxCollider b)
{
GameObject* gA = (GameObject*)(a.gameObjectPtr);
GameObject* gB = (GameObject*)(b.gameObjectPtr);

Vector3 aMin = Vector3(
gA->transform.position.x - (a.scale.x / 2) + a.center.x,
gA->transform.position.y - (a.scale.y / 2) + a.center.y,
gA->transform.position.z - (a.scale.z / 2) + a.center.z
);

Vector3 aMax = Vector3(
gA->transform.position.x + (a.scale.x / 2) + a.center.x,
gA->transform.position.y + (a.scale.y / 2) + a.center.y,
gA->transform.position.z + (a.scale.z / 2) + a.center.z
);

Vector3 bMin = Vector3(
gB->transform.position.x - (b.scale.x / 2) + b.center.x,
gB->transform.position.y - (b.scale.y / 2) + b.center.y,
gB->transform.position.z - (b.scale.z / 2) + b.center.z
);

Vector3 bMax = Vector3(
gB->transform.position.x + (b.scale.x / 2) + b.center.x,
gB->transform.position.y + (b.scale.y / 2) + b.center.y,
gB->transform.position.z + (b.scale.z / 2) + b.center.z
);

return (aMin.x <= bMax.x && aMax.x >= bMin.x) && (aMin.y <= bMax.y && aMax.y >= bMin.y) && (aMin.z <= bMax.z && aMax.z >= bMin.z);
}
21 changes: 21 additions & 0 deletions d3dcompiler_47_og/BoxCollider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "Vector3.h"
#include <cstdint>

namespace moddingApi
{
class BoxCollider
{
public:
uintptr_t gameObjectPtr;
Vector3 center;
Vector3 scale;

BoxCollider(uintptr_t gameObject, Vector3 _center, Vector3 _scale) : gameObjectPtr(gameObject), center(_center), scale(_scale)
{

}

static bool isColliding(BoxCollider a, BoxCollider b);
};
}
2 changes: 1 addition & 1 deletion d3dcompiler_47_og/FileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ std::string FileParser::b_ReadString(vector<BYTE> actual, int index, int count)
}
else
{
for (int x = index; x < count; x++)
for (int x = index; x < index + count; x++)
{
string str2 = a;
char c = (char)actual[x];
Expand Down
7 changes: 7 additions & 0 deletions d3dcompiler_47_og/GameMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ int GameMath::FrameToFps(int f)
{
if (ccGeneralGameFunctions::GetFPS() == 30) return f / 2;
else return f;
}

float GameMath::Lerp(float a, float b, float c)
{
float addtoa = b - a;

return a + (addtoa * c);
}
1 change: 1 addition & 0 deletions d3dcompiler_47_og/GameMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace moddingApi
static float DegToRad(float deg);
static float RadToDeg(float rad);
static int FrameToFps(int f);
static float Lerp(float a, float b, float t);
};
}

Expand Down
Loading

0 comments on commit 968b753

Please sign in to comment.