Replace the Database Tools with the Studio and cut Unity over
Cut 8b. The Unity project compiles with 0 errors in 6000.3.24f1 batchmode. Packages: manifest.json pins org.gamecult.cultlib at cultlib-unity-v1.0.57 and org.gamecult.caching.unity at caching-unity-v1.2.0, next to the 8a CultMath tag. Aetheria.Shared.Unity references GameCult.CultLib and keeps noEngineReferences. The Database Tools (Assets/Scripts/CultCache/Editor) are deleted in this commit, alongside their five ported drawers in Assets/Scripts/Editor/CultCacheDrawers.cs, each an [CultInspectorDrawer] ICultInspectorDrawer: - InspectableType: popup of the attribute type's [Union] member names, writing the string. - InspectableColor: float3 and float4 through ColorField. - InspectableAnimationCurve: float4[] and BezierCurve through CurveField. - InspectableTemperature: Kelvin, Celsius and Fahrenheit fields over one value. - InspectableSchematicShape: size and cell toggles. The old drawer also drew the item's schematic texture and tinted hull hardpoints, which need the parent document. The tagged Studio hands a drawer only the value, so those wait on the Studio exposing the open record. Unity call sites: - ActionGameManager opens the catalog through AetheriaStores; Cut 10 adds the run and player stores. - Refs resolve through ItemManager.GetData or Get(ref); orbit, planet and belt maps key by CultRecordKey; identity is compared by reference or key. - The PlayerSettings.msgpack reader and writer, which Cut 10 deletes, pass CultDocumentMessagePackSerialization.OptionsFor, since the embedded run reaches CultMath values and refs. Keyboard layouts need no resolver and keep MessagePack's defaults until Cut 10. - The input map uses the nested action to binding shape. - PropertiesPanel reads CultInspectorRangeAttribute. - NameTools loses its legacy name-file writer. - Slime compares serialized settings instead of the deleted SHA1 helper. - FieldDriver drops InspectorHeader. - .gitignore covers the test project's build output. Builds: Aetheria.Shared, AetherDb, Aetheria.Shared.Tests (6/6), Unity batchmode (0 errors). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
c2026142be
commit
9bdf6ef23f
21 changed files with 232 additions and 117 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -63,6 +63,8 @@ ExportedObj/
|
|||
/Aetheria.Shared/obj/
|
||||
/tools/**/bin/
|
||||
/tools/**/obj/
|
||||
/tests/**/bin/
|
||||
/tests/**/obj/
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
|
|
|
|||
114
Assets/Scripts/Editor/CultCacheDrawers.cs
Normal file
114
Assets/Scripts/Editor/CultCacheDrawers.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CultMath;
|
||||
using CultMath.UnityBridge;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Unity.Caching.Editor;
|
||||
using MessagePack;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static CultMath.math;
|
||||
|
||||
// Aetheria's Studio drawers: the inspection meaning CultLib's CultInspector attributes do not carry. Each draws only
|
||||
// the value types its attribute sits on and hands anything else back to built-in drawing.
|
||||
|
||||
// The simple name of one of the attribute type's [Union] members, as a string
|
||||
[CultInspectorDrawer(typeof(InspectableTypeAttribute))]
|
||||
public sealed class InspectableTypeDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(CultInspector inspector, string label, Type type, object value, MemberInfo member)
|
||||
{
|
||||
var attribute = member?.GetCustomAttribute<InspectableTypeAttribute>();
|
||||
if (type != typeof(string) || attribute == null) return inspector.DrawDefault(label, type, value, member);
|
||||
var names = attribute.Type.GetCustomAttributes<UnionAttribute>(false).Select(union => union.SubType.Name).ToArray();
|
||||
var index = Array.IndexOf(names, value as string) + 1;
|
||||
var picked = EditorGUILayout.Popup(label, index, names.Prepend("None").ToArray());
|
||||
return picked == index ? value : picked == 0 ? null : names[picked - 1];
|
||||
}
|
||||
}
|
||||
|
||||
[CultInspectorDrawer(typeof(InspectableColorAttribute))]
|
||||
public sealed class InspectableColorDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(CultInspector inspector, string label, Type type, object value, MemberInfo member)
|
||||
{
|
||||
if (type == typeof(float3)) return EditorGUILayout.ColorField(label, ((float3) value).ToColor()).ToFloat3();
|
||||
if (type == typeof(float4)) return EditorGUILayout.ColorField(label, ((float4) value).ToColor()).ToCultMath();
|
||||
return inspector.DrawDefault(label, type, value, member);
|
||||
}
|
||||
}
|
||||
|
||||
// Keyframes as (time, value, in tangent, out tangent), edited as a curve over the unit square
|
||||
[CultInspectorDrawer(typeof(InspectableAnimationCurveAttribute))]
|
||||
public sealed class InspectableAnimationCurveDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(CultInspector inspector, string label, Type type, object value, MemberInfo member)
|
||||
{
|
||||
float4[] keys;
|
||||
if (type == typeof(float4[])) keys = value as float4[];
|
||||
else if (type == typeof(BezierCurve)) keys = (value as BezierCurve)?.Keys;
|
||||
else return inspector.DrawDefault(label, type, value, member);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var curve = EditorGUILayout.CurveField(label, keys?.Length > 0 ? keys.ToCurve() : new AnimationCurve(), Color.yellow, new Rect(0, 0, 1, 1));
|
||||
if (!EditorGUI.EndChangeCheck()) return value;
|
||||
var edited = curve.keys.Select(k => float4(k.time, k.value, k.inTangent, k.outTangent)).ToArray();
|
||||
if (type == typeof(float4[])) return edited;
|
||||
var bezier = value as BezierCurve ?? new BezierCurve();
|
||||
bezier.Keys = edited;
|
||||
return bezier;
|
||||
}
|
||||
}
|
||||
|
||||
// One Kelvin value shown and edited as Kelvin, Celsius and Fahrenheit
|
||||
[CultInspectorDrawer(typeof(InspectableTemperatureAttribute))]
|
||||
public sealed class InspectableTemperatureDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(CultInspector inspector, string label, Type type, object value, MemberInfo member)
|
||||
{
|
||||
if (type != typeof(float)) return inspector.DrawDefault(label, type, value, member);
|
||||
var kelvin = (float) value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PrefixLabel(label);
|
||||
var indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
GUILayout.Label("°K", EditorStyles.miniLabel, GUILayout.Width(20));
|
||||
kelvin = EditorGUILayout.DelayedFloatField(kelvin);
|
||||
GUILayout.Label("°C", EditorStyles.miniLabel, GUILayout.Width(20));
|
||||
kelvin = EditorGUILayout.DelayedFloatField(kelvin - 273.15f) + 273.15f;
|
||||
GUILayout.Label("°F", EditorStyles.miniLabel, GUILayout.Width(20));
|
||||
kelvin = (EditorGUILayout.DelayedFloatField((kelvin - 273.15f) * 1.8f + 32) - 32) / 1.8f + 273.15f;
|
||||
EditorGUI.indentLevel = indent;
|
||||
}
|
||||
return EditorGUI.EndChangeCheck() ? kelvin : value;
|
||||
}
|
||||
}
|
||||
|
||||
// A size and a toggle per cell. The Database Tools drawer also laid the item's schematic texture under the grid,
|
||||
// derived the height from its aspect, and tinted hull hardpoints. Those read the document the shape belongs to, and a
|
||||
// Studio drawer is handed only the value, so they wait on the Studio exposing the open record.
|
||||
[CultInspectorDrawer(typeof(InspectableSchematicShapeAttribute))]
|
||||
public sealed class InspectableSchematicShapeDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(CultInspector inspector, string label, Type type, object value, MemberInfo member)
|
||||
{
|
||||
if (type != typeof(Shape)) return inspector.DrawDefault(label, type, value, member);
|
||||
var shape = value as Shape ?? new Shape();
|
||||
EditorGUILayout.LabelField(label);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
var width = max(EditorGUILayout.DelayedIntField("Width", shape.Width), 1);
|
||||
var height = max(EditorGUILayout.DelayedIntField("Height", shape.Height), 1);
|
||||
if (width != shape.Width || height != shape.Height) shape.Resize(width, height);
|
||||
}
|
||||
|
||||
for (var y = shape.Height - 1; y >= 0; y--)
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
for (var x = 0; x < shape.Width; x++)
|
||||
shape[int2(x, y)] = GUILayout.Toggle(shape[int2(x, y)], GUIContent.none, GUILayout.Width(16));
|
||||
return shape;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Editor/CultCacheDrawers.cs.meta
Normal file
11
Assets/Scripts/Editor/CultCacheDrawers.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e0b4c2d9f1a4b7e8c3d5a6f7b8e9c01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -11,7 +11,6 @@ using Random = CultMath.Random;
|
|||
|
||||
public class NameTools : EditorWindow
|
||||
{
|
||||
public TextAsset[] NameFiles;
|
||||
public int NameGeneratorMinLength = 5;
|
||||
public int NameGeneratorMaxLength = 10;
|
||||
public int NameGeneratorOrder = 4;
|
||||
|
|
@ -37,27 +36,6 @@ public class NameTools : EditorWindow
|
|||
|
||||
void OnGUI()
|
||||
{
|
||||
ScriptableObject target = this;
|
||||
SerializedObject so = new SerializedObject(target);
|
||||
SerializedProperty stringsProperty = so.FindProperty("NameFiles");
|
||||
|
||||
EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
|
||||
so.ApplyModifiedProperties(); // Remember to apply modified properties
|
||||
|
||||
if (GUILayout.Button("Save Name Files"))
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
var nameFilesDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("NameFile");
|
||||
foreach (var nameFile in NameFiles)
|
||||
{
|
||||
var entry = new NameFile
|
||||
{
|
||||
Name = nameFile.name,
|
||||
Names = nameFile.text.Split('\n')
|
||||
};
|
||||
File.WriteAllBytes(Path.Combine(nameFilesDirectory.FullName, $"{entry.ID.ToString()}.msgpack"), MessagePackSerializer.Serialize((DatabaseEntry) entry));
|
||||
}
|
||||
}
|
||||
|
||||
nameFile = (TextAsset) EditorGUILayout.ObjectField("Name File", nameFile, typeof(TextAsset), false);
|
||||
minWordLength = EditorGUILayout.IntField("Minimum File Word Length", minWordLength);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using TMPro;
|
||||
|
|
@ -47,7 +46,7 @@ public class ActionBarSlot : MonoBehaviour
|
|||
{
|
||||
ActionBarConsumableBinding actionBarConsumableBinding => new SavedActionBarConsumableBinding
|
||||
{
|
||||
Target = new DatabaseLink<ConsumableItemData>{LinkID = actionBarConsumableBinding.Target.ID}
|
||||
Target = actionBarConsumableBinding.Entity.ItemManager.ItemData.RefOf(actionBarConsumableBinding.Target)
|
||||
},
|
||||
ActionBarGearBinding actionBarGearBinding => new SavedActionBarGearBinding
|
||||
{
|
||||
|
|
@ -70,7 +69,7 @@ public class ActionBarSlot : MonoBehaviour
|
|||
new ActionBarConsumableBinding(
|
||||
entity,
|
||||
this,
|
||||
savedActionBarConsumableBinding.Target.Value),
|
||||
entity.ItemManager.ItemData.Get(savedActionBarConsumableBinding.Target)),
|
||||
SavedActionBarGearBinding savedActionBarGearBinding =>
|
||||
new ActionBarGearBinding(
|
||||
entity,
|
||||
|
|
@ -128,7 +127,7 @@ public class ActionBarConsumableBinding : ActionBarBinding
|
|||
|
||||
public override void Update()
|
||||
{
|
||||
Slot.QuantityRemaining.text = $"{Entity.CountItemsInCargo(Target.ID)}";
|
||||
Slot.QuantityRemaining.text = $"{Entity.CountItemsInCargo(Entity.ItemManager.ItemData.RefOf<ItemData>(Target).Key)}";
|
||||
var instance = Entity.FindActiveConsumable(Target);
|
||||
if (instance == null) Slot.Fill.fillAmount = 0;
|
||||
else Slot.Fill.fillAmount = instance.RemainingDuration / instance.Data.Duration;
|
||||
|
|
@ -145,7 +144,7 @@ public class ActionBarGearBinding : ActionBarBinding
|
|||
public ActionBarGearBinding(Entity entity, ActionBarSlot slot, EquippedItem item, IActivatedBehavior behavior) : base(entity, slot)
|
||||
{
|
||||
Item = item;
|
||||
var data = item.EquippableItem.Data.Value as EquippableItemData;
|
||||
var data = Entity.ItemManager.GetData(item.EquippableItem);
|
||||
Behavior = behavior;
|
||||
Slot.QuantityRemaining.gameObject.SetActive(false);
|
||||
Slot.Icon.gameObject.SetActive(true);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
* 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 GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -47,15 +49,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if (_cultCache != null) return _cultCache;
|
||||
|
||||
_cultCache = new CultCache();
|
||||
_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
|
||||
_cultCache.AddBackingStore(new MultiFileMessagePackBackingStore(GameDataDirectory.FullName), typeof(NameFile));
|
||||
|
||||
_cultCache.PullAllBackingStores();
|
||||
_cultCache = AetheriaStores.Open(Path.Combine(GameDataDirectory.FullName, "Aetheria.cc"));
|
||||
|
||||
return _cultCache;
|
||||
}
|
||||
|
|
@ -66,9 +60,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
get
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
return _playerSettings ??= File.Exists(_playerSettingsFilePath)
|
||||
? MessagePackSerializer.Deserialize<PlayerSettings>(File.ReadAllBytes(_playerSettingsFilePath))
|
||||
? MessagePackSerializer.Deserialize<PlayerSettings>(File.ReadAllBytes(_playerSettingsFilePath), CultDocumentMessagePackSerialization.OptionsFor(typeof(PlayerSettings).Assembly))
|
||||
: GetDefaultPlayerSettings();
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +69,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
private static string _playerSettingsFilePath => Path.Combine(GameDataDirectory.FullName, "PlayerSettings.msgpack");
|
||||
public static void SavePlayerSettings()
|
||||
{
|
||||
File.WriteAllBytes(_playerSettingsFilePath, MessagePackSerializer.Serialize(_playerSettings));
|
||||
File.WriteAllBytes(_playerSettingsFilePath, MessagePackSerializer.Serialize(_playerSettings, CultDocumentMessagePackSerialization.OptionsFor(typeof(PlayerSettings).Assembly)));
|
||||
}
|
||||
|
||||
private static PlayerSettings GetDefaultPlayerSettings()
|
||||
|
|
@ -240,7 +233,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
public void SaveState()
|
||||
{
|
||||
PlayerSettings.SavedRun = CurrentGalaxy == null ? null : new SavedGame(CurrentGalaxy, Zone, DockedEntity ?? CurrentEntity);
|
||||
PlayerSettings.SavedRun = CurrentGalaxy == null ? null : new SavedGame(CultCache, CurrentGalaxy, Zone, DockedEntity ?? CurrentEntity);
|
||||
if(PlayerSettings.SavedRun != null)
|
||||
{
|
||||
PlayerSettings.SavedRun.IsTutorial = IsTutorial;
|
||||
|
|
@ -278,7 +271,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
#region Input Handling
|
||||
|
||||
Input = new AetheriaInput();
|
||||
foreach (var x in PlayerSettings.InputSettings.InputActionMap) Input.asset[x.Key.action].ApplyBindingOverride(x.Key.binding, x.Value);
|
||||
foreach (var action in PlayerSettings.InputSettings.InputActionMap) foreach (var binding in action.Value) Input.asset[action.Key].ApplyBindingOverride(binding.Key, binding.Value);
|
||||
|
||||
InputDisplayLayout.Input = Input.asset;
|
||||
Input.Global.Enable();
|
||||
|
|
@ -443,7 +436,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
slot.Binding = new ActionBarGearBinding(CurrentEntity, slot, equippedItemDragAction.EquippedItem, trigger);
|
||||
return true;
|
||||
case ItemInstanceDragObject itemInstanceDragAction:
|
||||
if (!(itemInstanceDragAction.Item.Data.Value is ConsumableItemData consumable)) return false;
|
||||
if (!(ItemManager.GetData(itemInstanceDragAction.Item) is ConsumableItemData consumable)) return false;
|
||||
slot.Binding = new ActionBarConsumableBinding(CurrentEntity, slot, consumable);
|
||||
return true;
|
||||
case WeaponGroupDragObject weaponGroupDragAction:
|
||||
|
|
@ -752,12 +745,12 @@ public class ActionGameManager : MonoBehaviour
|
|||
ZoneRenderer.PerspectiveEntity = ship;
|
||||
var entityPosition = ship.Position.xz;
|
||||
var followOrbit = Zone.Orbits.Keys.MinBy(o => lengthsq(Zone.GetOrbitPosition(o) - entityPosition));
|
||||
var followPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == followOrbit).Key];
|
||||
var followPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit.Key.Equals(followOrbit)).Key];
|
||||
DockCamera.Follow = followPlanet.Body.transform;
|
||||
var rootOrbit = followOrbit;
|
||||
while (Zone.Orbits[rootOrbit].Data.Parent != Guid.Empty)
|
||||
rootOrbit = Zone.Orbits[rootOrbit].Data.Parent;
|
||||
var rootPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == rootOrbit).Key];
|
||||
while (Zone.Orbits[rootOrbit].Data.Parent.IsSet())
|
||||
rootOrbit = Zone.Orbits[rootOrbit].Data.Parent.Key;
|
||||
var rootPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit.Key.Equals(rootOrbit)).Key];
|
||||
DockCamera.LookAt = rootPlanet.Body.transform;
|
||||
|
||||
var shipVelocity = ship.GetBehavior<VelocityLimit>().Limit;
|
||||
|
|
@ -810,9 +803,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
FollowCamera.enabled = false;
|
||||
var orbital = (OrbitalEntity) entity;
|
||||
DockCamera.Follow = ZoneRenderer.EntityInstances[orbital].transform;
|
||||
var parentOrbit = Zone.Orbits[orbital.OrbitData].Data.Parent;
|
||||
var parentOrbitPlanet = Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key;
|
||||
if (ZoneRenderer.Planets.ContainsKey(parentOrbitPlanet))
|
||||
var parentOrbit = Zone.Orbits[orbital.OrbitData].Data.Parent.Key;
|
||||
var parentOrbitPlanet = Zone.Planets.FirstOrDefault(p => p.Value.Orbit.Key.Equals(parentOrbit)).Key;
|
||||
if (parentOrbitPlanet.IsSet() && ZoneRenderer.Planets.ContainsKey(parentOrbitPlanet))
|
||||
DockCamera.LookAt = ZoneRenderer.Planets[parentOrbitPlanet].Body.transform;
|
||||
else DockCamera.LookAt = ZoneRenderer.ZoneRoot;
|
||||
if (entity is OrbitalEntity {CanTow: true})
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class FieldDriver : MonoBehaviour
|
|||
[Inspectable]
|
||||
public ExponentialCurve MagnitudeTimeScaling;
|
||||
|
||||
[Inspectable, InspectorHeader("Melee")]
|
||||
[Inspectable]
|
||||
public float MeleeRange;
|
||||
[Inspectable]
|
||||
public float MeleeRangeExponent;
|
||||
|
|
@ -41,7 +41,7 @@ public class FieldDriver : MonoBehaviour
|
|||
[Inspectable]
|
||||
public float MeleeAngleExponent;
|
||||
|
||||
[Inspectable, InspectorHeader("Tendril")]
|
||||
[Inspectable]
|
||||
public float TendrilBaseRadius = 3;
|
||||
[Inspectable]
|
||||
public float TendrilTipRadius = .1f;
|
||||
|
|
@ -58,7 +58,7 @@ public class FieldDriver : MonoBehaviour
|
|||
// [Inspectable]
|
||||
// public float GrabScaleAnimationExponent = .5f;
|
||||
|
||||
[Inspectable, InspectorHeader("Grab")]
|
||||
[Inspectable]
|
||||
public float GrabExtendTime;
|
||||
[Inspectable]
|
||||
public float GrabEnvelopTime;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"name": "Aetheria.Shared.Unity",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GameCult.CultLib",
|
||||
"UniRx",
|
||||
"Ink"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ public class SchematicDisplay : MonoBehaviour
|
|||
//x.ListElement.Label.text = x.Item.EquippableItem.Name;
|
||||
if (!_enemy)
|
||||
{
|
||||
x.ListElement.InfiniteAmmoIcon.gameObject.SetActive(x.Weapon.WeaponData.AmmoType == Guid.Empty);
|
||||
x.ListElement.AmmoLabel.gameObject.SetActive(x.Weapon.WeaponData.AmmoType != Guid.Empty);
|
||||
x.ListElement.InfiniteAmmoIcon.gameObject.SetActive(!x.Weapon.WeaponData.AmmoType.IsSet());
|
||||
x.ListElement.AmmoLabel.gameObject.SetActive(x.Weapon.WeaponData.AmmoType.IsSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -222,12 +222,12 @@ public class SchematicDisplay : MonoBehaviour
|
|||
if (x.Cooldown != null)
|
||||
x.ListElement.CooldownFill.anchorMax = new Vector2(x.Cooldown.Progress, 1);
|
||||
x.ListElement.DurabilityLabel.text = $"{(int)(x.Item.EquippableItem.Durability / itemData.Durability * 100)}%";
|
||||
if (x.Weapon.WeaponData.AmmoType != Guid.Empty)
|
||||
if (x.Weapon.WeaponData.AmmoType.IsSet())
|
||||
{
|
||||
if(x.Weapon.WeaponData.MagazineSize > 1)
|
||||
x.ListElement.AmmoLabel.text = x.Weapon.Ammo.ToString();
|
||||
else
|
||||
x.ListElement.AmmoLabel.text = _entity.CountItemsInCargo(x.Weapon.WeaponData.AmmoType).ToString();
|
||||
x.ListElement.AmmoLabel.text = _entity.CountItemsInCargo(x.Weapon.WeaponData.AmmoType.Key).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
_canvas = transform.root.GetComponent<Canvas>();
|
||||
var path = Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.msgpack");
|
||||
// _inputLayout = ParseJson(LayoutFile.text);
|
||||
RegisterResolver.Register();
|
||||
_inputLayout = MessagePackSerializer.Deserialize<InputLayout>(File.ReadAllBytes(path));
|
||||
// _inputLayout = JsonConvert.DeserializeObject<InputLayout>(File.ReadAllText(path));
|
||||
// SaveLayout();
|
||||
|
|
@ -494,7 +493,6 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
|
||||
private void SaveLayout()
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
File.WriteAllBytes(
|
||||
Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.msgpack"),
|
||||
MessagePackSerializer.Serialize(_inputLayout));
|
||||
|
|
@ -525,8 +523,9 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
{
|
||||
_dragAction.Binding.overridePath = _previewButton.Button.InputSystemPath;
|
||||
_dragAction.Action.ApplyBindingOverride(_dragAction.Binding);
|
||||
ActionGameManager.PlayerSettings.InputSettings.InputActionMap[(_dragAction.Action.name,
|
||||
_dragAction.Action.GetBindingIndex(_dragAction.Binding))] = _previewButton.Button.InputSystemPath;
|
||||
var inputMap = ActionGameManager.PlayerSettings.InputSettings.InputActionMap;
|
||||
if (!inputMap.TryGetValue(_dragAction.Action.name, out var bindings)) inputMap[_dragAction.Action.name] = bindings = new Dictionary<int, string>();
|
||||
bindings[_dragAction.Action.GetBindingIndex(_dragAction.Binding)] = _previewButton.Button.InputSystemPath;
|
||||
// TODO: Assign New Binding
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ public class MainMenu : MonoBehaviour
|
|||
// Start loading the database in the background 'cause it takes a few seconds
|
||||
//_databaseLoad = Task.Run(() => ActionGameManager.Database);
|
||||
|
||||
RegisterResolver.Register();
|
||||
_panelPosition = PanelPrototype.transform.position;
|
||||
|
||||
var panel1 = PanelPrototype.Instantiate<PropertiesPanel>();
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
_selectedPanel = panel;
|
||||
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
|
||||
_selectedItem = item;
|
||||
_selectedItemData = item.Data.Value;
|
||||
_selectedItemData = GameManager.ItemManager.GetData(item);
|
||||
foreach (var v in _selectedItemData.Shape.Coordinates)
|
||||
{
|
||||
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
//Debug.Log("Entity Pointer Enter");
|
||||
if (!(GameManager.DragObject is ItemDragObject itemDragObject)) return;
|
||||
var item = itemDragObject.Item;
|
||||
var itemData = item.Data.Value;
|
||||
var itemData = GameManager.ItemManager.GetData(item);
|
||||
if (!(item is EquippableItem equippableItem)) return;
|
||||
var placementPosition = v + itemDragObject.OriginCellOffset;
|
||||
if (entity.ItemFits(equippableItem, placementPosition))
|
||||
|
|
@ -586,7 +586,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
if (item != null)
|
||||
{
|
||||
var itemPosition = cargo.Cargo[item];
|
||||
var itemData = item.Data.Value;
|
||||
var itemData = GameManager.ItemManager.GetData(item);
|
||||
var originalOccupancy = cargo.Data.InteriorShape.Inset(itemData.Shape, itemPosition, item.Rotation);
|
||||
_dragCells = originalOccupancy.Coordinates
|
||||
.Select(v1 => Instantiate(CellInstances[v1], DragParent, true).transform).ToArray();
|
||||
|
|
@ -633,7 +633,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
//Debug.Log("Inventory Pointer Enter");
|
||||
if (!(GameManager.DragObject is ItemDragObject itemDragObject)) return;
|
||||
var item = itemDragObject.Item;
|
||||
var itemData = item.Data.Value;
|
||||
var itemData = GameManager.ItemManager.GetData(item);
|
||||
var placementPosition = v + itemDragObject.OriginCellOffset;
|
||||
if (cargo.ItemFits(item, placementPosition))
|
||||
{
|
||||
|
|
@ -851,7 +851,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
return Color.white * .25f;
|
||||
|
||||
var c = float3(1);
|
||||
if (item.Data.Value is EquippableItemData equippable)
|
||||
if (GameManager.ItemManager.GetData(item) is EquippableItemData equippable)
|
||||
c = HardpointData.GetColor(equippable.HardpointType);
|
||||
|
||||
if(!highlight)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
Properties.Title.text = zone.Name;
|
||||
Properties.AddProperty("Owner", () => zone.Owner?.Name ?? "None");
|
||||
var otherFactions = zone.Factions
|
||||
.Where(f => f.ID != zone.Owner?.ID)
|
||||
.Where(f => f != zone.Owner)
|
||||
.Select(f=>f.Name).ToArray();
|
||||
if (otherFactions.Length > 0)
|
||||
Properties.AddProperty("Factions Present", () => string.Join(", ", otherFactions));
|
||||
|
|
@ -78,30 +78,30 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
}
|
||||
else
|
||||
{
|
||||
var planetCount = zone.PackedContents.Planets.Count(body => body is PlanetData).ToString();
|
||||
var planetCount = zone.PackedContents.Planets.Count(body => ActionGameManager.CultCache.Get(body) is PlanetData).ToString();
|
||||
Properties.AddProperty("Planets", () => planetCount);
|
||||
|
||||
var beltCount = zone.PackedContents.Planets.Count(body => body is AsteroidBeltData).ToString();
|
||||
var beltCount = zone.PackedContents.Planets.Count(body => ActionGameManager.CultCache.Get(body) is AsteroidBeltData).ToString();
|
||||
Properties.AddProperty("Asteroid Belts", () => beltCount);
|
||||
|
||||
var giantCount = zone.PackedContents.Planets.Count(body => body is GasGiantData && !(body is SunData)).ToString();
|
||||
var giantCount = zone.PackedContents.Planets.Count(body => ActionGameManager.CultCache.Get(body) is GasGiantData && !(ActionGameManager.CultCache.Get(body) is SunData)).ToString();
|
||||
Properties.AddProperty("Gas Giants", () => giantCount);
|
||||
|
||||
var starCount = zone.PackedContents.Planets.Count(body => body is SunData).ToString();
|
||||
var starCount = zone.PackedContents.Planets.Count(body => ActionGameManager.CultCache.Get(body) is SunData).ToString();
|
||||
Properties.AddProperty("Stars", () => starCount);
|
||||
|
||||
var stationCount = zone.PackedContents.Entities
|
||||
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Station)
|
||||
.Count(entity => ((HullData) GameManager.ItemManager.GetData(entity.Hull)).HullType == HullType.Station)
|
||||
.ToString();
|
||||
Properties.AddProperty("Stations", () => stationCount);
|
||||
|
||||
var turretCount = zone.PackedContents.Entities
|
||||
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Turret)
|
||||
.Count(entity => ((HullData) GameManager.ItemManager.GetData(entity.Hull)).HullType == HullType.Turret)
|
||||
.ToString();
|
||||
Properties.AddProperty("Turrets", () => turretCount);
|
||||
|
||||
var shipCount = zone.PackedContents.Entities
|
||||
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Ship)
|
||||
.Count(entity => ((HullData) GameManager.ItemManager.GetData(entity.Hull)).HullType == HullType.Ship)
|
||||
.ToString();
|
||||
Properties.AddProperty("Ships", () => shipCount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ public class TradeMenu : MonoBehaviour
|
|||
data => data.Shape.Width*data.Shape.Height));
|
||||
|
||||
var items = Inventory.Cargo.Keys
|
||||
.Select<ItemInstance, (ItemInstance item, ItemData data)>(ii=>(ii, ii.Data.Value));
|
||||
.Select<ItemInstance, (ItemInstance item, ItemData data)>(ii=>(ii, GameManager.ItemManager.GetData(ii)));
|
||||
|
||||
if (MinimumSizeFilter.gameObject.activeSelf)
|
||||
items = items.Where(i =>
|
||||
|
|
@ -289,18 +289,18 @@ public class TradeMenu : MonoBehaviour
|
|||
x => () =>
|
||||
{
|
||||
if (x.data is HullData)
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == x.data.ID && s is Ship {IsPlayerShip: true}).ToString();
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.Key.Equals(GameManager.ItemManager.ItemData.RefOf(x.data).Key) && s is Ship {IsPlayerShip: true}).ToString();
|
||||
if(x.data is SimpleCommodityData)
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(x.data.ID) ? _targetCargo.ItemsOfType[x.data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(x.data.ID) ? _targetCargo.ItemsOfType[x.data.ID].Count : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(x.data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(x.data).Key].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(x.data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(x.data).Key].Count : 0).ToString();
|
||||
},
|
||||
data =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true});
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.Key.Equals(GameManager.ItemManager.ItemData.RefOf(data).Key) && s is Ship {IsPlayerShip: true});
|
||||
if(data is SimpleCommodityData)
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Count : 0;
|
||||
}));
|
||||
|
||||
Spreadsheet.ShowData(
|
||||
|
|
|
|||
|
|
@ -272,18 +272,18 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
data => () =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true}).ToString();
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.Key.Equals(GameManager.ItemManager.ItemData.RefOf(data).Key) && s is Ship {IsPlayerShip: true}).ToString();
|
||||
if(data is SimpleCommodityData)
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
|
||||
return (_targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Count : 0).ToString();
|
||||
},
|
||||
data =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true});
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.Key.Equals(GameManager.ItemManager.ItemData.RefOf(data).Key) && s is Ship {IsPlayerShip: true});
|
||||
if(data is SimpleCommodityData)
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
|
||||
return _targetCargo.ItemsOfType.ContainsKey(GameManager.ItemManager.ItemData.RefOf(data).Key) ? _targetCargo.ItemsOfType[GameManager.ItemManager.ItemData.RefOf(data).Key].Count : 0;
|
||||
}));
|
||||
|
||||
Spreadsheet.ShowData(
|
||||
|
|
@ -359,7 +359,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
Entity entity;
|
||||
if(data.HullType==HullType.Ship)
|
||||
entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull, GameManager.Settings.GameplaySettings.DefaultEntitySettings) {IsPlayerShip = true};
|
||||
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, Guid.Empty, GameManager.Settings.GameplaySettings.DefaultEntitySettings);
|
||||
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, default, GameManager.Settings.GameplaySettings.DefaultEntitySettings);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
|
||||
GameManager.Credits -= data.Price;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
* 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 GameCult.Caching;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -359,7 +360,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
|
||||
private void AddItemProperties(ItemInstance item)
|
||||
{
|
||||
var data = item.Data.Value;
|
||||
var data = GameManager.ItemManager.GetData(item);
|
||||
|
||||
AddProperty(data.Description);
|
||||
|
||||
|
|
@ -419,7 +420,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
|
||||
private string GetTitle(EquippableItem item)
|
||||
{
|
||||
var data = item.Data.Value;
|
||||
var data = GameManager.ItemManager.GetData(item);
|
||||
var (tier, upgrades) = GameManager.ItemManager.GetTier(item);
|
||||
return
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
|
|
@ -585,7 +586,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedFloatAttribute ranged)
|
||||
if (field.GetCustomAttribute<CultInspectorRangeAttribute>() is { } ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
else
|
||||
|
|
@ -596,9 +597,9 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
if (readWrite)
|
||||
{
|
||||
if (inspectable is InspectableRangedIntAttribute ranged)
|
||||
if (field.GetCustomAttribute<CultInspectorRangeAttribute>() is { } ranged)
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f),
|
||||
ranged.Min, ranged.Max);
|
||||
(int) ranged.Min, (int) ranged.Max);
|
||||
else
|
||||
AddField(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f));
|
||||
} else AddProperty(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
* 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 GameCult.Caching;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -66,11 +67,11 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public Sprite WormholeIcon;
|
||||
|
||||
[HideInInspector] public Dictionary<Entity, EntityInstance> EntityInstances = new Dictionary<Entity, EntityInstance>();
|
||||
[HideInInspector] public Dictionary<Guid, PlanetObject> Planets = new Dictionary<Guid, PlanetObject>();
|
||||
[HideInInspector] public Dictionary<CultRecordKey, PlanetObject> Planets = new Dictionary<CultRecordKey, PlanetObject>();
|
||||
|
||||
private Dictionary<Guid, AsteroidBeltUI> _beltObjects = new Dictionary<Guid, AsteroidBeltUI>();
|
||||
private Dictionary<Guid, InstancedMesh[]> _beltMeshes = new Dictionary<Guid, InstancedMesh[]>();
|
||||
private Dictionary<Guid, Matrix4x4[][]> _beltMatrices = new Dictionary<Guid, Matrix4x4[][]>();
|
||||
private Dictionary<CultRecordKey, AsteroidBeltUI> _beltObjects = new Dictionary<CultRecordKey, AsteroidBeltUI>();
|
||||
private Dictionary<CultRecordKey, InstancedMesh[]> _beltMeshes = new Dictionary<CultRecordKey, InstancedMesh[]>();
|
||||
private Dictionary<CultRecordKey, Matrix4x4[][]> _beltMatrices = new Dictionary<CultRecordKey, Matrix4x4[][]>();
|
||||
private float _viewDistance;
|
||||
//private float _maxDepth;
|
||||
private float _minimapDistance;
|
||||
|
|
@ -188,8 +189,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
SectorBrushes.localScale = zone.Pack.Radius * 2 * Vector3.one;
|
||||
SlimeGravityCamera.orthographicSize = zone.Pack.Radius;
|
||||
SlimeRenderer.ZoneRadius = zone.Pack.Radius;
|
||||
foreach (var p in zone.Planets.Values)
|
||||
LoadPlanet(p);
|
||||
foreach (var p in zone.Planets)
|
||||
LoadPlanet(p.Key, p.Value);
|
||||
|
||||
_suns = Planets.Values.Where(p => p is SunObject).ToArray();
|
||||
|
||||
|
|
@ -333,32 +334,32 @@ public class ZoneRenderer : MonoBehaviour
|
|||
EntityInstances.Remove(entity);
|
||||
}
|
||||
|
||||
void LoadPlanet(BodyData planetData)
|
||||
void LoadPlanet(CultRecordKey key, BodyData planetData)
|
||||
{
|
||||
if (planetData is AsteroidBeltData beltData)
|
||||
{
|
||||
var meshes = AsteroidMeshes.ToList();
|
||||
while (meshes.Count > Settings.AsteroidMeshCount)
|
||||
meshes.RemoveAt(Random.Range(0, meshes.Count));
|
||||
_beltMeshes[planetData.ID] = meshes.ToArray();
|
||||
_beltMatrices[planetData.ID] = new Matrix4x4[meshes.Count][];
|
||||
_beltMeshes[key] = meshes.ToArray();
|
||||
_beltMatrices[key] = new Matrix4x4[meshes.Count][];
|
||||
var count = beltData.Asteroids.Length / meshes.Count;
|
||||
var remainder = beltData.Asteroids.Length - count * meshes.Count;
|
||||
for (int i = 0; i < meshes.Count; i++)
|
||||
{
|
||||
_beltMatrices[planetData.ID][i] = new Matrix4x4[i < meshes.Count - 1 ? count : count + remainder];
|
||||
_beltMatrices[key][i] = new Matrix4x4[i < meshes.Count - 1 ? count : count + remainder];
|
||||
}
|
||||
|
||||
var beltObject = Instantiate(AsteroidBeltUI, ZoneRoot);
|
||||
var collider = beltObject.GetComponent<MeshCollider>();
|
||||
var belt = new AsteroidBeltUI(Zone,
|
||||
Zone.AsteroidBelts[beltData.ID],
|
||||
Zone.AsteroidBelts[key],
|
||||
beltObject,
|
||||
collider,
|
||||
AsteroidSpritesheetWidth,
|
||||
AsteroidSpritesheetHeight,
|
||||
Settings.MinimapAsteroidSize);
|
||||
_beltObjects[beltData.ID] = belt;
|
||||
_beltObjects[key] = belt;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -369,7 +370,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
planet = Instantiate(Sun, ZoneRoot);
|
||||
var sunObject = (SunObject) planet;
|
||||
var sun = Zone.PlanetInstances[planetData.ID] as Sun;
|
||||
var sun = Zone.PlanetInstances[key] as Sun;
|
||||
sunObject.Light.color = sunData.LightColor.ToColor();
|
||||
sunObject.Light.range = sun.LightRadius;
|
||||
sunObject.FogTint.transform.localScale = sun.LightRadius * Vector3.one;
|
||||
|
|
@ -378,7 +379,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
else planet = Instantiate(GasGiant, ZoneRoot);
|
||||
|
||||
var gas = (GasGiantObject) planet;
|
||||
var gasGiant = Zone.PlanetInstances[planetData.ID] as GasGiant;
|
||||
var gasGiant = Zone.PlanetInstances[key] as GasGiant;
|
||||
gas.Body.material.SetTexture("_ColorRamp", gasGiantData.Colors.ToGradient(!(planetData is SunData)).ToTexture());
|
||||
// gasGiantData.AlbedoRotationSpeed.Subscribe(f => gas.SunMaterial.AlbedoRotationSpeed = f);
|
||||
// gasGiantData.FirstOffsetRotationSpeed.Subscribe(f => gas.SunMaterial.FirstOffsetRotationSpeed = f);
|
||||
|
|
@ -401,7 +402,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
//planet.Icon.material.mainTexture = planetData.Mass > Context.GlobalData.PlanetMass ? PlanetIcon : PlanetoidIcon;
|
||||
}
|
||||
|
||||
var planetInstance = Zone.PlanetInstances[planetData.ID];
|
||||
var planetInstance = Zone.PlanetInstances[key];
|
||||
planet.Body.transform.localScale = planetInstance.BodyRadius * Vector3.one;
|
||||
planet.GravityWell.transform.localScale = planetInstance.GravityWellRadius * Vector3.one;
|
||||
// var depth = planetInstance.GravityWellDepth;
|
||||
|
|
@ -411,7 +412,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
planet.Icon.transform.localScale = Settings.IconSize.Evaluate(planetInstance.BodyData.Mass) * Vector3.one;
|
||||
|
||||
|
||||
Planets[planetData.ID] = planet;
|
||||
Planets[key] = planet;
|
||||
if (!_rootFound)
|
||||
{
|
||||
_rootFound = true;
|
||||
|
|
@ -478,7 +479,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
foreach (var planet in Planets)
|
||||
{
|
||||
var planetInstance = Zone.PlanetInstances[planet.Key];
|
||||
var p = Zone.GetOrbitPosition(planetInstance.BodyData.Orbit);
|
||||
var p = Zone.GetOrbitPosition(planetInstance.BodyData.Orbit.Key);
|
||||
var height = Zone.GetHeight(p);
|
||||
if (-height > maxDepth) maxDepth = -height;
|
||||
planet.Value.transform.position = new Vector3(p.x, 0, p.y);
|
||||
|
|
@ -489,7 +490,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
Zone.Time * ((GasGiant) Zone.PlanetInstances[planet.Key]).GravityWavesSpeed);
|
||||
if (!(planet.Value is SunObject))
|
||||
{
|
||||
var toParent = normalize(Zone.GetOrbitPosition(Zone.Orbits[planetInstance.BodyData.Orbit].Data.Parent) - p);
|
||||
var toParent = normalize(Zone.GetOrbitPosition(Zone.Orbits[planetInstance.BodyData.Orbit.Key].Data.Parent.Key) - p);
|
||||
gasGiantObject.SunMaterial.LightingDirection = new Vector3(toParent.x, 0, toParent.y);
|
||||
}
|
||||
}
|
||||
|
|
@ -560,7 +561,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
var itemPickup = gridObject.gameObject.GetComponent<ItemPickup>();
|
||||
itemPickup.Item = item;
|
||||
itemPickup.ZoneRenderer = this;
|
||||
itemPickup.ScanLabel.text = item.Data.Value.Name;
|
||||
itemPickup.ScanLabel.text = ItemManager.GetData(item).Name;
|
||||
if (item is CraftedItemInstance craftedItemInstance)
|
||||
{
|
||||
var c = ItemManager.GetTier(craftedItemInstance).tier.Color.ToColor();
|
||||
|
|
@ -589,7 +590,7 @@ public class AsteroidBeltUI
|
|||
private Vector3[] _normals;
|
||||
private Vector2[] _uvs;
|
||||
private int[] _indices;
|
||||
private Guid _orbitParent;
|
||||
private CultRecordKey _orbitParent;
|
||||
private Mesh _mesh;
|
||||
private float _size;
|
||||
private Zone _zone;
|
||||
|
|
@ -608,8 +609,8 @@ public class AsteroidBeltUI
|
|||
_zone = zone;
|
||||
Filter = meshFilter;
|
||||
_collider = collider;
|
||||
var orbit = zone.Orbits[belt.Data.Orbit];
|
||||
_orbitParent = orbit.Data.Parent;
|
||||
var orbit = zone.Orbits[belt.Data.Orbit.Key];
|
||||
_orbitParent = orbit.Data.Parent.Key;
|
||||
_vertices = new Vector3[_belt.Data.Asteroids.Length * 4];
|
||||
_normals = new Vector3[_belt.Data.Asteroids.Length * 4];
|
||||
_uvs = new Vector2[_belt.Data.Asteroids.Length * 4];
|
||||
|
|
|
|||
|
|
@ -160,8 +160,7 @@ public class Slime : MonoBehaviour
|
|||
|
||||
void UpdateSettings()
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
var hash = MessagePackSerializer.Serialize(SlimeSettings).GetHashSHA1();
|
||||
var hash = System.Convert.ToBase64String(MessagePackSerializer.Serialize(SlimeSettings));
|
||||
if(hash != _settingsHash)
|
||||
{
|
||||
_settingsHash = hash;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
"com.unity.modules.vr": "1.0.0",
|
||||
"com.unity.modules.wind": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0",
|
||||
"org.gamecult.caching.unity": "https://github.com/GameCult/CultLib.git?path=/src/GameCult.Unity/Assets/Caching#caching-unity-v1.2.0",
|
||||
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.57",
|
||||
"org.gamecult.cultmath": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.2.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,6 +242,22 @@
|
|||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"org.gamecult.caching.unity": {
|
||||
"version": "https://github.com/GameCult/CultLib.git?path=/src/GameCult.Unity/Assets/Caching#caching-unity-v1.2.0",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"org.gamecult.cultlib": "1.0.57"
|
||||
},
|
||||
"hash": "ae194d5eb276f35194d2042451e228c640b3527b"
|
||||
},
|
||||
"org.gamecult.cultlib": {
|
||||
"version": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.57",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "ae194d5eb276f35194d2042451e228c640b3527b"
|
||||
},
|
||||
"org.gamecult.cultmath": {
|
||||
"version": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath#cultmath-unity-v0.2.3",
|
||||
"depth": 0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue