Game Loop Galaxy Integration
Added sector map in Galaxy tab of in-game menu Added player flag to Ship (replaces AGM.PlayerEntities) Refactored sector map to depend on AGM Moved sector generation to main menu Main menu now supports resuming previous playthrough Database and player settings now statically available via AGM AGM saves current game state in PlayerSettings on exit Sector generation is now asynchronous Added progress callbacks to sector gen + progress dialog in menu Confirmation Dialog / properties panel can now display dynamic text entry Added zone title to Zone map Eliminated ZoneData class (properties moved to ZonePack) Sector, Zone and Entity serialization now fully functional Entity settings now separate from player settings Cleaned up old unused networking message classes Name files now integrated with database cache Added ability to save/load additive DB cache files in database panel Cleaned up Wwise sound setup - removed redundant items & fixed spelling errors Deleted Wwise cache + added to .gitignore
This commit is contained in:
parent
6986ff2562
commit
73651bf16a
130 changed files with 13423 additions and 4406 deletions
|
|
@ -70,32 +70,6 @@ public class DatabaseInspector : EditorWindow
|
|||
Inspect(obj, field, inspectablesOnly);
|
||||
}
|
||||
|
||||
// if (obj is GalaxyMapLayerData mapLayer)
|
||||
// {
|
||||
// var global = DatabaseCache.GetAll<GlobalData>().FirstOrDefault();
|
||||
// if (global != null)
|
||||
// {
|
||||
// GUILayout.Label("Preview", EditorStyles.boldLabel);
|
||||
// _galaxyMat.SetFloat("Arms", global.Arms);
|
||||
// _galaxyMat.SetFloat("Twist", global.Twist);
|
||||
// _galaxyMat.SetFloat("TwistPower", global.TwistPower);
|
||||
// _galaxyMat.SetFloat("SpokeOffset", mapLayer.SpokeOffset);
|
||||
// _galaxyMat.SetFloat("SpokeScale", mapLayer.SpokeScale);
|
||||
// _galaxyMat.SetFloat("CoreBoost", mapLayer.CoreBoost);
|
||||
// _galaxyMat.SetFloat("CoreBoostOffset", mapLayer.CoreBoostOffset);
|
||||
// _galaxyMat.SetFloat("CoreBoostPower", mapLayer.CoreBoostPower);
|
||||
// _galaxyMat.SetFloat("EdgeReduction", mapLayer.EdgeReduction);
|
||||
// _galaxyMat.SetFloat("NoisePosition", mapLayer.NoisePosition);
|
||||
// _galaxyMat.SetFloat("NoiseAmplitude", mapLayer.NoiseAmplitude);
|
||||
// _galaxyMat.SetFloat("NoiseOffset", mapLayer.NoiseOffset);
|
||||
// _galaxyMat.SetFloat("NoiseGain", mapLayer.NoiseGain);
|
||||
// _galaxyMat.SetFloat("NoiseLacunarity", mapLayer.NoiseLacunarity);
|
||||
// _galaxyMat.SetFloat("NoiseFrequency", mapLayer.NoiseFrequency);
|
||||
// var rect = GetControlRect(false, Screen.width);
|
||||
// EditorGUI.DrawPreviewTexture(rect, _white, _galaxyMat);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (obj is EquippableItemData equippableItemData)
|
||||
{
|
||||
var restricted = false;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ public class DatabaseListView : EditorWindow
|
|||
private Dictionary<Guid, HashSet<Guid>> _itemBlueprints = new Dictionary<Guid, HashSet<Guid>>();
|
||||
private HashSet<Guid> _itemBlueprintFoldouts = new HashSet<Guid>();
|
||||
private HashSet<string> _itemGroupFoldouts = new HashSet<string>();
|
||||
private DirectoryInfo _filePath;
|
||||
private string _filePath => Path.Combine(ActionGameManager.GameDataDirectory.FullName, _fileName);
|
||||
private string _fileName = "AetherDB.msgpack";
|
||||
|
||||
public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ public class DatabaseListView : EditorWindow
|
|||
|
||||
void OnEnable()
|
||||
{
|
||||
_filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
//_filePath = ;
|
||||
// Create database cache
|
||||
_databaseCache = new DatabaseCache();
|
||||
|
||||
|
|
@ -140,16 +141,6 @@ public class DatabaseListView : EditorWindow
|
|||
{
|
||||
Event currentEvent = Event.current;
|
||||
EventType currentEventType = currentEvent.type;
|
||||
|
||||
_view = BeginScrollView(
|
||||
_view,
|
||||
false,
|
||||
false,
|
||||
GUIStyle.none,
|
||||
GUI.skin.verticalScrollbar,
|
||||
GUI.skin.scrollView,
|
||||
GUILayout.Width(EditorGUIUtility.currentViewWidth),
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
if (currentEventType == EventType.DragUpdated)
|
||||
// Indicate that we don't accept drags ourselves
|
||||
|
|
@ -163,24 +154,24 @@ public class DatabaseListView : EditorWindow
|
|||
EditorPrefs.SetString("RethinkDB.URL", _connectionString);
|
||||
_queryStatus = RethinkConnection.RethinkConnect(_databaseCache, _connectionString);
|
||||
}
|
||||
// if (GUILayout.Button("Connect All"))
|
||||
// {
|
||||
// EditorPrefs.SetString("RethinkDB.URL", _connectionString);
|
||||
// _queryStatus = RethinkConnection.RethinkConnect(_databaseCache, _connectionString, true, false);
|
||||
// }
|
||||
}
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Connect All"))
|
||||
{
|
||||
EditorPrefs.SetString("RethinkDB.URL", _connectionString);
|
||||
_queryStatus = RethinkConnection.RethinkConnect(_databaseCache, _connectionString, true, false);
|
||||
}
|
||||
|
||||
_fileName = TextField(_fileName);
|
||||
if (GUILayout.Button("Save"))
|
||||
{
|
||||
_databaseCache.Save(_filePath.FullName);
|
||||
_databaseCache.Save(_filePath);
|
||||
Debug.Log("Local DB Cache Saved!");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Load"))
|
||||
{
|
||||
_databaseCache.Load(_filePath.FullName);
|
||||
_databaseCache.Load(_filePath);
|
||||
Debug.Log("Loaded DB From Local Cache!");
|
||||
}
|
||||
}
|
||||
|
|
@ -207,18 +198,18 @@ public class DatabaseListView : EditorWindow
|
|||
var progressRect = GetControlRect(false, 20);
|
||||
EditorGUI.ProgressBar(progressRect, (float)_queryStatus.RetrievedItems/(_queryStatus.GalaxyEntries + _queryStatus.ItemsEntries), "Sync Progress");
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// if(_itemBlueprints == null)
|
||||
// _itemBlueprints = _databaseCache.GetAll<ItemData>()
|
||||
// .Select(itemData => new {itemData, blueprints = _databaseCache.GetAll<BlueprintData>()
|
||||
// .Where(blueprintData => blueprintData.Item == itemData.ID)
|
||||
// .Select(bp => bp.ID)
|
||||
// .ToList()})
|
||||
// .ToDictionary(x => x.itemData.ID, x => x.blueprints);
|
||||
// }
|
||||
GUILayout.Space(5);
|
||||
|
||||
_view = BeginScrollView(
|
||||
_view,
|
||||
false,
|
||||
false,
|
||||
GUIStyle.none,
|
||||
GUI.skin.verticalScrollbar,
|
||||
GUI.skin.scrollView,
|
||||
GUILayout.Width(EditorGUIUtility.currentViewWidth),
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
// if(GUILayout.Button("Log Cache Count"))
|
||||
// Debug.Log($"Cache contains {_databaseCache.AllEntries.Count()} elements");
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Random = Unity.Mathematics.Random;
|
|||
|
||||
public class NameTools : EditorWindow
|
||||
{
|
||||
public TextAsset[] NameFiles;
|
||||
public int NameGeneratorMinLength = 5;
|
||||
public int NameGeneratorMaxLength = 10;
|
||||
public int NameGeneratorOrder = 4;
|
||||
|
|
@ -18,6 +19,7 @@ public class NameTools : EditorWindow
|
|||
private MarkovNameGenerator _nameGenerator;
|
||||
private bool _stripNumberTokens;
|
||||
|
||||
|
||||
// Add menu named "My Window" to the Window menu
|
||||
[MenuItem("Window/Aetheria/Name Tools")]
|
||||
static void Init()
|
||||
|
|
@ -29,6 +31,25 @@ 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"))
|
||||
{
|
||||
var database = new DatabaseCache();
|
||||
foreach (var nameFile in NameFiles)
|
||||
{
|
||||
var entry = new NameFile();
|
||||
entry.Names = nameFile.text.Split('\n');
|
||||
database.Add(entry);
|
||||
}
|
||||
database.Save(Path.Combine(ActionGameManager.GameDataDirectory.FullName, "Names.msgpack"));
|
||||
}
|
||||
|
||||
nameFile = (TextAsset) EditorGUILayout.ObjectField("Name File", nameFile, typeof(TextAsset), false);
|
||||
minWordLength = EditorGUILayout.IntField("Minimum File Word Length", minWordLength);
|
||||
NameGeneratorMinLength = EditorGUILayout.IntField("Generated Minimum Word Length", NameGeneratorMinLength);
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ using MessagePack;
|
|||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
using quaternion = Unity.Mathematics.quaternion;
|
||||
|
|
@ -23,27 +24,41 @@ using Random = UnityEngine.Random;
|
|||
|
||||
public class ActionGameManager : MonoBehaviour
|
||||
{
|
||||
private static DirectoryInfo _gameDataDirectory;
|
||||
public static DirectoryInfo GameDataDirectory
|
||||
{
|
||||
get => _gameDataDirectory ??= new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
}
|
||||
private static DirectoryInfo _gameDataDirectory;
|
||||
|
||||
|
||||
private static DatabaseCache _database;
|
||||
|
||||
public static DatabaseCache Database
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_database != null) return _database;
|
||||
|
||||
_database = new DatabaseCache();
|
||||
_database.Load(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack"));
|
||||
|
||||
return _database;
|
||||
}
|
||||
}
|
||||
|
||||
private static PlayerSettings _playerSettings;
|
||||
public static PlayerSettings PlayerSettings
|
||||
{
|
||||
get => _playerSettings ??= File.Exists(_playerSettingsFilePath)
|
||||
? MessagePackSerializer.Deserialize<PlayerSettings>(File.ReadAllBytes(_playerSettingsFilePath))
|
||||
: new PlayerSettings {Name = Environment.UserName};
|
||||
}
|
||||
private static PlayerSettings _playerSettings;
|
||||
private static string _playerSettingsFilePath => Path.Combine(GameDataDirectory.FullName, "PlayerSettings.msgpack");
|
||||
public static void SavePlayerSettings()
|
||||
{
|
||||
File.WriteAllBytes(_playerSettingsFilePath, MessagePackSerializer.Serialize(_playerSettings));
|
||||
}
|
||||
|
||||
public static SavedGame Save;
|
||||
|
||||
|
||||
public static Sector CurrentSector;
|
||||
|
||||
public GameSettings Settings;
|
||||
public string StarterShipTemplate = "Longinus";
|
||||
|
|
@ -71,18 +86,20 @@ public class ActionGameManager : MonoBehaviour
|
|||
public Prototype LockIndicator;
|
||||
public PlaceUIElementWorldspace[] Crosshairs;
|
||||
public EventLog EventLog;
|
||||
public SectorRenderer SectorRenderer;
|
||||
[FormerlySerializedAs("SectorRenderer")] public ZoneRenderer ZoneRenderer;
|
||||
public CinemachineVirtualCamera DockCamera;
|
||||
public CinemachineVirtualCamera FollowCamera;
|
||||
public GameObject GameplayUI;
|
||||
public MenuPanel Menu;
|
||||
public MapRenderer MenuMap;
|
||||
//public SectorRenderer SectorRenderer;
|
||||
public SectorMap SectorMap;
|
||||
public SchematicDisplay SchematicDisplay;
|
||||
public SchematicDisplay TargetSchematicDisplay;
|
||||
public InventoryMenu Inventory;
|
||||
public InventoryPanel ShipPanel;
|
||||
public InventoryPanel TargetShipPanel;
|
||||
public ConfirmationDialog ConfirmationDialog;
|
||||
[FormerlySerializedAs("ConfirmationDialog")] public ConfirmationDialog Dialog;
|
||||
|
||||
//public PlayerInput Input;
|
||||
|
||||
|
|
@ -105,7 +122,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
private List<IDisposable> _shipSubscriptions = new List<IDisposable>();
|
||||
private float _severeHeatstrokePhase;
|
||||
|
||||
public List<Entity> PlayerEntities { get; } = new List<Entity>();
|
||||
public EquippedDockingBay DockingBay { get; private set; }
|
||||
public Entity DockedEntity { get; private set; }
|
||||
|
||||
|
|
@ -114,8 +130,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
get => _currentEntity;
|
||||
set => _currentEntity = value;
|
||||
}
|
||||
|
||||
public DatabaseCache ItemData { get; private set; }
|
||||
|
||||
public ItemManager ItemManager { get; private set; }
|
||||
public Zone Zone { get; private set; }
|
||||
public List<EntityPack> Loadouts { get; } = new List<EntityPack>();
|
||||
|
|
@ -130,21 +145,32 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
public void SaveLoadout(EntityPack pack)
|
||||
{
|
||||
File.WriteAllBytes(Path.Combine(_loadoutPath.FullName, $"{pack.Name}.preset"), MessagePackSerializer.Serialize(pack));
|
||||
File.WriteAllBytes(Path.Combine(_loadoutPath.FullName, $"{pack.Name}.loadout"), MessagePackSerializer.Serialize(pack));
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
if(CurrentSector!=null)
|
||||
{
|
||||
SaveState();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveState()
|
||||
{
|
||||
PlayerSettings.CurrentRun = new SavedGame(CurrentSector, Zone, CurrentEntity);
|
||||
SavePlayerSettings();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
AkSoundEngine.RegisterGameObj(gameObject);
|
||||
|
||||
ConsoleController.MessageReceiver = this;
|
||||
_loadoutPath = GameDataDirectory.CreateSubdirectory("Loadouts");
|
||||
|
||||
ItemData = new DatabaseCache();
|
||||
ItemData.Load(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack"));
|
||||
ItemManager = new ItemManager(ItemData, Settings.GameplaySettings, Debug.Log);
|
||||
SectorRenderer.ItemManager = ItemManager;
|
||||
ItemManager = new ItemManager(Database, Settings.GameplaySettings, Debug.Log);
|
||||
ZoneRenderer.ItemManager = ItemManager;
|
||||
|
||||
_loadoutPath = GameDataDirectory.CreateSubdirectory("Loadouts");
|
||||
Loadouts.AddRange(_loadoutPath.EnumerateFiles("*.loadout")
|
||||
.Select(fi => MessagePackSerializer.Deserialize<EntityPack>(File.ReadAllBytes(fi.FullName))));
|
||||
|
||||
|
|
@ -158,7 +184,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
_input.Player.MinimapZoom.performed += context =>
|
||||
{
|
||||
_zoomLevelIndex = (_zoomLevelIndex + 1) % Settings.MinimapZoomLevels.Length;
|
||||
SectorRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
|
||||
ZoneRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
|
||||
};
|
||||
|
||||
_input.Global.MapToggle.performed += context =>
|
||||
|
|
@ -214,9 +240,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
if (CurrentEntity == null)
|
||||
{
|
||||
AkSoundEngine.PostEvent("UI_Fail", gameObject);
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't undock. You dont have a ship!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't undock. You dont have a ship!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
else if (CurrentEntity.Parent == null) Dock();
|
||||
else Undock();
|
||||
|
|
@ -226,15 +253,15 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if(CurrentEntity is Ship ship)
|
||||
{
|
||||
foreach (var wormhole in SectorRenderer.WormholeInstances.Keys)
|
||||
foreach (var wormhole in ZoneRenderer.WormholeInstances.Keys)
|
||||
{
|
||||
if (length(wormhole.Position - CurrentEntity.Position.xz) < Settings.GameplaySettings.WormholeExitRadius)
|
||||
{
|
||||
ship.EnterWormhole(wormhole.Position);
|
||||
ship.OnEnteredWormhole += () =>
|
||||
{
|
||||
GenerateLevel();
|
||||
ship.ExitWormhole(SectorRenderer.WormholeInstances.Keys.First().Position,
|
||||
GenerateLevel(wormhole.Target);
|
||||
ship.ExitWormhole(ZoneRenderer.WormholeInstances.Keys.First().Position,
|
||||
Settings.GameplaySettings.WormholeExitVelocity * ItemManager.Random.NextFloat2Direction());
|
||||
CurrentEntity.Zone = Zone;
|
||||
};
|
||||
|
|
@ -418,36 +445,33 @@ public class ActionGameManager : MonoBehaviour
|
|||
#endregion
|
||||
|
||||
StartGame();
|
||||
// ConsoleController.AddCommand("editmode", _ => ToggleEditMode());
|
||||
ConsoleController.AddCommand("savezone", args =>
|
||||
{
|
||||
if (args.Length > 0)
|
||||
Zone.Data.Name = args[0];
|
||||
SaveZone();
|
||||
});
|
||||
|
||||
// MapButton.onClick.AddListener(() =>
|
||||
// {
|
||||
// if (_currentMenuTabButton == MapPanel) return;
|
||||
//
|
||||
// _currentMenuTabButton.GetComponent<TextMeshProUGUI>().color = Color.white;
|
||||
// _currentMenuTabButton = MapButton;
|
||||
// });
|
||||
//
|
||||
//InventoryPanel.Display(ItemManager, entity);
|
||||
}
|
||||
|
||||
public void GenerateLevel()
|
||||
public void GenerateLevel(SectorZone sectorZone = null)
|
||||
{
|
||||
var zonePack = ZoneGenerator.GenerateZone(
|
||||
settings: Settings.ZoneSettings,
|
||||
// mapLayers: Context.MapLayers,
|
||||
// resources: Context.Resources,
|
||||
mass: Settings.DefaultZoneMass,
|
||||
radius: Settings.DefaultZoneRadius
|
||||
);
|
||||
if (sectorZone != null)
|
||||
{
|
||||
if (sectorZone.Contents == null)
|
||||
{
|
||||
sectorZone.PackedContents ??= ZoneGenerator.GenerateZone(
|
||||
settings: Settings.ZoneSettings,
|
||||
mass: Settings.DefaultZoneMass,
|
||||
radius: Settings.DefaultZoneRadius
|
||||
);
|
||||
sectorZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, sectorZone.PackedContents, sectorZone);
|
||||
}
|
||||
Zone = sectorZone.Contents;
|
||||
}
|
||||
else
|
||||
{
|
||||
var zonePack = ZoneGenerator.GenerateZone(
|
||||
settings: Settings.ZoneSettings,
|
||||
mass: Settings.DefaultZoneMass,
|
||||
radius: Settings.DefaultZoneRadius
|
||||
);
|
||||
Zone = new Zone(ItemManager, Settings.PlanetSettings, zonePack, sectorZone);
|
||||
}
|
||||
|
||||
Zone = new Zone(ItemManager, Settings.PlanetSettings, zonePack);
|
||||
Zone.Log = s => Debug.Log($"Zone: {s}");
|
||||
|
||||
if (CurrentEntity != null)
|
||||
|
|
@ -462,7 +486,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
CurrentEntity.Activate();
|
||||
}
|
||||
|
||||
SectorRenderer.LoadZone(Zone);
|
||||
ZoneRenderer.LoadZone(Zone);
|
||||
|
||||
if (CurrentEntity != null)
|
||||
{
|
||||
|
|
@ -514,29 +538,45 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
private void StartGame()
|
||||
{
|
||||
GenerateLevel();
|
||||
if (CurrentSector != null)
|
||||
{
|
||||
if (PlayerSettings.CurrentRun == null)
|
||||
{
|
||||
GenerateLevel(CurrentSector.Entrance);
|
||||
var ship = EntitySerializer.Unpack(ItemManager, Zone, Loadouts.First(x => x.Name == StarterShipTemplate), true);
|
||||
ship.Zone = Zone;
|
||||
Zone.Entities.Add(ship);
|
||||
ship.Activate();
|
||||
BindToEntity(ship);
|
||||
}
|
||||
else
|
||||
{
|
||||
GenerateLevel(CurrentSector.Zones[PlayerSettings.CurrentRun.CurrentZone]);
|
||||
var targetEntity = Zone.Entities[PlayerSettings.CurrentRun.CurrentZoneEntity];
|
||||
if (targetEntity is OrbitalEntity orbitalEntity)
|
||||
DoDock(orbitalEntity, orbitalEntity.DockingBays.First());
|
||||
else
|
||||
BindToEntity(targetEntity);
|
||||
}
|
||||
}
|
||||
else GenerateLevel();
|
||||
|
||||
var stationType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Station);
|
||||
var stationHull = ItemManager.CreateInstance(stationType) as EquippableItem;
|
||||
var stationParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(3);
|
||||
var stationParentOrbit = stationParent.Orbit.Data.ID;
|
||||
var stationParentPos = Zone.GetOrbitPosition(stationParentOrbit);
|
||||
var stationPos = stationParentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f;
|
||||
var stationOrbit = Zone.CreateOrbit(stationParentOrbit, stationPos);
|
||||
var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID, Settings.DefaultEntitySettings);
|
||||
Zone.Entities.Add(station);
|
||||
var dockingBayData = ItemData.GetAll<DockingBayData>().First();
|
||||
var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem;
|
||||
station.TryEquip(dockingBay);
|
||||
station.Activate();
|
||||
// var stationType = Database.GetAll<HullData>().First(x=>x.HullType==HullType.Station);
|
||||
// var stationHull = ItemManager.CreateInstance(stationType) as EquippableItem;
|
||||
// var stationParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(3);
|
||||
// var stationParentOrbit = stationParent.Orbit.Data.ID;
|
||||
// var stationParentPos = Zone.GetOrbitPosition(stationParentOrbit);
|
||||
// var stationPos = stationParentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f;
|
||||
// var stationOrbit = Zone.CreateOrbit(stationParentOrbit, stationPos);
|
||||
// var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID, Settings.DefaultEntitySettings);
|
||||
// Zone.Entities.Add(station);
|
||||
// var dockingBayData = Database.GetAll<DockingBayData>().First();
|
||||
// var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem;
|
||||
// station.TryEquip(dockingBay);
|
||||
// station.Activate();
|
||||
//
|
||||
// DoDock(station, station.DockingBays.First());
|
||||
|
||||
DoDock(station, station.DockingBays.First());
|
||||
|
||||
// var ship = EntityPack.Unpack(ItemManager, Zone, Loadouts.First(x => x.Name == StarterShipTemplate), true);
|
||||
// ship.Zone = Zone;
|
||||
// Zone.Entities.Add(ship);
|
||||
// ship.Activate();
|
||||
// BindToEntity(ship);
|
||||
// ship.ExitWormhole(
|
||||
// SectorRenderer.WormholeInstances.Keys.First().Position,
|
||||
// ItemManager.Random.NextFloat2Direction() * Settings.GameplaySettings.WormholeExitVelocity);
|
||||
|
|
@ -569,14 +609,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
private void DoDock(Entity entity, EquippedDockingBay dockingBay)
|
||||
{
|
||||
DockedEntity = entity;
|
||||
SectorRenderer.PerspectiveEntity = DockedEntity;
|
||||
ZoneRenderer.PerspectiveEntity = DockedEntity;
|
||||
DockingBay = dockingBay;
|
||||
DockCamera.enabled = true;
|
||||
FollowCamera.enabled = false;
|
||||
var orbital = (OrbitalEntity) entity;
|
||||
DockCamera.Follow = SectorRenderer.EntityInstances[orbital].transform;
|
||||
DockCamera.Follow = ZoneRenderer.EntityInstances[orbital].transform;
|
||||
var parentOrbit = Zone.Orbits[orbital.OrbitData].Data.Parent;
|
||||
var parentPlanet = SectorRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key];
|
||||
var parentPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key];
|
||||
DockCamera.LookAt = parentPlanet.Body.transform;
|
||||
Menu.ShowTab(MenuTab.Inventory);
|
||||
}
|
||||
|
|
@ -588,23 +628,26 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if (CurrentEntity.GetBehavior<Cockpit>() == null)
|
||||
{
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't undock. Missing cockpit component!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't undock. Missing cockpit component!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
AkSoundEngine.PostEvent("UI_Fail", gameObject);
|
||||
}
|
||||
else if (CurrentEntity.GetBehavior<Thruster>() == null)
|
||||
{
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't undock. Missing thruster component!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't undock. Missing thruster component!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
AkSoundEngine.PostEvent("UI_Fail", gameObject);
|
||||
}
|
||||
else if (CurrentEntity.GetBehavior<Reactor>() == null)
|
||||
{
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't undock. Missing reactor component!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't undock. Missing reactor component!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
AkSoundEngine.PostEvent("UI_Fail", gameObject);
|
||||
}
|
||||
else if (CurrentEntity.Parent.TryUndock(ship))
|
||||
|
|
@ -614,8 +657,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
else
|
||||
{
|
||||
ConfirmationDialog.Title.text = "Can't undock. Must empty docking bay!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Title.text = "Can't undock. Must empty docking bay!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
AkSoundEngine.PostEvent("UI_Fail", gameObject);
|
||||
}
|
||||
}
|
||||
|
|
@ -641,7 +685,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
private void BindToEntity(Entity entity)
|
||||
{
|
||||
if (!SectorRenderer.EntityInstances.ContainsKey(entity))
|
||||
if (!ZoneRenderer.EntityInstances.ContainsKey(entity))
|
||||
{
|
||||
Debug.LogError($"Attempted to bind to entity {entity.Name}, but SectorRenderer has no such instance!");
|
||||
return;
|
||||
|
|
@ -649,7 +693,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
CurrentEntity = entity;
|
||||
DeathPP.weight = 0;
|
||||
SectorRenderer.PerspectiveEntity = CurrentEntity;
|
||||
ZoneRenderer.PerspectiveEntity = CurrentEntity;
|
||||
|
||||
Menu.gameObject.SetActive(false);
|
||||
DockedEntity = null;
|
||||
|
|
@ -663,17 +707,17 @@ public class ActionGameManager : MonoBehaviour
|
|||
ShipPanel.Display(CurrentEntity, true);
|
||||
SchematicDisplay.ShowShip(CurrentEntity);
|
||||
|
||||
FollowCamera.LookAt = SectorRenderer.EntityInstances[CurrentEntity].LookAtPoint;
|
||||
FollowCamera.Follow = SectorRenderer.EntityInstances[CurrentEntity].transform;
|
||||
FollowCamera.LookAt = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint;
|
||||
FollowCamera.Follow = ZoneRenderer.EntityInstances[CurrentEntity].transform;
|
||||
_articulationGroups = CurrentEntity.Equipment
|
||||
.Where(item => item.Behaviors.Any(x => x.Data is WeaponData && !(x.Data is LauncherData)))
|
||||
.GroupBy(item => SectorRenderer.EntityInstances[CurrentEntity]
|
||||
.GroupBy(item => ZoneRenderer.EntityInstances[CurrentEntity]
|
||||
.GetBarrel(CurrentEntity.Hardpoints[item.Position.x, item.Position.y])
|
||||
.GetComponentInParent<ArticulationPoint>()?.Group ?? -1)
|
||||
.Select((group, index) => {
|
||||
return (
|
||||
group.Select(item => CurrentEntity.Hardpoints[item.Position.x, item.Position.y]).ToArray(),
|
||||
group.Select(item => SectorRenderer.EntityInstances[CurrentEntity].GetBarrel(CurrentEntity.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
|
||||
group.Select(item => ZoneRenderer.EntityInstances[CurrentEntity].GetBarrel(CurrentEntity.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
|
||||
Crosshairs[index]
|
||||
);
|
||||
}).ToArray();
|
||||
|
|
@ -715,9 +759,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
var deathTime = Time.time;
|
||||
UnbindEntity();
|
||||
CurrentEntity = null;
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "You have died!";
|
||||
ConfirmationDialog.Show(StartGame, null, "Try again!");
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "You have died!";
|
||||
Dialog.Show(StartGame, null, "Try again!");
|
||||
Dialog.MoveToCursor();
|
||||
Observable.EveryUpdate()
|
||||
.Select(_ => (Time.time - deathTime) / DeathPPTransitionTime)
|
||||
.Where(t => t < 1)
|
||||
|
|
@ -742,8 +787,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
}).ToArray();
|
||||
}
|
||||
|
||||
public void SaveZone() => File.WriteAllBytes(
|
||||
Path.Combine(_gameDataDirectory.FullName, $"{Zone.Data.Name}.zone"), MessagePackSerializer.Serialize(Zone.Pack()));
|
||||
public void SaveZone(string name) => File.WriteAllBytes(
|
||||
Path.Combine(_gameDataDirectory.FullName, $"{name}.zone"), MessagePackSerializer.Serialize(Zone.PackZone()));
|
||||
|
||||
// public void ToggleEditMode()
|
||||
// {
|
||||
|
|
@ -758,7 +803,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
foreach (var bay in CurrentEntity.Parent.DockingBays)
|
||||
{
|
||||
if (PlayerEntities.Contains(bay.DockedShip)) yield return bay;
|
||||
if (bay.DockedShip.IsPlayerShip) yield return bay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -766,9 +811,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
public IEnumerable<Entity> AvailableEntities()
|
||||
{
|
||||
if(DockedEntity != null)
|
||||
foreach (var entity in PlayerEntities)
|
||||
foreach (var entity in DockedEntity.Children)
|
||||
{
|
||||
if (DockedEntity.Children.Contains(entity)) yield return entity;
|
||||
if (entity is Ship { IsPlayerShip: true }) yield return entity;
|
||||
}
|
||||
else if (CurrentEntity != null)
|
||||
yield return CurrentEntity;
|
||||
|
|
@ -809,7 +854,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
Zone.Update(_time, Time.deltaTime);
|
||||
SectorRenderer.GameTime = _time;
|
||||
ZoneRenderer.GameTime = _time;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
|
|
@ -821,7 +866,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if (CurrentEntity == null || CurrentEntity.Parent != null) return;
|
||||
|
||||
ViewDot.Target = SectorRenderer.EntityInstances[CurrentEntity].LookAtPoint.position;
|
||||
ViewDot.Target = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint.position;
|
||||
if (CurrentEntity.Target.Value != null)
|
||||
TargetIndicator.Target = CurrentEntity.Target.Value.Position;
|
||||
var distance = length((float3)ViewDot.Target - CurrentEntity.Position);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class EntityInstance : MonoBehaviour
|
|||
public Dictionary<Radiator, MeshRenderer> RadiatorMeshes { get; private set; }
|
||||
public Transform LookAtPoint { get; private set; }
|
||||
public Entity Entity { get; private set; }
|
||||
public SectorRenderer SectorRenderer { get; private set; }
|
||||
public ZoneRenderer ZoneRenderer { get; private set; }
|
||||
public bool Visible
|
||||
{
|
||||
get => _fade > 0.01f;
|
||||
|
|
@ -132,11 +132,11 @@ public class EntityInstance : MonoBehaviour
|
|||
_fadingIn = false;
|
||||
}
|
||||
|
||||
public virtual void SetEntity(SectorRenderer sectorRenderer, Entity entity)
|
||||
public virtual void SetEntity(ZoneRenderer zoneRenderer, Entity entity)
|
||||
{
|
||||
gameObject.name = entity.Name;
|
||||
Entity = entity;
|
||||
SectorRenderer = sectorRenderer;
|
||||
ZoneRenderer = zoneRenderer;
|
||||
var hullData = entity.ItemManager.GetData(entity.Hull) as HullData;
|
||||
|
||||
if(Shield)
|
||||
|
|
@ -161,7 +161,7 @@ public class EntityInstance : MonoBehaviour
|
|||
}
|
||||
|
||||
instantWeapon.OnFire += () =>
|
||||
_instantWeaponManagers[data].Fire(instantWeapon, item, this, entity.Target.Value != null && SectorRenderer.EntityInstances.ContainsKey(entity.Target.Value) ? SectorRenderer.EntityInstances[entity.Target.Value] : null);
|
||||
_instantWeaponManagers[data].Fire(instantWeapon, item, this, entity.Target.Value != null && ZoneRenderer.EntityInstances.ContainsKey(entity.Target.Value) ? ZoneRenderer.EntityInstances[entity.Target.Value] : null);
|
||||
|
||||
if (behavior is ChargedWeapon chargedWeapon)
|
||||
{
|
||||
|
|
@ -190,7 +190,7 @@ public class EntityInstance : MonoBehaviour
|
|||
}
|
||||
|
||||
constantWeapon.OnStartFiring += () =>
|
||||
_constantWeaponManagers[data].StartFiring(data, item, this, entity.Target.Value != null ? SectorRenderer.EntityInstances[entity.Target.Value] : null);
|
||||
_constantWeaponManagers[data].StartFiring(data, item, this, entity.Target.Value != null ? ZoneRenderer.EntityInstances[entity.Target.Value] : null);
|
||||
constantWeapon.OnStopFiring += () =>
|
||||
_constantWeaponManagers[data].StopFiring(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class GameSettings : ScriptableObject
|
|||
public PlanetSettings PlanetSettings;
|
||||
public ZoneGenerationSettings ZoneSettings;
|
||||
public GameplaySettings GameplaySettings;
|
||||
public EntitySettings DefaultEntitySettings;
|
||||
public Color HullHitColor;
|
||||
public Color ArmorHitColor;
|
||||
public Color HardpointHitColor;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ public class ShipInstance : EntityInstance
|
|||
|
||||
public Ship Ship { get; private set; }
|
||||
|
||||
public override void SetEntity(SectorRenderer sectorRenderer, Entity entity)
|
||||
public override void SetEntity(ZoneRenderer zoneRenderer, Entity entity)
|
||||
{
|
||||
base.SetEntity(sectorRenderer, entity);
|
||||
base.SetEntity(zoneRenderer, entity);
|
||||
var ship = entity as Ship;
|
||||
if (ship == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,14 +2,20 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
public SectorGenerationSettings Settings;
|
||||
public ConfirmationDialog Dialog;
|
||||
public bool InGame;
|
||||
public Prototype PanelPrototype;
|
||||
public float FadeTime = .5f;
|
||||
|
|
@ -22,10 +28,13 @@ public class MainMenu : MonoBehaviour
|
|||
private float _fadeLerp;
|
||||
private bool _fading;
|
||||
private Vector3 _panelPosition;
|
||||
private DirectoryInfo _saveDirectory;
|
||||
//private Task<DatabaseCache> _databaseLoad;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Start loading the database in the background 'cause it takes a few seconds
|
||||
//_databaseLoad = Task.Run(() => ActionGameManager.Database);
|
||||
|
||||
RegisterResolver.Register();
|
||||
_panelPosition = PanelPrototype.transform.position;
|
||||
|
||||
|
|
@ -36,7 +45,7 @@ public class MainMenu : MonoBehaviour
|
|||
_nextMenu = (panel2, panel2.GetComponent<CanvasGroup>());
|
||||
|
||||
_currentMenu.panel.gameObject.SetActive(false);
|
||||
_saveDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("Saves");
|
||||
//_saveDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("Saves");
|
||||
|
||||
ShowMain();
|
||||
Fade(true);
|
||||
|
|
@ -84,14 +93,36 @@ public class MainMenu : MonoBehaviour
|
|||
if (!InGame)
|
||||
{
|
||||
if(ActionGameManager.PlayerSettings.CurrentRun != null)
|
||||
_nextMenu.panel.AddButton("Continue", () => SceneManager.LoadScene("ARPG"));
|
||||
_nextMenu.panel.AddButton("Continue",
|
||||
() =>
|
||||
{
|
||||
ActionGameManager.CurrentSector = new Sector(ActionGameManager.Database, ActionGameManager.PlayerSettings.CurrentRun);
|
||||
SceneManager.LoadScene("ARPG");
|
||||
});
|
||||
else
|
||||
_nextMenu.panel.AddButton("Continue", null);
|
||||
}
|
||||
_nextMenu.panel.AddButton("New Game",
|
||||
() =>
|
||||
{
|
||||
// TODO: Initialize Run
|
||||
var generatorState = "Loading Database Contents";
|
||||
Action<string> setState = s => generatorState = s;
|
||||
|
||||
Fade(true);
|
||||
_nextMenu.panel.gameObject.SetActive(false);
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Generating Galaxy";
|
||||
Dialog.AddProperty(() => generatorState);
|
||||
Dialog.Show();
|
||||
Settings.NoisePosition = Random.value * 100;
|
||||
|
||||
var task = Task.Run(() => new Sector(Settings, ActionGameManager.Database, 0, setState));
|
||||
task.ContinueWith(task => Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
ActionGameManager.PlayerSettings.CurrentRun = null;
|
||||
ActionGameManager.CurrentSector = task.Result;
|
||||
SceneManager.LoadScene("ARPG");
|
||||
}));
|
||||
});
|
||||
_nextMenu.panel.AddButton("Settings",
|
||||
() =>
|
||||
|
|
|
|||
|
|
@ -147,10 +147,10 @@ public static class RethinkConnection
|
|||
}
|
||||
}).WrapErrors();
|
||||
|
||||
Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).Subscribe(_ =>
|
||||
{
|
||||
Debug.Log(R.Now().Run<DateTime>(connection).ToString() as string);
|
||||
});
|
||||
// Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).Subscribe(_ =>
|
||||
// {
|
||||
// Debug.Log(R.Now().Run<DateTime>(connection).ToString() as string);
|
||||
// });
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class MapView : MonoBehaviour
|
||||
{
|
||||
|
|
@ -15,7 +16,7 @@ public class MapView : MonoBehaviour
|
|||
public Camera Minimap;
|
||||
public MeshRenderer GravityRenderer;
|
||||
public float ZoomSpeed;
|
||||
public SectorRenderer SectorRenderer;
|
||||
[FormerlySerializedAs("SectorRenderer")] public ZoneRenderer ZoneRenderer;
|
||||
|
||||
private Transform _minimapTransform;
|
||||
private CopyTransform _minimapCopyTransform;
|
||||
|
|
@ -57,7 +58,7 @@ public class MapView : MonoBehaviour
|
|||
|
||||
void SetZoom()
|
||||
{
|
||||
SectorRenderer.ViewDistance = _viewDistance * _aspectRatio;
|
||||
ZoneRenderer.ViewDistance = _viewDistance * _aspectRatio;
|
||||
Minimap.orthographicSize = MinimapGravity.orthographicSize = _viewDistance;
|
||||
_gravityRendererTransform.localScale = new Vector3(_viewDistance*_aspectRatio*2, _viewDistance*2, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using Unity.Mathematics;
|
|||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
||||
public class SectorRenderer : MonoBehaviour
|
||||
public class ZoneRenderer : MonoBehaviour
|
||||
{
|
||||
public Transform WormholePrefab;
|
||||
public float EntityFadeTime;
|
||||
|
|
@ -151,7 +151,7 @@ public class SectorRenderer : MonoBehaviour
|
|||
ClearZone();
|
||||
_maxDepth = 0;
|
||||
Zone = zone;
|
||||
SectorBrushes.localScale = zone.Data.Radius * 2 * Vector3.one;
|
||||
SectorBrushes.localScale = zone.Pack.Radius * 2 * Vector3.one;
|
||||
foreach(var p in zone.Planets.Values)
|
||||
LoadPlanet(p);
|
||||
|
||||
|
|
@ -187,12 +187,15 @@ public class SectorRenderer : MonoBehaviour
|
|||
LoadEntity(entity);
|
||||
zone.Entities.ObserveAdd().Subscribe(e => LoadEntity(e.Value));
|
||||
zone.Entities.ObserveRemove().Subscribe(e => UnloadEntity(e.Value));
|
||||
|
||||
var southernWormhole = new Wormhole {Position = float2(0, -Settings.DefaultZoneRadius * Settings.WormholeDistanceRatio)};
|
||||
AddWormhole(southernWormhole);
|
||||
|
||||
var northernWormhole = new Wormhole {Position = float2(0, Settings.DefaultZoneRadius * Settings.WormholeDistanceRatio)};
|
||||
AddWormhole(northernWormhole);
|
||||
if(zone.SectorZone != null)
|
||||
{
|
||||
foreach (var adjacentZone in zone.SectorZone.AdjacentZones)
|
||||
{
|
||||
var dir = normalize(adjacentZone.Position - zone.SectorZone.Position);
|
||||
AddWormhole(new Wormhole {Position = dir * Settings.DefaultZoneRadius * Settings.WormholeDistanceRatio});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddWormhole(Wormhole wormhole)
|
||||
|
|
@ -62,16 +62,14 @@ public class MegaCorporation : DatabaseEntry, INamedEntry
|
|||
[InspectableColor, JsonProperty("secondaryColor"), Key(8)]
|
||||
public float3 SecondaryColor;
|
||||
|
||||
[InspectableTextAsset, JsonProperty("geonames"), Key(9)]
|
||||
public string GeonameFile;
|
||||
[InspectableDatabaseLink(typeof(NameFile)), JsonProperty("nameFile"), Key(9)]
|
||||
public Guid GeonameFile;
|
||||
|
||||
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("bossHull"), Key(10)]
|
||||
public Guid BossHull;
|
||||
|
||||
[InspectableField, JsonProperty("influence"), Key(11)]
|
||||
public int InfluenceDistance = 4;
|
||||
|
||||
[IgnoreMember] public MarkovNameGenerator NameGenerator { get; set; }
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
|
|
@ -79,3 +77,10 @@ public class MegaCorporation : DatabaseEntry, INamedEntry
|
|||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class NameFile : DatabaseEntry
|
||||
{
|
||||
[JsonProperty("names"), Key(1)]
|
||||
public string[] Names;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,6 @@ public class DatabaseCache
|
|||
{
|
||||
RegisterResolver.Register();
|
||||
var entries = AllEntries.ToArray();
|
||||
File.WriteAllBytes(Path.Combine(path, "AetherDB.msgpack"), MessagePackSerializer.Serialize(entries));
|
||||
File.WriteAllBytes(path, MessagePackSerializer.Serialize(entries));
|
||||
}
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ public interface INamedEntry
|
|||
Union(6, typeof(EquippableItem)),
|
||||
Union(7, typeof(BlueprintData)),
|
||||
Union(8, typeof(GalaxyMapLayerData)),
|
||||
// Union(9, typeof(GlobalData)),
|
||||
Union(10, typeof(ZoneData)),
|
||||
Union(9, typeof(NameFile)),
|
||||
//Union(10, typeof(ZoneData)),
|
||||
Union(11, typeof(PlayerData)),
|
||||
Union(12, typeof(Corporation)),
|
||||
Union(13, typeof(MegaCorporation)),
|
||||
|
|
@ -56,4 +56,7 @@ public abstract class DatabaseEntry
|
|||
{
|
||||
[JsonProperty("id"), Key(0)]
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
[IgnoreMember]
|
||||
public DatabaseCache Database;
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ using Unity.Mathematics;
|
|||
|
||||
public static class EntitySerializer
|
||||
{
|
||||
|
||||
public static EntityPack Pack(Entity entity)
|
||||
{
|
||||
EntityPack pack;
|
||||
|
|
@ -21,9 +20,12 @@ public static class EntitySerializer
|
|||
pack = new ShipPack
|
||||
{
|
||||
Position = ship.Position,
|
||||
Direction = ship.Direction
|
||||
Direction = ship.Direction,
|
||||
IsPlayerShip = ship.IsPlayerShip
|
||||
};
|
||||
else throw new ArgumentException("Attempted to pack an instance of abstract class Entity!");
|
||||
|
||||
pack.Settings = entity.Settings;
|
||||
|
||||
// Filter item behavior collections by those with any persistent behaviors
|
||||
// For each item create an object containing the item position and a list of persistent behaviors
|
||||
|
|
@ -52,6 +54,8 @@ public static class EntitySerializer
|
|||
|
||||
public static Entity Unpack(ItemManager itemManager, Zone zone, EntityPack pack, bool instantiate = false)
|
||||
{
|
||||
pack.Settings ??= MessagePackSerializer.Deserialize<EntitySettings>(
|
||||
MessagePackSerializer.Serialize(itemManager.GameplaySettings.DefaultEntitySettings));
|
||||
return pack switch
|
||||
{
|
||||
ShipPack shipPack => Unpack(itemManager, zone, shipPack, instantiate),
|
||||
|
|
@ -63,8 +67,12 @@ public static class EntitySerializer
|
|||
|
||||
private static Ship Unpack(ItemManager itemManager, Zone zone, ShipPack pack, bool instantiate = false)
|
||||
{
|
||||
|
||||
var entity = new Ship(itemManager, zone, instantiate ? (EquippableItem) itemManager.Instantiate(pack.Hull) : pack.Hull, pack.Settings);
|
||||
Restore(itemManager, zone, pack, entity, instantiate);
|
||||
entity.Position = pack.Position;
|
||||
entity.Direction = pack.Direction;
|
||||
entity.IsPlayerShip = pack.IsPlayerShip;
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
|
@ -130,11 +138,9 @@ public static class EntitySerializer
|
|||
[MessagePackObject]
|
||||
public class ShipPack : EntityPack
|
||||
{
|
||||
[Key(15)]
|
||||
public float3 Position;
|
||||
|
||||
[Key(16)]
|
||||
public float2 Direction;
|
||||
[Key(15)] public float3 Position;
|
||||
[Key(16)] public float2 Direction;
|
||||
[Key(17)] public bool IsPlayerShip;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -147,7 +153,7 @@ public class OrbitalEntityPack : EntityPack
|
|||
[MessagePackObject,
|
||||
Union(0, typeof(OrbitalEntityPack)),
|
||||
Union(1, typeof(ShipPack))]
|
||||
public class EntityPack
|
||||
public abstract class EntityPack
|
||||
{
|
||||
[Key(0)]
|
||||
public string Name;
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ public class MarkovNameGenerator
|
|||
private int _maxLength;
|
||||
private Random _random;
|
||||
|
||||
public MarkovNameGenerator(ref Random random, string nameData, SectorGenerationSettings settings)
|
||||
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, SectorGenerationSettings settings)
|
||||
{
|
||||
var names = new HashSet<string>();
|
||||
var lines = nameData.Split('\n');
|
||||
foreach (var line in lines)
|
||||
foreach (var line in sampleNames)
|
||||
{
|
||||
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
|
||||
if (word.Length >= settings.NameGeneratorMinLength && !names.Contains(word))
|
||||
|
|
|
|||
|
|
@ -18,12 +18,6 @@ using Unity.Mathematics;
|
|||
Union(6, typeof(ChatMessage)),
|
||||
Union(7, typeof(ChatBroadcastMessage)),
|
||||
Union(8, typeof(ChangeNameMessage)),
|
||||
Union(9, typeof(GalaxyRequestMessage)),
|
||||
Union(10, typeof(GalaxyResponseMessage)),
|
||||
Union(11, typeof(ZoneRequestMessage)),
|
||||
Union(12, typeof(ZoneResponseMessage)),
|
||||
Union(13, typeof(BlueprintsRequestMessage)),
|
||||
Union(14, typeof(BlueprintsResponseMessage)),
|
||||
MessagePackObject]
|
||||
public abstract class Message
|
||||
{
|
||||
|
|
@ -88,52 +82,3 @@ public class ChangeNameMessage : Message
|
|||
{
|
||||
[Key(0)] public string Name;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class GalaxyRequestMessage : Message
|
||||
{
|
||||
//[Key(0)] public int RequiredByMessagePack;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class GalaxyResponseMessage : Message
|
||||
{
|
||||
[Key(0)] public ZoneDefinition[] Zones;
|
||||
[Key(1)] public GalaxyMapLayerData StarDensity;
|
||||
// [Key(2)] public GlobalData GlobalData;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class ZoneDefinition
|
||||
{
|
||||
[Key(0)] public Guid ZoneID;
|
||||
[Key(1)] public Guid[] Links;
|
||||
[Key(2)] public string Name;
|
||||
[Key(3)] public float2 Position;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class ZoneRequestMessage : Message
|
||||
{
|
||||
[Key(0)] public Guid ZoneID;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class ZoneResponseMessage : Message
|
||||
{
|
||||
[Key(0)] public ZoneData Zone;
|
||||
[Key(1)] public DatabaseEntry[] Contents;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class BlueprintsRequestMessage : Message
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class BlueprintsResponseMessage : Message
|
||||
{
|
||||
[Key(0)] public BlueprintData[] Blueprints;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public static class WeightedSampleElimination
|
|||
}, d_max);
|
||||
}
|
||||
|
||||
public static float2[] GeneratePoints(int count, Func<float2, float> density = null, Func<float2, float> envelope = null, uint seed = 1337)
|
||||
public static float2[] GeneratePoints(int count, Func<float2, float> density = null, Func<float2, float> envelope = null, Action<string> progressCallback = null, uint seed = 1337)
|
||||
{
|
||||
if (density == null) density = v => .5f;
|
||||
if (envelope == null) envelope = v => 1;
|
||||
|
|
@ -101,9 +101,11 @@ public static class WeightedSampleElimination
|
|||
{
|
||||
accumulator = 0;
|
||||
inputSamples[sample++] = v;
|
||||
progressCallback?.Invoke($"Generating Samples: {sample} / {inputSamples.Length}");
|
||||
}
|
||||
}
|
||||
var outputSamples = new float2[count];
|
||||
progressCallback?.Invoke("Eliminating Samples");
|
||||
Eliminate(inputSamples, outputSamples, density);
|
||||
return outputSamples;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,15 @@ public class SavedGame
|
|||
|
||||
[Key(7)]
|
||||
public int CurrentZoneEntity;
|
||||
|
||||
[Key(8)]
|
||||
public SectorGenerationSettings Settings;
|
||||
|
||||
public SavedGame() { }
|
||||
|
||||
public SavedGame(Sector sector)
|
||||
public SavedGame(Sector sector, Zone currentZone, Entity currentEntity)
|
||||
{
|
||||
Settings = sector.Settings;
|
||||
Factions = sector.HomeZones.Keys.Select(f => f.ID).ToArray();
|
||||
|
||||
HomeZones = sector.HomeZones.ToDictionary(
|
||||
|
|
@ -45,15 +49,18 @@ public class SavedGame
|
|||
x => Array.IndexOf(Factions, x.Key.ID),
|
||||
x => Array.IndexOf(sector.Zones, x.Value));
|
||||
|
||||
Zones = sector.Zones.Select(zone=> new SavedZone
|
||||
Zones = sector.Zones.Select(zone => new SavedZone
|
||||
{
|
||||
Name = zone.Name,
|
||||
Position = zone.Position,
|
||||
AdjacentZones = zone.AdjacentZones.Select(az=> Array.IndexOf(sector.Zones, az)).ToArray(),
|
||||
Factions = zone.Factions.Select(f=> Array.IndexOf(Factions, f.ID)).ToArray(),
|
||||
Contents = zone.Contents.Pack(),
|
||||
Owner = Array.IndexOf(Factions, zone.Owner.ID)
|
||||
Contents = zone.Contents?.PackZone(),
|
||||
Owner = zone.Owner == null ? -1 : Array.IndexOf(Factions, zone.Owner.ID)
|
||||
}).ToArray();
|
||||
|
||||
CurrentZone = Array.FindIndex(sector.Zones, zone => zone.Contents == currentZone);
|
||||
CurrentZoneEntity = currentZone.Entities.IndexOf(currentEntity);
|
||||
|
||||
Entrance = Array.IndexOf(sector.Zones, sector.Entrance);
|
||||
Exit = Array.IndexOf(sector.Zones, sector.Exit);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DataStructures.ViliWonka.Heap;
|
||||
using MIConvexHull;
|
||||
using JM.LinqFaster;
|
||||
|
|
@ -13,11 +15,14 @@ public class Sector
|
|||
public Dictionary<MegaCorporation, SectorZone> HomeZones = new Dictionary<MegaCorporation, SectorZone>();
|
||||
public Dictionary<MegaCorporation, SectorZone> BossZones = new Dictionary<MegaCorporation, SectorZone>();
|
||||
|
||||
public SectorGenerationSettings Settings { get; }
|
||||
public MegaCorporation[] Factions { get; }
|
||||
public SectorZone[] Zones { get; }
|
||||
public SectorZone Entrance { get; }
|
||||
public SectorZone Exit { get; }
|
||||
|
||||
private SectorZone[] _exitPath;
|
||||
private Dictionary<MegaCorporation, MarkovNameGenerator> _nameGenerators = new Dictionary<MegaCorporation, MarkovNameGenerator>();
|
||||
|
||||
public SectorZone[] ExitPath
|
||||
{
|
||||
|
|
@ -29,28 +34,30 @@ public class Sector
|
|||
|
||||
public Sector(DatabaseCache database, SavedGame savedGame)
|
||||
{
|
||||
var factions = savedGame.Factions.Select(database.Get<MegaCorporation>).ToArray();
|
||||
Settings = savedGame.Settings;
|
||||
Factions = savedGame.Factions.Select(database.Get<MegaCorporation>).ToArray();
|
||||
Zones = savedGame.Zones.Select(zone =>
|
||||
{
|
||||
return new SectorZone
|
||||
{
|
||||
Name = zone.Name,
|
||||
Position = zone.Position
|
||||
Position = zone.Position,
|
||||
PackedContents = zone.Contents
|
||||
};
|
||||
}).ToArray();
|
||||
for (var i = 0; i < Zones.Length; i++)
|
||||
{
|
||||
Zones[i].AdjacentZones = savedGame.Zones[i].AdjacentZones.Select(azi => Zones[azi]).ToList();
|
||||
Zones[i].Factions = savedGame.Zones[i].Factions.Select(mi => factions[mi]).ToArray();
|
||||
Zones[i].Owner = factions[savedGame.Zones[i].Owner];
|
||||
Zones[i].Factions = savedGame.Zones[i].Factions.Select(mi => Factions[mi]).ToArray();
|
||||
Zones[i].Owner = savedGame.Zones[i].Owner < 0 ? null : Factions[savedGame.Zones[i].Owner];
|
||||
}
|
||||
|
||||
HomeZones = savedGame.HomeZones.ToDictionary(
|
||||
x => factions[x.Key],
|
||||
x => Factions[x.Key],
|
||||
x => Zones[x.Value]);
|
||||
|
||||
BossZones = savedGame.BossZones.ToDictionary(
|
||||
x => factions[x.Key],
|
||||
x => Factions[x.Key],
|
||||
x => Zones[x.Value]);
|
||||
|
||||
Entrance = Zones[savedGame.Entrance];
|
||||
|
|
@ -59,15 +66,24 @@ public class Sector
|
|||
CalculateDistanceMatrix();
|
||||
}
|
||||
|
||||
public Sector(SectorGenerationSettings settings, MegaCorporation[] factions, ref Random random, float minLineSeparation = .01f)
|
||||
public Sector(SectorGenerationSettings settings, DatabaseCache database, uint seed = 0, Action<string> progressCallback = null, float minLineSeparation = .01f)
|
||||
{
|
||||
Settings = settings;
|
||||
var megas = database.GetAll<MegaCorporation>();
|
||||
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
|
||||
Factions = megas.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
|
||||
|
||||
var outputSamples = WeightedSampleElimination.GeneratePoints(settings.ZoneCount,
|
||||
settings.CloudDensity,
|
||||
v => (.2f - lengthsq(v - float2(.5f))) * 4);
|
||||
v => (.2f - lengthsq(v - float2(.5f))) * 4,
|
||||
progressCallback);
|
||||
Zones = outputSamples.Select(v => new SectorZone {Position = v}).ToArray();
|
||||
|
||||
#region Link Placement
|
||||
|
||||
progressCallback?.Invoke("Triangulating Zone Positions");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
|
||||
// Create a delaunay triangulation to connect adjacent sectors
|
||||
var triangulation = DelaunayTriangulation<Vertex2<SectorZone>, Cell2<SectorZone>>
|
||||
.Create(Zones.Select(z => new Vertex2<SectorZone>(z.Position, z)).ToList(), 1e-5f);
|
||||
|
|
@ -85,6 +101,8 @@ public class Sector
|
|||
links.Add((cell.Vertices[0].StoredObject, cell.Vertices[2].StoredObject));
|
||||
}
|
||||
|
||||
progressCallback?.Invoke("Eliminating Zone Links");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
foreach (var link in links.ToArray())
|
||||
{
|
||||
foreach (var zone in Zones)
|
||||
|
|
@ -133,25 +151,33 @@ public class Sector
|
|||
|
||||
#endregion
|
||||
|
||||
progressCallback?.Invoke("Calculating Distance Matrix");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
CalculateDistanceMatrix();
|
||||
|
||||
progressCallback?.Invoke("Finding Chokepoints");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
|
||||
// Entrance is the most isolated zone (highest total distance to all other zones
|
||||
Entrance = Zones.MaxBy(z => z.Isolation);
|
||||
|
||||
// Exit is the zone furthest from the exit
|
||||
Exit = Zones.MaxBy(z => Exit.Distance[z]);
|
||||
// Exit is the zone furthest from the entrance
|
||||
Exit = Zones.MaxBy(z => Entrance.Distance[z]);
|
||||
|
||||
// Find all zones on the exit path where removing that zone would disconnect the entrance from the exit
|
||||
// Disregard "corridor" zones with only two adjacent zones
|
||||
var chokePoints = ExitPath
|
||||
.Where(z => z.AdjacentZones.Count > 2 && !ConnectedRegion(Entrance, z).Contains(Exit));
|
||||
|
||||
|
||||
progressCallback?.Invoke("Placing Factions");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
|
||||
// Choose some megas to have bosses placed based on whether a boss hull is assigned
|
||||
var bossMegas = factions
|
||||
var bossMegas = Factions
|
||||
.Where(m => m.BossHull != Guid.Empty)
|
||||
.Take(settings.BossCount)
|
||||
.ToArray();
|
||||
|
||||
|
||||
// Place boss zones along the critical path as far apart from each other as possible
|
||||
foreach (var mega in bossMegas)
|
||||
{
|
||||
|
|
@ -171,7 +197,7 @@ public class Sector
|
|||
}
|
||||
|
||||
// Place remaining headquarters away from existing megas while also maximizing territory
|
||||
foreach (var mega in factions.Where(m=>!bossMegas.Contains(m)))
|
||||
foreach (var mega in Factions.Where(m=>!bossMegas.Contains(m)))
|
||||
{
|
||||
HomeZones[mega] = Zones.MaxBy(z =>
|
||||
pow(ConnectedRegion(z, mega.InfluenceDistance).Count, HomeZones.Count) *
|
||||
|
|
@ -179,24 +205,53 @@ public class Sector
|
|||
HomeZones.Values.Aggregate(1f, (i, os) => i * sqrt(os.Distance[z])) *
|
||||
BossZones.Values.Aggregate(1f, (i, os) => i * sqrt(os.Distance[z])));
|
||||
}
|
||||
|
||||
progressCallback?.Invoke("Calculating Faction Influence");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
|
||||
// Assign faction presence
|
||||
foreach (var zone in Zones)
|
||||
{
|
||||
// Factions are present in all zones within their sphere of influence
|
||||
zone.Factions = factions
|
||||
zone.Factions = Factions
|
||||
.Where(m => zone.Distance[HomeZones[m]] <= m.InfluenceDistance)
|
||||
.ToArray();
|
||||
|
||||
// Owner of a zone is the faction with the nearest headquarters
|
||||
var nearestFaction = factions.MinBy(m => zone.Distance[HomeZones[m]]);
|
||||
var nearestFaction = Factions.MinBy(m => zone.Distance[HomeZones[m]]);
|
||||
if (zone.Distance[HomeZones[nearestFaction]] <= nearestFaction.InfluenceDistance)
|
||||
zone.Owner = nearestFaction;
|
||||
}
|
||||
|
||||
for (var i = 0; i < Factions.Length; i++)
|
||||
{
|
||||
progressCallback?.Invoke($"Feeding Markov Chains: {i} / {Factions.Length}");
|
||||
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
var faction = Factions[i];
|
||||
_nameGenerators[faction] = new MarkovNameGenerator(ref random, database.Get<NameFile>(faction.GeonameFile).Names, settings);
|
||||
}
|
||||
|
||||
// Generate zone name using the owner's name generator, otherwise assign catalogue ID
|
||||
foreach (var zone in Zones)
|
||||
zone.Name = zone.Owner?.NameGenerator.NextName ?? $"EAC-{random.NextInt(99999).ToString()}";
|
||||
foreach (var zone in Zones)
|
||||
{
|
||||
if (zone.Owner != null)
|
||||
{
|
||||
zone.Name = _nameGenerators[zone.Owner].NextName.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
zone.Name = $"EAC-{random.NextInt(99999).ToString()}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
progressCallback?.Invoke("Done!");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
}
|
||||
|
||||
private void GenerateSector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Cache distance matrix and calculate isolation for every zone (used extensively for placing stuff)
|
||||
|
|
@ -328,4 +383,5 @@ public class SectorZone
|
|||
public MegaCorporation[] Factions;
|
||||
public MegaCorporation Owner;
|
||||
public Zone Contents;
|
||||
public ZonePack PackedContents;
|
||||
}
|
||||
|
|
@ -61,7 +61,6 @@ public class SectorGenerationSettings
|
|||
public float NoiseGain;
|
||||
public float NoiseLacunarity;
|
||||
public float NoiseFrequency;
|
||||
public float Zoom = 1;
|
||||
|
||||
public float fBm(float2 p, int octaves)
|
||||
{
|
||||
|
|
@ -80,7 +79,7 @@ public class SectorGenerationSettings
|
|||
|
||||
public float CloudDensity(float2 uv)
|
||||
{
|
||||
float noise = fBm(uv / Zoom + NoisePosition, 10);
|
||||
float noise = fBm(uv + NoisePosition, 10);
|
||||
return pow(noise, CloudExponent) * CloudAmplitude;
|
||||
}
|
||||
}
|
||||
|
|
@ -133,6 +132,7 @@ public class ZoneGenerationSettings
|
|||
[Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject]
|
||||
public class GameplaySettings
|
||||
{
|
||||
public EntitySettings DefaultEntitySettings;
|
||||
public RarityTier[] Tiers;
|
||||
public float DefaultShutdownPerformance = .25f;
|
||||
public float SevereHeatstrokeRiskThreshold = .25f;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class Ship : Entity
|
|||
// [IgnoreMember] public Targetable Target;
|
||||
public Entity HomeEntity;
|
||||
public float2 MovementDirection;
|
||||
public bool IsPlayerShip;
|
||||
|
||||
private HashSet<EquippedItem> _thrusterItems;
|
||||
private Thruster[] _allThrusters;
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ using Unity.Mathematics;
|
|||
public class Wormhole
|
||||
{
|
||||
public float2 Position;
|
||||
public SectorZone Target;
|
||||
}
|
||||
|
|
@ -34,15 +34,18 @@ public class Zone
|
|||
private Random _random;
|
||||
public List<Agent> Agents = new List<Agent>();
|
||||
|
||||
public ZoneData Data { get; }
|
||||
private List<Task> BeltUpdates = new List<Task>();
|
||||
|
||||
public ZonePack Pack { get; }
|
||||
public SectorZone SectorZone { get; }
|
||||
|
||||
public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack)
|
||||
public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, SectorZone sectorZone)
|
||||
{
|
||||
SectorZone = sectorZone;
|
||||
Pack = pack;
|
||||
_itemManager = itemManager;
|
||||
Data = pack.Data;
|
||||
Settings = settings;
|
||||
_random = new Random(Convert.ToUInt32(abs(Data.ID.GetHashCode())));
|
||||
_random = new Random(Convert.ToUInt32(abs(sectorZone?.Name.GetHashCode() ?? 1337)));
|
||||
|
||||
foreach (var orbit in pack.Orbits)
|
||||
{
|
||||
|
|
@ -66,19 +69,22 @@ public class Zone
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var entity in pack.Entities)
|
||||
foreach (var entityPack in pack.Entities)
|
||||
{
|
||||
Entities.Add(EntitySerializer.Unpack(_itemManager, this, entity));
|
||||
var entity = EntitySerializer.Unpack(_itemManager, this, entityPack);
|
||||
Entities.Add(entity);
|
||||
entity.Activate();
|
||||
}
|
||||
|
||||
// TODO: Associate planets with stored entities for planetary colonies
|
||||
}
|
||||
|
||||
public ZonePack Pack()
|
||||
public ZonePack PackZone()
|
||||
{
|
||||
return new ZonePack
|
||||
{
|
||||
Data = Data,
|
||||
Radius = Pack.Radius,
|
||||
Mass = Pack.Mass,
|
||||
Entities = Entities.Select(EntitySerializer.Pack).ToList(),
|
||||
Orbits = Orbits.Values.Select(o=>o.Data).ToList(),
|
||||
Planets = Planets.Values.ToList()
|
||||
|
|
@ -118,12 +124,6 @@ public class Zone
|
|||
|
||||
foreach (var entity in Entities.ToArray()) entity.Update(deltaTime);
|
||||
}
|
||||
|
||||
public float2 WormholePosition(ZoneDefinition target)
|
||||
{
|
||||
var direction = target.Position - Data.Position;
|
||||
return normalize(direction) * Data.Radius * .95f;
|
||||
}
|
||||
|
||||
// Determine orbital position recursively, caching parent positions to avoid repeated calculations
|
||||
public float2 GetOrbitPosition(Guid orbitID)
|
||||
|
|
@ -284,7 +284,7 @@ public class Zone
|
|||
}
|
||||
public float GetHeight(float2 position)
|
||||
{
|
||||
float result = -PowerPulse(length(position)/(Data.Radius*2), Settings.ZoneDepthExponent) * Settings.ZoneDepth;
|
||||
float result = -PowerPulse(length(position)/(Pack.Radius*2), Settings.ZoneDepthExponent) * Settings.ZoneDepth;
|
||||
foreach (var body in PlanetInstances.Values)
|
||||
{
|
||||
var p = position - body.Orbit.Position; //GetOrbitPosition(body.BodyData.Orbit)
|
||||
|
|
@ -343,11 +343,6 @@ public class Zone
|
|||
float3 normal = new float3((hL - hR), (hD - hU), step*2);
|
||||
return normalize(normal).xzy;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Data.ID.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class Planet
|
||||
|
|
|
|||
|
|
@ -13,60 +13,23 @@ using static Unity.Mathematics.math;
|
|||
using float2 = Unity.Mathematics.float2;
|
||||
using float3 = Unity.Mathematics.float3;
|
||||
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ZoneData : DatabaseEntry, INamedEntry
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ZonePack
|
||||
{
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[JsonProperty("position"), Key(2)]
|
||||
public float2 Position = 500;
|
||||
|
||||
[JsonProperty("planets"), Key(0)]
|
||||
public List<BodyData> Planets = new List<BodyData>();
|
||||
|
||||
[JsonProperty("orbits"), Key(1)]
|
||||
public List<OrbitData> Orbits = new List<OrbitData>();
|
||||
|
||||
[JsonProperty("entities"), Key(2)]
|
||||
public List<EntityPack> Entities = new List<EntityPack>();
|
||||
|
||||
[JsonProperty("radius"), Key(3)]
|
||||
public float Radius = 2000;
|
||||
|
||||
[JsonProperty("mass"), Key(4)]
|
||||
public float Mass = 10000;
|
||||
|
||||
// [JsonProperty("visited"), Key(5)]
|
||||
// public bool Visited;
|
||||
|
||||
[JsonProperty("wormholes"), Key(5)]
|
||||
public List<Guid> Wormholes = new List<Guid>();
|
||||
|
||||
// [JsonProperty("planets"), Key(7)]
|
||||
// public Guid[] Planets;// = new List<Guid>();
|
||||
//
|
||||
// [JsonProperty("orbits"), Key(8)]
|
||||
// public List<Guid> Orbits = new List<Guid>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ZonePack : INamedEntry
|
||||
{
|
||||
[JsonProperty("data"), Key(0)]
|
||||
public ZoneData Data;
|
||||
|
||||
[JsonProperty("planets"), Key(1)]
|
||||
public List<BodyData> Planets = new List<BodyData>();
|
||||
|
||||
[JsonProperty("orbits"), Key(2)]
|
||||
public List<OrbitData> Orbits = new List<OrbitData>();
|
||||
|
||||
[JsonProperty("entities"), Key(3)]
|
||||
public List<EntityPack> Entities = new List<EntityPack>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Data.Name;
|
||||
set => Data.Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
// [RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -227,7 +190,7 @@ public class OrbitData : DatabaseEntry
|
|||
[JsonProperty("phase"), Key(3)]
|
||||
public float Phase;
|
||||
|
||||
[JsonProperty("phase"), Key(3)]
|
||||
[JsonProperty("phase"), Key(4)]
|
||||
public float2 FixedPosition = float2.zero;
|
||||
|
||||
// [JsonProperty("period"), Key(4)]
|
||||
|
|
|
|||
|
|
@ -73,19 +73,11 @@ public class ZoneGenerator
|
|||
Random random,
|
||||
int targetSubzoneCount)
|
||||
{
|
||||
var zone = new ZoneData
|
||||
{
|
||||
Name = name,
|
||||
Position = position
|
||||
};
|
||||
|
||||
var pack = new ZonePack();
|
||||
|
||||
var pack = new ZonePack
|
||||
{
|
||||
Data = zone
|
||||
};
|
||||
|
||||
zone.Radius = radius;
|
||||
zone.Mass = mass;
|
||||
pack.Radius = radius;
|
||||
pack.Mass = mass;
|
||||
|
||||
//Debug.Log($"Generating zone at position {zone.Position} with radius {zoneRadius} and mass {zoneMass}");
|
||||
|
||||
|
|
@ -122,11 +114,11 @@ public class ZoneGenerator
|
|||
var totalArea = occupiedAreas.Sum(c => c.Area);
|
||||
foreach (var c in occupiedAreas)
|
||||
{
|
||||
planets.AddRange(GenerateEntities(settings, ref random, c.Area / totalArea * zone.Mass, c.Radius, c.Center));
|
||||
planets.AddRange(GenerateEntities(settings, ref random, c.Area / totalArea * pack.Mass, c.Radius, c.Center));
|
||||
}
|
||||
}
|
||||
else
|
||||
planets.AddRange(GenerateEntities(settings, ref random, zone.Mass, zone.Radius, float2.zero));
|
||||
planets.AddRange(GenerateEntities(settings, ref random, pack.Mass, pack.Radius, float2.zero));
|
||||
|
||||
// Create collections to map between zone generator output and database entries
|
||||
var orbitMap = new Dictionary<GeneratorPlanet, OrbitData>();
|
||||
|
|
|
|||
|
|
@ -18,26 +18,20 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
public Button Confirm;
|
||||
public TextMeshProUGUI ConfirmText;
|
||||
public TextMeshProUGUI CancelText;
|
||||
|
||||
public bool LockDialog { get; set; }
|
||||
|
||||
private Action _onCancel;
|
||||
private Action _onConfirm;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cancel.onClick.AddListener(() =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
End();
|
||||
});
|
||||
Confirm.onClick.AddListener(() =>
|
||||
{
|
||||
_onConfirm?.Invoke();
|
||||
End();
|
||||
});
|
||||
Cancel.onClick.AddListener(() => End());
|
||||
Confirm.onClick.AddListener(() => End());
|
||||
if (CancelClickCatcher != null)
|
||||
CancelClickCatcher.OnClick += data =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
if (LockDialog) return;
|
||||
End();
|
||||
};
|
||||
|
||||
|
|
@ -49,12 +43,19 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void End()
|
||||
public void End(bool success = false)
|
||||
{
|
||||
CancelClickCatcher.gameObject.SetActive(false);
|
||||
if(success) _onConfirm?.Invoke();
|
||||
else _onCancel?.Invoke();
|
||||
CancelClickCatcher?.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void MoveToCursor()
|
||||
{
|
||||
transform.position = Mouse.current.position.ReadValue();
|
||||
}
|
||||
|
||||
public void Show(Action onConfirm = null, Action onCancel = null, string confirmText = "OK", string cancelText = "Cancel")
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
|
@ -69,7 +70,6 @@ public class ConfirmationDialog : PropertiesPanel
|
|||
|
||||
ButtonGroup.SetActive(onConfirm!=null || onCancel!=null);
|
||||
|
||||
transform.position = Mouse.current.position.ReadValue();
|
||||
CancelClickCatcher.gameObject.SetActive(true);
|
||||
CancelClickCatcher?.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class ConsoleView : MonoBehaviour {
|
|||
{
|
||||
//AcceptingInput = false;
|
||||
//_console = new ConsoleController();
|
||||
Application.logMessageReceived += (condition, trace, type) => ConsoleController.Instance.AppendLogLine("<color=" + (type == LogType.Error ? "red" : type == LogType.Warning ? "yellow" : "white") + ">" + condition + "</color>");
|
||||
Application.logMessageReceived += OnLogCallback;
|
||||
|
||||
SetVisibility(false);
|
||||
|
||||
|
|
@ -56,8 +56,14 @@ public class ConsoleView : MonoBehaviour {
|
|||
|
||||
// var sizeFitter = GetComponentInChildren<ContentSizeFitter>().on
|
||||
}
|
||||
|
||||
~ConsoleView() {
|
||||
|
||||
private void OnLogCallback(string condition, string trace, LogType type)
|
||||
{
|
||||
ConsoleController.Instance.AppendLogLine("<color=" + (type == LogType.Error ? "red" : type == LogType.Warning ? "yellow" : "white") + ">" + condition + "</color>");
|
||||
}
|
||||
|
||||
~ConsoleView() {
|
||||
Application.logMessageReceived -= OnLogCallback;
|
||||
ConsoleController.Instance.VisibilityChanged -= OnVisibilityChanged;
|
||||
ConsoleController.Instance.LogChanged -= OnLogChanged;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
Dialog.Title.text = "Unable to move item!";
|
||||
Dialog.AddProperty("Verify that cargo bays are empty before un-equipping them.");
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +207,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
Dialog.Title.text = "Unable to destroy item!";
|
||||
Dialog.AddProperty("Verify that cargo bays are empty before un-equipping them.");
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -389,6 +391,8 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
panel.OnBackgroundClick.Subscribe(data =>
|
||||
{
|
||||
if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh!
|
||||
|
||||
PropertiesPanel.Clear();
|
||||
PropertiesPanel.AddField("Shutdown Threshold",
|
||||
() => GameManager.CurrentEntity.Settings.ShutdownPerformance,
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ using UnityEngine.UI;
|
|||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Serialization;
|
||||
using static Unity.Mathematics.math;
|
||||
using int2 = Unity.Mathematics.int2;
|
||||
|
||||
public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public ConfirmationDialog ConfirmationDialog;
|
||||
[FormerlySerializedAs("ConfirmationDialog")] public ConfirmationDialog Dialog;
|
||||
public bool Flip;
|
||||
public GameSettings Settings;
|
||||
public ActionGameManager GameManager;
|
||||
|
|
@ -113,9 +114,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
ConfirmationDialog.Clear();
|
||||
ConfirmationDialog.Title.text = "Can't select entity, you can only pilot a ship!";
|
||||
ConfirmationDialog.Show();
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Can't select entity, you can only pilot a ship!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -157,11 +159,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
{
|
||||
var entity = EntitySerializer.Unpack(GameManager.ItemManager, GameManager.Zone, pack, true);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
GameManager.PlayerEntities.Add(entity);
|
||||
GameManager.Credits -= pack.Price(GameManager.ItemManager);
|
||||
GameManager.CurrentEntity = entity;
|
||||
if(entity is Ship ship)
|
||||
{
|
||||
ship.IsPlayerShip = true;
|
||||
GameManager.DockingBay.DockedShip = ship;
|
||||
}
|
||||
Display(entity);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -13,7 +14,8 @@ using int2 = Unity.Mathematics.int2;
|
|||
|
||||
public class MapRenderer : MonoBehaviour
|
||||
{
|
||||
public Canvas Canvas;
|
||||
public ActionGameManager GameManager;
|
||||
public TextMeshProUGUI Title;
|
||||
public Camera MapOverlayCamera;
|
||||
public Camera GravityCamera;
|
||||
public Camera TintCamera;
|
||||
|
|
@ -41,6 +43,7 @@ public class MapRenderer : MonoBehaviour
|
|||
MapOverlayCamera.gameObject.SetActive(true);
|
||||
GravityCamera.gameObject.SetActive(true);
|
||||
TintCamera.gameObject.SetActive(true);
|
||||
Title.text = $"Zone: {GameManager.Zone.SectorZone.Name}";
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
|
@ -75,8 +78,6 @@ public class MapRenderer : MonoBehaviour
|
|||
_tintTexture.Release();
|
||||
_tintTexture = null;
|
||||
}
|
||||
var canvasCorners = new Vector3[4];
|
||||
Canvas.GetComponent<RectTransform>().GetWorldCorners(canvasCorners);
|
||||
_mapTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
|
||||
MapOverlayCamera.targetTexture = _mapTexture;
|
||||
OverlayDisplay.material.SetTexture("_DetailTex", _mapTexture);
|
||||
|
|
|
|||
|
|
@ -72,5 +72,6 @@ public enum MenuTab
|
|||
{
|
||||
Map,
|
||||
Inventory,
|
||||
Trade
|
||||
Trade,
|
||||
Galaxy
|
||||
}
|
||||
|
|
@ -95,6 +95,19 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return section;
|
||||
}
|
||||
|
||||
public Property AddProperty(Func<string> read)
|
||||
{
|
||||
if (read == null) throw new ArgumentException("Attempted to add property with null read function!");
|
||||
|
||||
var property = Instantiate(Property, Content ?? transform);
|
||||
property.Label.text = read();
|
||||
|
||||
RefreshPropertyValues += () => property.Label.text = read();
|
||||
Properties.Add(property.gameObject);
|
||||
OnPropertyAdded?.Invoke(property.gameObject);
|
||||
return property;
|
||||
}
|
||||
|
||||
public Property AddProperty(string name, Func<string> read = null)
|
||||
{
|
||||
Property property;
|
||||
|
|
@ -348,7 +361,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public void AddItemProperties(Entity entity, ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
AddProperty(data.Description).Label.fontStyle = FontStyles.Normal;
|
||||
AddProperty(data.Description);//.Label.fontStyle = FontStyles.Normal;
|
||||
var manufacturer = Context.ItemData.Get<MegaCorporation>(data.Manufacturer);
|
||||
if (manufacturer != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -16,7 +17,6 @@ public class SectorMap : MonoBehaviour
|
|||
public Camera InfluenceCamera;
|
||||
public Prototype InfluenceRendererPrototype;
|
||||
public MeshRenderer SectorRenderer;
|
||||
public SectorGenerationSettings Settings;
|
||||
public Prototype ZonePrototype;
|
||||
public Prototype LinkPrototype;
|
||||
public Prototype IconPrototype;
|
||||
|
|
@ -38,40 +38,34 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private Dictionary<MegaCorporation, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
|
||||
new Dictionary<MegaCorporation, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
|
||||
|
||||
void Start()
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
var cache = new DatabaseCache();
|
||||
cache.Load(Path.Combine(filePath.FullName, "AetherDB.msgpack"));
|
||||
|
||||
var megas = cache.GetAll<MegaCorporation>();
|
||||
|
||||
var random = new Unity.Mathematics.Random((uint) (DateTime.Now.Ticks % uint.MaxValue));
|
||||
var sectorMegas = megas.OrderBy(x => Random.value).Take(Settings.MegaCount).ToArray();
|
||||
foreach (var mega in sectorMegas)
|
||||
if (ActionGameManager.CurrentSector == null)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var primary = Instantiate(ZonePrimaryMaterial);
|
||||
primary.SetColor("_TintColor", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
|
||||
primary.SetColor("_Color", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
|
||||
var secondary = Instantiate(ZoneSecondaryMaterial);
|
||||
secondary.SetColor("_TintColor", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
|
||||
secondary.SetColor("_Color", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
|
||||
var link = Instantiate(ZoneLinkMaterial);
|
||||
link.SetColor("_TintColor", (mega.PrimaryColor * MegaLinkBoost).ToColor());
|
||||
_factionMaterials.Add(mega, (new RenderTexture(1024, 1024, 1, RenderTextureFormat.RHalf), primary, secondary, link));
|
||||
mega.NameGenerator = new MarkovNameGenerator(ref random, UnityHelpers.LoadAsset<TextAsset>(mega.GeonameFile).text, Settings);
|
||||
link.SetColor("_Color", (mega.PrimaryColor * MegaLinkBoost).ToColor());
|
||||
_factionMaterials.Add(mega, (new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf), primary, secondary, link));
|
||||
var legendElement = LegendPrototype.Instantiate<LegendElement>();
|
||||
legendElement.Primary.color = mega.PrimaryColor.ToColor();
|
||||
legendElement.Secondary.color = mega.SecondaryColor.ToColor();
|
||||
legendElement.Label.text = mega.ShortName;
|
||||
}
|
||||
|
||||
Settings.NoisePosition = Random.value * 100;
|
||||
var sector = new Sector(Settings, sectorMegas, ref random);
|
||||
var visitedZones = new HashSet<SectorZone>();
|
||||
Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
|
||||
//Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
|
||||
|
||||
var zoneInstances = new Dictionary<SectorZone, SectorZoneUI>();
|
||||
foreach (var zone in sector.Zones)
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
zoneInstances[zone] = zoneInstance;
|
||||
|
|
@ -109,10 +103,10 @@ public class SectorMap : MonoBehaviour
|
|||
zoneText.text = zone.Name;
|
||||
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
|
||||
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
|
||||
visitedZones.Add(zone);
|
||||
|
||||
if (zone == sector.Entrance)
|
||||
if (zone == ActionGameManager.CurrentSector.Entrance)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = EntranceIcon;
|
||||
|
|
@ -122,7 +116,7 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
if (zone == sector.Exit)
|
||||
if (zone == ActionGameManager.CurrentSector.Exit)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = ExitIcon;
|
||||
|
|
@ -132,15 +126,16 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var homeMega = sector.HomeZones.Keys.FirstOrDefault(m => sector.HomeZones[m] == zone);
|
||||
var homeMega = ActionGameManager.CurrentSector.HomeZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.HomeZones[m] == zone);
|
||||
if (homeMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_TintColor", homeMega.SecondaryColor.ToColor());
|
||||
backgroundInstance.material.SetColor("_Color", homeMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = HomeIcon;
|
||||
iconInstance.material.SetColor("_TintColor", homeMega.PrimaryColor.ToColor());
|
||||
iconInstance.material.SetColor("_Color", homeMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
|
@ -155,15 +150,16 @@ public class SectorMap : MonoBehaviour
|
|||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var bossMega = sector.BossZones.Keys.FirstOrDefault(m => sector.BossZones[m] == zone);
|
||||
var bossMega = ActionGameManager.CurrentSector.BossZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.BossZones[m] == zone);
|
||||
if (bossMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_TintColor", bossMega.SecondaryColor.ToColor());
|
||||
backgroundInstance.material.SetColor("_Color", bossMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = BossIcon;
|
||||
iconInstance.material.SetColor("_TintColor", bossMega.PrimaryColor.ToColor());
|
||||
iconInstance.material.SetColor("_Color", bossMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
|
@ -188,10 +184,10 @@ public class SectorMap : MonoBehaviour
|
|||
}
|
||||
|
||||
// Render Influence Textures
|
||||
foreach (var mega in sectorMegas)
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
|
||||
foreach (var zone in sector.Zones)
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var instance = zoneInstances[zone];
|
||||
var influence = 0f;
|
||||
|
|
@ -214,21 +210,16 @@ public class SectorMap : MonoBehaviour
|
|||
influenceRenderer.material.mainTexture = _factionMaterials[mega].influence;
|
||||
influenceRenderer.material.SetColor("_Color1", mega.PrimaryColor.ToColor());
|
||||
influenceRenderer.material.SetColor("_Color2", mega.SecondaryColor.ToColor());
|
||||
influenceRenderer.material.SetFloat("_FillTilt", random.NextFloat(PI));
|
||||
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
SectorRenderer.material.SetFloat("CloudAmplitude", Settings.CloudAmplitude);
|
||||
SectorRenderer.material.SetFloat("CloudExponent", Settings.CloudExponent);
|
||||
SectorRenderer.material.SetFloat("NoisePosition", Settings.NoisePosition);
|
||||
SectorRenderer.material.SetFloat("Zoom", Settings.Zoom);
|
||||
SectorRenderer.material.SetFloat("NoiseAmplitude", Settings.NoiseAmplitude);
|
||||
SectorRenderer.material.SetFloat("NoiseOffset", Settings.NoiseOffset);
|
||||
SectorRenderer.material.SetFloat("NoiseGain", Settings.NoiseGain);
|
||||
SectorRenderer.material.SetFloat("NoiseLacunarity", Settings.NoiseLacunarity);
|
||||
SectorRenderer.material.SetFloat("NoiseFrequency", Settings.NoiseFrequency);
|
||||
|
||||
SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentSector.Settings.CloudAmplitude);
|
||||
SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentSector.Settings.CloudExponent);
|
||||
SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentSector.Settings.NoisePosition);
|
||||
SectorRenderer.material.SetFloat("NoiseAmplitude", ActionGameManager.CurrentSector.Settings.NoiseAmplitude);
|
||||
SectorRenderer.material.SetFloat("NoiseOffset", ActionGameManager.CurrentSector.Settings.NoiseOffset);
|
||||
SectorRenderer.material.SetFloat("NoiseGain", ActionGameManager.CurrentSector.Settings.NoiseGain);
|
||||
SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentSector.Settings.NoiseLacunarity);
|
||||
SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentSector.Settings.NoiseFrequency);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ public class TradeMenu : MonoBehaviour
|
|||
data => () =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.PlayerEntities.Count(s => s.Hull.Data == data.ID && s.Parent == GameManager.DockedEntity).ToString();
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && 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();
|
||||
|
|
@ -280,7 +280,7 @@ public class TradeMenu : MonoBehaviour
|
|||
data =>
|
||||
{
|
||||
if (data is HullData)
|
||||
return GameManager.PlayerEntities.Count(s => s.Hull.Data == data.ID && s.Parent == GameManager.DockedEntity);
|
||||
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && 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;
|
||||
|
|
@ -344,6 +344,7 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
Populate();
|
||||
});
|
||||
Dialog.MoveToCursor();
|
||||
});
|
||||
ContextMenu.Show();
|
||||
}
|
||||
|
|
@ -358,10 +359,9 @@ public class TradeMenu : MonoBehaviour
|
|||
var hull = GameManager.ItemManager.CreateInstance(data) as EquippableItem;
|
||||
Entity entity;
|
||||
if(data.HullType==HullType.Ship)
|
||||
entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull, GameManager.Settings.DefaultEntitySettings);
|
||||
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, Guid.Empty, GameManager.Settings.DefaultEntitySettings);
|
||||
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);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
GameManager.PlayerEntities.Add(entity);
|
||||
|
||||
GameManager.Credits -= data.Price;
|
||||
}
|
||||
|
|
@ -370,6 +370,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,6 +389,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -396,6 +398,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -421,6 +424,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -429,6 +433,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Dialog.Clear();
|
||||
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
|
||||
Dialog.Show();
|
||||
Dialog.MoveToCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -448,7 +453,7 @@ public class TradeMenu : MonoBehaviour
|
|||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
});
|
||||
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(GameManager.PlayerEntities.Contains))
|
||||
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(e => e is Ship {IsPlayerShip: true}))
|
||||
{
|
||||
foreach (var bay in ship.CargoBays.Select((bay, index) => (bay, index)))
|
||||
ContextMenu.AddOption($"{ship.Name} Bay {bay.index}",
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
using System;
|
||||
/* 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;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ZoneRenderer : MonoBehaviour
|
||||
{
|
||||
public Camera FollowCamera;
|
||||
public RenderTexture GravityTexture;
|
||||
public MeshRenderer GravityRenderer;
|
||||
|
||||
private int _resX, _resY;
|
||||
private float _ratio;
|
||||
private Camera _camera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
private void OnPreRender()
|
||||
{
|
||||
_camera.transform.position = FollowCamera.transform.position;
|
||||
if (Screen.width != _resX || Screen.height != _resY)
|
||||
{
|
||||
_resX = Screen.width;
|
||||
_resY = Screen.height;
|
||||
_ratio = (float) _resX / _resY;
|
||||
if (GravityTexture != null)
|
||||
{
|
||||
GravityTexture?.Release();
|
||||
}
|
||||
GravityTexture = new RenderTexture(_resX, _resY, 0, RenderTextureFormat.RFloat);
|
||||
}
|
||||
|
||||
GravityRenderer.material.mainTexture = GravityTexture;
|
||||
|
||||
var size = _camera.orthographicSize = FollowCamera.orthographicSize;
|
||||
|
||||
GravityRenderer.transform.position = new Vector3(transform.position.x, transform.position.y, .25f);
|
||||
GravityRenderer.transform.localScale = new Vector3(size * 2 * _ratio, size * 2, 1);
|
||||
|
||||
_camera.targetTexture = GravityTexture;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04277e392af12204397c334ea824f957
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue