Slime Stuff & DB Prep
Put the finishing touches on the microfauna Prepared the repository for database extraction
This commit is contained in:
parent
ad499a09ac
commit
48759380c5
773 changed files with 5278 additions and 805 deletions
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"name": "Economy.Shared.Unity",
|
||||
"name": "Aetheria.Shared.Unity",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"MessagePack",
|
||||
"Unity.Mathematics",
|
||||
"UniRx"
|
||||
"UniRx",
|
||||
"CultCache"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RethinkDb.Driver.Ast;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
|
|
|||
|
|
@ -14,17 +14,6 @@ public class NameAttribute : Attribute
|
|||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RethinkTableAttribute : Attribute
|
||||
{
|
||||
public string TableName;
|
||||
|
||||
public RethinkTableAttribute(string tableName)
|
||||
{
|
||||
TableName = tableName;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderAttribute : Attribute
|
||||
{
|
||||
public int Order;
|
||||
|
|
@ -47,124 +36,6 @@ public class EntityTypeRestrictionAttribute : Attribute
|
|||
}
|
||||
|
||||
public class RuntimeInspectable : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class InspectableAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ExternalEntryAttribute : Attribute { }
|
||||
|
||||
public class InspectableFieldAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableUnityObjectAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public Type ObjectType;
|
||||
|
||||
public InspectableUnityObjectAttribute(Type type)
|
||||
{
|
||||
ObjectType = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectablePrefabAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAssetAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTemperatureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableAnimationCurveAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableColorAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly Type EntryType;
|
||||
|
||||
public InspectableDatabaseLinkAttribute(Type entryType)
|
||||
{
|
||||
EntryType = entryType;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatInspectableAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly float Min, Max;
|
||||
|
||||
public RangedFloatInspectableAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatAttribute : Attribute
|
||||
{
|
||||
public readonly float Min, Max;
|
||||
|
||||
public RangedFloatAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedIntInspectableAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly int Min, Max;
|
||||
|
||||
public RangedIntInspectableAttribute(int min, int max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public class InspectableTypeAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
public InspectableTypeAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SimplePerformanceStatAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specify a tooltip for a field in the Inspector window.</para>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class TooltipAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>The tooltip text.</para>
|
||||
/// </summary>
|
||||
public readonly string tooltip;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specify a tooltip for a field.</para>
|
||||
/// </summary>
|
||||
/// <param name="tooltip">The tooltip text.</param>
|
||||
public TooltipAttribute(string tooltip) => this.tooltip = tooltip;
|
||||
}
|
||||
// public class CategoryAttribute : Attribute
|
||||
// {
|
||||
// public readonly Type Type;
|
||||
|
|
|
|||
|
|
@ -1,155 +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 RethinkDb.Driver.Ast;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
// public class SurveyControllerData : ControllerData
|
||||
// {
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new SurveyController(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class SurveyController : ControllerBase<Survey>, IBehavior, IPersistentBehavior, IInitializableBehavior
|
||||
// {
|
||||
// private EquippedItem Item { get; }
|
||||
//
|
||||
// private SurveyControllerData _data;
|
||||
// private bool _taskStarted;
|
||||
// private ResourceScanner _scanningTool;
|
||||
// private Switch _toolSwitch;
|
||||
// private Guid _targetPlanet;
|
||||
// private int _asteroid = -1;
|
||||
//
|
||||
// public SurveyController(ItemManager itemManager, SurveyControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
// {
|
||||
// _data = data;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public new void Initialize()
|
||||
// {
|
||||
// _scanningTool = Entity.GetBehavior<ResourceScanner>();
|
||||
// // _toolSwitch = Entity.GetSwitch<ResourceScanner>();
|
||||
// base.Initialize();
|
||||
// }
|
||||
//
|
||||
// public new bool Execute(float delta)
|
||||
// {
|
||||
// // var corporation = _context.ItemData.Get<Corporation>(_entity.Corporation);
|
||||
// // if (surveyTask != null)
|
||||
// // {
|
||||
// // if (!_taskStarted)
|
||||
// // {
|
||||
// // if (surveyTask.Planets.Any())
|
||||
// // {
|
||||
// // _entity.SetMessage("Moving to survey target.");
|
||||
// // NextPlanet();
|
||||
// // _scanningTool.ScanTarget = _targetPlanet;
|
||||
// // _scanningTool.Asteroid = _asteroid;
|
||||
// // if (!corporation.PlanetSurveyFloor.ContainsKey(_targetPlanet) ||
|
||||
// // corporation.PlanetSurveyFloor[_targetPlanet] + .5f < _scanningTool.MinimumDensity)
|
||||
// // {
|
||||
// // var planetData = _context.ItemData.Get<BodyData>(_targetPlanet);
|
||||
// // MoveTo(() =>
|
||||
// // {
|
||||
// // var target = GetPosition(planetData, _asteroid);
|
||||
// // var targetToUs = _entity.Position - target;
|
||||
// // return target + normalize(targetToUs) * _scanningTool.Range / 2;
|
||||
// // },
|
||||
// // () => GetVelocity(planetData, _asteroid),
|
||||
// // () => _entity.SetMessage("Arrived at target. Scanning for resources."));
|
||||
// // _taskStarted = true;
|
||||
// // }
|
||||
// // else
|
||||
// // surveyTask.Planets.Remove(_targetPlanet);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // _entity.SetMessage("Survey complete. Returning Home.");
|
||||
// // FinishTask();
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (!Moving)
|
||||
// // {
|
||||
// // var planetData = _context.ItemData.Get<BodyData>(_targetPlanet);
|
||||
// // if ((!corporation.PlanetSurveyFloor.ContainsKey(_targetPlanet) ||
|
||||
// // corporation.PlanetSurveyFloor[_targetPlanet] + .5f < _scanningTool.MinimumDensity) &&
|
||||
// // length(_entity.Position - GetPosition(planetData, _asteroid)) < _scanningTool.Range)
|
||||
// // {
|
||||
// // _toolSwitch.Activated = true;
|
||||
// // Aim.Objective = GetPosition(planetData, _asteroid);
|
||||
// // Aim.Update(delta);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // _toolSwitch.Activated = false;
|
||||
// // _taskStarted = false;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// return base.Execute(delta);
|
||||
// }
|
||||
//
|
||||
// private void NextPlanet()
|
||||
// {
|
||||
// var planets = Task.Planets.Select(id => Zone.Planets[id]);
|
||||
// var nearestPlanet = planets.MinBy(p => lengthsq(Entity.Position.xz - GetPosition(p)));
|
||||
// _asteroid = nearestPlanet is AsteroidBeltData ? Zone.NearestAsteroid(nearestPlanet.ID, Entity.Position.xz) : -1;
|
||||
// _targetPlanet = nearestPlanet.ID;
|
||||
// }
|
||||
//
|
||||
// private float2 GetPosition(BodyData planet, int asteroid = -1)
|
||||
// {
|
||||
// if (planet is AsteroidBeltData)
|
||||
// {
|
||||
// if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz);
|
||||
// return Zone.AsteroidBelts[planet.ID].Positions[asteroid].xz;
|
||||
// }
|
||||
// return Zone.GetOrbitPosition(planet.Orbit);
|
||||
// }
|
||||
//
|
||||
// private float2 GetVelocity(BodyData planet, int asteroid = -1)
|
||||
// {
|
||||
// if (planet is AsteroidBeltData)
|
||||
// {
|
||||
// if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz);
|
||||
// return Zone.AsteroidBelts[planet.ID].Velocities[asteroid];
|
||||
// }
|
||||
// return Zone.GetOrbitVelocity(planet.Orbit);
|
||||
// }
|
||||
//
|
||||
// public PersistentBehaviorData Store()
|
||||
// {
|
||||
// return new SurveyControllerPersistence
|
||||
// {
|
||||
// Task = Task
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public void Restore(PersistentBehaviorData data)
|
||||
// {
|
||||
// var surveyControllerPersistence = data as SurveyControllerPersistence;
|
||||
// Task = surveyControllerPersistence.Task;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class SurveyControllerPersistence : PersistentBehaviorData
|
||||
// {
|
||||
// [JsonProperty("task"), Key(0)]
|
||||
// public Survey Task;
|
||||
// }
|
||||
|
|
@ -1,78 +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 RethinkDb.Driver.Ast;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
// [MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
// public class WanderControllerData : ControllerData
|
||||
// {
|
||||
// [InspectableField, JsonProperty("randomDockTime"), Key(6)]
|
||||
// public float RandomDockTime = 5;
|
||||
//
|
||||
// public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
// {
|
||||
// return new WanderController(context, this, entity, item);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class WanderController : ControllerBase<WanderTask>, IBehavior
|
||||
// {
|
||||
// public WanderTarget WanderTarget;
|
||||
//
|
||||
// private WanderControllerData _data;
|
||||
// private EquippedItem Item { get; }
|
||||
// private Guid _target;
|
||||
// private float _dockTime = -1;
|
||||
//
|
||||
// public WanderController(ItemManager itemManager, WanderControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
// {
|
||||
// _data = data;
|
||||
// Item = item;
|
||||
// }
|
||||
//
|
||||
// public new bool Execute(float delta)
|
||||
// {
|
||||
// if (!Moving && _dockTime < 0)
|
||||
// {
|
||||
// NextTarget();
|
||||
// }
|
||||
//
|
||||
// _dockTime -= delta;
|
||||
// return base.Execute(delta);
|
||||
// }
|
||||
//
|
||||
// private void NextTarget()
|
||||
// {
|
||||
// if (WanderTarget == WanderTarget.Planets)
|
||||
// {
|
||||
// var planets = Zone.Planets.Values.ToArray();
|
||||
// var randomPlanet = planets[ItemManager.Random.NextInt(planets.Length)];
|
||||
// MoveTo(() => Zone.GetOrbitPosition(randomPlanet.Orbit), () => Zone.GetOrbitVelocity(randomPlanet.Orbit));
|
||||
// }
|
||||
// else if (WanderTarget == WanderTarget.Orbitals)
|
||||
// {
|
||||
// var entities = Zone.Entities.Where(e=>e is OrbitalEntity).ToArray();
|
||||
// var randomEntity = entities[ItemManager.Random.NextInt(entities.Length)];
|
||||
// MoveTo(randomEntity, true, () =>
|
||||
// {
|
||||
// Entity.SetParent(randomEntity);
|
||||
// _dockTime = ItemManager.Random.NextFloat(_data.RandomDockTime);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public enum WanderTarget
|
||||
// {
|
||||
// Planets,
|
||||
// Orbitals
|
||||
// }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38e6f1535d5cf5642bd01b1ab7a34492
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ServerShared/CultCache.meta
Normal file
8
Assets/Scripts/ServerShared/CultCache.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 49ec0c83548c7084ab0d3f6c2175ee71
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Assets/Scripts/ServerShared/CultCache/Attributes.cs
Normal file
140
Assets/Scripts/ServerShared/CultCache/Attributes.cs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class InspectableAttribute : Attribute { }
|
||||
|
||||
public abstract class PreferredInspectorAttribute : InspectableAttribute
|
||||
{
|
||||
public Type TargetType;
|
||||
|
||||
public PreferredInspectorAttribute(Type targetType)
|
||||
{
|
||||
TargetType = targetType;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ExternalEntryAttribute : Attribute { }
|
||||
|
||||
public class InspectableFieldAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableUnityObjectAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public Type ObjectType;
|
||||
|
||||
public InspectableUnityObjectAttribute(Type type)
|
||||
{
|
||||
ObjectType = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectablePrefabAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAssetAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTemperatureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableAnimationCurveAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableColorAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly Type EntryType;
|
||||
|
||||
public InspectableDatabaseLinkAttribute(Type entryType)
|
||||
{
|
||||
EntryType = entryType;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatInspectableAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly float Min, Max;
|
||||
|
||||
public RangedFloatInspectableAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatAttribute : Attribute
|
||||
{
|
||||
public readonly float Min, Max;
|
||||
|
||||
public RangedFloatAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedIntInspectableAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly int Min, Max;
|
||||
|
||||
public RangedIntInspectableAttribute(int min, int max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public class InspectableTypeAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
public InspectableTypeAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SimplePerformanceStatAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specify a tooltip for a field in the Inspector window.</para>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class TooltipAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>The tooltip text.</para>
|
||||
/// </summary>
|
||||
public readonly string tooltip;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specify a tooltip for a field.</para>
|
||||
/// </summary>
|
||||
/// <param name="tooltip">The tooltip text.</param>
|
||||
public TooltipAttribute(string tooltip) => this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RethinkTableAttribute : Attribute
|
||||
{
|
||||
public string TableName;
|
||||
|
||||
public RethinkTableAttribute(string tableName)
|
||||
{
|
||||
TableName = tableName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1511795bf85d6e41ab89cb05c7cec84
|
||||
guid: d078a6b39f8c440fabe8d43881207c5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -84,7 +84,6 @@ public class DatabaseCache
|
|||
{
|
||||
if (entry != null)
|
||||
{
|
||||
entry.Database = this;
|
||||
var exists = _entries.ContainsKey(entry.ID);
|
||||
|
||||
// If an external entry is added, store it separately
|
||||
|
|
@ -148,7 +147,6 @@ public class DatabaseCache
|
|||
{
|
||||
var bytes = File.ReadAllBytes(_externalEntries[guid].FilePath);
|
||||
var e = MessagePackSerializer.Deserialize<DatabaseEntry>(bytes);
|
||||
e.Database = this;
|
||||
_externalEntries[guid].Entry = e;
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +196,6 @@ public class DatabaseCache
|
|||
{
|
||||
var bytes = File.ReadAllBytes(_filePath);
|
||||
var entries = MessagePackSerializer.Deserialize<DatabaseEntry[]>(bytes);
|
||||
foreach (var entry in entries) entry.Database = this;
|
||||
AddAll(entries);
|
||||
}
|
||||
|
||||
|
|
@ -6,6 +6,7 @@ using System;
|
|||
using System.Linq;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using Newtonsoft.Json;
|
||||
// TODO: USE THIS EVERYWHERE
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -17,7 +18,10 @@ public interface INamedEntry
|
|||
}
|
||||
|
||||
[InspectableField,
|
||||
MessagePackObject,
|
||||
MessagePackObject,
|
||||
//MessagePackFormatter(typeof(TypelessFormatter)),
|
||||
JsonObject(MemberSerialization.OptIn),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>)),
|
||||
Union(0, typeof(SimpleCommodityData)),
|
||||
Union(1, typeof(CompoundCommodityData)),
|
||||
Union(2, typeof(GearData)),
|
||||
|
|
@ -48,15 +52,11 @@ public interface INamedEntry
|
|||
Union(28, typeof(PlanetData)),
|
||||
Union(29, typeof(CargoBayData)),
|
||||
Union(30, typeof(DockingBayData)),
|
||||
Union(31, typeof(WeaponItemData)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
//[Union(21, typeof(ContractData))]
|
||||
//[Union(22, typeof(Station))]
|
||||
Union(31, typeof(WeaponItemData))]
|
||||
public abstract class DatabaseEntry
|
||||
{
|
||||
[JsonProperty("id"), Key(0)]
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
[IgnoreMember]
|
||||
public DatabaseCache Database;
|
||||
|
||||
public DatabaseEntry(){}
|
||||
}
|
||||
64
Assets/Scripts/ServerShared/CultCache/Extensions.cs
Normal file
64
Assets/Scripts/ServerShared/CultCache/Extensions.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class CultCacheExtensions
|
||||
{
|
||||
private static Dictionary<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllInterfaceClasses(this Type type)
|
||||
{
|
||||
if (InterfaceClasses.ContainsKey(type))
|
||||
return InterfaceClasses[type];
|
||||
return InterfaceClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(t => t.IsClass && t.GetInterfaces().Contains(type)).ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> ParentTypes = new Dictionary<Type, Type[]>();
|
||||
|
||||
public static Type[] GetParentTypes(this Type type)
|
||||
{
|
||||
if (ParentTypes.ContainsKey(type))
|
||||
return ParentTypes[type];
|
||||
return ParentTypes[type] = type.GetParents().ToArray();
|
||||
}
|
||||
|
||||
private static IEnumerable<Type> GetParents(this Type type)
|
||||
{
|
||||
// is there any base type?
|
||||
if (type == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return type;
|
||||
|
||||
// return all implemented or inherited interfaces
|
||||
foreach (var i in type.GetInterfaces())
|
||||
{
|
||||
yield return i;
|
||||
}
|
||||
|
||||
// return all inherited types
|
||||
var currentBaseType = type.BaseType;
|
||||
while (currentBaseType != null)
|
||||
{
|
||||
yield return currentBaseType;
|
||||
currentBaseType= currentBaseType.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> ChildClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllChildClasses(this Type type)
|
||||
{
|
||||
if (ChildClasses.ContainsKey(type))
|
||||
return ChildClasses[type];
|
||||
return ChildClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type.IsAssignableFrom).ToArray();
|
||||
}
|
||||
|
||||
public static async void WrapAwait(this Task task)
|
||||
{
|
||||
await task;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ServerShared/CultCache/Extensions.cs.meta
Normal file
3
Assets/Scripts/ServerShared/CultCache/Extensions.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd5642f26b80465fb57f3d2610633140
|
||||
timeCreated: 1617055075
|
||||
4
Assets/Scripts/ServerShared/CultCache/MathExtensions.cs
Normal file
4
Assets/Scripts/ServerShared/CultCache/MathExtensions.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
public static class MathExtensions
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5effe288f2074414930e040d4531709f
|
||||
timeCreated: 1617057296
|
||||
8
Assets/Scripts/ServerShared/CultCache/Serialization.meta
Normal file
8
Assets/Scripts/ServerShared/CultCache/Serialization.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8035c545a12367f419eb4a2fe1c917b6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using JsonKnownTypes.Exceptions;
|
||||
using JsonKnownTypes.Utils;
|
||||
|
||||
|
|
@ -8,6 +10,13 @@ namespace JsonKnownTypes
|
|||
public static class JsonKnownTypesSettingsManager
|
||||
{
|
||||
public static JsonDiscriminatorSettings DefaultDiscriminatorSettings { get; set; } = new JsonDiscriminatorSettings();
|
||||
|
||||
private static HashSet<Assembly> RegisteredAssemblies = new HashSet<Assembly>();
|
||||
public static void RegisterTypeAssembly<T>()
|
||||
{
|
||||
var type = typeof(T);
|
||||
RegisteredAssemblies.Add(type.Assembly);
|
||||
}
|
||||
|
||||
public static JsonKnownTypesSettings GetSettings<T>()
|
||||
{
|
||||
|
|
@ -41,9 +50,9 @@ namespace JsonKnownTypes
|
|||
|
||||
private static Type[] GetAllInheritance<T>()
|
||||
{
|
||||
RegisterTypeAssembly<T>();
|
||||
var type = typeof(T);
|
||||
return type.Assembly
|
||||
.GetTypes()
|
||||
return RegisteredAssemblies.SelectMany(a=>a.GetTypes())
|
||||
.Where(x => type.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
|
||||
.ToArray();
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using RethinkDb.Driver.Ast;
|
||||
using Unity.Mathematics;
|
||||
|
||||
public static class EntitySerializer
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ public static class Extensions
|
|||
{
|
||||
//public static IDatabaseEntry Get(this Guid entry) => Database.Get(entry);
|
||||
//public static T Get<T>(this Guid entry) where T : class, IDatabaseEntry => Database.Get(entry) as T;
|
||||
public static string ToJson(this DatabaseEntry entry) => MessagePackSerializer.SerializeToJson(entry);
|
||||
public static byte[] Serialize(this DatabaseEntry entry) => MessagePackSerializer.Serialize(entry);
|
||||
|
||||
public static bool IsImplementationOf(this Type baseType, Type interfaceType)
|
||||
{
|
||||
|
|
@ -166,59 +164,7 @@ public static class Extensions
|
|||
pow((pow(max, exp + 1) - pow(min, exp + 1)) * pow(random.NextFloat(), randexp) + pow(min, exp + 1), 1 / (exp + 1));
|
||||
public static float NextUnbounded(this ref Random random) => 1 / (1 - random.NextFloat()) - 1;
|
||||
public static float NextUnbounded(this ref Random random, float bias, float power, float ceiling) => 1 / (1 - pow(min(random.NextFloat(), ceiling), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
|
||||
|
||||
private static Dictionary<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllInterfaceClasses(this Type type)
|
||||
{
|
||||
if (InterfaceClasses.ContainsKey(type))
|
||||
return InterfaceClasses[type];
|
||||
return InterfaceClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(t => t.IsClass && t.GetInterfaces().Contains(type)).ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> ParentTypes = new Dictionary<Type, Type[]>();
|
||||
|
||||
public static Type[] GetParentTypes(this Type type)
|
||||
{
|
||||
if (ParentTypes.ContainsKey(type))
|
||||
return ParentTypes[type];
|
||||
return ParentTypes[type] = type.GetParents().ToArray();
|
||||
}
|
||||
|
||||
private static IEnumerable<Type> GetParents(this Type type)
|
||||
{
|
||||
// is there any base type?
|
||||
if (type == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return type;
|
||||
|
||||
// return all implemented or inherited interfaces
|
||||
foreach (var i in type.GetInterfaces())
|
||||
{
|
||||
yield return i;
|
||||
}
|
||||
|
||||
// return all inherited types
|
||||
var currentBaseType = type.BaseType;
|
||||
while (currentBaseType != null)
|
||||
{
|
||||
yield return currentBaseType;
|
||||
currentBaseType= currentBaseType.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> ChildClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllChildClasses(this Type type)
|
||||
{
|
||||
if (ChildClasses.ContainsKey(type))
|
||||
return ChildClasses[type];
|
||||
return ChildClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type.IsAssignableFrom).ToArray();
|
||||
}
|
||||
|
||||
public static bool IsDefault<T>(this T value) where T : struct
|
||||
{
|
||||
bool isDefault = value.Equals(default(T));
|
||||
|
|
|
|||
8
Assets/Scripts/ServerShared/NIH/RethinkDb.meta
Normal file
8
Assets/Scripts/ServerShared/NIH/RethinkDb.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9af1bb2d775b93c40b0cc7f40a6a2a54
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "RethinkDB"
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b2a4424e75e7709478154ddd9db0b344
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue