diff --git a/Assets/Resources/Settings.asset b/Assets/Resources/Settings.asset index a42239c6e..d3d82f554 100644 --- a/Assets/Resources/Settings.asset +++ b/Assets/Resources/Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d36bc575eff8aa453ae459076b9dbde85fac0c1b918c19ca69dd68e3e0aa857e -size 7880 +oid sha256:53b8c532e6449c6366238fdcd637a70de6dfb16194d04ddbaba2e421881bad9e +size 8652 diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index bdbe4b14f..5405f35c8 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -3068,10 +3068,10 @@ RectTransform: m_Father: {fileID: 746825913} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 90.5, y: -8} + m_SizeDelta: {x: 181, y: 16} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &232470598 MonoBehaviour: @@ -4292,7 +4292,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &346000247 RectTransform: m_ObjectHideFlags: 0 @@ -15853,10 +15853,10 @@ RectTransform: m_Father: {fileID: 204301710} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 92, y: -220} + m_SizeDelta: {x: 184, y: 16} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1277237367 MonoBehaviour: @@ -16837,7 +16837,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 439, y: 204} - m_SizeDelta: {x: 128, y: 0} + m_SizeDelta: {x: 128, y: 16} m_Pivot: {x: 0, y: 1} --- !u!114 &1399423351 MonoBehaviour: @@ -19161,10 +19161,10 @@ RectTransform: m_Father: {fileID: 1399423350} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 63.5, y: -8} + m_SizeDelta: {x: 127, y: 16} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1564656282 MonoBehaviour: @@ -19356,7 +19356,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} m_AnchoredPosition: {x: 0, y: -224} - m_SizeDelta: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 325.58} m_Pivot: {x: 0.5, y: 0} --- !u!114 &1590553660 MonoBehaviour: @@ -22290,10 +22290,10 @@ RectTransform: m_Father: {fileID: 1359207439} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 127, y: -130} + m_SizeDelta: {x: 16, y: 16} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1889622744 MonoBehaviour: @@ -29173,10 +29173,10 @@ RectTransform: m_Father: {fileID: 7628189704016736659} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 127, y: -130} + m_SizeDelta: {x: 16, y: 16} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7628189703197605887 MonoBehaviour: diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 500ae5071..a6a19e4c5 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -432,7 +432,7 @@ public class ActionGameManager : MonoBehaviour testCorp.PlayerHostile = true; var stationType = ItemData.GetAll().First(x=>x.HullType==HullType.Station); - var stationHull = ItemManager.CreateInstance(stationType, 0, 1) as EquippableItem; + 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); @@ -442,7 +442,7 @@ public class ActionGameManager : MonoBehaviour station.Faction = testCorp; Zone.Entities.Add(station); var dockingBayData = ItemData.GetAll().First(); - var dockingBay = ItemManager.CreateInstance(dockingBayData, 1, 1) as EquippableItem; + var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem; station.TryEquip(dockingBay); station.Activate(); diff --git a/Assets/Scripts/Gameplay/GameSettings.cs b/Assets/Scripts/Gameplay/GameSettings.cs index b0ad1ea57..aebb63cc4 100644 --- a/Assets/Scripts/Gameplay/GameSettings.cs +++ b/Assets/Scripts/Gameplay/GameSettings.cs @@ -42,4 +42,4 @@ public class BodySettingsCollection { public float MinimumMass; public CelestialBodySettings[] BodySettings; -} +} \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Weapons/GuidedProjectileManager.cs b/Assets/Scripts/Gameplay/Weapons/GuidedProjectileManager.cs index 8713e53f1..8311b0cc5 100644 --- a/Assets/Scripts/Gameplay/Weapons/GuidedProjectileManager.cs +++ b/Assets/Scripts/Gameplay/Weapons/GuidedProjectileManager.cs @@ -10,6 +10,7 @@ public class GuidedProjectileManager : InstantWeaponEffectManager public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) { + if (target == null) return; if(weapon.Data is LauncherData launcher) { var p = ProjectilePrototype.Instantiate(); diff --git a/Assets/Scripts/ServerShared/ItemData.cs b/Assets/Scripts/ServerShared/ItemData.cs index dfc66915c..7d430e724 100644 --- a/Assets/Scripts/ServerShared/ItemData.cs +++ b/Assets/Scripts/ServerShared/ItemData.cs @@ -193,8 +193,8 @@ public abstract class ItemData : DatabaseEntry, INamedEntry [InspectableText, JsonProperty("description"), Key(2)] public string Description; - [InspectableText, JsonProperty("manufacturer"), Key(3)] - public string Manufacturer; + [InspectableDatabaseLink(typeof(MegaCorporation)), JsonProperty("creator"), Key(3)] + public Guid Manufacturer; [InspectableField, JsonProperty("mass"), Key(4)] public float Mass; diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index a939851ce..6165a2726 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -432,7 +432,7 @@ public class ItemManager var data = GetData(item); if(data is CraftedItemData c) { - var i = CreateInstance(c, 0, 1); + var i = CreateInstance(c); i.Rotation = item.Rotation; return i; } @@ -445,7 +445,7 @@ public class ItemManager return null; } - public CraftedItemInstance CreateInstance(CraftedItemData item, float qualityMin, float qualityMax) + public CraftedItemInstance CreateInstance(CraftedItemData item) { if (item == null) { @@ -481,7 +481,7 @@ public class ItemManager var craftedIngredientData = ItemData.Get(ingredient.Key); for (int i = 0; i < ingredient.Value; i++) { - var itemInstance = CreateInstance(craftedIngredientData, qualityMin, qualityMax); + var itemInstance = CreateInstance(craftedIngredientData); if (itemInstance == null) { invalidIngredientFound = true; @@ -499,6 +499,14 @@ public class ItemManager { _logger($"Unable to create crafted item ingredient: {invalidIngredient?.Name??"null"} for item {item.Name}"); } + + var quality = Random.NextFloat(); + var tier = GameplaySettings.Tiers[0]; + foreach (var t in GameplaySettings.Tiers) + { + if (t.Rarity > quality) + tier = t; + } if (item is EquippableItemData equippableItemData) { @@ -506,7 +514,7 @@ public class ItemManager { Data = item.ID, Ingredients = ingredients, - Quality = Random.NextFloat(qualityMin, qualityMax), + Quality = tier.Quality, Blueprint = blueprint.ID, Name = $"{item.Name}" }; @@ -518,134 +526,20 @@ public class ItemManager { Data = item.ID, Ingredients = ingredients, - Quality = Random.NextFloat(qualityMin, qualityMax), + Quality = tier.Quality, Blueprint = blueprint.ID, Name = $"{item.Name}" }; return newCommodity; } - - // class DijkstraNode - // { - // public float Cost; - // public DijkstraNode Parent; - // public ZoneDefinition Zone; - // } - // - // public List FindPath(ZoneDefinition source, ZoneDefinition target, bool bestFirst = false) - // { - // SortedList members = new SortedList{{0,new DijkstraNode{Zone = source}}}; - // List searched = new List(); - // while (true) - // { - // var s = members.FirstOrDefault(m => !searched.Contains(m.Value)).Value; // Lowest cost unsearched node - // if (s == null) return null; // No vertices left unsearched - // if (s.Zone == target) // We found the path - // { - // Stack path = new Stack(); // Since we start at the end, use a LIFO collection - // path.Push(s); - // while(path.Peek().Parent!=null) // Keep pushing until we reach the start, which has no parent - // path.Push(path.Peek().Parent); - // return path.Select(dv => dv.Zone).ToList(); - // } - // // For each adjacent star (filter already visited zones unless heuristic is in use) - // foreach (var dijkstraStar in s.Zone.Links.WhereSelectF(i => !bestFirst || members.All(m => m.Value.Zone != GalaxyZones[i]), - // // Cost is parent cost plus distance - // i => new DijkstraNode {Parent = s, Zone = GalaxyZones[i], Cost = s.Cost + length(s.Zone.Position - GalaxyZones[i].Position)})) - // // Add new member to list, sorted by cost plus optional heuristic - // members.Add(bestFirst ? dijkstraStar.Cost + length(dijkstraStar.Zone.Position - target.Position) : dijkstraStar.Cost, dijkstraStar); - // searched.Add(s); - // } - // } - // public bool MoveCargo(Entity source, Entity target, ItemInstance item, int quantity = int.MaxValue) - // { - // if (item is CraftedItemInstance craftedItemInstance) - // { - // var craftedItemData = Cache.Get(craftedItemInstance.Data); - // if (target.Capacity - target.OccupiedCapacity > craftedItemData.Size) - // { - // // Target has the cargo capacity for the item, simply move the instance - // source.Cargo.Remove(item.ID); - // target.Cargo.Add(item.ID); - // source.RecalculateMass(); - // target.RecalculateMass(); - // return true; - // } - // return false; - // } - // - // if (item is SimpleCommodity simpleCommoditySource) - // { - // quantity = min(quantity, simpleCommoditySource.Quantity); - // var simpleCommodityData = Cache.Get(simpleCommoditySource.Data); - // var spareCapacity = (int) (target.Capacity - target.OccupiedCapacity); - // var simpleCommodityTarget = target.Cargo - // .Select(i => Cache.Get(i)) - // .FirstOrDefault(i => i.Data == simpleCommodityData.ID) as SimpleCommodity; - // var success = spareCapacity >= quantity; - // quantity = min(quantity, spareCapacity); - // if (simpleCommodityTarget == null) - // { - // if (quantity == simpleCommoditySource.Quantity) - // { - // // Target has the cargo capacity to hold the full quantity, - // // and the target has no matching item instance; - // // simply move the existing item instance to the target - // source.Cargo.Remove(simpleCommoditySource.ID); - // target.Cargo.Add(simpleCommoditySource.ID); - // source.RecalculateMass(); - // target.RecalculateMass(); - // return success; - // } - // else - // { - // // Target has the cargo capacity to hold the desired quantity - // // and the target has no matching item instance; - // // Create a new item instance on the target and decrement the quantity of the source instance - // var newSimpleCommodity = new SimpleCommodity - // { - // Context = this, - // Data = simpleCommodityData.ID, - // Quantity = simpleCommoditySource.Quantity - // }; - // Cache.Add(newSimpleCommodity); - // target.Cargo.Add(newSimpleCommodity.ID); - // simpleCommoditySource.Quantity -= quantity; - // source.RecalculateMass(); - // target.RecalculateMass(); - // return success; - // } - // } - // else - // { - // if (quantity == simpleCommoditySource.Quantity) - // { - // // Target has the cargo capacity to hold the full quantity, - // // and there is already a matching item instance; - // // delete the source entity's item instance and increment the target's quantity - // source.Cargo.Remove(simpleCommoditySource.ID); - // Cache.Delete(simpleCommoditySource); - // simpleCommodityTarget.Quantity += quantity; - // source.RecalculateMass(); - // target.RecalculateMass(); - // return success; - // } - // else - // { - // // Target has the cargo capacity to hold the desired quantity, - // // and there is already a matching item instance; - // // decrement the source's quantity and increment the target's quantity - // simpleCommoditySource.Quantity -= quantity; - // simpleCommodityTarget.Quantity += quantity; - // source.RecalculateMass(); - // target.RecalculateMass(); - // return success; - // } - // } - // - // } - // - // return false; - // } + public (RarityTier tier, int upgrades) GetTier(CraftedItemInstance item) + { + var tier = GameplaySettings.Tiers[0]; + foreach (var t in GameplaySettings.Tiers) + if (item.Quality + .001f > t.Quality) + tier = t; + int upgrades = (int) ((item.Quality - tier.Quality) / .0499f); + return (tier, upgrades); + } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Settings.cs b/Assets/Scripts/ServerShared/Settings.cs index 580952b7c..ff25925f9 100644 --- a/Assets/Scripts/ServerShared/Settings.cs +++ b/Assets/Scripts/ServerShared/Settings.cs @@ -88,6 +88,7 @@ public class ZoneGenerationSettings [Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject] public class GameplaySettings { + public RarityTier[] Tiers; public float DefaultShutdownPerformance = .25f; public float SevereHeatstrokeRiskThreshold = .25f; public float WormholeDepth = 1000; @@ -129,4 +130,13 @@ public class GameplaySettings public float AgentForwardLerp = .5f; public float AgentMaxForwardDistance = 50; public float AgentFiringMinDot = .99f; +} + +[Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject] +public class RarityTier +{ + public string Name; + public float Quality; + public float3 Color; + public float Rarity; } \ No newline at end of file diff --git a/Assets/Scripts/UI/PropertiesPanel.cs b/Assets/Scripts/UI/PropertiesPanel.cs index f38844fe4..bab02a47a 100644 --- a/Assets/Scripts/UI/PropertiesPanel.cs +++ b/Assets/Scripts/UI/PropertiesPanel.cs @@ -71,6 +71,7 @@ public class PropertiesPanel : MonoBehaviour //RemoveListener(); foreach(var property in Properties) Destroy(property); + Title.text = "Properties"; Properties.Clear(); Buttons.Clear(); SelectedChild = null; @@ -340,34 +341,30 @@ public class PropertiesPanel : MonoBehaviour { AddField("Name", () => entity.Name, name => entity.Name = name); AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}"); - // AddProperty("Temperature", () => $"{entity.Temperature:0}°K"); - // AddProperty("Energy", () => $"{entity.Energy:0}/{entity.GetBehavior()?.Capacitance??0:0}"); } public void AddItemProperties(Entity entity, ItemInstance item) { var data = Context.ItemData.Get(item.Data); - AddProperty("Type", () => data.Name); AddProperty(data.Description).Label.fontStyle = FontStyles.Normal; - // if (item is CraftedItemInstance craftedItemInstance) - // { - // var sourceEntity = Context.ItemData.Get(craftedItemInstance.SourceEntity); - // if (sourceEntity != null) - // { - // var corporation = Context.ItemData.Get(sourceEntity.Corporation); - // AddProperty("Manufacturer", () => corporation.Name); - // } - // else - // { - // AddProperty("Manufacturer", () => "GameCult"); - // } - // } + var manufacturer = Context.ItemData.Get(data.Manufacturer); + if (manufacturer != null) + { + AddProperty("Manufacturer", () => manufacturer.Name); + } + else + { + AddProperty("Manufacturer", () => "GameCult"); + } if (item is SimpleCommodity simpleCommodity) AddProperty("Quantity", () => simpleCommodity.Quantity.ToString()); AddProperty("Mass", () => Context.GetMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits)); AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits)); if (item is EquippableItem gear) { + var tier = entity.ItemManager.GetTier(gear); + Title.text = + $"{gear.Name} ({tier.tier.Name}{new string('+', tier.upgrades)})"; var gearData = Context.GetData(gear); AddProperty("Durability", () => $"{gear.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}/{gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}"); @@ -497,53 +494,6 @@ public class PropertiesPanel : MonoBehaviour () => 0, () => entity.Population - entity.AssignedPopulation + populationAssignment.AssignedPopulation); if (behavior is Thermotoggle thermotoggle) AddField("Target Temperature", () => thermotoggle.TargetTemperature, temp => thermotoggle.TargetTemperature = temp); - // if (behavior is Factory factory) - // { - // AddField("Production Quality", () => factory.ProductionQuality, f => factory.ProductionQuality = f, 0, 1); - // var corporation = Context.ItemData.Get(entity.Corporation); - // var compatibleBlueprints = corporation.UnlockedBlueprints - // .Select(id => Context.ItemData.Get(id)) - // .Where(bp => bp.FactoryItem == item.ItemData.ID).ToList(); - // if (factory.RetoolingTime > 0) - // { - // AddProgressField("Retooling", () => (factory.ToolingTime - (float) factory.RetoolingTime) / factory.ToolingTime); - // } - // else - // { - // AddField("Item", - // () => compatibleBlueprints.FindIndex(bp=>bp.ID== factory.Blueprint) + 1, - // i => factory.Blueprint = i == 0 ? Guid.Empty : compatibleBlueprints[i - 1].ID, - // new []{"None"}.Concat(compatibleBlueprints.Select(bp=>bp.Name)).ToArray()); - // AddField("Active", () => factory.Active, active => factory.Active = active); - // if (factory.Blueprint != Guid.Empty) - // { - // if (factory.Active && factory.ItemUnderConstruction != Guid.Empty) - // { - // AddProgressField("Production", () => - // { - // if (factory.ItemUnderConstruction == Guid.Empty) return 1; - // var itemInstance = Context.ItemData.Get(factory.ItemUnderConstruction); - // var blueprintData = Context.ItemData.Get(itemInstance.Blueprint); - // return (blueprintData.ProductionTime - (float) entity.IncompleteCargo[factory.ItemUnderConstruction]) / blueprintData.ProductionTime; - // }); - // } - // else - // { - // //AddField("Product Name", () => factory.ItemName, name => factory.ItemName = name); - // AddField("Product Name", () => factory.ItemName, name => factory.ItemName = name); - // var ingredientsList = AddList("Ingredients Needed"); - // var blueprintData = Context.ItemData.Get(factory.Blueprint); - // foreach (var ingredient in blueprintData.Ingredients) - // { - // var itemData = Context.ItemData.Get(ingredient.Key); - // ingredientsList.AddProperty(itemData.Name, () => ingredient.Value.ToString()); - // } - // // ingredientsList.SetExpanded(false, true); - // ingredientsList.RefreshValues(); - // } - // } - // } - // } } } RefreshValues(); diff --git a/Assets/Scripts/UI/TradeMenu.cs b/Assets/Scripts/UI/TradeMenu.cs index 1b0692002..1f4b4cc7d 100644 --- a/Assets/Scripts/UI/TradeMenu.cs +++ b/Assets/Scripts/UI/TradeMenu.cs @@ -355,7 +355,7 @@ public class TradeMenu : MonoBehaviour { if (data.Price < GameManager.Credits) { - var hull = GameManager.ItemManager.CreateInstance(data, .1f, 1) as EquippableItem; + var hull = GameManager.ItemManager.CreateInstance(data) as EquippableItem; Entity entity; if(data.HullType==HullType.Ship) entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull); @@ -379,7 +379,7 @@ public class TradeMenu : MonoBehaviour { if (data.Price < GameManager.Credits) { - if (_targetCargo.TryStore(GameManager.ItemManager.CreateInstance(data, .1f, 1))) + if (_targetCargo.TryStore(GameManager.ItemManager.CreateInstance(data))) { GameManager.Credits -= data.Price; } diff --git a/GameData/AetherDB.msgpack b/GameData/AetherDB.msgpack index 8982d0837..6c1df56db 100644 Binary files a/GameData/AetherDB.msgpack and b/GameData/AetherDB.msgpack differ