diff --git a/Asset Sources/Alakrita1.blend b/Asset Sources/Alakrita1.blend new file mode 100644 index 000000000..b3a308d38 --- /dev/null +++ b/Asset Sources/Alakrita1.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ce3ee9a61aff675c8dc5239618973954315a80188fe771cc4f005251df211e6 +size 96189756 diff --git a/Asset Sources/Alakrita1.blend1 b/Asset Sources/Alakrita1.blend1 new file mode 100644 index 000000000..a71045b70 Binary files /dev/null and b/Asset Sources/Alakrita1.blend1 differ diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index 718ff9aa1..45a62ffe4 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -15960,12 +15960,12 @@ MonoBehaviour: Credits: 100000000 TargetSpottedBlinkFrequency: 20 TargetSpottedBlinkOffset: -0.25 - DeathPPTransitionTime: 1 - DeathPP: {fileID: 803284856} - HeatstrokePP: {fileID: 1404901906} - HypothermiaPP: {fileID: 1800086610} - SevereHeatstrokePP: {fileID: 837424435} - SevereHypothermiaPP: {fileID: 694183021} + DeathPostTransitionTime: 1 + DeathPost: {fileID: 803284856} + HeatstrokePost: {fileID: 1404901906} + HypothermiaPost: {fileID: 1800086610} + SevereHeatstrokePost: {fileID: 837424435} + SevereHypothermiaPost: {fileID: 694183021} UiRoot: {fileID: 761574177} HelpScreen: {fileID: 1210651002} InputDisplayLayout: {fileID: 1088218870} @@ -16151,8 +16151,6 @@ MonoBehaviour: CompassIconPrototype: {fileID: 336445422} OrbitalIcon: {fileID: 21300000, guid: 97bce58bfe43bfa40870ca062cfb7ec1, type: 3} WormholeIcon: {fileID: 21300000, guid: 6d0b27330fdcc8347b1e09a2d17a0673, type: 3} - PlanetoidIcon: {fileID: 2800000, guid: 823d8a1c4e071994087624c39f62b319, type: 3} - PlanetIcon: {fileID: 2800000, guid: 0d2acbd593b7fd349b0b26b4844733ef, type: 3} --- !u!114 &1009503735 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 812d38f89..12269baba 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -121,7 +121,7 @@ public class ActionGameManager : MonoBehaviour return settings; } - public static Sector CurrentSector; + public static Galaxy CurrentGalaxy; public static bool IsTutorial; public GameSettings Settings; @@ -132,12 +132,12 @@ public class ActionGameManager : MonoBehaviour public float TargetSpottedBlinkOffset = -.25f; [Header("Postprocessing")] - public float DeathPPTransitionTime; - public PostProcessVolume DeathPP; - public PostProcessVolume HeatstrokePP; - public PostProcessVolume HypothermiaPP; - public PostProcessVolume SevereHeatstrokePP; - public PostProcessVolume SevereHypothermiaPP; + public float DeathPostTransitionTime; + public PostProcessVolume DeathPost; + public PostProcessVolume HeatstrokePost; + public PostProcessVolume HypothermiaPost; + public PostProcessVolume SevereHeatstrokePost; + public PostProcessVolume SevereHypothermiaPost; [Header("Scene Links")] public GameObject UiRoot; @@ -262,7 +262,7 @@ public class ActionGameManager : MonoBehaviour public void SaveState() { - PlayerSettings.SavedRun = CurrentSector == null ? null : new SavedGame(CurrentSector, Zone, DockedEntity ?? CurrentEntity); + PlayerSettings.SavedRun = CurrentGalaxy == null ? null : new SavedGame(CurrentGalaxy, Zone, DockedEntity ?? CurrentEntity); if(PlayerSettings.SavedRun != null) { PlayerSettings.SavedRun.IsTutorial = IsTutorial; @@ -499,9 +499,9 @@ public class ActionGameManager : MonoBehaviour ConsoleController.AddCommand("revealzones", _ => { - foreach (var zones in CurrentSector.Zones - .Where(z=>!CurrentSector.DiscoveredZones.Contains(z)) - .GroupBy(z=>z.Distance[CurrentSector.Entrance]) + foreach (var zones in CurrentGalaxy.Zones + .Where(z=>!CurrentGalaxy.DiscoveredZones.Contains(z)) + .GroupBy(z=>z.Distance[CurrentGalaxy.Entrance]) .OrderBy(g=>g.Key)) { SectorMap.QueueZoneReveal(zones); @@ -541,13 +541,13 @@ public class ActionGameManager : MonoBehaviour ConsoleController.AddCommand("spawnturret", _ => { - var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]); + var nearestFaction = CurrentGalaxy.Factions.MinBy(f => CurrentGalaxy.HomeZones[f].Distance[Zone.GalaxyZone]); var loadoutGenerator = IsTutorial ? new LoadoutGenerator( ref ItemManager.Random, ItemManager, - CurrentSector, - Zone.SectorZone, + CurrentGalaxy, + Zone.GalaxyZone, nearestFaction, .5f) : new LoadoutGenerator( ref ItemManager.Random, @@ -644,7 +644,7 @@ public class ActionGameManager : MonoBehaviour private void EnterWormhole(Wormhole wormhole) { - if (!(CurrentEntity is Ship ship)) return; + if (!(CurrentEntity is Ship ship) || ship.WormholeAnimationInProgress) return; // var wormholeCameraFollow = new GameObject("Wormhole Camera Follow").transform; // wormholeCameraFollow.position = new Vector3(wormhole.Position.x, -50, wormhole.Position.y); // wormholeCameraFollow.rotation = Quaternion.LookRotation(Vector3.down, ship.LookDirection); @@ -657,31 +657,31 @@ public class ActionGameManager : MonoBehaviour var oldZone = Zone; PopulateLevel(wormhole.Target); foreach (var zone in wormhole.Target.AdjacentZones) - CurrentSector.DiscoveredZones.Add(zone); + CurrentGalaxy.DiscoveredZones.Add(zone); SectorMap.QueueZoneReveal(wormhole.Target.AdjacentZones); - ship.ExitWormhole(ZoneRenderer.WormholeInstances.Keys.First(w => w.Target == oldZone.SectorZone).Position, + ship.ExitWormhole(ZoneRenderer.WormholeInstances.Keys.First(w => w.Target == oldZone.GalaxyZone).Position, Settings.GameplaySettings.WormholeExitVelocity * ItemManager.Random.NextFloat2Direction()); CurrentEntity.Zone = Zone; SaveState(); }; } - public void PopulateLevel(SectorZone sectorZone) + public void PopulateLevel(GalaxyZone galaxyZone) { - if (sectorZone == null) throw new ArgumentNullException(nameof(sectorZone)); + if (galaxyZone == null) throw new ArgumentNullException(nameof(galaxyZone)); - if (sectorZone.Contents == null) + if (galaxyZone.Contents == null) { - sectorZone.PackedContents ??= ZoneGenerator.GenerateZone( + galaxyZone.PackedContents ??= ZoneGenerator.GenerateZone( ItemManager, Settings.ZoneSettings, - CurrentSector, - sectorZone, + CurrentGalaxy, + galaxyZone, IsTutorial ); - sectorZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, sectorZone.PackedContents, sectorZone, CurrentSector); + galaxyZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, galaxyZone.PackedContents, galaxyZone, CurrentGalaxy); } - Zone = sectorZone.Contents; + Zone = galaxyZone.Contents; PlayMusic(MusicType.Overworld); Zone.Log = s => Debug.Log($"Zone: {s}"); @@ -756,14 +756,14 @@ public class ActionGameManager : MonoBehaviour private void StartGame() { - if (CurrentSector != null) + if (CurrentGalaxy != null) { if (PlayerSettings.SavedRun == null) { - SectorMap.QueueZoneReveal(CurrentSector.Entrance.AdjacentZones.Prepend(CurrentSector.Entrance)); - PopulateLevel(CurrentSector.Entrance); + SectorMap.QueueZoneReveal(CurrentGalaxy.Entrance.AdjacentZones.Prepend(CurrentGalaxy.Entrance)); + PopulateLevel(CurrentGalaxy.Entrance); var loadoutGenerator = IsTutorial ? new LoadoutGenerator(ref ItemManager.Random, ItemManager, null, 2) : - new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentSector, Zone.SectorZone, null, 2); + new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentGalaxy, Zone.GalaxyZone, null, 2); var ship = EntitySerializer.Unpack( ItemManager, Zone, @@ -779,10 +779,10 @@ public class ActionGameManager : MonoBehaviour } else { - foreach(var group in CurrentSector.DiscoveredZones - .GroupBy(dz=>dz.Distance[CurrentSector.Entrance])) + foreach(var group in CurrentGalaxy.DiscoveredZones + .GroupBy(dz=>dz.Distance[CurrentGalaxy.Entrance])) SectorMap.QueueZoneReveal(group); - PopulateLevel(CurrentSector.Zones[PlayerSettings.SavedRun.CurrentZone]); + PopulateLevel(CurrentGalaxy.Zones[PlayerSettings.SavedRun.CurrentZone]); var targetEntity = Zone.Entities[PlayerSettings.SavedRun.CurrentZoneEntity]; if (targetEntity is OrbitalEntity orbitalEntity) { @@ -944,7 +944,7 @@ public class ActionGameManager : MonoBehaviour } CurrentEntity = entity; - DeathPP.weight = 0; + DeathPost.weight = 0; ZoneRenderer.PerspectiveEntity = CurrentEntity; Menu.gameObject.SetActive(false); @@ -1090,32 +1090,32 @@ public class ActionGameManager : MonoBehaviour VolumeRenderer.EnableDepth = false; MainMenu.gameObject.SetActive(true); Menu.gameObject.SetActive(false); - CurrentSector = null; + CurrentGalaxy = null; SavePlayerSettings(); Observable.EveryUpdate() - .Where(_ => Time.time - deathTime < DeathPPTransitionTime) + .Where(_ => Time.time - deathTime < DeathPostTransitionTime) .Subscribe(_ => { - var t = (Time.time - deathTime) / DeathPPTransitionTime; + var t = (Time.time - deathTime) / DeathPostTransitionTime; if(cause==CauseOfDeath.Heatstroke) { - HeatstrokePP.weight = 1 - t; - SevereHeatstrokePP.weight = 1 - t; + HeatstrokePost.weight = 1 - t; + SevereHeatstrokePost.weight = 1 - t; } else if (cause == CauseOfDeath.Hypothermia) { - HypothermiaPP.weight = 1 - t; - SevereHypothermiaPP.weight = 1 - t; + HypothermiaPost.weight = 1 - t; + SevereHypothermiaPost.weight = 1 - t; } - DeathPP.weight = t; + DeathPost.weight = t; }, () => { - HeatstrokePP.weight = 0; - SevereHeatstrokePP.weight = 0; - HypothermiaPP.weight = 0; - SevereHypothermiaPP.weight = 0; - DeathPP.weight = 1; + HeatstrokePost.weight = 0; + SevereHeatstrokePost.weight = 0; + HypothermiaPost.weight = 0; + SevereHypothermiaPost.weight = 0; + DeathPost.weight = 1; }); } @@ -1155,9 +1155,9 @@ public class ActionGameManager : MonoBehaviour { var soundbank = type switch { - MusicType.Overworld => Zone.SectorZone.Owner?.OverworldMusic ?? 0, - MusicType.Combat => Zone.SectorZone.Owner?.CombatMusic ?? 0, - MusicType.Boss => Zone.SectorZone.Owner?.BossMusic ?? 0, + MusicType.Overworld => Zone.GalaxyZone.Owner?.OverworldMusic ?? 0, + MusicType.Combat => Zone.GalaxyZone.Owner?.CombatMusic ?? 0, + MusicType.Boss => Zone.GalaxyZone.Owner?.BossMusic ?? 0, _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) }; if (soundbank == 0) @@ -1213,9 +1213,9 @@ public class ActionGameManager : MonoBehaviour _entityYawPitch = float2(_entityYawPitch.x + look.x * Sensitivity.x, clamp(_entityYawPitch.y + look.y * Sensitivity.y, -.45f * PI, .45f * PI)); _viewDirection = mul(float3(0, 0, 1), Unity.Mathematics.float3x3.Euler(float3(_entityYawPitch.yx, 0), RotationOrder.YXZ)); CurrentEntity.LookDirection = _viewDirection; - HeatstrokePP.weight = saturate(unlerp(0, Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, CurrentEntity.Heatstroke)); + HeatstrokePost.weight = saturate(unlerp(0, Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, CurrentEntity.Heatstroke)); var severeHeatstrokeLerp = saturate(unlerp(Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, 1, CurrentEntity.Heatstroke)); - SevereHeatstrokePP.weight = + SevereHeatstrokePost.weight = severeHeatstrokeLerp + severeHeatstrokeLerp * (1 - severeHeatstrokeLerp) * max(Settings.HeatstrokePhasingFloor, sin(Time.time * Settings.HeatstrokePhasingFrequency)); diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index d9ab1be46..f5692ca10 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -146,6 +146,15 @@ public abstract class Entity //ItemManager.Log($"Entity {Name} is activating!"); _active = true; Heatstroke = 0; + + // The entity's presence is permitted when its faction owns the zone, or the current security level at its location is low enough + PresencePermitted = new ReadOnlyReactiveProperty(CurrentSecurityLevel.Select(security => + { + var factionRelationship = GetFactionRelationship(Zone.GalaxyZone.Owner); + var presencePermitted = IsPresencePermitted(factionRelationship, security); + return presencePermitted; + }), initialValue: true); + foreach (var item in Equipment) foreach (var behavior in item.Behaviors) { @@ -269,9 +278,7 @@ public abstract class Entity .Merge(HypothermiaDeath.Select(_ => CauseOfDeath.Hypothermia)) .Merge(ItemDestroyed.Where(i=>i.GetBehavior()!=null).Select(_ => CauseOfDeath.CockpitDestroyed)); - // The entity's presence is permitted when its faction owns the zone, or the current security level at its location is low enough - PresencePermitted = new ReadOnlyReactiveProperty(CurrentSecurityLevel.Select(security => - IsPresencePermitted(GetFactionRelationship(Zone.SectorZone.Owner), security)), true); + //CurrentSecurityLevel.Value = SecurityLevel.Open; } public bool IsHostileTo(Entity other, bool recursive = false) @@ -281,8 +288,8 @@ public abstract class Entity // TODO: Inter-faction hostility // When the entity faction owns the zone, they are hostile to trespassers or those hostile to them - if (Faction.ID == Zone.SectorZone.Owner.ID) - return recursive ? !other.PresencePermitted.Value : !other.PresencePermitted.Value || other.IsHostileTo(this, true); + if (Faction.ID == Zone.GalaxyZone.Owner.ID) + return recursive ? !(other.PresencePermitted?.Value ?? true) : !(other.PresencePermitted?.Value ?? true)|| other.IsHostileTo(this, true); return !recursive && other.IsHostileTo(this, true); } @@ -293,7 +300,7 @@ public abstract class Entity if (faction == null) return FactionRelationship.Neutral; if (this is Ship {IsPlayerShip: true}) - return Zone.Sector.FactionRelationships[faction]; + return Zone.Galaxy.FactionRelationships[faction]; return faction.ID == Faction.ID ? FactionRelationship.Beloved : FactionRelationship.Neutral; } diff --git a/Assets/Scripts/ServerShared/Enums.cs b/Assets/Scripts/ServerShared/Enums.cs index f685e12ba..8eb6c7f4d 100644 --- a/Assets/Scripts/ServerShared/Enums.cs +++ b/Assets/Scripts/ServerShared/Enums.cs @@ -165,6 +165,12 @@ public enum CompoundCommodityCategory Assemblies = 5 } +public enum LocationType +{ + Station, + Planet +} + public enum FactionRelationship { Hated = 0, // Kill on sight diff --git a/Assets/Scripts/ServerShared/Sector.cs b/Assets/Scripts/ServerShared/Galaxy.cs similarity index 89% rename from Assets/Scripts/ServerShared/Sector.cs rename to Assets/Scripts/ServerShared/Galaxy.cs index d2e987640..588c7af20 100644 --- a/Assets/Scripts/ServerShared/Sector.cs +++ b/Assets/Scripts/ServerShared/Galaxy.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using DataStructures.ViliWonka.Heap; +using Ink.Runtime; using MIConvexHull; using JM.LinqFaster; using UniRx; @@ -12,25 +13,25 @@ using Unity.Mathematics; using static Unity.Mathematics.math; using Random = Unity.Mathematics.Random; -public class Sector +public class Galaxy { - public Dictionary HomeZones = new Dictionary(); - public Dictionary BossZones = new Dictionary(); - public HashSet DiscoveredZones = new HashSet(); + public Dictionary HomeZones = new Dictionary(); + public Dictionary BossZones = new Dictionary(); + public HashSet DiscoveredZones = new HashSet(); public SectorBackgroundSettings Background { get; } public NameGeneratorSettings NameGeneratorSettings { get; } public Faction[] Factions { get; } - public SectorZone[] Zones { get; } - public SectorZone Entrance { get; } - public SectorZone Exit { get; } + public GalaxyZone[] Zones { get; } + public GalaxyZone Entrance { get; } + public GalaxyZone Exit { get; } public Dictionary FactionRelationships { get; } = new Dictionary(); private HashSet _containedFactions; - private SectorZone[] _exitPath; + private GalaxyZone[] _exitPath; private Dictionary _nameGenerators = new Dictionary(); - public SectorZone[] ExitPath + public GalaxyZone[] ExitPath { get { @@ -40,7 +41,7 @@ public class Sector } } - public Sector(CultCache cultCache, SavedGame savedGame) + public Galaxy(CultCache cultCache, SavedGame savedGame) { Background = savedGame.Background; @@ -52,7 +53,7 @@ public class Sector Zones = savedGame.Zones.Select(zone => { - return new SectorZone + return new GalaxyZone { Name = zone.Name, Position = zone.Position, @@ -82,7 +83,7 @@ public class Sector CalculateDistanceMatrix(); } - public Sector( + public Galaxy( SectorGenerationSettings settings, SectorBackgroundSettings background, NameGeneratorSettings nameGeneratorSettings, @@ -121,7 +122,7 @@ public class Sector if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao } - public Sector( + public Galaxy( TutorialGenerationSettings settings, SectorBackgroundSettings background, NameGeneratorSettings nameGeneratorSettings, @@ -229,14 +230,14 @@ public class Sector if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao } - private SectorZone[] GenerateZones(int zoneCount, ref Random random, Action progressCallback = null) + private GalaxyZone[] GenerateZones(int zoneCount, ref Random random, Action progressCallback = null) { var outputSamples = WeightedSampleElimination.GeneratePoints(zoneCount, ref random, Background.CloudDensity, v => (.2f - lengthsq(v - float2(.5f))) * 4, progressCallback); - return outputSamples.Select(v => new SectorZone {Position = v}).ToArray(); + return outputSamples.Select(v => new GalaxyZone {Position = v}).ToArray(); } private void PlaceFactionsMain(int bossCount, Action progressCallback = null) @@ -343,9 +344,9 @@ public class Sector 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, Cell2> - .Create(Zones.Select(z => new Vertex2(z.Position, z)).ToList(), 1e-7f); - var links = new HashSet<(SectorZone, SectorZone)>(); + var triangulation = DelaunayTriangulation, Cell2> + .Create(Zones.Select(z => new Vertex2(z.Position, z)).ToList(), 1e-7f); + var links = new HashSet<(GalaxyZone, GalaxyZone)>(); foreach (var cell in triangulation.Cells) { if (!links.Contains((cell.Vertices[0].StoredObject, cell.Vertices[1].StoredObject)) && @@ -377,14 +378,14 @@ public class Sector link.Item2.AdjacentZones.Add(link.Item1); } - float LinkWeight((SectorZone, SectorZone) link) + float LinkWeight((GalaxyZone, GalaxyZone) link) { return 1 / saturate(Background.CloudDensity((link.Item1.Position + link.Item2.Position) / 2)) * lengthsq(link.Item1.Position - link.Item2.Position) * (link.Item1.AdjacentZones.Count - 1) * (link.Item2.AdjacentZones.Count - 1); } - var heap = new MaxHeap<(SectorZone, SectorZone)>(links.Count); + var heap = new MaxHeap<(GalaxyZone, GalaxyZone)>(links.Count); foreach (var link in links) heap.PushObj(link, LinkWeight(link)); while (heap.Count > linkDensity * links.Count) { @@ -430,12 +431,12 @@ public class Sector { public float Cost; public DijkstraVertex Parent; - public SectorZone Zone; + public GalaxyZone Zone; } - public Dictionary ConnectedRegionDistance(SectorZone v) + public Dictionary ConnectedRegionDistance(GalaxyZone v) { - var members = new Dictionary {{v, 0}}; + var members = new Dictionary {{v, 0}}; int cost = 1; while (true) { @@ -455,36 +456,36 @@ public class Sector } } - public HashSet ConnectedRegion( - SectorZone v, - SectorZone ignoreLinkSource, - SectorZone ignoreLinkTarget, + public HashSet ConnectedRegion( + GalaxyZone v, + GalaxyZone ignoreLinkSource, + GalaxyZone ignoreLinkTarget, int maxDistance = int.MaxValue) { return ConnectedRegion(v, x => x.Item1 != ignoreLinkSource || x.Item2 != ignoreLinkTarget, maxDistance); } - public HashSet ConnectedRegion( - SectorZone v, - SectorZone ignoreZone, + public HashSet ConnectedRegion( + GalaxyZone v, + GalaxyZone ignoreZone, int maxDistance = int.MaxValue) { return ConnectedRegion(v, x => x.Item2 != ignoreZone, maxDistance); } - public HashSet ConnectedRegion( - SectorZone v, + public HashSet ConnectedRegion( + GalaxyZone v, int maxDistance = int.MaxValue) { return ConnectedRegion(v, x => true, maxDistance); } - public HashSet ConnectedRegion( - SectorZone v, - Predicate<(SectorZone source, SectorZone target)> linkFilter, + public HashSet ConnectedRegion( + GalaxyZone v, + Predicate<(GalaxyZone source, GalaxyZone target)> linkFilter, int maxDistance = int.MaxValue) { - var visited = new HashSet {v}; + var visited = new HashSet {v}; int cost = 1; while (true) { @@ -504,12 +505,12 @@ public class Sector } } - public SectorZone[] FindPath(SectorZone source, SectorZone target, bool bestFirst = false) + public GalaxyZone[] FindPath(GalaxyZone source, GalaxyZone target, bool bestFirst = false) { MinHeap unsearchedNodes = new MinHeap(); unsearchedNodes.PushObj(new DijkstraVertex{Zone = source}, 0); //SortedList members = new SortedList{{0, new DijkstraVertex{Zone = source}}}; - var searched = new HashSet(); + var searched = new HashSet(); while (true) { if(unsearchedNodes.Count == 0) return null; // No nodes left unsearched @@ -523,7 +524,7 @@ public class Sector return path.Select(dv => dv.Zone).ToArray(); } // For each adjacent star (filter already visited stars unless heuristic is in use) - IEnumerable zonesToSearch = s.Zone.AdjacentZones; + IEnumerable zonesToSearch = s.Zone.AdjacentZones; if (!bestFirst) zonesToSearch = zonesToSearch.Where(z => !searched.Contains(z)); foreach (var dijkstraStar in zonesToSearch // Cost is parent cost plus distance squared @@ -535,15 +536,33 @@ public class Sector } } -public class SectorZone +public class GalaxyZone { public string Name; public float2 Position; - public List AdjacentZones = new List(); + public List AdjacentZones = new List(); public int Isolation; - public Dictionary Distance; + public Dictionary Distance; public Faction[] Factions; public Faction Owner; public Zone Contents; public ZonePack PackedContents; + public bool NamedZone; + public List Locations = new List(); +} + +public class GalaxyQuest +{ + public Story Story; + public Dictionary Locations = new Dictionary(); +} + +public class LocationStory +{ + public string FileName; + public string Name; + public Story Story; + public Faction Faction; + public SecurityLevel Security; + public LocationType Type; } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Sector.cs.meta b/Assets/Scripts/ServerShared/Galaxy.cs.meta similarity index 100% rename from Assets/Scripts/ServerShared/Sector.cs.meta rename to Assets/Scripts/ServerShared/Galaxy.cs.meta diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index b2f9874dd..612b62f66 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -10,22 +10,22 @@ public class LoadoutGenerator { public Random Random; public ItemManager ItemManager { get; } - public Sector Sector { get; } - public SectorZone Zone { get; } + public Galaxy Galaxy { get; } + public GalaxyZone Zone { get; } public Faction Faction { get; } public float PriceExponent { get; } public LoadoutGenerator( ref Random random, ItemManager itemManager, - Sector sector, - SectorZone zone, + Galaxy galaxy, + GalaxyZone zone, Faction faction, float priceExponent) { Random = random; ItemManager = itemManager; - Sector = sector; + Galaxy = galaxy; Zone = zone; Faction = faction; PriceExponent = priceExponent; @@ -107,12 +107,12 @@ public class LoadoutGenerator (hullFilter?.Invoke(item) ?? true) && item.HullType == type && item.Manufacturer != Guid.Empty && - (Sector?.ContainsFaction(item.Manufacturer) ?? true) && + (Galaxy?.ContainsFaction(item.Manufacturer) ?? true) && (Faction == null || item.Manufacturer == Faction.ID || Faction.Allegiance.ContainsKey(item.Manufacturer))) .WeightedRandomElements(ref Random, item => (Faction == null || item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance[item.Manufacturer]) / // Prioritize items from allied manufacturers - (Zone?.Distance[Sector.HomeZones[ItemManager.ItemData.Get(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters + (Zone?.Distance[Galaxy.HomeZones[ItemManager.ItemData.Get(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters pow(item.Price, PriceExponent), // Penalize item price to a controllable degree 1 ).FirstOrDefault(); @@ -124,13 +124,13 @@ public class LoadoutGenerator .Where(item => item.Price > 0 && item.Manufacturer != Guid.Empty && - (Sector?.ContainsFaction(item.Manufacturer) ?? true) && + (Galaxy?.ContainsFaction(item.Manufacturer) ?? true) && (Faction == null || Faction.Allegiance.ContainsKey(item.Manufacturer)) && (filter?.Invoke(item) ?? true)) .WeightedRandomElements(ref Random, item => (Faction == null || item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance[item.Manufacturer]) * // Prioritize items from allied manufacturers pow(item.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items - (Zone?.Distance[Sector.HomeZones[ItemManager.ItemData.Get(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters + (Zone?.Distance[Galaxy.HomeZones[ItemManager.ItemData.Get(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters pow(item.Price, PriceExponent), // Penalize item price to a controllable degree count ); diff --git a/Assets/Scripts/ServerShared/Narrative/StoryProcessor.cs b/Assets/Scripts/ServerShared/Narrative/StoryProcessor.cs index 1fad0c751..af240037a 100644 --- a/Assets/Scripts/ServerShared/Narrative/StoryProcessor.cs +++ b/Assets/Scripts/ServerShared/Narrative/StoryProcessor.cs @@ -4,10 +4,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Ink; -using Ink.Runtime; +using Ink.Parsed; using MessagePack; using Path = System.IO.Path; using Random = Unity.Mathematics.Random; +using Story = Ink.Runtime.Story; public class StoryProcessor : IZoneResolver, IFactionResolver { @@ -24,62 +25,67 @@ public class StoryProcessor : IZoneResolver, IFactionResolver public string LoadInkFileContents (string fullFilename) => File.ReadAllText (fullFilename); } - private Dictionary _placedStories = new Dictionary(); + private Dictionary _storyKnotPaths = new Dictionary(); + private Dictionary _storyLocations = new Dictionary(); private Dictionary _processedStories = new Dictionary(); private DirectoryInfo _locationsPath; + private DirectoryInfo _questsPath; private IFileHandler _inkFileHandler; public DirectoryInfo NarrativeDirectory { get; } private Random _random; - public Sector Sector { get; } + public Galaxy Galaxy { get; } public PlayerSettings Settings { get; } - public StoryProcessor(PlayerSettings settings, DirectoryInfo narrativeDirectory, Sector sector, ref Random random) + public StoryProcessor(PlayerSettings settings, DirectoryInfo narrativeDirectory, Galaxy galaxy, ref Random random) { NarrativeDirectory = narrativeDirectory; - Sector = sector; + Galaxy = galaxy; _random = random; Settings = settings; _inkFileHandler = new AetheriaInkFileHandler(narrativeDirectory); _locationsPath = narrativeDirectory.CreateSubdirectory("Locations"); + _questsPath = narrativeDirectory.CreateSubdirectory("Quests"); } - public Dictionary PlaceStories() + public void ProcessStories() { var locationFiles = _locationsPath.EnumerateFiles("*.ink"); - foreach(var inkFile in locationFiles) PlaceStory(GetStory(inkFile)); - return _placedStories; + foreach(var inkFile in locationFiles) ProcessLocation(GetStory(inkFile), inkFile); + + var questFiles = _questsPath.EnumerateFiles("*ink"); + foreach(var inkFile in questFiles) ProcessQuest(GetStory(inkFile)); } - public SectorZone ResolveZone(string path) + public GalaxyZone ResolveZone(string path) { // Handle special cases: "start" and "end" if (path.Equals("start", StringComparison.InvariantCultureIgnoreCase)) - return Sector.Entrance; + return Galaxy.Entrance; if (path.Equals("end", StringComparison.InvariantCultureIgnoreCase)) - return Sector.Exit; + return Galaxy.Exit; // Handle faction home reference: format = "home." if(path.StartsWith("home")) { var factionString = path.Substring(5); var faction = ResolveFaction(factionString); - return !Sector.HomeZones.ContainsKey(faction) ? null : Sector.HomeZones[faction]; + return !Galaxy.HomeZones.ContainsKey(faction) ? null : Galaxy.HomeZones[faction]; } var locationInkFile = new FileInfo(Path.Combine(_locationsPath.FullName, $"{path}.ink")); if (!locationInkFile.Exists) return null; var story = GetStory(locationInkFile); - PlaceStory(story); - return _placedStories.ContainsKey(story) ? _placedStories[story] : null; + ProcessLocation(story, locationInkFile); + return _storyLocations.ContainsKey(story) ? _storyLocations[story] : null; } public Faction ResolveFaction(string name) { - return Sector.Factions.FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); + return Galaxy.Factions.FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); } Story GetStory(FileInfo inkFile) @@ -109,16 +115,30 @@ public class StoryProcessor : IZoneResolver, IFactionResolver fileHandler = _inkFileHandler }); var story = compiler.Compile(); + var knots = compiler.parsedStory.FindAll().Select(k=>k.runtimePath.ToString()).ToArray(); + _storyKnotPaths[story] = knots; File.WriteAllText(compiledFileName, story.ToJson()); return story; } - - public void PlaceStory(Story story) - { - if (_placedStories.ContainsKey(story)) return; // Don't place already placed stories, idiot! - _placedStories[story] = null; // Avoids potential for infinite loops when evaluating constraints - var contentTags = GetContentTags(story); + public void ProcessQuest(Story story) + { + var quest = new GalaxyQuest(); + quest.Story = story; + foreach (var knot in _storyKnotPaths[story]) + { + var tags = GetContentTags(story.TagsForContentAtPath(knot)); + + } + } + + public void ProcessLocation(Story story, FileInfo inkFile) + { + if (_storyLocations.ContainsKey(story)) return; // Don't place already placed stories, idiot! + _storyLocations[story] = null; // Avoids potential for infinite loops when evaluating constraints + var fileName = Path.GetFileNameWithoutExtension(inkFile.FullName); + + var contentTags = GetContentTags(story.globalTags); var constraints = new List(); if(contentTags.ContainsKey("constraint")) @@ -157,16 +177,34 @@ public class StoryProcessor : IZoneResolver, IFactionResolver else selector = new RandomSelector(ref _random); - var zoneCandidates = new List(); - zoneCandidates.AddRange(Sector.Zones.Where(z=>constraints.All(c=>c.Test(z)))); - _placedStories[story] = selector.SelectZone(zoneCandidates); + var zoneCandidates = new List(); + zoneCandidates.AddRange(Galaxy.Zones.Where(z=>!z.NamedZone && constraints.All(c=>c.Test(z)))); + + var zone = selector.SelectZone(zoneCandidates); + + var location = new LocationStory + { + FileName = fileName, + Name = contentTags.ContainsKey("name") ? contentTags["name"].First() : fileName, + Faction = contentTags.ContainsKey("faction") ? ResolveFaction(contentTags["faction"].First()) : zone.Owner, + Security = contentTags.ContainsKey("security") + ? (SecurityLevel) Enum.Parse(typeof(SecurityLevel), contentTags["security"].First(), true) + : SecurityLevel.Open, + Story = story, + Type = contentTags.ContainsKey("type") + ? (LocationType) Enum.Parse(typeof(LocationType), contentTags["type"].First(), true) + : LocationType.Station + }; + zone.Locations.Add(location); + + _storyLocations[story] = zone; } // Parse all tags of the format X:Y into a dictionary with a list of every Y for each X - public static Dictionary> GetContentTags(Story story) + public static Dictionary> GetContentTags(List tags) { var contentTags = new Dictionary>(); - foreach (var tag in story.globalTags) + foreach (var tag in tags) { if (tag.IndexOf(':') == -1) continue; diff --git a/Assets/Scripts/ServerShared/Narrative/ZoneConstraints.cs b/Assets/Scripts/ServerShared/Narrative/ZoneConstraints.cs index 7f91617ff..f707dc399 100644 --- a/Assets/Scripts/ServerShared/Narrative/ZoneConstraints.cs +++ b/Assets/Scripts/ServerShared/Narrative/ZoneConstraints.cs @@ -4,7 +4,7 @@ using System.Linq; public interface IZoneResolver { - public SectorZone ResolveZone(string path); + public GalaxyZone ResolveZone(string path); } public interface IFactionResolver @@ -16,12 +16,12 @@ public abstract class ZoneConstraint { public bool Flip = false; - public bool Test(SectorZone zone) + public bool Test(GalaxyZone zone) { return Flip ^ TestZone(zone); } - protected abstract bool TestZone(SectorZone zone); + protected abstract bool TestZone(GalaxyZone zone); } public class FactionPresenceConstraint : ZoneConstraint @@ -32,7 +32,7 @@ public class FactionPresenceConstraint : ZoneConstraint TargetFaction = resolver.ResolveFaction(args[0]); } - protected override bool TestZone(SectorZone zone) + protected override bool TestZone(GalaxyZone zone) { return zone.Factions.Any(f=>f.ID == TargetFaction?.ID); } @@ -47,7 +47,7 @@ public class FactionOwnerConstraint : ZoneConstraint TargetFaction = resolver.ResolveFaction(args[0]); } - protected override bool TestZone(SectorZone zone) + protected override bool TestZone(GalaxyZone zone) { return zone.Owner.ID == TargetFaction?.ID; } @@ -55,7 +55,7 @@ public class FactionOwnerConstraint : ZoneConstraint public class DistanceConstraint : ZoneConstraint { - private SectorZone _targetZone; + private GalaxyZone _targetZone; private Predicate _test; public DistanceConstraint(string[] args, IZoneResolver zoneResolver) @@ -82,7 +82,7 @@ public class DistanceConstraint : ZoneConstraint } } - protected override bool TestZone(SectorZone zone) + protected override bool TestZone(GalaxyZone zone) { return _targetZone != null && _test(zone.Distance[_targetZone]); } diff --git a/Assets/Scripts/ServerShared/Narrative/ZoneSelectors.cs b/Assets/Scripts/ServerShared/Narrative/ZoneSelectors.cs index 7ebda07ce..0dab2bae9 100644 --- a/Assets/Scripts/ServerShared/Narrative/ZoneSelectors.cs +++ b/Assets/Scripts/ServerShared/Narrative/ZoneSelectors.cs @@ -6,16 +6,16 @@ using Random = Unity.Mathematics.Random; public abstract class ZoneSelector { - public abstract SectorZone SelectZone(List candidates); + public abstract GalaxyZone SelectZone(List candidates); } public abstract class OrderedZoneSelector : ZoneSelector { public bool Flip = false; - protected abstract Func Comparison { get; } + protected abstract Func Comparison { get; } - public override SectorZone SelectZone(List candidates) + public override GalaxyZone SelectZone(List candidates) { var sorted = candidates.OrderBy(Comparison); return Flip ? sorted.Last() : sorted.First(); @@ -24,7 +24,7 @@ public abstract class OrderedZoneSelector : ZoneSelector public class DistanceSelector : OrderedZoneSelector { - private SectorZone Target { get; } + private GalaxyZone Target { get; } public DistanceSelector(string[] args, IZoneResolver zoneResolver) @@ -32,7 +32,7 @@ public class DistanceSelector : OrderedZoneSelector Target = zoneResolver.ResolveZone(args[0].Trim()); } - protected override Func Comparison => zone => Target?.Distance[zone] ?? 0; + protected override Func Comparison => zone => Target?.Distance[zone] ?? 0; } public class RandomSelector : ZoneSelector @@ -44,7 +44,7 @@ public class RandomSelector : ZoneSelector Random = random; } - public override SectorZone SelectZone(List candidates) + public override GalaxyZone SelectZone(List candidates) { return candidates[Random.NextInt(candidates.Count)]; } diff --git a/Assets/Scripts/ServerShared/OrbitalEntity.cs b/Assets/Scripts/ServerShared/OrbitalEntity.cs index e4e107521..30325b64c 100644 --- a/Assets/Scripts/ServerShared/OrbitalEntity.cs +++ b/Assets/Scripts/ServerShared/OrbitalEntity.cs @@ -37,7 +37,7 @@ public class OrbitalEntity : Entity { if (SecurityRadius < 1) return false; if (Faction == null) return false; - return !IsPresencePermitted(Zone.Sector.FactionRelationships[Faction], SecurityLevel); + return !IsPresencePermitted(Zone.Galaxy.FactionRelationships[Faction], SecurityLevel); } } } diff --git a/Assets/Scripts/ServerShared/SavedGame.cs b/Assets/Scripts/ServerShared/SavedGame.cs index a93b00f32..4f1c26a80 100644 --- a/Assets/Scripts/ServerShared/SavedGame.cs +++ b/Assets/Scripts/ServerShared/SavedGame.cs @@ -49,35 +49,35 @@ public class SavedGame public SavedGame() { } - public SavedGame(Sector sector, Zone currentZone, Entity currentEntity) + public SavedGame(Galaxy galaxy, Zone currentZone, Entity currentEntity) { - DiscoveredZones = sector.DiscoveredZones.Select(dz => Array.IndexOf(sector.Zones, dz)).ToArray(); - Background = sector.Background; - Factions = sector.HomeZones.Keys.Select(f => f.ID).ToArray(); - Relationships = sector.Factions.Select(f => sector.FactionRelationships[f]).ToArray(); + DiscoveredZones = galaxy.DiscoveredZones.Select(dz => Array.IndexOf(galaxy.Zones, dz)).ToArray(); + Background = galaxy.Background; + Factions = galaxy.HomeZones.Keys.Select(f => f.ID).ToArray(); + Relationships = galaxy.Factions.Select(f => galaxy.FactionRelationships[f]).ToArray(); - HomeZones = sector.HomeZones.ToDictionary( + HomeZones = galaxy.HomeZones.ToDictionary( x => Array.IndexOf(Factions, x.Key.ID), - x => Array.IndexOf(sector.Zones, x.Value)); - BossZones = sector.BossZones.ToDictionary( + x => Array.IndexOf(galaxy.Zones, x.Value)); + BossZones = galaxy.BossZones.ToDictionary( x => Array.IndexOf(Factions, x.Key.ID), - x => Array.IndexOf(sector.Zones, x.Value)); + x => Array.IndexOf(galaxy.Zones, x.Value)); - Zones = sector.Zones.Select(zone => new SavedZone + Zones = galaxy.Zones.Select(zone => new SavedZone { Name = zone.Name, Position = zone.Position, - AdjacentZones = zone.AdjacentZones.Select(az=> Array.IndexOf(sector.Zones, az)).ToArray(), + AdjacentZones = zone.AdjacentZones.Select(az=> Array.IndexOf(galaxy.Zones, az)).ToArray(), Factions = zone.Factions.Select(f=> Array.IndexOf(Factions, f.ID)).ToArray(), 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); + CurrentZone = Array.FindIndex(galaxy.Zones, zone => zone.Contents == currentZone); CurrentZoneEntity = currentZone.Entities.IndexOf(currentEntity); - Entrance = Array.IndexOf(sector.Zones, sector.Entrance); - Exit = Array.IndexOf(sector.Zones, sector.Exit); + Entrance = Array.IndexOf(galaxy.Zones, galaxy.Entrance); + Exit = Array.IndexOf(galaxy.Zones, galaxy.Exit); } } diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs index f125fb887..529c07b39 100644 --- a/Assets/Scripts/ServerShared/Ship.cs +++ b/Assets/Scripts/ServerShared/Ship.cs @@ -46,6 +46,7 @@ public class Ship : Entity private float2 _wormholePosition; private float2 _wormholeExitVelocity; + public bool WormholeAnimationInProgress => _enteringWormhole || _exitingWormhole; public float ForwardThrust { get; private set; } public float ReverseThrust { get; private set; } public float LeftStrafeThrust { get; private set; } diff --git a/Assets/Scripts/ServerShared/Wormhole.cs b/Assets/Scripts/ServerShared/Wormhole.cs index a8e1bd7a3..447cf174c 100644 --- a/Assets/Scripts/ServerShared/Wormhole.cs +++ b/Assets/Scripts/ServerShared/Wormhole.cs @@ -3,5 +3,5 @@ using Unity.Mathematics; public class Wormhole { public float2 Position; - public SectorZone Target; + public GalaxyZone Target; } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index 6fb6149d2..39b9ae64f 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -41,18 +41,18 @@ public class Zone get => (float) _time; } public ZonePack Pack { get; } - public SectorZone SectorZone { get; } - public Sector Sector { get; } + public GalaxyZone GalaxyZone { get; } + public Galaxy Galaxy { get; } - public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, SectorZone sectorZone, Sector sector) + public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, GalaxyZone galaxyZone, Galaxy galaxy) { _time = pack.Time; - SectorZone = sectorZone; - Sector = sector; + GalaxyZone = galaxyZone; + Galaxy = galaxy; Pack = pack; _itemManager = itemManager; Settings = settings; - _random = new Random(Convert.ToUInt32(abs(sectorZone?.Name.GetHashCode() ?? 1337))); + _random = new Random(Convert.ToUInt32(abs(galaxyZone?.Name.GetHashCode() ?? 1337))); foreach (var orbit in pack.Orbits) { @@ -311,12 +311,12 @@ public class Zone public SecurityLevel GetSecurityLevel(float2 pos) { - if (SectorZone.Owner==null) return SecurityLevel.Open; + if (GalaxyZone.Owner==null) return SecurityLevel.Open; var security = SecurityLevel.Open; foreach (var entity in Entities) { - if (entity is OrbitalEntity orbitalEntity && orbitalEntity.SecurityRadius > 1 && entity.Faction.ID == SectorZone.Owner.ID) + if (entity is OrbitalEntity orbitalEntity && orbitalEntity.SecurityRadius > 1 && entity.Faction.ID == GalaxyZone.Owner.ID) { if (orbitalEntity.SecurityLevel > security && length(orbitalEntity.Position.xz - pos) < orbitalEntity.SecurityRadius * Settings.SecureAreaRadiusMultiplier) security = orbitalEntity.SecurityLevel; diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index 5c6547b89..ddd65cb58 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -38,15 +38,15 @@ public static class ZoneGenerator public static ZonePack GenerateZone( ItemManager itemManager, ZoneGenerationSettings zoneSettings, - Sector sector, - SectorZone sectorZone, + Galaxy galaxy, + GalaxyZone galaxyZone, bool isTutorial = false) { var pack = new ZonePack(); - var random = new Random(unchecked((uint) sectorZone.Name.GetHashCode()) ^ hash(sectorZone.Position)); + var random = new Random(unchecked((uint) galaxyZone.Name.GetHashCode()) ^ hash(galaxyZone.Position)); - var density = saturate(sector.Background.CloudDensity(sectorZone.Position)/2); + var density = saturate(galaxy.Background.CloudDensity(galaxyZone.Position)/2); pack.Radius = zoneSettings.ZoneRadius.Evaluate(density); pack.Mass = zoneSettings.ZoneMass.Evaluate(density); var targetSubzoneCount = zoneSettings.SubZoneCount.Evaluate(density); @@ -222,9 +222,9 @@ public static class ZoneGenerator return planetData; }).ToList(); - var nearestFaction = sector.Factions.MinBy(f => sector.HomeZones[f].Distance[sectorZone]); - var nearestFactionHomeZone = sector.HomeZones[nearestFaction]; - var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[sectorZone] + 1; + var nearestFaction = galaxy.Factions.MinBy(f => galaxy.HomeZones[f].Distance[galaxyZone]); + var nearestFactionHomeZone = galaxy.HomeZones[nearestFaction]; + var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[galaxyZone] + 1; var stationCount = (int)(random.NextFloat() * (factionPresence + 1)); var potentialLagrangePoints = planets @@ -240,7 +240,7 @@ public static class ZoneGenerator .ToArray(); var loadoutGenerator = isTutorial ? new LoadoutGenerator(ref random, itemManager, nearestFaction, .5f) : - new LoadoutGenerator(ref random, itemManager, sector, sectorZone, nearestFaction, .5f); + new LoadoutGenerator(ref random, itemManager, galaxy, galaxyZone, nearestFaction, .5f); foreach (var orbit in selectedStationOrbits) { diff --git a/Assets/Scripts/UI/GalaxyZone.cs b/Assets/Scripts/UI/GalaxyZone.cs deleted file mode 100644 index 393d10356..000000000 --- a/Assets/Scripts/UI/GalaxyZone.cs +++ /dev/null @@ -1,15 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -using System.Collections; -using System.Collections.Generic; -using TMPro; -using UnityEngine; - -public class GalaxyZone : MonoBehaviour -{ - public MeshRenderer Background; - public MeshRenderer Icon; - public TextMeshPro Label; -} diff --git a/Assets/Scripts/UI/GalaxyZone.cs.meta b/Assets/Scripts/UI/GalaxyZone.cs.meta deleted file mode 100644 index 1745ff07a..000000000 --- a/Assets/Scripts/UI/GalaxyZone.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 685a87786d510214eb9f9a11f756dcde -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index 1c41cf0ec..a91622967 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -98,7 +98,7 @@ public class MainMenu : MonoBehaviour () => { ActionGameManager.IsTutorial = ActionGameManager.PlayerSettings.SavedRun.IsTutorial; - ActionGameManager.CurrentSector = new Sector( + ActionGameManager.CurrentGalaxy = new Galaxy( ActionGameManager.CultCache, ActionGameManager.PlayerSettings.SavedRun); SceneManager.LoadScene("ARPG"); @@ -125,7 +125,7 @@ public class MainMenu : MonoBehaviour ActionGameManager.IsTutorial = false; Task.Run(() => { - var sector = new Sector( + var sector = new Galaxy( Settings.SectorGenerationSettings, Settings.SectorBackgroundSettings, Settings.NameGeneratorSettings, @@ -134,7 +134,7 @@ public class MainMenu : MonoBehaviour Observable.NextFrame().Subscribe(_ => { ActionGameManager.PlayerSettings.SavedRun = null; - ActionGameManager.CurrentSector = sector; + ActionGameManager.CurrentGalaxy = sector; SceneManager.LoadScene("ARPG"); }); }).WrapErrors(); @@ -151,7 +151,7 @@ public class MainMenu : MonoBehaviour ActionGameManager.IsTutorial = true; Task.Run(() => { - var sector = new Sector( + var sector = new Galaxy( Settings.TutorialGenerationSettings, Settings.TutorialBackgroundSettings, Settings.NameGeneratorSettings, @@ -162,7 +162,7 @@ public class MainMenu : MonoBehaviour Observable.NextFrame().Subscribe(_ => { ActionGameManager.PlayerSettings.SavedRun = null; - ActionGameManager.CurrentSector = sector; + ActionGameManager.CurrentGalaxy = sector; SceneManager.LoadScene("ARPG"); }); }).WrapErrors(); diff --git a/Assets/Scripts/UI/Menu/MapRenderer.cs b/Assets/Scripts/UI/Menu/MapRenderer.cs index f10ea1462..0da65c536 100644 --- a/Assets/Scripts/UI/Menu/MapRenderer.cs +++ b/Assets/Scripts/UI/Menu/MapRenderer.cs @@ -48,7 +48,7 @@ public class MapRenderer : MonoBehaviour GravityCamera.gameObject.SetActive(true); TintCamera.gameObject.SetActive(true); InfluenceCamera.gameObject.SetActive(true); - Title.text = $"Zone: {GameManager.Zone.SectorZone.Name}"; + Title.text = $"Zone: {GameManager.Zone.GalaxyZone.Name}"; } private void OnDisable() diff --git a/Assets/Scripts/UI/Menu/SectorMap.cs b/Assets/Scripts/UI/Menu/SectorMap.cs index 2239db6bd..44f82af09 100644 --- a/Assets/Scripts/UI/Menu/SectorMap.cs +++ b/Assets/Scripts/UI/Menu/SectorMap.cs @@ -42,19 +42,19 @@ public class SectorMap : MonoBehaviour public Color PlayerLocationLabelColor; public float PlayerLocationIconSize = 1.25f; - public Subject ZoneClicked = new Subject(); + public Subject ZoneClicked = new Subject(); - private SectorZone _currentPlayerLocation; - private HashSet _revealedZones = new HashSet(); - private HashSet<(SectorZone, SectorZone)> _revealedLinks = new HashSet<(SectorZone, SectorZone)>(); + private GalaxyZone _currentPlayerLocation; + private HashSet _revealedZones = new HashSet(); + private HashSet<(GalaxyZone, GalaxyZone)> _revealedLinks = new HashSet<(GalaxyZone, GalaxyZone)>(); private Dictionary _factionMaterials = new Dictionary(); - private Dictionary _zoneInstances = new Dictionary(); - private Queue> _queuedZoneReveals = new Queue>(); + private Dictionary _zoneInstances = new Dictionary(); + private Queue> _queuedZoneReveals = new Queue>(); - public void MarkPlayerLocation(SectorZone zone) + public void MarkPlayerLocation(GalaxyZone zone) { if (_currentPlayerLocation != null) { @@ -77,7 +77,7 @@ public class SectorMap : MonoBehaviour zoneUI.IconContainer.localScale = new Vector3(PlayerLocationIconSize, PlayerLocationIconSize, 1); } - public void QueueZoneReveal(IEnumerable zones) + public void QueueZoneReveal(IEnumerable zones) { _queuedZoneReveals.Enqueue(zones); } @@ -90,7 +90,7 @@ public class SectorMap : MonoBehaviour } } - public IEnumerator RevealZone(IEnumerable zones, float linkDuration, float iconDuration) + public IEnumerator RevealZone(IEnumerable zones, float linkDuration, float iconDuration) { var linksToReveal = new List<(float2 start, float2 end, Transform linkInstance, bool critical)>(); var zoneTransforms = new List(); @@ -112,7 +112,7 @@ public class SectorMap : MonoBehaviour { zoneInstance.Primary.sharedMaterial = _factionMaterials[zone.Owner].primaryMaterial; zoneInstance.Secondary.sharedMaterial = _factionMaterials[zone.Owner].secondaryMaterial; - if(zone == ActionGameManager.CurrentSector.HomeZones[zone.Owner]) + if(zone == ActionGameManager.CurrentGalaxy.HomeZones[zone.Owner]) zoneInstance.Secondary.transform.localScale = Vector3.one * 4; } else @@ -120,7 +120,7 @@ public class SectorMap : MonoBehaviour zoneInstance.Secondary.gameObject.SetActive(false); } - var isOnCriticalPath = ActionGameManager.CurrentSector.ExitPath?.Contains(zone) ?? false; + var isOnCriticalPath = ActionGameManager.CurrentGalaxy.ExitPath?.Contains(zone) ?? false; foreach (var adjacentZone in zone.AdjacentZones) { // If the adjacent zone is in the set already revealed, then show the link @@ -129,7 +129,7 @@ public class SectorMap : MonoBehaviour _revealedLinks.Contains((adjacentZone, zone)))) { var link = LinkPrototype.Instantiate(); - var critical = isOnCriticalPath && (ActionGameManager.CurrentSector.ExitPath?.Contains(adjacentZone) ?? false); + var critical = isOnCriticalPath && (ActionGameManager.CurrentGalaxy.ExitPath?.Contains(adjacentZone) ?? false); linksToReveal.Add((zone.Position, adjacentZone.Position, link, critical)); if (zone.Owner != null && zone.Owner == adjacentZone.Owner) link.GetComponent().sharedMaterial = _factionMaterials[zone.Owner].linkMaterial; @@ -152,7 +152,7 @@ public class SectorMap : MonoBehaviour zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f); zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1); - if (zone == ActionGameManager.CurrentSector.Entrance) + if (zone == ActionGameManager.CurrentGalaxy.Entrance) { var iconInstance = IconPrototype.Instantiate(); iconInstance.material.mainTexture = EntranceIcon; @@ -162,7 +162,7 @@ public class SectorMap : MonoBehaviour iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance); } - if (zone == ActionGameManager.CurrentSector.Exit) + if (zone == ActionGameManager.CurrentGalaxy.Exit) { var iconInstance = IconPrototype.Instantiate(); iconInstance.material.mainTexture = ExitIcon; @@ -172,8 +172,8 @@ public class SectorMap : MonoBehaviour iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance); } - var homeMega = ActionGameManager.CurrentSector.HomeZones.Keys - .FirstOrDefault(m => ActionGameManager.CurrentSector.HomeZones[m] == zone); + var homeMega = ActionGameManager.CurrentGalaxy.HomeZones.Keys + .FirstOrDefault(m => ActionGameManager.CurrentGalaxy.HomeZones[m] == zone); if (homeMega != null) { var backgroundInstance = IconBackgroundPrototype.Instantiate(); @@ -196,8 +196,8 @@ public class SectorMap : MonoBehaviour iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance); } - var bossMega = ActionGameManager.CurrentSector.BossZones.Keys - .FirstOrDefault(m => ActionGameManager.CurrentSector.BossZones[m] == zone); + var bossMega = ActionGameManager.CurrentGalaxy.BossZones.Keys + .FirstOrDefault(m => ActionGameManager.CurrentGalaxy.BossZones[m] == zone); if (bossMega != null) { var backgroundInstance = IconBackgroundPrototype.Instantiate(); @@ -269,12 +269,12 @@ public class SectorMap : MonoBehaviour public void Start() { - if (ActionGameManager.CurrentSector == null) + if (ActionGameManager.CurrentGalaxy == null) { gameObject.SetActive(false); return; } - foreach (var mega in ActionGameManager.CurrentSector.Factions) + foreach (var mega in ActionGameManager.CurrentGalaxy.Factions) { var influenceTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf); var influenceRenderer = InfluenceRendererPrototype.Instantiate(); @@ -301,22 +301,22 @@ public class SectorMap : MonoBehaviour legendElement.Label.text = mega.ShortName; } - SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentSector.Background.CloudAmplitude); - SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentSector.Background.CloudExponent); - SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentSector.Background.NoisePosition); - SectorRenderer.material.SetFloat("NoiseAmplitude", ActionGameManager.CurrentSector.Background.NoiseAmplitude); - SectorRenderer.material.SetFloat("NoiseOffset", ActionGameManager.CurrentSector.Background.NoiseOffset); - SectorRenderer.material.SetFloat("NoiseGain", ActionGameManager.CurrentSector.Background.NoiseGain); - SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentSector.Background.NoiseLacunarity); - SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentSector.Background.NoiseFrequency); + SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentGalaxy.Background.CloudAmplitude); + SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentGalaxy.Background.CloudExponent); + SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentGalaxy.Background.NoisePosition); + SectorRenderer.material.SetFloat("NoiseAmplitude", ActionGameManager.CurrentGalaxy.Background.NoiseAmplitude); + SectorRenderer.material.SetFloat("NoiseOffset", ActionGameManager.CurrentGalaxy.Background.NoiseOffset); + SectorRenderer.material.SetFloat("NoiseGain", ActionGameManager.CurrentGalaxy.Background.NoiseGain); + SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentGalaxy.Background.NoiseLacunarity); + SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentGalaxy.Background.NoiseFrequency); } private void RenderInfluence() { // Render Influence Textures - foreach (var mega in ActionGameManager.CurrentSector.Factions) + foreach (var mega in ActionGameManager.CurrentGalaxy.Factions) { - foreach (var zone in ActionGameManager.CurrentSector.Zones) + foreach (var zone in ActionGameManager.CurrentGalaxy.Zones) { if(_zoneInstances.ContainsKey(zone)) { diff --git a/Assets/Scripts/UI/Menu/SectorRenderer.cs b/Assets/Scripts/UI/Menu/SectorRenderer.cs index ccba5a498..e6c6b2190 100644 --- a/Assets/Scripts/UI/Menu/SectorRenderer.cs +++ b/Assets/Scripts/UI/Menu/SectorRenderer.cs @@ -66,7 +66,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS .Select(f=>f.Name).ToArray(); if (otherFactions.Length > 0) Properties.AddProperty("Factions Present", () => string.Join(", ", otherFactions)); - var density = saturate(ActionGameManager.CurrentSector.Background.CloudDensity(zone.Position)/2); + var density = saturate(ActionGameManager.CurrentGalaxy.Background.CloudDensity(zone.Position)/2); var radius = GameManager.Settings.ZoneSettings.ZoneRadius.Evaluate(density); var mass = GameManager.Settings.ZoneSettings.ZoneMass.Evaluate(density); Properties.AddProperty("Mass", () => ActionGameManager.PlayerSettings.Format(mass)); @@ -145,11 +145,11 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS { _init = true; SectorCamera.gameObject.SetActive(true); - _position = GameManager.Zone.SectorZone.Position; + _position = GameManager.Zone.GalaxyZone.Position; _viewSize = .25f; Map.StartReveal(LinkAnimationDuration, IconAnimationDuration); - Map.MarkPlayerLocation(GameManager.CurrentEntity.Zone.SectorZone); + Map.MarkPlayerLocation(GameManager.CurrentEntity.Zone.GalaxyZone); } private void OnDisable() diff --git a/Assets/Scripts/Zone Display/ZoneRenderer.cs b/Assets/Scripts/Zone Display/ZoneRenderer.cs index 93b142487..aa3b363bd 100644 --- a/Assets/Scripts/Zone Display/ZoneRenderer.cs +++ b/Assets/Scripts/Zone Display/ZoneRenderer.cs @@ -197,11 +197,11 @@ public class ZoneRenderer : MonoBehaviour UnloadEntity(e.Value); })); - if (zone.SectorZone != null) + if (zone.GalaxyZone != null) { - foreach (var adjacentZone in zone.SectorZone.AdjacentZones) + foreach (var adjacentZone in zone.GalaxyZone.AdjacentZones) { - var dir = normalize(adjacentZone.Position - zone.SectorZone.Position); + var dir = normalize(adjacentZone.Position - zone.GalaxyZone.Position); AddWormhole(new Wormhole { Target = adjacentZone, diff --git a/GameData/PlayerSettings.msgpack b/GameData/PlayerSettings.msgpack index 31c56c220..e3432f3c4 100644 --- a/GameData/PlayerSettings.msgpack +++ b/GameData/PlayerSettings.msgpack @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8fa080338afaf0efce90a7acb89b95724143db2a40e803c446013b2f8593e9e -size 47573 +oid sha256:5e3deabd2f0de5d092e8427fb5f87f5d0e0347d183f9e3edf327a9f3f3b65c80 +size 66911