diff --git a/Assets/Materials/ShinyParticleEffect.mat b/Assets/Materials/ShinyParticleEffect.mat new file mode 100644 index 000000000..29b60b300 --- /dev/null +++ b/Assets/Materials/ShinyParticleEffect.mat @@ -0,0 +1,107 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ShinyParticleEffect + m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: + - _ALPHABLEND_ON + m_InvalidKeywords: [] + m_LightmapFlags: 0 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + disabledShaderPasses: + - GRABPASS + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 1bf7079096e7ce64897a955662d3d65c, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BlendOp: 0 + - _BumpScale: 1 + - _CameraFadingEnabled: 0 + - _CameraFarFadeDistance: 2 + - _CameraNearFadeDistance: 1 + - _ColorMode: 0 + - _Cull: 0 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DistortionBlend: 0.5 + - _DistortionEnabled: 0 + - _DistortionStrength: 1 + - _DistortionStrengthScaled: 0 + - _DstBlend: 1 + - _EmissionEnabled: 0 + - _FlipbookMode: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InvFade: 1 + - _LightingEnabled: 0 + - _Metallic: 0 + - _Mode: 4 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SoftParticlesEnabled: 0 + - _SoftParticlesFarFadeDistance: 1 + - _SoftParticlesNearFadeDistance: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 5 + - _UVSec: 0 + - _ZWrite: 0 + m_Colors: + - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _ColorAddSubDiff: {r: -1, g: 1, b: 0, a: 0} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} + - _TintColor: {r: 0.27450982, g: 0.27450982, b: 0.27450982, a: 0.5} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/ShinyParticleEffect.mat.meta b/Assets/Materials/ShinyParticleEffect.mat.meta new file mode 100644 index 000000000..3bf9b9c7b --- /dev/null +++ b/Assets/Materials/ShinyParticleEffect.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd6a02fc212211047ba40ac4c71242ac +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/HUD Prefabs/Ship Builder.prefab b/Assets/Prefabs/HUD Prefabs/Ship Builder.prefab index ecad40fe5..75574c2c9 100644 --- a/Assets/Prefabs/HUD Prefabs/Ship Builder.prefab +++ b/Assets/Prefabs/HUD Prefabs/Ship Builder.prefab @@ -5562,19 +5562,7 @@ MonoBehaviour: m_Calls: [] m_OnValueChanged: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 8776915232209613947} - m_TargetAssemblyTypeName: - m_MethodName: ChangePartImage - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} m_CustomCaretColor: 0 m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} diff --git a/Assets/Prefabs/Shellcore Prefabs/Part Prefabs/BasePartPrefab.prefab b/Assets/Prefabs/Shellcore Prefabs/Part Prefabs/BasePartPrefab.prefab index 139e64fa7..bcfde42ec 100644 --- a/Assets/Prefabs/Shellcore Prefabs/Part Prefabs/BasePartPrefab.prefab +++ b/Assets/Prefabs/Shellcore Prefabs/Part Prefabs/BasePartPrefab.prefab @@ -106,7 +106,8 @@ MonoBehaviour: craft: {fileID: 0} partHealth: 500 partMass: 0.2 - detachible: 1 + weapon: 0 + detachable: 1 shooter: {fileID: 0} info: location: {x: -0.2, y: 0.6} @@ -137,7 +138,6 @@ MonoBehaviour: e31: 0 e32: 0 e33: 0 - weapon: 0 --- !u!198 &5915238074567533318 ParticleSystem: m_ObjectHideFlags: 0 @@ -389,9 +389,9 @@ ParticleSystem: m_NumAlphaKeys: 2 startSize: serializedVersion: 2 - minMaxState: 0 - scalar: 0.15 - minScalar: 1 + minMaxState: 3 + scalar: 0.35 + minScalar: 0.1 maxCurve: serializedVersion: 2 m_Curve: @@ -442,7 +442,7 @@ ParticleSystem: m_RotationOrder: 4 startSizeY: serializedVersion: 2 - minMaxState: 0 + minMaxState: 3 scalar: 1 minScalar: 1 maxCurve: @@ -495,7 +495,7 @@ ParticleSystem: m_RotationOrder: 4 startSizeZ: serializedVersion: 2 - minMaxState: 0 + minMaxState: 3 scalar: 1 minScalar: 1 maxCurve: @@ -1082,38 +1082,29 @@ ParticleSystem: curve: serializedVersion: 2 minMaxState: 1 - scalar: 1 + scalar: 0.96762455 minScalar: 1 maxCurve: serializedVersion: 2 m_Curve: - serializedVersion: 3 time: 0 - value: 1 - inSlope: Infinity - outSlope: Infinity - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0 - - serializedVersion: 3 - time: 0.6473296 - value: 1 - inSlope: -0.4047008 - outSlope: -0.4047008 + value: 0.5405392 + inSlope: 2.6181443 + outSlope: 2.6181443 tangentMode: 0 weightedMode: 0 - inWeight: 0.07919627 - outWeight: 0.1514359 + inWeight: 0 + outWeight: 0.16316672 - serializedVersion: 3 - time: 1 + time: 0.99328613 value: 0 - inSlope: -4.1076946 - outSlope: -4.1076946 + inSlope: -2.5718505 + outSlope: -2.5718505 tangentMode: 0 weightedMode: 0 - inWeight: 0.0835512 - outWeight: 0.33333334 + inWeight: 0.4277069 + outWeight: 0 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 @@ -1249,7 +1240,7 @@ ParticleSystem: m_RotationOrder: 4 separateAxes: 0 RotationModule: - enabled: 1 + enabled: 0 x: serializedVersion: 2 minMaxState: 3 @@ -2298,7 +2289,7 @@ ParticleSystem: m_RotationOrder: 4 m_Range: {x: 0, y: 1} ForceModule: - enabled: 1 + enabled: 0 x: serializedVersion: 2 minMaxState: 0 @@ -4887,7 +4878,7 @@ ParticleSystemRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 37f63c819ae6c274d8ed924fc281a206, type: 2} + - {fileID: 2100000, guid: fd6a02fc212211047ba40ac4c71242ac, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index d3a2b0680..d5e23c173 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -12746,7 +12745,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 1, b: 0, a: 1} + m_Color: {r: 0, g: 0.5019608, b: 0, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -16572,6 +16571,7 @@ GameObject: - component: {fileID: 1296363338} - component: {fileID: 1296363340} - component: {fileID: 1296363339} + - component: {fileID: 1296363341} m_Layer: 5 m_Name: Tally m_TagString: Untagged @@ -16640,6 +16640,21 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1296363337} m_CullTransparentMesh: 0 +--- !u!114 &1296363341 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1296363337} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5} + m_EffectDistance: {x: 1, y: -1} + m_UseGraphicAlpha: 1 --- !u!1 &1299087295 GameObject: m_ObjectHideFlags: 0 @@ -22980,6 +22995,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: GlobalObjectIdHash: 2077927833 + InScenePlacedSourceGlobalObjectIdHash: 0 AlwaysReplicateAsRoot: 0 SynchronizeTransform: 1 ActiveSceneSynchronization: 0 @@ -23666,8 +23682,8 @@ MonoBehaviour: stealthGasBoosted: 0 flatDamageIncrease: 0 absorptions: 0 + invertTractors: 0 canUseAbilities: 1 - tractorSwitched: 0 sectorMngr: {fileID: 0} entityName: isStandardTractorTarget: 0 @@ -23710,8 +23726,10 @@ MonoBehaviour: missions: [] reputation: 0 episode: 0 + partyLock: 0 unlockedPartyIDs: [] disabledPartyIDs: [] + currentPartyMembers: [] abilityHotkeys: skills: spawns: [] @@ -27564,12 +27582,12 @@ PrefabInstance: - target: {fileID: 4076859594884605426, guid: 32a32bac7ec6ea947bc6f2b367fb7171, type: 3} propertyPath: m_AnchorMax.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4076859594884605426, guid: 32a32bac7ec6ea947bc6f2b367fb7171, type: 3} propertyPath: m_AnchorMin.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4076859594884605426, guid: 32a32bac7ec6ea947bc6f2b367fb7171, type: 3} @@ -27584,7 +27602,7 @@ PrefabInstance: - target: {fileID: 4076859594884605426, guid: 32a32bac7ec6ea947bc6f2b367fb7171, type: 3} propertyPath: m_AnchoredPosition.y - value: 0 + value: -10 objectReference: {fileID: 0} - target: {fileID: 4076859596742077408, guid: 32a32bac7ec6ea947bc6f2b367fb7171, type: 3} diff --git a/Assets/Scripts/PartIndexScript.cs b/Assets/Scripts/PartIndexScript.cs index 62ce736fe..55cfc29ca 100644 --- a/Assets/Scripts/PartIndexScript.cs +++ b/Assets/Scripts/PartIndexScript.cs @@ -1,353 +1,354 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; - -public class PartIndexScript : MonoBehaviour -{ - // The Part Index assumes this field is already set up by the Sector Manager upon reading world data. - public static WorldData.PartIndexData[] index; - - public Dictionary parts = new Dictionary(); - public GameObject inventoryPrefab; - - public Transform[] contents; - public GameObject[] texts; - public GameObject infoBox; - public PartDisplayBase partDisplay; - - // Tallies how many parts the player has interacted with and how. - // Stats numbers - - // 0: number of shiny parts - // 1: number of obtained parts - // 2: number of seen parts - // 3: number of total parts - public Image[] statsBar; - public int[] statsNumbers; - public Text statsTotalTally; - public static PartIndexScript instance; - - public enum PartStatus - { - Unseen, - Seen, - Obtained - } - - public static int GetNumberOfPartsObtained(bool percentEnabled) - { - int count = 0; - int total = 0; - foreach (var part in index) - { - var part2 = CullToPartIndexValues(part.part); - if (CheckPartObtained(part2)) - { - count++; - } - total++; - } - - if (percentEnabled) - return (int)((count / (double)total) * 100); - else - return count; - } - - public static int GetNumberOfPartsSeen(bool percentEnabled) - { - int count = 0; - int total = 0; - foreach (var part in index) - { - var part2 = CullToPartIndexValues(part.part); - if (CheckPartSeen(part2)) - { - count++; - } - total++; - } - - if (percentEnabled) - return (int)((count / (double)total) * 100); - else - return count; - } - - public void SetPartAsSeen(EntityBlueprint.PartInfo part) - { - if (!parts.ContainsKey(part)) return; - var button = parts[part].GetComponent(); - if (!button) return; - if (button.status == PartStatus.Seen || button.status == PartStatus.Obtained) return; - button.status = PartStatus.Seen; - button.displayShiny = false; - // Update only the seen tally - statsNumbers[2]++; - button.UpdateButton(); - } - - private void SetPartAsObtained(EntityBlueprint.PartInfo part) - { - if (!parts.ContainsKey(part)) return; - var button = parts[part].GetComponent(); - if (!button) return; - if (button.status == PartStatus.Obtained) return; - statsNumbers[1]++; - statsNumbers[2]++; - - button.status = PartStatus.Obtained; - button.displayShiny = PlayerCore.Instance.cursave.partsObtained.Find(x => CullToPartIndexValues(x).Equals(part)).shiny; - - // Update stats on 3 tallies, possibly the shiny tally - if (button.displayShiny) - { - statsNumbers[0]++; - } - - button.UpdateButton(); - } - - - - - /// - /// Attempt to add a part into the index, check if the player obtained/saw it - /// - public void AttemptAddPart(EntityBlueprint.PartInfo part, List origins) - { - part = CullToPartIndexValues(part); - if (!parts.ContainsKey(part)) - { - var button = Instantiate(inventoryPrefab, contents[ResourceManager.GetAsset(part.partID).size]).GetComponent(); - parts.Add(part, button.gameObject); - button.part = part; - if (CheckPartObtained(part)) - { - SetPartAsObtained(part); - } - else if (CheckPartSeen(part)) - { - SetPartAsSeen(part); - } - else - { - button.status = PartStatus.Unseen; - button.displayShiny = false; - } - - button.infoBox = infoBox; - button.partDisplay = partDisplay; - // Update total number - statsNumbers[3]++; - foreach (var origin in origins) - { - parts[part].GetComponent().origins.Add(origin); - } - } - } - - public static bool partsObtainedCheat; - - public static bool CheckPartObtained(EntityBlueprint.PartInfo part) - { - if (partsObtainedCheat) - { - return true; - } - - part = CullToPartIndexValues(part); - return PlayerCore.Instance.cursave.partsObtained.Exists(x => CullToPartIndexValues(x).Equals(part)); - } - - public static bool CheckPartSeen(EntityBlueprint.PartInfo part) - { - part = CullToPartIndexValues(part); - return PlayerCore.Instance.cursave.partsSeen.Exists(x => CullToPartIndexValues(x).Equals(part)); - } - - void OnEnable() - { - instance = this; - ResetContent(); - UpdateContent(null, null); - - var partsSeen = new List(); - foreach (var part in PlayerCore.Instance.cursave.partsSeen) - { - if (!partsSeen.Contains(CullToPartIndexValues(part))) - { - partsSeen.Add(CullToPartIndexValues(part)); - } - } - PlayerCore.Instance.cursave.partsSeen = partsSeen; - - Entity.OnEntityDeath += UpdateContent; - } - - private void OnDisable() - { - Entity.OnEntityDeath -= UpdateContent; - ResetContent(); - } - - private void ResetContent() - { - statsNumbers = new int[] { 0, 0, 0, 0 }; - foreach (var content in contents) - { - for (int i = 0; i < content.childCount; i++) - { - Destroy(content.GetChild(i).gameObject); - } - } - - parts.Clear(); - } - - - - public void UpdateContent(Entity _, Entity __) - { - if (index == null) - { - Debug.LogWarning("The Part Index cache has not been set up for this world. Please rewrite this world, it will rebuild automatically."); - return; - } - - // player metadata - if (PlayerCore.Instance.cursave.partsObtained == null || PlayerCore.Instance.cursave.partsObtained.Count == 0) - { - PlayerCore.Instance.cursave.partsObtained = new List(); - foreach (var part in PlayerCore.Instance.GetInventory()) - { - AttemptAddToPartsObtained(part); - } - - foreach (var part in PlayerCore.Instance.blueprint.parts) - { - AttemptAddToPartsObtained(part); - } - } - - if (PlayerCore.Instance.cursave.partsSeen == null || PlayerCore.Instance.cursave.partsSeen.Count == 0) - { - PlayerCore.Instance.cursave.partsSeen = new List(); - var partsSeen = PlayerCore.Instance.cursave.partsSeen; - foreach (var part in PlayerCore.Instance.cursave.partsObtained) - { - AttemptAddToPartsSeen(CullToPartIndexValues(part)); - } - } - - if (attemptAddPartCoroutine != null) - { - StopCoroutine(attemptAddPartCoroutine); - attemptAddPartCoroutine = null; - } - GetComponentInParent().sortingOrder = ++PlayerViewScript.currentLayer; // move window to top - attemptAddPartCoroutine = AttemptAddPartHelper(); - StartCoroutine(attemptAddPartCoroutine); - } - - private IEnumerator attemptAddPartCoroutine; - - private IEnumerator AttemptAddPartHelper() - { - int x = 0; - // index assembly - foreach (var partData in index) - { - AttemptAddPart(partData.part, partData.origins); - x++; - if (x >= 10) - { - x = 0; - UpdateTextAndTally(); - yield return new WaitForEndOfFrame(); - } - } - - UpdateTextAndTally(); - yield return null; - } - - private void UpdateTextAndTally() - { - for (int i = 0; i < contents.Length; i++) - { - texts[i].SetActive(contents[i].childCount > 0); - } - - UpdateTallyGraphic(); - } - - private void UpdateTallyGraphic() - { - // Update tally graphic bar - if (statsNumbers[3] > 0) - { - for (int i = 0; i < statsBar.Length; i++) - { - statsBar[i].rectTransform.sizeDelta = new Vector2(statsNumbers[i] * 800 / statsNumbers[3], 20); - } - } - else - { - // no parts in world, just hide the bars - for (int i = 0; i < statsBar.Length; i++) - { - statsBar[i].gameObject.SetActive(false); - } - } - - // Just found out about string interpolation. Damn that stuff rocks. - statsTotalTally.text = $"{statsNumbers[3]}"; - } - - public static void AttemptAddToPartsObtained(EntityBlueprint.PartInfo part) - { - var partsObtained = PlayerCore.Instance.cursave.partsObtained; - if (!partsObtained.Exists(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))) - { - partsObtained.Add(CullToPartIndexValues(part)); - if (instance) instance.SetPartAsObtained(CullToPartIndexValues(part)); - } - else if (part.shiny) - { - partsObtained[partsObtained.FindIndex(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))] = part; - if (instance) instance.SetPartAsObtained(CullToPartIndexValues(part)); - } - } - - public static void AttemptAddToPartsSeen(EntityBlueprint.PartInfo part) - { - var partsSeen = PlayerCore.Instance.cursave.partsSeen; - if (!partsSeen.Exists(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))) - { - partsSeen.Add(CullToPartIndexValues(part)); - if (instance) instance.SetPartAsSeen(CullToPartIndexValues(part)); - } - } - - /// - /// Culls unnecessary data in the passed PartInfo for adding into the Part Index. - /// Notably, it nullifies secondary data if the part does not spawn drones. - /// - public static EntityBlueprint.PartInfo CullToPartIndexValues(EntityBlueprint.PartInfo partToCull) - { - var part = new EntityBlueprint.PartInfo(); - part.partID = partToCull.partID; - part.abilityID = partToCull.abilityID; - if (!ShipBuilder.CheckSecondaryDataPurge(partToCull)) - { - part.secondaryData = partToCull.secondaryData; - var data = DroneUtilities.GetDroneSpawnDataByShorthand(part.secondaryData); - part.secondaryData = DroneUtilities.GetDefaultSecondaryDataByType(data.type); - } - - part.tier = partToCull.tier; - part.shiny = false; - return part; - } -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class PartIndexScript : MonoBehaviour +{ + // The Part Index assumes this field is already set up by the Sector Manager upon reading world data. + public static WorldData.PartIndexData[] index; + + public Dictionary parts = new Dictionary(); + public GameObject inventoryPrefab; + + public Transform[] contents; + public GameObject[] texts; + public GameObject infoBox; + public PartDisplayBase partDisplay; + + // Tallies how many parts the player has interacted with and how. + // Stats numbers - + // 0: number of shiny parts + // 1: number of obtained parts + // 2: number of seen parts + // 3: number of total parts + public Image[] statsBar; + public int[] statsNumbers; + public Text statsTotalTally; + public static PartIndexScript instance; + + public enum PartStatus + { + Unseen, + Seen, + Obtained + } + + public static int GetNumberOfPartsObtained(bool percentEnabled) + { + int count = 0; + int total = 0; + foreach (var part in index) + { + var part2 = CullToPartIndexValues(part.part); + if (CheckPartObtained(part2)) + { + count++; + } + total++; + } + + if (percentEnabled) + return (int)((count / (double)total) * 100); + else + return count; + } + + public static int GetNumberOfPartsSeen(bool percentEnabled) + { + int count = 0; + int total = 0; + foreach (var part in index) + { + var part2 = CullToPartIndexValues(part.part); + if (CheckPartSeen(part2)) + { + count++; + } + total++; + } + + if (percentEnabled) + return (int)((count / (double)total) * 100); + else + return count; + } + + public void SetPartAsSeen(EntityBlueprint.PartInfo part) + { + if (!parts.ContainsKey(part)) return; + var button = parts[part].GetComponent(); + if (!button) return; + if (button.status == PartStatus.Seen || button.status == PartStatus.Obtained) return; + button.status = PartStatus.Seen; + button.displayShiny = false; + // Update only the seen tally + statsNumbers[2]++; + button.UpdateButton(); + } + + private void SetPartAsObtained(EntityBlueprint.PartInfo part) + { + if (!parts.ContainsKey(part)) return; + var button = parts[part].GetComponent(); + if (!button) return; + if (button.status == PartStatus.Obtained) return; + statsNumbers[1]++; + statsNumbers[2]++; + + button.status = PartStatus.Obtained; + button.displayShiny = PlayerCore.Instance.cursave.partsObtained.Find(x => CullToPartIndexValues(x).Equals(part)).shiny; + + // Update stats on 3 tallies, possibly the shiny tally + if (button.displayShiny) + { + statsNumbers[0]++; + } + + button.UpdateButton(); + } + + + + + /// + /// Attempt to add a part into the index, check if the player obtained/saw it + /// + public void AttemptAddPart(EntityBlueprint.PartInfo part, List origins) + { + part = CullToPartIndexValues(part); + if (!parts.ContainsKey(part)) + { + var button = Instantiate(inventoryPrefab, contents[ResourceManager.GetAsset(part.partID).size]).GetComponent(); + parts.Add(part, button.gameObject); + button.part = part; + if (CheckPartObtained(part)) + { + SetPartAsObtained(part); + } + else if (CheckPartSeen(part)) + { + SetPartAsSeen(part); + } + else + { + button.status = PartStatus.Unseen; + button.displayShiny = false; + } + + button.infoBox = infoBox; + button.partDisplay = partDisplay; + // Update total number + statsNumbers[3]++; + foreach (var origin in origins) + { + parts[part].GetComponent().origins.Add(origin); + } + } + } + + public static bool partsObtainedCheat; + + public static bool CheckPartObtained(EntityBlueprint.PartInfo part) + { + if (partsObtainedCheat) + { + return true; + } + + part = CullToPartIndexValues(part); + return PlayerCore.Instance.cursave.partsObtained.Exists(x => CullToPartIndexValues(x).Equals(part)); + } + + public static bool CheckPartSeen(EntityBlueprint.PartInfo part) + { + part = CullToPartIndexValues(part); + return PlayerCore.Instance.cursave.partsSeen.Exists(x => CullToPartIndexValues(x).Equals(part)); + } + + void OnEnable() + { + instance = this; + ResetContent(); + UpdateContent(null, null); + + var partsSeen = new List(); + foreach (var part in PlayerCore.Instance.cursave.partsSeen) + { + if (!partsSeen.Contains(CullToPartIndexValues(part))) + { + partsSeen.Add(CullToPartIndexValues(part)); + } + } + PlayerCore.Instance.cursave.partsSeen = partsSeen; + + Entity.OnEntityDeath += UpdateContent; + } + + private void OnDisable() + { + Entity.OnEntityDeath -= UpdateContent; + ResetContent(); + } + + private void ResetContent() + { + statsNumbers = new int[] { 0, 0, 0, 0 }; + foreach (var content in contents) + { + for (int i = 0; i < content.childCount; i++) + { + Destroy(content.GetChild(i).gameObject); + } + } + + parts.Clear(); + } + + + + public void UpdateContent(Entity _, Entity __) + { + if (index == null) + { + Debug.LogWarning("The Part Index cache has not been set up for this world. Please rewrite this world, it will rebuild automatically."); + return; + } + + // player metadata + if (PlayerCore.Instance.cursave.partsObtained == null || PlayerCore.Instance.cursave.partsObtained.Count == 0) + { + PlayerCore.Instance.cursave.partsObtained = new List(); + foreach (var part in PlayerCore.Instance.GetInventory()) + { + AttemptAddToPartsObtained(part); + } + + foreach (var part in PlayerCore.Instance.blueprint.parts) + { + AttemptAddToPartsObtained(part); + } + } + + if (PlayerCore.Instance.cursave.partsSeen == null || PlayerCore.Instance.cursave.partsSeen.Count == 0) + { + PlayerCore.Instance.cursave.partsSeen = new List(); + var partsSeen = PlayerCore.Instance.cursave.partsSeen; + foreach (var part in PlayerCore.Instance.cursave.partsObtained) + { + AttemptAddToPartsSeen(CullToPartIndexValues(part)); + } + } + + if (attemptAddPartCoroutine != null) + { + StopCoroutine(attemptAddPartCoroutine); + attemptAddPartCoroutine = null; + } + GetComponentInParent().sortingOrder = ++PlayerViewScript.currentLayer; // move window to top + attemptAddPartCoroutine = AttemptAddPartHelper(); + StartCoroutine(attemptAddPartCoroutine); + } + + private IEnumerator attemptAddPartCoroutine; + + private IEnumerator AttemptAddPartHelper() + { + int x = 0; + // index assembly + foreach (var partData in index) + { + AttemptAddPart(partData.part, partData.origins); + x++; + if (x >= 10) + { + x = 0; + UpdateTextAndTally(); + yield return new WaitForEndOfFrame(); + } + } + + UpdateTextAndTally(); + yield return null; + } + + private void UpdateTextAndTally() + { + for (int i = 0; i < contents.Length; i++) + { + texts[i].SetActive(contents[i].childCount > 0); + } + + UpdateTallyGraphic(); + } + + private void UpdateTallyGraphic() + { + // Update tally graphic bar + if (statsNumbers[3] > 0) + { + for (int i = 0; i < statsBar.Length; i++) + { + statsBar[i].rectTransform.sizeDelta = new Vector2(statsNumbers[i] * 800 / statsNumbers[3], 20); + } + } + else + { + // no parts in world, just hide the bars + for (int i = 0; i < statsBar.Length; i++) + { + statsBar[i].gameObject.SetActive(false); + } + } + + // Just found out about string interpolation. Damn that stuff rocks. + statsTotalTally.text = $"{statsNumbers[3]}"; + } + + public static void AttemptAddToPartsObtained(EntityBlueprint.PartInfo part) + { + var partsObtained = PlayerCore.Instance.cursave.partsObtained; + if (!partsObtained.Exists(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))) + { + partsObtained.Add(CullToPartIndexValues(part)); + if (instance) instance.SetPartAsObtained(CullToPartIndexValues(part)); + } + + if (part.shiny && partsObtained.Exists(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))) + { + partsObtained[partsObtained.FindIndex(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))] = part; + if (instance) instance.SetPartAsObtained(CullToPartIndexValues(part)); + } + } + + public static void AttemptAddToPartsSeen(EntityBlueprint.PartInfo part) + { + var partsSeen = PlayerCore.Instance.cursave.partsSeen; + if (!partsSeen.Exists(x => CullToPartIndexValues(x).Equals(CullToPartIndexValues(part)))) + { + partsSeen.Add(CullToPartIndexValues(part)); + if (instance) instance.SetPartAsSeen(CullToPartIndexValues(part)); + } + } + + /// + /// Culls unnecessary data in the passed PartInfo for adding into the Part Index. + /// Notably, it nullifies secondary data if the part does not spawn drones. + /// + public static EntityBlueprint.PartInfo CullToPartIndexValues(EntityBlueprint.PartInfo partToCull) + { + var part = new EntityBlueprint.PartInfo(); + part.partID = partToCull.partID; + part.abilityID = partToCull.abilityID; + if (!ShipBuilder.CheckSecondaryDataPurge(partToCull)) + { + part.secondaryData = partToCull.secondaryData; + var data = DroneUtilities.GetDroneSpawnDataByShorthand(part.secondaryData); + part.secondaryData = DroneUtilities.GetDefaultSecondaryDataByType(data.type); + } + + part.tier = partToCull.tier; + part.shiny = false; + return part; + } +} diff --git a/Assets/Sprites/SFX Sprites/ShinyParticle.png b/Assets/Sprites/SFX Sprites/ShinyParticle.png new file mode 100644 index 000000000..84c6ea5a1 Binary files /dev/null and b/Assets/Sprites/SFX Sprites/ShinyParticle.png differ diff --git a/Assets/Sprites/SFX Sprites/ShinyParticle.png.meta b/Assets/Sprites/SFX Sprites/ShinyParticle.png.meta new file mode 100644 index 000000000..17c24c86b --- /dev/null +++ b/Assets/Sprites/SFX Sprites/ShinyParticle.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 1bf7079096e7ce64897a955662d3d65c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 1 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/World Creator Assets/Scripts/WCBasePropertyHandler.cs b/Assets/World Creator Assets/Scripts/WCBasePropertyHandler.cs index 92beee35c..3e5b2ad8b 100644 --- a/Assets/World Creator Assets/Scripts/WCBasePropertyHandler.cs +++ b/Assets/World Creator Assets/Scripts/WCBasePropertyHandler.cs @@ -420,7 +420,7 @@ void DeleteSelectedProperty(int index) } var factionPath = System.IO.Path.Combine( - System.IO.Path.Combine(Application.streamingAssetsPath, "FactionPlaceholder"), $"{manager.factions[index].factionName}.json"); + System.IO.Path.Combine(Application.streamingAssetsPath, "FactionPlaceholder"), $"{manager.factions[index].factionName}-{manager.factions[index].ID}.json"); if (File.Exists(factionPath)) { File.Delete(factionPath);