-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Immersive-Plugins-Team/1.4.1
1.4.1
- Loading branch information
Showing
54 changed files
with
410 additions
and
3,168 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @opus49 |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Rage; | ||
|
||
namespace IPT.Common.API | ||
{ | ||
/// <summary> | ||
/// Math helper. | ||
/// </summary> | ||
public static class MathHelperExtensions | ||
{ | ||
/// <summary> | ||
/// Calculates a forward vector. | ||
/// </summary> | ||
/// <param name="heading">The heading for the vector.</param> | ||
/// <returns>A forward vector.</returns> | ||
public static Vector3 GetForwardVector(float heading) | ||
{ | ||
var headingRads = MathHelper.ConvertDegreesToRadians(90f - heading); | ||
float x = System.Convert.ToSingle(-System.Math.Cos(headingRads)); | ||
float y = System.Convert.ToSingle(System.Math.Sin(headingRads)); | ||
return new Vector3(x, y, 0f); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the angle (0-180 degrees) between the source and target entities. | ||
/// </summary> | ||
/// <param name="source">The source entity.</param> | ||
/// <param name="target">The target entity.</param> | ||
/// <returns>A double indicating the angle in degrees.</returns> | ||
public static double GetVectorAngle(Entity source, Entity target) | ||
{ | ||
var targetVector = target.Position - source.Position; | ||
var dotProduct = Vector3.Dot(source.ForwardVector.ToNormalized(), targetVector.ToNormalized()); | ||
return MathHelper.ConvertRadiansToDegrees(System.Math.Acos(dotProduct)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the angle (0-180 degrees) between the source and target positions given the heading. | ||
/// </summary> | ||
/// <param name="sourcePosition">The source position.</param> | ||
/// <param name="targetPosition">The target position.</param> | ||
/// <param name="heading">The in-game heading (where 0 degrees is due north).</param> | ||
/// <returns>The offset from 0 degrees (straight towards) between the source and target along a heading.</returns> | ||
public static double GetVectorAngle(Vector3 sourcePosition, Vector3 targetPosition, float heading) | ||
{ | ||
var targetVector = targetPosition - sourcePosition; | ||
var forwardVector = GetForwardVector(heading); | ||
var dotProduct = Vector3.Dot(forwardVector.ToNormalized(), targetVector.ToNormalized()); | ||
return MathHelper.ConvertRadiansToDegrees(System.Math.Acos(dotProduct)); | ||
} | ||
|
||
/// <summary> | ||
/// Wraps an angle. | ||
/// </summary> | ||
/// <param name="angle">The angle.</param> | ||
/// <returns>The wrapped angle.</returns> | ||
public static float WrapAngle(float angle) | ||
{ | ||
angle %= 360f; | ||
if (angle > 180f) | ||
{ | ||
angle -= 360f; | ||
} | ||
else if (angle < -180f) | ||
{ | ||
angle += 360f; | ||
} | ||
|
||
return angle; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using IPT.Common.Handlers; | ||
using Rage; | ||
|
||
namespace IPT.Common.API | ||
{ | ||
/// <summary> | ||
/// Notification commands for a consistent style. | ||
/// </summary> | ||
public static class Notifications | ||
{ | ||
/// <summary> | ||
/// Sends a notification that looks like a message from the dispatcher. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public static void DispatchMessage(string message) | ||
{ | ||
Game.DisplayNotification($"~b~Dispatch: ~w~{message}"); | ||
} | ||
|
||
/// <summary> | ||
/// Sends a dispach related notification. | ||
/// </summary> | ||
/// <param name="subtitle">The category of notification.</param> | ||
/// <param name="message">The message.</param> | ||
public static void DispatchNotification(string subtitle, string message) | ||
{ | ||
OfficialNotification("DISPATCH", subtitle, message); | ||
} | ||
|
||
/// <summary> | ||
/// Sends an official looking notification. | ||
/// </summary> | ||
/// <param name="title">The title of the notification.</param> | ||
/// <param name="subtitle">The substitle of the notification.</param> | ||
/// <param name="message">The message of the notification.</param> | ||
public static void OfficialNotification(string title, string subtitle, string message) | ||
{ | ||
Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", title, $"~b~{subtitle}", message); | ||
} | ||
|
||
/// <summary> | ||
/// Sends the status notification. | ||
/// </summary> | ||
public static void StatusNotification() | ||
{ | ||
string message = $"~w~Callsign: ~g~{PlayerHandler.GetCallsign()}~n~~w~Status: {PlayerHandler.GetStatus().ToColorString()}"; | ||
DispatchNotification("~b~Officer Status", message); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.