mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
Fix bugs
This commit is contained in:
parent
bdd8bb4c60
commit
e5d1083ca1
10 changed files with 89 additions and 23 deletions
|
|
@ -76,12 +76,18 @@ class CameraController extends Object {
|
|||
function onEvent(e:Event) {
|
||||
switch (e.kind) {
|
||||
case EMove:
|
||||
orbit(e.relX, e.relY);
|
||||
Sdl.warpMouseGlobal(cast this.screenWidth / 2, cast this.screenHeight / 2);
|
||||
if (this.level.cursorLock) {
|
||||
orbit(e.relX, e.relY);
|
||||
lockCursor();
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public function lockCursor() {
|
||||
Sdl.warpMouseGlobal(cast this.screenWidth / 2, cast this.screenHeight / 2);
|
||||
}
|
||||
|
||||
function orbit(mouseX:Float, mouseY:Float) {
|
||||
var window = Window.getInstance();
|
||||
var deltaposX = (window.width / 2) - mouseX;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class DtsObject extends GameObject {
|
|||
if (level != null)
|
||||
this.level = level;
|
||||
|
||||
var isInstanced = false;
|
||||
isInstanced = false;
|
||||
if (this.level != null)
|
||||
isInstanced = this.level.instanceManager.isInstanced(this) && useInstancing;
|
||||
if (!isInstanced)
|
||||
|
|
@ -360,10 +360,10 @@ class DtsObject extends GameObject {
|
|||
}
|
||||
if (flags & 4 > 0) {
|
||||
material.blendMode = BlendMode.Alpha;
|
||||
material.mainPass.depthWrite = false;
|
||||
// material.mainPass.culling = h3d.mat.Data.Face.Front;
|
||||
// mmaterial.mainPass.depthWrite = false;
|
||||
material.mainPass.culling = h3d.mat.Data.Face.Front;
|
||||
}
|
||||
// TODO TRANSPARENCY SHIT
|
||||
// // TODO TRANSPARENCY SHIT
|
||||
if (flags & 8 > 0) {
|
||||
material.blendMode = BlendMode.Add;
|
||||
material.mainPass.setPassName("overlay");
|
||||
|
|
@ -373,11 +373,12 @@ class DtsObject extends GameObject {
|
|||
material.blendMode = BlendMode.Sub;
|
||||
|
||||
if (flags & 32 > 0) {
|
||||
var pbrprops = material.mainPass.getShader(h3d.shader.pbr.PropsValues);
|
||||
pbrprops.emissiveValue = 1;
|
||||
pbrprops.roughnessValue = 0;
|
||||
pbrprops.occlusionValue = 0;
|
||||
pbrprops.metalnessValue = 1;
|
||||
material.mainPass.setPassName("overlay");
|
||||
// var pbrprops = material.mainPass.getShader(h3d.shader.pbr.PropsValues);
|
||||
// pbrprops.emissiveValue = 1;
|
||||
// pbrprops.roughnessValue = 1;
|
||||
// pbrprops.occlusionValue = 0;
|
||||
// pbrprops.metalnessValue = 0;
|
||||
}
|
||||
|
||||
// if (this.isTSStatic && !(flags & 64 > 0)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import gui.PlayMissionGui;
|
||||
import gui.ExitGameDlg;
|
||||
import hxd.Key;
|
||||
import src.Mission;
|
||||
|
|
@ -35,10 +36,27 @@ class MarbleGame {
|
|||
if (Key.isPressed(Key.ESCAPE)) {
|
||||
paused = !paused;
|
||||
if (paused) {
|
||||
exitGameDlg = new ExitGameDlg();
|
||||
world.setCursorLock(false);
|
||||
exitGameDlg = new ExitGameDlg((sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
paused = !paused;
|
||||
world.dispose();
|
||||
world = null;
|
||||
canvas.setContent(new PlayMissionGui());
|
||||
}, (sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
paused = !paused;
|
||||
world.setCursorLock(true);
|
||||
}, (sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
world.restart();
|
||||
world.setCursorLock(true);
|
||||
paused = !paused;
|
||||
});
|
||||
canvas.pushDialog(exitGameDlg);
|
||||
} else {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
world.setCursorLock(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import sdl.Cursor;
|
||||
import src.ForceObject;
|
||||
import h3d.scene.pbr.DirLight;
|
||||
import h3d.col.Bounds;
|
||||
|
|
@ -94,6 +95,8 @@ class MarbleWorld extends Scheduler {
|
|||
public var totalGems:Int = 0;
|
||||
public var gemCount:Int = 0;
|
||||
|
||||
public var cursorLock:Bool = true;
|
||||
|
||||
var helpTextTimeState:Float = -1e8;
|
||||
var alertTextTimeState:Float = -1e8;
|
||||
|
||||
|
|
@ -862,6 +865,21 @@ class MarbleWorld extends Scheduler {
|
|||
// if (this.replay.mode != = 'playback')
|
||||
this.schedule(this.timeState.currentAttemptTime + 2, () -> this.restart());
|
||||
}
|
||||
|
||||
public function setCursorLock(enabled:Bool) {
|
||||
this.cursorLock = enabled;
|
||||
if (enabled) {
|
||||
this.marble.camera.lockCursor();
|
||||
Cursor.show(false);
|
||||
} else {
|
||||
Cursor.show(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function dispose() {
|
||||
this.playGui.dispose();
|
||||
scene.removeChildren();
|
||||
}
|
||||
}
|
||||
|
||||
typedef ScheduleInfo = {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ class Mission {
|
|||
var path = StringTools.replace(rawElementPath.substring(rawElementPath.indexOf('data/')), "\"", "");
|
||||
if (StringTools.contains(path, 'interiors_mbg/'))
|
||||
path = StringTools.replace(path, 'interiors_mbg/', 'interiors/');
|
||||
return path;
|
||||
if (ResourceLoader.fileSystem.exists(path))
|
||||
return path;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Collision {
|
|||
var p = PlaneF.PointNormal(new Point3F(v0.x, v0.y, v0.z), new Point3F(normal.x, normal.y, normal.z));
|
||||
var pdist = p.distance(new Point3F(center.x, center.y, center.z));
|
||||
|
||||
if (pdist < 0) {
|
||||
if (Math.abs(pdist) < 0.001) {
|
||||
return res; // Dont collide internal edges
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +68,11 @@ class Collision {
|
|||
}
|
||||
|
||||
if (pdist < radius) {
|
||||
var t = -toDifPoint(center).dot(p.getNormal()) / p.getNormal().lengthSq();
|
||||
var pt = fromDifPoint(p.project(toDifPoint(center))); // center.add(fromDifPoint(p.getNormal().scalar(t)));
|
||||
var n = normal.normalized();
|
||||
var t = center.dot(n) - v0.dot(n);
|
||||
|
||||
var pt = center.sub(n.multiply(t));
|
||||
|
||||
if (PointInTriangle(pt, v0, v1, v2)) {
|
||||
res.result = true;
|
||||
res.point = pt;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package gui;
|
||||
|
||||
import hxd.res.BitmapFont;
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
|
||||
class ExitGameDlg extends GuiControl {
|
||||
public function new() {
|
||||
public function new(yesFunc:GuiControl->Void, noFunc:GuiControl->Void, restartFunc:GuiControl->Void) {
|
||||
super();
|
||||
|
||||
this.horizSizing = Width;
|
||||
|
|
@ -25,24 +26,41 @@ class ExitGameDlg extends GuiControl {
|
|||
dialogImg.position = new Vector(134, 148);
|
||||
dialogImg.extent = new Vector(388, 186);
|
||||
|
||||
var domcasual32fontdata = ResourceLoader.loader.load("data/font/DomCasual32px.fnt");
|
||||
var domcasual32 = new BitmapFont(domcasual32fontdata.entry);
|
||||
@:privateAccess domcasual32.loader = ResourceLoader.loader;
|
||||
|
||||
var exitGameText = new GuiText(domcasual32);
|
||||
exitGameText.text.textColor = 0x000000;
|
||||
exitGameText.text.text = "Exit from this Level?";
|
||||
exitGameText.justify = Center;
|
||||
exitGameText.position = new Vector(95, 46);
|
||||
exitGameText.extent = new Vector(198, 23);
|
||||
exitGameText.horizSizing = Center;
|
||||
exitGameText.vertSizing = Bottom;
|
||||
|
||||
var yesButton = new GuiButton(loadButtonImages("data/ui/common/yes"));
|
||||
yesButton.position = new Vector(47, 107);
|
||||
yesButton.extent = new Vector(88, 52);
|
||||
yesButton.vertSizing = Top;
|
||||
yesButton.horizSizing = Right;
|
||||
yesButton.pressedAction = yesFunc;
|
||||
|
||||
var noButton = new GuiButton(loadButtonImages("data/ui/common/no"));
|
||||
noButton.position = new Vector(151, 107);
|
||||
noButton.extent = new Vector(83, 55);
|
||||
noButton.vertSizing = Top;
|
||||
noButton.horizSizing = Right;
|
||||
noButton.pressedAction = noFunc;
|
||||
|
||||
var restartButton = new GuiButton(loadButtonImages("data/ui/common/restart"));
|
||||
restartButton.position = new Vector(249, 107);
|
||||
restartButton.extent = new Vector(103, 56);
|
||||
restartButton.vertSizing = Top;
|
||||
restartButton.horizSizing = Right;
|
||||
restartButton.pressedAction = restartFunc;
|
||||
|
||||
dialogImg.addChild(exitGameText);
|
||||
dialogImg.addChild(yesButton);
|
||||
dialogImg.addChild(noButton);
|
||||
dialogImg.addChild(restartButton);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@ class Skybox extends hxsl.Shader {
|
|||
var view:Mat4;
|
||||
var proj:Mat4;
|
||||
};
|
||||
var projNorm:Vec3;
|
||||
function vertex() {
|
||||
transformedNormal = transformedPosition - camera.position;
|
||||
projNorm = transformedPosition - camera.position;
|
||||
}
|
||||
function fragment() {
|
||||
pixelColor.rgb = texture.get(normalize(transformedNormal)).rgb;
|
||||
pixelColor.rgba = texture.get(normalize(projNorm)).rgba;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@ class Tornado extends ForceObject {
|
|||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/hazards/tornado.dts";
|
||||
this.isCollideable = true;
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "Tornado";
|
||||
// this.useInstancing = false;
|
||||
this.forceDatas = [
|
||||
{
|
||||
forceType: ForceSpherical,
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ class MustChangeTrigger extends Trigger {
|
|||
}
|
||||
|
||||
public override function onMarbleEnter(time:TimeState) {
|
||||
this.interior.setTargetTime(time, MisParser.parseNumber(this.element.targettime));
|
||||
this.interior.setTargetTime(time, MisParser.parseNumber(this.element.targettime) / 1000);
|
||||
if (this.element.instant == "1") {
|
||||
if (this.element.icontinuetottime != null && this.element.icontinuetottime != "0") {
|
||||
// Absolutely strange, and not sure if it's even a thing in MBG, but is implement nonetheless.
|
||||
this.interior.currentTime = this.interior.targetTime;
|
||||
this.interior.targetTime = MisParser.parseNumber(this.element.icontinuetottime);
|
||||
this.interior.targetTime = MisParser.parseNumber(this.element.icontinuetottime) / 1000;
|
||||
} else {
|
||||
this.interior.changeTime = Math.NEGATIVE_INFINITY; // "If instant is 1, the MP will warp to targetTime instantly."
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue