Shields
Created field bubble shields / propulsion, currently just a prototype with its own test scene
This commit is contained in:
parent
47e500e1ce
commit
c6ffcad3f1
213 changed files with 2145 additions and 1213 deletions
|
|
@ -143,6 +143,15 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Turn"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""b93a3495-742e-4536-a9c7-57d6ab81d04c"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
|
|
@ -160,7 +169,7 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
{
|
||||
""name"": ""WASD"",
|
||||
""id"": ""00ca640b-d935-4593-8157-c05846ea39b3"",
|
||||
""path"": ""Dpad"",
|
||||
""path"": ""Dpad(mode=1)"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
|
|
@ -376,6 +385,39 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
""action"": ""Tractor Beam"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""0a0e25af-91a6-4e29-ad62-649fdcb137bd"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Turn"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""8536ca60-1fed-4f29-8060-04d46cfffcab"",
|
||||
""path"": ""<Keyboard>/q"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Turn"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""19c175bf-d4e6-4626-8bee-91e0c473a94b"",
|
||||
""path"": ""<Keyboard>/e"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Turn"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -1027,6 +1069,7 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
m_Player_Ping = m_Player.FindAction("Ping", throwIfNotFound: true);
|
||||
m_Player_HideUI = m_Player.FindAction("Hide UI", throwIfNotFound: true);
|
||||
m_Player_TractorBeam = m_Player.FindAction("Tractor Beam", throwIfNotFound: true);
|
||||
m_Player_Turn = m_Player.FindAction("Turn", throwIfNotFound: true);
|
||||
// UI
|
||||
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
|
||||
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
|
||||
|
|
@ -1118,6 +1161,7 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
private readonly InputAction m_Player_Ping;
|
||||
private readonly InputAction m_Player_HideUI;
|
||||
private readonly InputAction m_Player_TractorBeam;
|
||||
private readonly InputAction m_Player_Turn;
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @AetheriaInput m_Wrapper;
|
||||
|
|
@ -1135,6 +1179,7 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
public InputAction @Ping => m_Wrapper.m_Player_Ping;
|
||||
public InputAction @HideUI => m_Wrapper.m_Player_HideUI;
|
||||
public InputAction @TractorBeam => m_Wrapper.m_Player_TractorBeam;
|
||||
public InputAction @Turn => m_Wrapper.m_Player_Turn;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
|
|
@ -1183,6 +1228,9 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
@TractorBeam.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTractorBeam;
|
||||
@TractorBeam.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTractorBeam;
|
||||
@TractorBeam.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTractorBeam;
|
||||
@Turn.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTurn;
|
||||
@Turn.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTurn;
|
||||
@Turn.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnTurn;
|
||||
}
|
||||
m_Wrapper.m_PlayerActionsCallbackInterface = instance;
|
||||
if (instance != null)
|
||||
|
|
@ -1226,6 +1274,9 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
@TractorBeam.started += instance.OnTractorBeam;
|
||||
@TractorBeam.performed += instance.OnTractorBeam;
|
||||
@TractorBeam.canceled += instance.OnTractorBeam;
|
||||
@Turn.started += instance.OnTurn;
|
||||
@Turn.performed += instance.OnTurn;
|
||||
@Turn.canceled += instance.OnTurn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1442,6 +1493,7 @@ public partial class @AetheriaInput : IInputActionCollection2, IDisposable
|
|||
void OnPing(InputAction.CallbackContext context);
|
||||
void OnHideUI(InputAction.CallbackContext context);
|
||||
void OnTractorBeam(InputAction.CallbackContext context);
|
||||
void OnTurn(InputAction.CallbackContext context);
|
||||
}
|
||||
public interface IUIActions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ using UnityEngine.Rendering.PostProcessing;
|
|||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor.Localization.Plugins.XLIFF.V12;
|
||||
using UnityEngine.EventSystems;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
|
@ -294,7 +295,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
Input.Global.ZoneMap.performed += context =>
|
||||
{
|
||||
ToggleMenuTab(MenuTab.Map);
|
||||
MenuMap.Position = CurrentEntity.Position.xz;
|
||||
MenuMap.Position = CurrentEntity.Position.xz;
|
||||
};
|
||||
|
||||
Input.Global.Inventory.performed += context => ToggleMenuTab(MenuTab.Inventory);
|
||||
|
|
@ -457,7 +458,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
return slot;
|
||||
}
|
||||
|
||||
foreach (var actionBarInput in PlayerSettings.InputSettings.ActionBarInputs.OrderBy(i=>i)) createBinding(actionBarInput);
|
||||
var bindings = PlayerSettings.InputSettings.ActionBarInputs.OrderBy(i => i)
|
||||
.Select(createBinding).ToList();
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -465,6 +467,16 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
StartGame();
|
||||
|
||||
//if (!PlayerSettings.InputSettings.ActionBarInputs.Any())
|
||||
{
|
||||
var newbinds = Enumerable.Range(0, 64)//CurrentEntity.WeaponGroups
|
||||
.Zip(
|
||||
bindings,
|
||||
(i, slot) =>
|
||||
slot.Binding = new ActionBarWeaponGroupBinding(CurrentEntity, slot, i)
|
||||
);
|
||||
}
|
||||
|
||||
ConsoleController.AddCommand("revealzones",
|
||||
_ =>
|
||||
{
|
||||
|
|
@ -1306,4 +1318,4 @@ public class EquippedItemDragObject : ItemDragObject
|
|||
|
||||
public EquippedItem EquippedItem { get; }
|
||||
public Entity OriginEntity { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ public class EntityInstance : MonoBehaviour
|
|||
// U coordinate between 0-1 indicates a hit that didn't land directly on a hardpoint
|
||||
// Find the 2D position of the hit scaled to the schematic
|
||||
float2 hitPos = float2.zero;
|
||||
if (hardpointIndex < 0)
|
||||
if (hardpointIndex < 0 || hardpointIndex >= hullData.Hardpoints.Count)
|
||||
{
|
||||
hitPos = float2(hit.TexCoord.x * hullData.Shape.Width, hit.TexCoord.y * hullData.Shape.Height);
|
||||
// Search all schematic border cells for the cell which is closest to the hit position
|
||||
|
|
|
|||
|
|
@ -4,31 +4,28 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Animations;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class FieldDriver : MonoBehaviour
|
||||
{
|
||||
public Camera Camera;
|
||||
public float2 Push;
|
||||
public float FrontTwist;
|
||||
public float RearTwist;
|
||||
[Inspectable]
|
||||
public float TestMagnitude;
|
||||
public float2 Throttle;
|
||||
[Inspectable]
|
||||
public float ThrottleDecay = 1;
|
||||
[Inspectable]
|
||||
public float FlowSpeed;
|
||||
[Inspectable]
|
||||
public float FlowSpeedThrottleExponent;
|
||||
[Inspectable]
|
||||
public float FlowMagnitude;
|
||||
[Inspectable]
|
||||
public float FlowMagnitudeThrottleExponent;
|
||||
[Inspectable]
|
||||
public float FlowOpacityThrottleExponent;
|
||||
public float WaveThrottleExponent;
|
||||
|
||||
public int MaxHits;
|
||||
[Inspectable]
|
||||
public ExponentialCurve MagnitudeTimeScaling;
|
||||
|
||||
[Inspectable]
|
||||
|
||||
[Inspectable, InspectorHeader("Melee")]
|
||||
public float MeleeRange;
|
||||
[Inspectable]
|
||||
public float MeleeRangeExponent;
|
||||
|
|
@ -42,16 +39,60 @@ public class FieldDriver : MonoBehaviour
|
|||
public float MeleeAngle;
|
||||
[Inspectable]
|
||||
public float MeleeAngleExponent;
|
||||
|
||||
[Inspectable, InspectorHeader("Tendril")]
|
||||
public float TendrilBaseRadius = 3;
|
||||
[Inspectable]
|
||||
public Axis RefractionAxis = Axis.X;
|
||||
public float TendrilTipRadius = .1f;
|
||||
[Inspectable]
|
||||
public float TendrilExtensionExponent = .75f;
|
||||
[Inspectable]
|
||||
public float TendrilExtendBaseAnimationExponent = .5f;
|
||||
[Inspectable]
|
||||
public float TendrilBaseDamping = 2;
|
||||
[Inspectable]
|
||||
public float TendrilTipRadiusAnimationExponent = 2f;
|
||||
[Inspectable]
|
||||
public float TendrilFadeExponent = 2;
|
||||
// [Inspectable]
|
||||
// public float GrabScaleAnimationExponent = .5f;
|
||||
|
||||
[Inspectable, InspectorHeader("Grab")]
|
||||
public float GrabExtendTime;
|
||||
[Inspectable]
|
||||
public float GrabEnvelopTime;
|
||||
[Inspectable]
|
||||
public float GrabPullTime;
|
||||
|
||||
[Inspectable]
|
||||
public RectTransform.Axis RefractionAxis = RectTransform.Axis.Horizontal;
|
||||
|
||||
private Material _field;
|
||||
private ComputeBuffer _hitBuffer;
|
||||
private List<FieldHit> _hits = new List<FieldHit>();
|
||||
private float _pushWaveOffset;
|
||||
private double2 _throttle;
|
||||
private float _waveOffset;
|
||||
private float _meleeTime;
|
||||
private bool _meleeActive;
|
||||
private MeshCollider _collider;
|
||||
private Transform _grabObject;
|
||||
private Vector3 _grabObjectStartPos;
|
||||
private Vector3 _grabObjectStartTendrilBasePos;
|
||||
private Vector3 _grabObjectEndPos;
|
||||
private Vector3 _grabObjectVelocity;
|
||||
private float _grabObjectScale;
|
||||
private float _grabTime;
|
||||
private GrabPhase _grabPhase;
|
||||
private Vector3 _tendrilBasePos;
|
||||
private Vector3 _tendrilBendTarget;
|
||||
private Vector3 _tendrilTargetPos;
|
||||
private float _fadePoint;
|
||||
|
||||
private enum GrabPhase
|
||||
{
|
||||
Extend,
|
||||
Envelop,
|
||||
Pull
|
||||
}
|
||||
|
||||
private struct FieldHit
|
||||
{
|
||||
|
|
@ -63,6 +104,7 @@ public class FieldDriver : MonoBehaviour
|
|||
|
||||
void Start()
|
||||
{
|
||||
_collider = GetComponent<MeshCollider>();
|
||||
_field = GetComponent<MeshRenderer>().material;
|
||||
var clickableCollider = GetComponent<ClickableCollider>();
|
||||
if(clickableCollider!=null)
|
||||
|
|
@ -80,12 +122,12 @@ public class FieldDriver : MonoBehaviour
|
|||
if (_hits.Count >= MaxHits) return;
|
||||
var hit = new FieldHit
|
||||
{
|
||||
Position = normalize(transform.InverseTransformPoint(position)),
|
||||
Position = Vector3.Scale(normalize(transform.InverseTransformPoint(position)), transform.localScale),
|
||||
Direction = normalize(transform.rotation * direction),
|
||||
Magnitude = magnitude,
|
||||
Time = 0
|
||||
};
|
||||
Debug.Log($"Received hit: Position={hit.Position}, Direction={hit.Direction}");
|
||||
//Debug.Log($"Received hit: Position={hit.Position}, Direction={hit.Direction}");
|
||||
_hits.Add(hit);
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +139,39 @@ public class FieldDriver : MonoBehaviour
|
|||
_meleeTime = 0;
|
||||
}
|
||||
|
||||
public bool CanGrab => _grabObject == null;
|
||||
|
||||
public void GrabObject(Transform t, Vector3 v)
|
||||
{
|
||||
_grabPhase = GrabPhase.Extend;
|
||||
_grabObject = t;
|
||||
_grabObjectStartPos = t.position;
|
||||
_grabObjectVelocity = v;
|
||||
_grabObjectScale = t.localScale.x;
|
||||
_tendrilBasePos = _grabObjectStartTendrilBasePos = _collider.ClosestPoint(_grabObjectStartPos);
|
||||
_fadePoint = .999f;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
var pushMag = min(length(Push), 1);
|
||||
|
||||
_waveOffset = frac(_waveOffset + Time.deltaTime * FlowSpeed * pow(max(pushMag, max(abs(FrontTwist), abs(RearTwist))), FlowSpeedThrottleExponent));
|
||||
|
||||
var refractionRotation = Matrix4x4.Rotate(Camera.transform.rotation).inverse;
|
||||
if (RefractionAxis == RectTransform.Axis.Vertical) refractionRotation =
|
||||
Matrix4x4.Rotate(Quaternion.Euler(90, 0, 0)) * refractionRotation;
|
||||
|
||||
_field.SetFloat("_WaveOffset", _waveOffset * PI * 2);
|
||||
_field.SetFloat("_Push", pushMag);
|
||||
_field.SetVector("_PushDirection", new Vector4(-Push.x, 0, -Push.y));
|
||||
_field.SetFloat("_TwistFront", FrontTwist);
|
||||
_field.SetFloat("_TwistRear", RearTwist);
|
||||
|
||||
_field.SetVector("_InverseScale", new Vector4(1/transform.localScale.x,1/transform.localScale.y,1/transform.localScale.z));
|
||||
_field.SetMatrix("_ReflRotate", refractionRotation);
|
||||
|
||||
for (int i = 0; i < _hits.Count; i++)
|
||||
{
|
||||
var hit = _hits[i];
|
||||
|
|
@ -110,38 +183,123 @@ public class FieldDriver : MonoBehaviour
|
|||
i--;
|
||||
}
|
||||
}
|
||||
_hitBuffer.SetData(_hits);
|
||||
_field.SetBuffer("_Hits", _hitBuffer);
|
||||
_field.SetInt("_HitCount", _hits.Count);
|
||||
|
||||
if (_meleeActive)
|
||||
{
|
||||
_meleeTime += Time.deltaTime / MeleeDuration;
|
||||
if (_meleeTime > 1)
|
||||
if (_meleeTime < 1)
|
||||
{
|
||||
_field.SetVector("_MeleeDirection", Quaternion.AngleAxis(sign(_meleeTime*2-1) * MeleeAngle * pow(abs(_meleeTime * 2 - 1), MeleeAngleExponent), Vector3.up) * -Vector3.forward);
|
||||
_field.SetFloat("_MeleeDisplacement", pow(1 - 2 * abs(_meleeTime - .5f), MeleeRangeExponent) * MeleeRange);
|
||||
_field.SetFloat("_MeleeShape", MeleeShaping);
|
||||
_field.SetFloat("_MeleeFlattening", MeleeFlatness);
|
||||
}
|
||||
else
|
||||
{
|
||||
_meleeActive = false;
|
||||
_field.SetFloat("_MeleeDisplacement", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(_grabObject != null)
|
||||
{
|
||||
_grabTime += Time.deltaTime / _grabPhase switch
|
||||
{
|
||||
GrabPhase.Extend => GrabExtendTime,
|
||||
GrabPhase.Envelop => GrabEnvelopTime,
|
||||
GrabPhase.Pull => GrabPullTime,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
if (_grabTime > 1)
|
||||
{
|
||||
_grabTime = 0;
|
||||
if (_grabPhase == GrabPhase.Envelop)
|
||||
{
|
||||
_grabObjectEndPos = _grabObject.position;
|
||||
}
|
||||
if (_grabPhase == GrabPhase.Pull)
|
||||
{
|
||||
Destroy(_grabObject.gameObject);
|
||||
_grabObject = null;
|
||||
_field.SetFloat("_TendrilInfluence", 0);
|
||||
}
|
||||
else _grabPhase++;
|
||||
}
|
||||
|
||||
_throttle = AetheriaMath.Damp(_throttle, Throttle, ThrottleDecay, Time.deltaTime);
|
||||
var throttleDir = (float2) normalize(_throttle);
|
||||
if (_grabObject != null)
|
||||
{
|
||||
_tendrilBasePos = AetheriaMath.Damp(_tendrilBasePos, _grabObject.position, TendrilBaseDamping, Time.deltaTime);
|
||||
switch (_grabPhase)
|
||||
{
|
||||
case GrabPhase.Extend:
|
||||
_tendrilBendTarget = _grabObjectStartPos;
|
||||
_grabObject.position += _grabObjectVelocity * Time.deltaTime;
|
||||
_tendrilTargetPos = lerp(
|
||||
lerp(_grabObjectStartTendrilBasePos, _grabObjectStartPos, _grabTime),
|
||||
lerp(_grabObjectStartPos, _grabObject.position, _grabTime),
|
||||
pow(_grabTime, TendrilExtensionExponent));
|
||||
_field.SetFloat("_TendrilInfluence", pow(_grabTime, TendrilExtendBaseAnimationExponent));
|
||||
_field.SetFloat("_TendrilSize", lerp(TendrilBaseRadius/2,TendrilBaseRadius,pow(_grabTime, TendrilExtendBaseAnimationExponent)));
|
||||
_field.SetFloat("_TendrilRadius", _grabObjectScale * pow(_grabTime, TendrilTipRadiusAnimationExponent) * TendrilTipRadius);
|
||||
break;
|
||||
case GrabPhase.Envelop:
|
||||
_tendrilBendTarget = _grabObjectStartPos;
|
||||
_tendrilTargetPos = _grabObject.position += _grabObjectVelocity * Time.deltaTime * (1-_grabTime);
|
||||
_field.SetFloat("_TendrilInfluence", 1);
|
||||
_field.SetFloat("_TendrilSize", TendrilBaseRadius);
|
||||
_field.SetFloat("_TendrilRadius", _grabObjectScale * TendrilTipRadius);
|
||||
break;
|
||||
case GrabPhase.Pull:
|
||||
_tendrilTargetPos = _grabObject.position = lerp(_grabObjectEndPos, transform.position, _grabTime*_grabTime);
|
||||
_tendrilBendTarget = lerp(_grabObjectStartPos, _grabObjectEndPos, _grabTime*_grabTime);
|
||||
if (_fadePoint > .99 && transform.InverseTransformPoint(_grabObject.position).sqrMagnitude < 1)
|
||||
_fadePoint = _grabTime;
|
||||
_field.SetFloat("_TendrilInfluence", pow(smoothstep(1, _fadePoint, _grabTime), TendrilFadeExponent));
|
||||
_field.SetFloat("_TendrilSize", TendrilBaseRadius);
|
||||
_field.SetFloat("_TendrilRadius", _grabObjectScale * TendrilTipRadius);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
_field.SetVector("_TendrilBase", Vector3.Scale(transform.InverseTransformPoint(_tendrilBasePos).normalized, transform.localScale));
|
||||
_field.SetVector("_TendrilBend", Vector3.Scale(transform.InverseTransformPoint(_tendrilBendTarget), transform.localScale));
|
||||
_field.SetVector("_TendrilTarget", Vector3.Scale(transform.InverseTransformPoint(_tendrilTargetPos), transform.localScale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float almostIdentity( float x )
|
||||
{
|
||||
return x*x*(2.0f-x);
|
||||
}
|
||||
|
||||
var throttleMag = min(length(_throttle), 1);
|
||||
private float smooth(float t)
|
||||
{
|
||||
return t * t * (3.0f - 2.0f * t);
|
||||
}
|
||||
|
||||
_pushWaveOffset = frac(_pushWaveOffset + Time.deltaTime * FlowSpeed * (float) pow(throttleMag, FlowSpeedThrottleExponent));
|
||||
private const int GIZMO_STEPS = 16;
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (_grabObject != null)
|
||||
{
|
||||
Vector3 previous = _tendrilBasePos;
|
||||
for (int i = 1; i <= GIZMO_STEPS; i++)
|
||||
{
|
||||
var l = (float)i / GIZMO_STEPS;
|
||||
var next = AetheriaMath.GetQuadraticSplinePosition(_tendrilBasePos, _tendrilBendTarget, _tendrilTargetPos, l);
|
||||
Gizmos.DrawLine(previous, next);
|
||||
previous = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var refractionRotation = Matrix4x4.Rotate(transform.rotation);
|
||||
if (RefractionAxis == Axis.Y) refractionRotation = Matrix4x4.Rotate(Quaternion.Euler(90, 0, 0)) * refractionRotation;
|
||||
if (RefractionAxis == Axis.X) refractionRotation = Matrix4x4.Rotate(Quaternion.Euler(0, 90, 0)) * refractionRotation;
|
||||
_hitBuffer.SetData(_hits);
|
||||
_field.SetBuffer("_Hits", _hitBuffer);
|
||||
_field.SetInt("_HitCount", _hits.Count);
|
||||
_field.SetFloat("_PushWaveMagnitude", FlowMagnitude * (float) pow(throttleMag, FlowMagnitudeThrottleExponent));
|
||||
_field.SetFloat("_PushOpacity", (float) pow(throttleMag, FlowOpacityThrottleExponent));
|
||||
_field.SetFloat("_PushWaveOffset", _pushWaveOffset);
|
||||
_field.SetVector("_PushDirection", new Vector4(throttleDir.x,0,throttleDir.y));
|
||||
_field.SetVector("_InverseScale", new Vector4(1/transform.localScale.x,1/transform.localScale.y,1/transform.localScale.z));
|
||||
_field.SetMatrix("_ReflRotate", refractionRotation);
|
||||
_field.SetVector("_MeleeDirection", Quaternion.AngleAxis(sign(_meleeTime*2-1) * MeleeAngle * pow(abs(_meleeTime * 2 - 1), MeleeAngleExponent), Vector3.up) * -Vector3.forward);
|
||||
_field.SetFloat("_MeleeDisplacement", pow(1 - 2 * abs(_meleeTime - .5f), MeleeRangeExponent) * MeleeRange);
|
||||
_field.SetFloat("_MeleeShape", MeleeShaping);
|
||||
_field.SetFloat("_MeleeFlattening", MeleeFlatness);
|
||||
private void OnDestroy()
|
||||
{
|
||||
_hitBuffer.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
|||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 300
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@ public class GridObject : MonoBehaviour
|
|||
|
||||
void Update()
|
||||
{
|
||||
var t = transform;
|
||||
t.localRotation = Quaternion.Euler(sin(Time.time - _timeOffset * RotationSpeed) * 90, 0, cos(Time.time - _timeOffset * RotationSpeed) * 90);
|
||||
|
||||
if (Zone == null) return;
|
||||
|
||||
var t = transform;
|
||||
var position = t.position;
|
||||
var gridHeight = Zone.GetHeight(position.Flatland()) + GridOffset;
|
||||
Velocity += Vector3.up * (sign(gridHeight - position.y) * GridAttraction * Time.deltaTime);
|
||||
|
|
@ -44,6 +46,5 @@ public class GridObject : MonoBehaviour
|
|||
|
||||
_selfVelocity *= max(0, 1 - Drag * Time.deltaTime);
|
||||
t.position = position + (Velocity + new Vector3(_selfVelocity.x, 0, _selfVelocity.y)) * Time.deltaTime;
|
||||
t.localRotation = Quaternion.Euler(sin(Time.time - _timeOffset * RotationSpeed) * 90, 0, cos(Time.time - _timeOffset * RotationSpeed) * 90);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,6 @@ public class ItemPickup : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ZoneRenderer.DestroyLoot(this);
|
||||
ZoneRenderer?.DestroyLoot(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// using System;
|
||||
// using System.Collections;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using MessagePack;
|
||||
// using Newtonsoft.Json;
|
||||
// using Unity.Mathematics;
|
||||
// using static Unity.Mathematics.math;
|
||||
//
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
// public class HaulingControllerData : ControllerData
|
||||
// {
|
||||
// [InspectableField, JsonProperty("targetDistance"), Key(6)]
|
||||
// public float DockTime = 2;
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new HaulingController(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class HaulingController : ControllerBase<HaulingTask>, IBehavior, IPersistentBehavior
|
||||
// {
|
||||
// private HaulingControllerData _data;
|
||||
// private EquippedItem Item { get; }
|
||||
//
|
||||
// private bool _taskStarted;
|
||||
// private int _itemsDelivered;
|
||||
// private int _itemsCarried;
|
||||
// private SimpleCommodity _simpleCommodityDelivery;
|
||||
// private List<CraftedItemInstance> _craftedItemDelivery = new List<CraftedItemInstance>();
|
||||
//
|
||||
// public HaulingController(ItemManager itemManager, HaulingControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
// {
|
||||
// _data = data;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public new bool Execute(float delta)
|
||||
// {
|
||||
// if (Task != null)
|
||||
// {
|
||||
// if (!_taskStarted)
|
||||
// {
|
||||
// MoveTo(Task.Origin, true, OnPickup);
|
||||
// //MoveTo(haulingTask.Zone, OnOriginZoneArrival);
|
||||
// _taskStarted = true;
|
||||
// }
|
||||
// }
|
||||
// return base.Execute(delta);
|
||||
// }
|
||||
//
|
||||
// // void OnOriginZoneArrival()
|
||||
// // {
|
||||
// // var haulingTask = _context.ItemData.Get<HaulingTask>(Task);
|
||||
// //
|
||||
// // _entity.SetMessage("Entering pickup phase.");
|
||||
// //
|
||||
// // MoveTo(_context.ItemData.Get<Entity>(haulingTask.Origin), true, OnPickup);
|
||||
// // }
|
||||
//
|
||||
// void OnPickup()
|
||||
// {
|
||||
// Entity.SetParent(Task.Origin);
|
||||
//
|
||||
// _itemsCarried = Task.Origin.TryTransferItems(Entity, Task.ItemType, Task.Quantity - _itemsDelivered);
|
||||
//
|
||||
// if (_itemsCarried == 0)
|
||||
// {
|
||||
// FinishTask();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Wait(_data.DockTime, OnItemObtained);
|
||||
// }
|
||||
//
|
||||
// void OnItemObtained()
|
||||
// {
|
||||
// Entity.SetMessage("Entering delivery phase.");
|
||||
//
|
||||
// MoveTo(Task.Target, true, OnDelivery);
|
||||
// //MoveTo(target.Zone.Data.ID, OnTargetZoneArrival);
|
||||
// }
|
||||
//
|
||||
// // void OnTargetZoneArrival()
|
||||
// // {
|
||||
// // var haulingTask = _context.ItemData.Get<HaulingTask>(Task);
|
||||
// //
|
||||
// // MoveTo(_context.ItemData.Get<Entity>(haulingTask.Target), true, OnDelivery);
|
||||
// // }
|
||||
//
|
||||
// void OnDelivery()
|
||||
// {
|
||||
// Entity.SetParent(Task.Target);
|
||||
//
|
||||
// var itemsDelivered = Entity.TryTransferItems(Task.Target, Task.ItemType, _itemsCarried);
|
||||
// _itemsCarried -= itemsDelivered;
|
||||
// _itemsDelivered += itemsDelivered;
|
||||
//
|
||||
// Wait(_data.DockTime, () =>
|
||||
// {
|
||||
// // We were unable to transfer all onboard items to target entity, cargo is probably full. Bring back the surplus and end the mission
|
||||
// if(_itemsCarried > 0)
|
||||
// MoveTo(Task.Origin, true, ReturnSurplusToOrigin);
|
||||
// // We have delivered the target quantity of items, end the mission
|
||||
// else if(_itemsDelivered >= Task.Quantity)
|
||||
// FinishTask();
|
||||
// // We aren't done yet. Resetting the task will make us go for another delivery run
|
||||
// else
|
||||
// _taskStarted = false;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// void ReturnSurplusToOrigin()
|
||||
// {
|
||||
// Entity.SetParent(Task.Origin);
|
||||
//
|
||||
// Entity.TryTransferItems(Task.Origin, Task.ItemType, _itemsCarried);
|
||||
//
|
||||
// Wait(_data.DockTime, OnItemObtained);
|
||||
//
|
||||
// FinishTask();
|
||||
// }
|
||||
//
|
||||
// public PersistentBehaviorData Store()
|
||||
// {
|
||||
// return new HaulingControllerPersistence
|
||||
// {
|
||||
// Task = Task
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public void Restore(PersistentBehaviorData data)
|
||||
// {
|
||||
// var towingControllerPersistence = data as HaulingControllerPersistence;
|
||||
// Task = towingControllerPersistence.Task;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class HaulingControllerPersistence : PersistentBehaviorData
|
||||
// {
|
||||
// [JsonProperty("task"), Key(0)]
|
||||
// public HaulingTask Task;
|
||||
// }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8c5153aa2579174c901c552bfb495a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
// public class MiningControllerData : ControllerData
|
||||
// {
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new MiningController(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class MiningController : ControllerBase<Mining>, IBehavior, IPersistentBehavior, IInitializableBehavior
|
||||
// {
|
||||
//
|
||||
// private MiningControllerData _data;
|
||||
// private EquippedItem Item { get; }
|
||||
// private bool _taskStarted;
|
||||
// private int _asteroid = -1;
|
||||
// private MiningTool _miningTool;
|
||||
// private Switch _toolSwitch;
|
||||
//
|
||||
// public MiningController(ItemManager itemManager, MiningControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
// {
|
||||
// _data = data;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public new void Initialize()
|
||||
// {
|
||||
// // _miningTool = Entity.GetBehavior<MiningTool>();
|
||||
// // _toolSwitch = Entity.GetSwitch<MiningTool>();
|
||||
// base.Initialize();
|
||||
// }
|
||||
//
|
||||
// public new bool Execute(float delta)
|
||||
// {
|
||||
// // if (Task != null)
|
||||
// // {
|
||||
// // if (!_taskStarted)
|
||||
// // {
|
||||
// // NextAsteroid();
|
||||
// // _taskStarted = true;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (!Moving)
|
||||
// // {
|
||||
// // if (_entity.OccupiedCapacity < _entity.Capacity - 1)
|
||||
// // {
|
||||
// // var asteroidTransform = Zone.GetAsteroidTransform(Task.Asteroids, _asteroid);
|
||||
// // if (length(_entity.Position - asteroidTransform.xy) - asteroidTransform.w > _miningTool.Range)
|
||||
// // {
|
||||
// // _entity.SetMessage("Moving to target asteroid.");
|
||||
// // MoveTo(() => Zone.GetAsteroidTransform(Task.Asteroids, _asteroid).xy,
|
||||
// // () => Zone.GetAsteroidVelocity(Task.Asteroids, _asteroid));
|
||||
// // _toolSwitch.Activated = false;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (Zone.AsteroidExists(Task.Asteroids, _asteroid))
|
||||
// // {
|
||||
// // _miningTool.AsteroidBelt = Task.Asteroids;
|
||||
// // _miningTool.Asteroid = _asteroid;
|
||||
// // _toolSwitch.Activated = true;
|
||||
// // Aim.Objective = Zone.GetAsteroidTransform(Task.Asteroids, _asteroid).xy;
|
||||
// // Aim.Update(delta);
|
||||
// // }
|
||||
// // else NextAsteroid();
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // _entity.SetMessage("Out of cargo space. Returning home to offload cargo.");
|
||||
// // GoHome(OnArriveHome);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// return base.Execute(delta);
|
||||
// }
|
||||
//
|
||||
// // private void OnArriveHome()
|
||||
// // {
|
||||
// // var homeEntity = _context.ItemData.Get<Entity>(HomeEntity);
|
||||
// // foreach (var item in _entity.Cargo
|
||||
// // .Select(id => _context.ItemData.Get<ItemInstance>(id))
|
||||
// // .Where(item => item is SimpleCommodity)
|
||||
// // .Cast<SimpleCommodity>()
|
||||
// // .ToArray())
|
||||
// // {
|
||||
// // int quantity = min((int) ((homeEntity.Capacity - homeEntity.OccupiedCapacity) / _context.GetData(item).Size), item.Quantity);
|
||||
// // var newItem = _entity.RemoveCargo(item, quantity);
|
||||
// // homeEntity.AddCargo(newItem);
|
||||
// //
|
||||
// // if (quantity < item.Quantity)
|
||||
// // {
|
||||
// // homeEntity.SetMessage("Colony is out of cargo space. Closing Mining Task.");
|
||||
// // FinishTask();
|
||||
// // _taskStarted = false;
|
||||
// // return;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// private void NextAsteroid()
|
||||
// {
|
||||
// _asteroid = Zone.NearestAsteroid(Task.Asteroids, Entity.Position.xz);
|
||||
// Entity.SetMessage("Selecting new asteroid.");
|
||||
// }
|
||||
//
|
||||
// public PersistentBehaviorData Store()
|
||||
// {
|
||||
// return new MiningControllerPersistence
|
||||
// {
|
||||
// Task = Task
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public void Restore(PersistentBehaviorData data)
|
||||
// {
|
||||
// var miningControllerPersistence = data as MiningControllerPersistence;
|
||||
// Task = miningControllerPersistence.Task;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class MiningControllerPersistence : PersistentBehaviorData
|
||||
// {
|
||||
// [JsonProperty("task"), Key(0)]
|
||||
// public Mining Task;
|
||||
// }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b476455dca4333e4da76388aae46ac5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
// public class ParticleEffectData : BehaviorData
|
||||
// {
|
||||
// [InspectablePrefab, JsonProperty("Particles"), Key(1)]
|
||||
// public string ParticlesPrefab;
|
||||
//
|
||||
// [InspectableField, JsonProperty("thrust"), Key(2)]
|
||||
// public bool AreaEmitter;
|
||||
//
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new ParticleEffect(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class ParticleEffect : IBehavior, IAlwaysUpdatedBehavior
|
||||
// {
|
||||
// private ParticleEffectData _data;
|
||||
//
|
||||
// public Entity Entity { get; }
|
||||
// public EquippedItem Item { get; }
|
||||
// public ItemManager Context { get; }
|
||||
//
|
||||
// public BehaviorData Data => _data;
|
||||
//
|
||||
// public float Emission { get; private set; }
|
||||
//
|
||||
// public ParticleEffect(ItemManager context, ParticleEffectData data, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// Context = context;
|
||||
// _data = data;
|
||||
// Entity = entity;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public float Execute(float delta, float input)
|
||||
// {
|
||||
// Emission = saturate(input);
|
||||
// return input;
|
||||
// }
|
||||
//
|
||||
// public void Update(float delta)
|
||||
// {
|
||||
// Emission = 0;
|
||||
// }
|
||||
// }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c26dc8102d619a429a178bc6670242d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
// public class TowingControllerData : ControllerData
|
||||
// {
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new TowingController(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class TowingController : ControllerBase<StationTowing>, IBehavior, IPersistentBehavior
|
||||
// {
|
||||
//
|
||||
// private TowingControllerData _data;
|
||||
// private EquippedItem Item { get; }
|
||||
// private bool _taskStarted;
|
||||
//
|
||||
// public TowingController(ItemManager itemManager, TowingControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
// {
|
||||
// _data = data;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public new bool Execute(float delta)
|
||||
// {
|
||||
// if (Task != null)
|
||||
// {
|
||||
// if (!_taskStarted)
|
||||
// {
|
||||
// MoveTo(Task.Station, true, OnPickup);
|
||||
// _taskStarted = true;
|
||||
// }
|
||||
// }
|
||||
// return base.Execute(delta);
|
||||
// }
|
||||
//
|
||||
// // void OnZoneArrival()
|
||||
// // {
|
||||
// // var towingTask = _context.ItemData.Get<StationTowing>(Task);
|
||||
// //
|
||||
// // _entity.SetMessage("Entering pickup phase.");
|
||||
// //
|
||||
// // MoveTo(_context.ItemData.Get<Entity>(towingTask.Station), true, OnPickup);
|
||||
// // }
|
||||
//
|
||||
// void OnPickup()
|
||||
// {
|
||||
// Task.Station.SetParent(Entity);
|
||||
//
|
||||
// Entity.SetMessage("Entering delivery phase.");
|
||||
//
|
||||
// MoveTo(() =>
|
||||
// {
|
||||
// var orbitParent = Zone.GetOrbitPosition(Task.OrbitParent);
|
||||
// var parentToUs = Entity.Position.xz - orbitParent;
|
||||
// return orbitParent + normalize(parentToUs) * Task.OrbitDistance;
|
||||
// }, () => Zone.GetOrbitVelocity(Task.OrbitParent), OnDelivery);
|
||||
// }
|
||||
//
|
||||
// void OnDelivery()
|
||||
// {
|
||||
// Task.Station.RemoveParent();
|
||||
//
|
||||
// Entity.SetMessage("Target delivered. Returning Home.");
|
||||
//
|
||||
// var orbit = Zone.CreateOrbit(Task.OrbitParent, Entity.Position.xz);
|
||||
// Task.Station.OrbitData = orbit.ID;
|
||||
//
|
||||
// FinishTask();
|
||||
// _taskStarted = false;
|
||||
// }
|
||||
//
|
||||
// public PersistentBehaviorData Store()
|
||||
// {
|
||||
// return new TowingControllerPersistence
|
||||
// {
|
||||
// Task = Task
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public void Restore(PersistentBehaviorData data)
|
||||
// {
|
||||
// var towingControllerPersistence = data as TowingControllerPersistence;
|
||||
// Task = towingControllerPersistence.Task;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class TowingControllerPersistence : PersistentBehaviorData
|
||||
// {
|
||||
// [JsonProperty("task"), Key(0)]
|
||||
// public StationTowing Task;
|
||||
// }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de134a549a7d86f43a3590b78a2edeee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -135,4 +135,12 @@ public class OrderAttribute : Attribute
|
|||
{
|
||||
Order = order;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class InspectorHeaderAttribute : Attribute
|
||||
{
|
||||
public readonly string header;
|
||||
|
||||
public InspectorHeaderAttribute(string header) => this.header = header;
|
||||
}
|
||||
|
|
@ -12,7 +12,8 @@ public class ZoneEnvironment
|
|||
[JsonProperty("nebula"), Key(0)] public NebulaSettings Nebula;
|
||||
[JsonProperty("flow"), Key(1)] public FlowSettings Flow;
|
||||
[JsonProperty("noise"), Key(2)] public NoiseSettings Noise;
|
||||
[JsonProperty("lighting"), Key(2)] public AmbientLightingSettings Lighting;
|
||||
[JsonProperty("lighting"), Key(3)] public AmbientLightingSettings Lighting;
|
||||
[JsonProperty("grid"), Key(4)] public GridSettings Grid;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -33,6 +34,13 @@ public class NebulaSettings
|
|||
[JsonProperty("safetyDistance"), Key(10)] public float SafetyDistance;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class GridSettings
|
||||
{
|
||||
[JsonProperty("enabled"), Key(0)] public bool Enabled;
|
||||
[JsonProperty("offset"), Key(1)] public float Offset;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class AmbientLightingSettings
|
||||
{
|
||||
|
|
@ -50,7 +58,7 @@ public class FlowSettings
|
|||
[JsonProperty("scrollSpeed"), Key(2)] public float GlobalScrollSpeed;
|
||||
[JsonProperty("period"), Key(3)] public float Period;
|
||||
[JsonProperty("amplitudeSlope"), Key(4)] public float SlopeAmplitude;
|
||||
[JsonProperty("amplitudeSwirl"), Key(4)] public float SwirlAmplitude;
|
||||
[JsonProperty("amplitudeSwirl"), Key(5)] public float SwirlAmplitude;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -151,4 +159,3 @@ public class RadialWaveBrush : TextureBrush
|
|||
return cos((ang + Phase.x) * Frequency.x * PI + (pow(dist, WaveExponent) + Phase.y) * Frequency.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -523,7 +523,6 @@ public class Galaxy
|
|||
{
|
||||
MinHeap<DijkstraVertex> unsearchedNodes = new MinHeap<DijkstraVertex>();
|
||||
unsearchedNodes.PushObj(new DijkstraVertex{Zone = source}, 0);
|
||||
//SortedList<float,DijkstraVertex> members = new SortedList<float,DijkstraVertex>{{0, new DijkstraVertex{Zone = source}}};
|
||||
var searched = new HashSet<GalaxyZone>();
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -543,7 +542,7 @@ public class Galaxy
|
|||
foreach (var dijkstraStar in zonesToSearch
|
||||
// Cost is parent cost plus distance squared
|
||||
.Select(zone => new DijkstraVertex {Parent = s, Zone = zone, Cost = s.Cost + lengthsq(s.Zone.Position - zone.Position)}))
|
||||
// Add new member to list, sorted by cost plus optional heuristic
|
||||
// Add new member to list, sorted by cost plus optional heuristic
|
||||
unsearchedNodes.PushObj(dijkstraStar, bestFirst ? dijkstraStar.Cost + lengthsq(dijkstraStar.Zone.Position - target.Position) : dijkstraStar.Cost);
|
||||
searched.Add(s.Zone);
|
||||
}
|
||||
|
|
@ -582,4 +581,4 @@ public class LocationStory
|
|||
public LocationType Type;
|
||||
public int Turrets;
|
||||
public Dictionary<string, List<GalaxyQuest>> KnotQuests = new Dictionary<string, List<GalaxyQuest>>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,112 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class FieldTester : MonoBehaviour
|
||||
{
|
||||
public int PickupCount;
|
||||
public ItemPickup[] PickupPrefabs;
|
||||
public float PickupTravelDistance;
|
||||
public float PickupTravelTimeMin;
|
||||
public float PickupTravelTimeMax;
|
||||
public float PickupSizeMin;
|
||||
public float PickupSizeMax;
|
||||
public float ScaleExponent;
|
||||
public float PickupSpawnDistanceMin;
|
||||
public float PickupSpawnDistanceMax;
|
||||
public Camera Camera;
|
||||
public FieldDriver TestField;
|
||||
public PropertiesPanel Properties;
|
||||
|
||||
private AetheriaInput _input;
|
||||
private bool _forceThrust;
|
||||
private float _throttleDecay = 2;
|
||||
private bool _directionalPush;
|
||||
private float _twistFront;
|
||||
private float _twistRear;
|
||||
|
||||
private List<(float lerp, float time, Transform transform)> _pickups = new List<(float lerp, float time, Transform transform)>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_input = new AetheriaInput();
|
||||
_input.Player.Enable();
|
||||
Properties.AddField("Time Scale", () => Time.timeScale, f => Time.timeScale = f, 0, 2);
|
||||
Properties.AddField("FOV", () => Camera.fieldOfView, f => Camera.fieldOfView = f, 15, 45);
|
||||
Properties.AddButton("Melee", () => TestField.Melee());
|
||||
Properties.AddField("Force Thrust", () => _forceThrust, b => _forceThrust = b);
|
||||
Properties.AddField("Directional Push", () => _directionalPush, b => _directionalPush = b);
|
||||
Properties.AddField("Throttle Decay", () => _throttleDecay, f => _throttleDecay = f);
|
||||
Properties.Inspect(TestField, true, true);
|
||||
Properties.AddProperty("Current Hits", () => TestField.HitCount.ToString());
|
||||
Properties.AddProperty("Push X", () => $"{(int)(TestField.Push.x * 100)}%");
|
||||
Properties.AddProperty("Push Y", () => $"{(int)(TestField.Push.y * 100)}%");
|
||||
Properties.AddProperty("Front Twist", () => $"{(int)(TestField.FrontTwist * 100)}%");
|
||||
Properties.AddProperty("Rear Twist", () => $"{(int)(TestField.RearTwist * 100)}%");
|
||||
|
||||
for (int i = 0; i < PickupCount; i++)
|
||||
{
|
||||
var l = (float)i / PickupCount;
|
||||
var pickup = Instantiate(PickupPrefabs[(int)(l * PickupPrefabs.Length)], transform);
|
||||
var i1 = i;
|
||||
var click = pickup.GetComponent<ClickableCollider>();
|
||||
click.OnClick += (collider, data, ray, hit) =>
|
||||
{
|
||||
if (!TestField.CanGrab) return;
|
||||
click.Clear();
|
||||
var p = _pickups[i1];
|
||||
var travelTime = lerp(PickupTravelTimeMin, PickupTravelTimeMax, l);
|
||||
TestField.GrabObject(p.transform, Vector3.forward * (PickupTravelDistance / travelTime));
|
||||
p.transform = null;
|
||||
_pickups[i1] = p;
|
||||
};
|
||||
|
||||
pickup.ScanLabelContainer.gameObject.SetActive(false);
|
||||
pickup.enabled = false;
|
||||
var pickupTransform = pickup.transform;
|
||||
var time = Random.value;
|
||||
var circle = Random.insideUnitCircle.normalized * Random.Range(PickupSpawnDistanceMin,PickupSpawnDistanceMax);
|
||||
pickupTransform.position = new Vector3(circle.x,circle.y, (time-.5f)*PickupTravelDistance);
|
||||
_pickups.Add((l, time, pickupTransform));
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
TestField.Throttle = _forceThrust ? float2(0,1) : _input.Player.Move.ReadValue<Vector2>();
|
||||
var move = _forceThrust ? float2(0,1) : (float2)_input.Player.Move.ReadValue<Vector2>();
|
||||
var turn = _input.Player.Turn.ReadValue<float>();
|
||||
if (_directionalPush)
|
||||
{
|
||||
TestField.Push = AetheriaMath.Damp(TestField.Push, move, _throttleDecay, Time.deltaTime);
|
||||
TestField.FrontTwist = AetheriaMath.Damp(TestField.FrontTwist,
|
||||
turn,
|
||||
_throttleDecay, Time.deltaTime);
|
||||
TestField.RearTwist = AetheriaMath.Damp(TestField.RearTwist,
|
||||
turn,
|
||||
_throttleDecay, Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
TestField.Push = AetheriaMath.Damp(TestField.Push, float2(0,move.y), _throttleDecay, Time.deltaTime);
|
||||
TestField.FrontTwist = AetheriaMath.Damp(TestField.FrontTwist,
|
||||
clamp(turn + move.x, -1, 1) * (1+min(move.y,0)),
|
||||
_throttleDecay, Time.deltaTime);
|
||||
TestField.RearTwist = AetheriaMath.Damp(TestField.RearTwist,
|
||||
clamp(turn - move.x, -1, 1) * (1+min(-move.y,0)),
|
||||
_throttleDecay, Time.deltaTime);
|
||||
}
|
||||
|
||||
for (var i = 0; i < _pickups.Count; i++)
|
||||
{
|
||||
var (l, time, t) = _pickups[i];
|
||||
if (t == null) continue;
|
||||
time = frac(time + Time.deltaTime / lerp(PickupTravelTimeMin, PickupTravelTimeMax, l));
|
||||
t.localScale = Vector3.one * lerp(PickupSizeMin, PickupSizeMax, l) * Zone.PowerPulse(time - .5f, ScaleExponent);
|
||||
t.position = new Vector3(t.position.x, t.position.y, (time - .5f) * PickupTravelDistance);
|
||||
_pickups[i] = (l, time, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -466,7 +466,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
Transform dragObject = null;
|
||||
weaponGroups.OnBeginDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
//Debug.Log($"Began dragging weapon group {x.group}");
|
||||
Debug.Log($"Began dragging weapon group {x.group}");
|
||||
GameManager.BeginDrag(new WeaponGroupDragObject(x.group));
|
||||
dragObject = Instantiate(weaponGroups.Groups[x.group], DragParent, true).transform;
|
||||
dragOffset = (Vector2)dragObject.position - x.pointerEventData.position;
|
||||
|
|
@ -477,7 +477,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
});
|
||||
weaponGroups.OnEndDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
//Debug.Log($"Ended dragging weapon group {x.group}");
|
||||
Debug.Log($"Ended dragging weapon group {x.group}");
|
||||
GameManager.EndDrag();
|
||||
Destroy(dragObject.gameObject);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using static Unity.Mathematics.noise;
|
|||
[RequireComponent( typeof( Camera ) )]
|
||||
public class VolumeSampling : MonoBehaviour
|
||||
{
|
||||
public Transform GridMesh;
|
||||
public Camera GridCamera;
|
||||
public GameSettings Settings;
|
||||
|
||||
|
|
@ -48,6 +49,13 @@ public class VolumeSampling : MonoBehaviour
|
|||
Shader.SetGlobalVector("_GridTransform", new Vector4(_gridTransform.position.x,_gridTransform.position.z,GridCamera.orthographicSize*2));
|
||||
|
||||
var environment = ActionGameManager.Instance?.CurrentEnvironment ?? Settings.DefaultEnvironment;
|
||||
|
||||
if (GridMesh != null)
|
||||
{
|
||||
GridMesh.gameObject.SetActive(environment.Grid.Enabled);
|
||||
GridMesh.position = new Vector3(_gridTransform.position.x, environment.Grid.Offset, _gridTransform.position.z);
|
||||
GridMesh.localScale = new Vector3(GridCamera.orthographicSize, 1, GridCamera.orthographicSize);
|
||||
}
|
||||
|
||||
// Volumetric sampling parameters are used by several shaders
|
||||
Shader.SetGlobalTexture("_NebulaSurfaceHeight", NebulaSurfaceHeight);
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
var distance = length(difference);
|
||||
|
||||
entityInstance.CompassIcon.gameObject.SetActive(
|
||||
PerspectiveEntity.EntityInfoGathered.ContainsKey(entityInstance.Entity) &&
|
||||
PerspectiveEntity.EntityInfoGathered[entityInstance.Entity] > Settings.GameplaySettings.TargetDetectionInfoThreshold &&
|
||||
distance > _minimapDistance);
|
||||
entityInstance.CompassIcon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
|
||||
|
|
@ -699,4 +700,4 @@ public class AsteroidBeltUI
|
|||
_mesh.vertices = _vertices;
|
||||
//_collider.sharedMesh = _mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue