Make N/S/W/E autorotate more intuitive

This commit is contained in:
UnknownShadow200 2018-03-11 11:19:43 +11:00
parent e01bdcc60c
commit a42b74cc44
2 changed files with 19 additions and 49 deletions

View File

@ -59,7 +59,7 @@ namespace ClassicalSharp {
static BlockID RotateOther(Game game, BlockID block, string name, Vector3 offset) {
// Fence type blocks
if (BlockInfo.FindID(name + "-UD") == -1) {
float headY = LocationUpdate.Clamp(game.LocalPlayer.HeadY);
float headY = LocationUpdate.Clamp(game.LocalPlayer.HeadY);
if (headY < 45 || (headY >= 135 && headY < 225) || headY > 315)
return Find(game, block, name + "-WE");
return Find(game, block, name + "-NS");
@ -77,30 +77,14 @@ namespace ClassicalSharp {
}
static BlockID RotateDirection(Game game, BlockID block, string name, Vector3 offset) {
Vector3 southEast = new Vector3 (1, 0, 1);
Vector3 southWest = new Vector3 (-1, 0, 1);
Vector3I pos = game.SelectedPos.TranslatedPos;
Vector3 posExact = game.SelectedPos.Intersect;
Vector3 posExactFlat = posExact; posExactFlat.Y = 0;
Vector3 southEastToPoint = posExactFlat - new Vector3 (pos.X, 0, pos.Z);
Vector3 southWestToPoint = posExactFlat - new Vector3 (pos.X +1, 0, pos.Z);
float dotSouthEast = Vector3.Dot(southEastToPoint, southWest);
float dotSouthWest= Vector3.Dot(southWestToPoint, southEast);
if (dotSouthEast <= 0) { // NorthEast
if (dotSouthWest <= 0) { //NorthWest
return Find(game, block, name + "-N");
} else { //SouthEast
return Find(game, block, name + "-E");
}
} else { //SouthWest
if (dotSouthWest <= 0) { //NorthWest
return Find(game, block, name + "-W");
} else { //SouthEast
return Find(game, block, name + "-S");
}
}
float headY = LocationUpdate.Clamp(game.LocalPlayer.HeadY);
if (headY >= 45 && headY < 135)
return Find(game, block, name + "-E");
if (headY >= 135 && headY < 225)
return Find(game, block, name + "-S");
if (headY >= 225 && headY < 315)
return Find(game, block, name + "-W");
return Find(game, block, name + "-N");
}
static BlockID Find(Game game, BlockID block, string name) {

View File

@ -522,31 +522,17 @@ BlockID AutoRotate_RotateOther(BlockID block, String* name, Vector3 offset) {
}
BlockID AutoRotate_RotateDirection(BlockID block, String* name, Vector3 offset) {
Vector3 SE = Vector3_Create3(+1.0f, 0.0f, 1.0f);
Vector3 SW = Vector3_Create3(-1.0f, 0.0f, 1.0f);
Real32 headY = LocalPlayer_Instance.Base.Base.HeadY;
headY = LocationUpdate_Clamp(headY);
Vector3I pos = Game_SelectedPos.TranslatedPos;
Vector3 exact = Game_SelectedPos.Intersect;
Vector3 exactFlat = exact; exactFlat.Y = 0.0f;
Vector3 SEToPoint = exactFlat; SEToPoint.X -= pos.X; SEToPoint.Z -= pos.Z;
Vector3 SWToPoint = exactFlat; SWToPoint.X -= (pos.X + 1); SWToPoint.Z -= pos.Z;
Real32 dotSE = Vector3_Dot(&SEToPoint, &SW);
Real32 dotSW = Vector3_Dot(&SWToPoint, &SE);
if (dotSE <= 0.0f) { /* NorthEast */
if (dotSW <= 0.0f) { /* NorthWest */
return AutoRotate_Find(block, name, "-N");
} else { /* SouthEast */
return AutoRotate_Find(block, name, "-E");
}
} else { /* SouthWest */
if (dotSW <= 0.0f) { /* NorthWest */
return AutoRotate_Find(block, name, "-W");
} else { /* SouthEast */
return AutoRotate_Find(block, name, "-S");
}
if (headY >= 45.0f && headY < 135.0f) {
return AutoRotate_Find(block, name, "-E");
} else if (headY >= 135.0f && headY < 225.0f) {
return AutoRotate_Find(block, name, "-S");
} else if (headY >= 225.0f && headY < 315.0f) {
return AutoRotate_Find(block, name, "-W");
} else {
return AutoRotate_Find(block, name, "-N");
}
}