Playability
Fixed loadout generator tutorial edge cases Recreated missing items Created field shader & test scene
This commit is contained in:
parent
69aca09f63
commit
47e500e1ce
72 changed files with 3579 additions and 693 deletions
|
|
@ -47,9 +47,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
if (_cultCache != null) return _cultCache;
|
||||
|
||||
_cultCache = new CultCache();
|
||||
_cultCache.AddBackingStore(new MultiFileJsonBackingStore(GameDataDirectory.FullName));
|
||||
// _cultCache.AddBackingStore(
|
||||
// new SingleFileMessagePackBackingStore(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack")));
|
||||
//RethinkConnection.RethinkConnect(_cultCache, "gamecult.org:28016", DatabaseName);
|
||||
//_cultCache.AddBackingStore(new MultiFileJsonBackingStore(GameDataDirectory.FullName));
|
||||
_cultCache.AddBackingStore(
|
||||
new SingleFileMessagePackBackingStore(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack")));
|
||||
|
||||
// Particularly heavy objects should be stored in / retrieved from MsgPack files as it's much tighter than JSON
|
||||
// Such as NameFiles, which are just huge collections of geonames used to condition Markov chains
|
||||
|
|
@ -425,7 +426,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
slot.PointerEnterTrigger.OnPointerEnterAsObservable().Subscribe(_ =>
|
||||
{
|
||||
//Debug.Log($"Pointer entered action bar slot {controlPath}");
|
||||
Debug.Log($"Pointer entered action bar slot {controlPath}");
|
||||
RegisterDragTarget(dragAction =>
|
||||
{
|
||||
//Debug.Log("Registering binding!");
|
||||
|
|
@ -520,6 +521,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
.5f) : new LoadoutGenerator(
|
||||
ref ItemManager.Random,
|
||||
ItemManager,
|
||||
CurrentGalaxy,
|
||||
Zone.GalaxyZone,
|
||||
nearestFaction,
|
||||
.5f);
|
||||
|
||||
|
|
@ -730,8 +733,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
SectorMap.QueueZoneReveal(CurrentGalaxy.Entrance.AdjacentZones.Prepend(CurrentGalaxy.Entrance));
|
||||
PopulateLevel(CurrentGalaxy.Entrance);
|
||||
var loadoutGenerator = IsTutorial ? new LoadoutGenerator(ref ItemManager.Random, ItemManager, null, 2) :
|
||||
new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentGalaxy, Zone.GalaxyZone, null, 2);
|
||||
var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentGalaxy, Zone.GalaxyZone, IsTutorial ? CurrentGalaxy.ResolveFaction(Settings.TutorialGenerationSettings.ProtagonistFaction) : null, 2);
|
||||
var ship = EntitySerializer.Unpack(
|
||||
ItemManager,
|
||||
Zone,
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public class EntityInstance : MonoBehaviour
|
|||
_pingBrightness = pingMesh.material.GetFloat("_Depth");
|
||||
_currentPing = (pingInstance, pingMesh);
|
||||
};
|
||||
sensor.OnPingEnd += () => Destroy(_currentPing.transform.gameObject);
|
||||
sensor.OnPingEnd += OnSensorPingEnd;
|
||||
}
|
||||
|
||||
if (behavior is InstantWeapon instantWeapon)
|
||||
|
|
@ -443,7 +443,12 @@ public class EntityInstance : MonoBehaviour
|
|||
_influenceInstance.transform.localScale = Vector3.one * orbital.SecurityRadius;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnSensorPingEnd()
|
||||
{
|
||||
Destroy(_currentPing.transform.gameObject);
|
||||
}
|
||||
|
||||
public Transform GetBarrel(HardpointData hardpoint)
|
||||
{
|
||||
if (Barrels.ContainsKey(hardpoint))
|
||||
|
|
@ -519,6 +524,8 @@ public class EntityInstance : MonoBehaviour
|
|||
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
if(_sensor!=null)
|
||||
_sensor.OnPingEnd -= OnSensorPingEnd;
|
||||
if (_influenceInstance) Destroy(_influenceInstance.gameObject);
|
||||
Destroy(LocalSpace.gameObject);
|
||||
foreach(var x in _subscriptions)
|
||||
|
|
|
|||
147
Assets/Scripts/Gameplay/FieldDriver.cs
Normal file
147
Assets/Scripts/Gameplay/FieldDriver.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Animations;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class FieldDriver : MonoBehaviour
|
||||
{
|
||||
[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 int MaxHits;
|
||||
[Inspectable]
|
||||
public ExponentialCurve MagnitudeTimeScaling;
|
||||
|
||||
[Inspectable]
|
||||
public float MeleeRange;
|
||||
[Inspectable]
|
||||
public float MeleeRangeExponent;
|
||||
[Inspectable]
|
||||
public float MeleeFlatness;
|
||||
[Inspectable]
|
||||
public float MeleeShaping;
|
||||
[Inspectable]
|
||||
public float MeleeDuration;
|
||||
[Inspectable]
|
||||
public float MeleeAngle;
|
||||
[Inspectable]
|
||||
public float MeleeAngleExponent;
|
||||
[Inspectable]
|
||||
public Axis RefractionAxis = Axis.X;
|
||||
|
||||
private Material _field;
|
||||
private ComputeBuffer _hitBuffer;
|
||||
private List<FieldHit> _hits = new List<FieldHit>();
|
||||
private float _pushWaveOffset;
|
||||
private double2 _throttle;
|
||||
private float _meleeTime;
|
||||
private bool _meleeActive;
|
||||
|
||||
private struct FieldHit
|
||||
{
|
||||
public float3 Position;
|
||||
public float3 Direction;
|
||||
public float Magnitude;
|
||||
public float Time;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_field = GetComponent<MeshRenderer>().material;
|
||||
var clickableCollider = GetComponent<ClickableCollider>();
|
||||
if(clickableCollider!=null)
|
||||
{
|
||||
clickableCollider.OnClick += (_, _, ray, hit) =>
|
||||
{
|
||||
AddHit(hit.point, ray.direction, TestMagnitude);
|
||||
};
|
||||
}
|
||||
_hitBuffer = new ComputeBuffer(MaxHits, 32);
|
||||
}
|
||||
|
||||
public void AddHit(float3 position, float3 direction, float magnitude)
|
||||
{
|
||||
if (_hits.Count >= MaxHits) return;
|
||||
var hit = new FieldHit
|
||||
{
|
||||
Position = normalize(transform.InverseTransformPoint(position)),
|
||||
Direction = normalize(transform.rotation * direction),
|
||||
Magnitude = magnitude,
|
||||
Time = 0
|
||||
};
|
||||
Debug.Log($"Received hit: Position={hit.Position}, Direction={hit.Direction}");
|
||||
_hits.Add(hit);
|
||||
}
|
||||
|
||||
public int HitCount => _hits.Count;
|
||||
|
||||
public void Melee()
|
||||
{
|
||||
_meleeActive = true;
|
||||
_meleeTime = 0;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
for (int i = 0; i < _hits.Count; i++)
|
||||
{
|
||||
var hit = _hits[i];
|
||||
hit.Time += Time.deltaTime / MagnitudeTimeScaling.Evaluate(_hits[i].Magnitude);
|
||||
_hits[i] = hit;
|
||||
if (hit.Time > 1)
|
||||
{
|
||||
_hits.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (_meleeActive)
|
||||
{
|
||||
_meleeTime += Time.deltaTime / MeleeDuration;
|
||||
if (_meleeTime > 1)
|
||||
{
|
||||
_meleeActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
_throttle = AetheriaMath.Damp(_throttle, Throttle, ThrottleDecay, Time.deltaTime);
|
||||
var throttleDir = (float2) normalize(_throttle);
|
||||
|
||||
var throttleMag = min(length(_throttle), 1);
|
||||
|
||||
_pushWaveOffset = frac(_pushWaveOffset + Time.deltaTime * FlowSpeed * (float) pow(throttleMag, FlowSpeedThrottleExponent));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Gameplay/FieldDriver.cs.meta
Normal file
11
Assets/Scripts/Gameplay/FieldDriver.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a9ee74b07ad0390459302080d186cc58
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue