41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using DV.OriginShift;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace CommunityMapLocation.Api.Location
|
|
{
|
|
public class LocationResponse
|
|
{
|
|
public LocationResponse(Transform playerTransform, bool reverse)
|
|
: this(playerTransform, playerTransform, reverse)
|
|
{
|
|
}
|
|
|
|
public LocationResponse(Transform playerTransform, Transform rotationTransform, bool reverse)
|
|
{
|
|
var position = playerTransform.AbsolutePosition();
|
|
|
|
X = position.x;
|
|
Y = position.y;
|
|
Z = position.z;
|
|
|
|
var targetTransform = rotationTransform != null ? rotationTransform : playerTransform;
|
|
var angle = targetTransform.rotation.eulerAngles.y;
|
|
|
|
if (reverse)
|
|
{
|
|
angle += 180;
|
|
}
|
|
|
|
Rotation = angle * (Mathf.PI / 180);
|
|
}
|
|
|
|
public float X { get; }
|
|
public float Y { get; }
|
|
public float Z { get; }
|
|
public float Rotation { get; }
|
|
|
|
public IEnumerable<CarLocationResponse> Cars { get; set; }
|
|
}
|
|
}
|