Created
January 9, 2014 17:07
-
-
Save phrohdoh/8337871 to your computer and use it in GitHub Desktop.
A function written before realizing OpenRA has FindActorsInCircle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool IsInRangeOf(Actor actorInQuestion, Actor sourceActor, bool use3D = false) | |
{ | |
// convert distance (px -> cells) | |
var distX = (sourceActor.Location.CenterPosition.X - actorInQuestion.Location.CenterPosition.X) / 1024; | |
var distY = (sourceActor.Location.CenterPosition.Y - actorInQuestion.Location.CenterPosition.Y) / 1024; | |
var distZ = (sourceActor.Location.CenterPosition.Z - actorInQuestion.Location.CenterPosition.Z) / 1024; | |
// convert Info.Range (px -> cells) | |
var range = (Info.Range * 1024); | |
if (use3D) | |
if (distX < range && distY < range && distZ < range) | |
return true; | |
if (distX < range && distY < range) | |
return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment