Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at each engine boundary: FieldDriver, GuidedProjectile(Manager), EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance, ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace, MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math calls that were handed Unity vectors now take converted values; Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's Vector3.Dot on float3s becomes dot. packages-lock.json records the cultmath git package at f0605367 and demotes com.unity.mathematics to a transitive dependency. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3dc00e1225
commit
2281793154
17 changed files with 86 additions and 63 deletions
|
|
@ -5,6 +5,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using CultMath;
|
||||
using CultMath.UnityBridge;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
|
|
@ -26,22 +27,22 @@ public class MapMenuInput : MonoBehaviour, IBeginDragHandler, IDragHandler, IScr
|
|||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
_startMousePosition = eventData.position;
|
||||
_startMapPosition = Map.Position;
|
||||
_startMapPosition = Map.Position.ToUnity();
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Map.Position = _startMapPosition - (eventData.position - _startMousePosition) * Map.Scale;
|
||||
Map.Position = (_startMapPosition - (eventData.position - _startMousePosition) * Map.Scale).ToCultMath();
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
Vector3[] mapCorners = new Vector3[4];
|
||||
_mapRect.GetWorldCorners(mapCorners);
|
||||
var mapCenter = ((float3)(mapCorners[2] + mapCorners[0]) / 2).xy;
|
||||
var oldPointerPosition = Map.Position + ((float2)eventData.position - mapCenter) * Map.Scale;
|
||||
var mapCenter = ((mapCorners[2] + mapCorners[0]).ToCultMath() / 2).xy;
|
||||
var oldPointerPosition = Map.Position + (eventData.position.ToCultMath() - mapCenter) * Map.Scale;
|
||||
Map.Scale *= 1 - eventData.scrollDelta.y * ZoomSpeed;
|
||||
var pointerPosition = Map.Position + ((float2)eventData.position - mapCenter) * Map.Scale;
|
||||
var pointerPosition = Map.Position + (eventData.position.ToCultMath() - mapCenter) * Map.Scale;
|
||||
Map.Position += oldPointerPosition - pointerPosition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue