diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml index a25e58a96..2c6726abe 100644 --- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml +++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml @@ -9,18 +9,32 @@ + + + + + + + - + + + + + + + + @@ -672,6 +686,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -690,11 +980,17 @@ + + + + + + diff --git a/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml b/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml index 8d9241bcb..75ee64a49 100644 --- a/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml +++ b/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml @@ -14,6 +14,7 @@ .idea Economy.Server Economy.Shared + GameData Library Logs Server diff --git a/.idea/.idea.Economy/.idea/indexLayout.xml b/.idea/.idea.Economy/.idea/indexLayout.xml index 0710d7d7f..11cb44604 100644 --- a/.idea/.idea.Economy/.idea/indexLayout.xml +++ b/.idea/.idea.Economy/.idea/indexLayout.xml @@ -13,6 +13,7 @@ .git .idea + GameData Library Logs Server diff --git a/Assembly-CSharp-Editor.csproj b/Assembly-CSharp-Editor.csproj index a92bfae91..e381789a0 100644 --- a/Assembly-CSharp-Editor.csproj +++ b/Assembly-CSharp-Editor.csproj @@ -60,6 +60,7 @@ + diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 767279a42..863b67659 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -60,15 +60,18 @@ + + + - + @@ -555,30 +558,43 @@ + + + + + + + + + + + + + C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll diff --git a/Assets/Gravity.renderTexture b/Assets/Gravity.renderTexture new file mode 100644 index 000000000..aea473145 --- /dev/null +++ b/Assets/Gravity.renderTexture @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!84 &8400000 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Gravity + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_Width: 512 + m_Height: 512 + m_AntiAliasing: 1 + m_DepthFormat: 0 + m_ColorFormat: 14 + m_MipMap: 1 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 2 + m_WrapV: 2 + m_WrapW: 2 + m_Dimension: 2 + m_VolumeDepth: 1 diff --git a/Assets/Gravity.renderTexture.meta b/Assets/Gravity.renderTexture.meta new file mode 100644 index 000000000..f2d9c7219 --- /dev/null +++ b/Assets/Gravity.renderTexture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 52760f4ab4dd58647b2947db37572725 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 8400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials.meta b/Assets/Materials.meta new file mode 100644 index 000000000..3ac234462 --- /dev/null +++ b/Assets/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c50848eb7835204891c6f78524e3710 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/Gravity Well.mat b/Assets/Materials/Gravity Well.mat new file mode 100644 index 000000000..b0d8a3d3e --- /dev/null +++ b/Assets/Materials/Gravity Well.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Gravity Well + m_Shader: {fileID: 4800000, guid: 105a94389fb66cf4bb41ad040d8c5fdb, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + 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: 0} + 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_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Depth: 100 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _Power: 4 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/Gravity Well.mat.meta b/Assets/Materials/Gravity Well.mat.meta new file mode 100644 index 000000000..4dacfd423 --- /dev/null +++ b/Assets/Materials/Gravity Well.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44a8bbb89acb4e34c9f41a9da5842bb4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/Zone Background.mat b/Assets/Materials/Zone Background.mat new file mode 100644 index 000000000..7aaaa2cd4 --- /dev/null +++ b/Assets/Materials/Zone Background.mat @@ -0,0 +1,84 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Zone Background + m_Shader: {fileID: 4800000, guid: 0ec0ecdb30ff1614698ae885ebcd873d, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + 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: 0} + 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_Floats: + - _AngleFade: 8 + - _AngleWidth: 0.001 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _HeightRange: 100 + - _LineFade: 8 + - _LineWidth: 0.001 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StartHeight: 0 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _AngleColor: {r: 0.053221796, g: 0.49056602, b: 0.29599926, a: 1} + - _Color: {r: 0.062299743, g: 0.2874376, b: 0.5283019, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/Zone Background.mat.meta b/Assets/Materials/Zone Background.mat.meta new file mode 100644 index 000000000..fff065f2b --- /dev/null +++ b/Assets/Materials/Zone Background.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90cead50364300d47bb35194fb52c117 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources.meta b/Assets/Resources.meta new file mode 100644 index 000000000..a1a01fd7b --- /dev/null +++ b/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 766fda6a352c32f43bd8fa57c06042b0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Icons.asset b/Assets/Resources/Icons.asset new file mode 100644 index 000000000..362bf8ad8 --- /dev/null +++ b/Assets/Resources/Icons.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59c9fde0f1bea591982eb8627d909806368bbf83c994b0737575faf8b4515d85 +size 435 diff --git a/Assets/Resources/Icons.asset.meta b/Assets/Resources/Icons.asset.meta new file mode 100644 index 000000000..7c6fa0e74 --- /dev/null +++ b/Assets/Resources/Icons.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50ac72e1e2474804287a2d4f1693f9b8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sprites.meta b/Assets/Resources/Sprites.meta new file mode 100644 index 000000000..0d4dfe244 --- /dev/null +++ b/Assets/Resources/Sprites.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f54a1a9bd4868164c851d251e87b1d73 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sprites/add.png b/Assets/Resources/Sprites/add.png new file mode 100644 index 000000000..67d0858c0 --- /dev/null +++ b/Assets/Resources/Sprites/add.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24800085053fb848f01c019ba76a1efb494669dafff4bf0fb880d6bf5f273d95 +size 22624 diff --git a/Assets/Resources/Sprites/add.png.meta b/Assets/Resources/Sprites/add.png.meta new file mode 100644 index 000000000..ebbed7e21 --- /dev/null +++ b/Assets/Resources/Sprites/add.png.meta @@ -0,0 +1,110 @@ +fileFormatVersion: 2 +guid: 1d55ddcd5a3c2354faea7e99db862d21 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + 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 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + 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: 2 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: e0989b2b95dfc1f41a5c3b899d889c0b + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sprites/remove.png b/Assets/Resources/Sprites/remove.png new file mode 100644 index 000000000..0e460ecee --- /dev/null +++ b/Assets/Resources/Sprites/remove.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64d91be4e1f920fd705bdd75fe55506f6fb1071bd84a53241495e0a3eac15dde +size 22065 diff --git a/Assets/Resources/Sprites/remove.png.meta b/Assets/Resources/Sprites/remove.png.meta new file mode 100644 index 000000000..66d5f55ae --- /dev/null +++ b/Assets/Resources/Sprites/remove.png.meta @@ -0,0 +1,110 @@ +fileFormatVersion: 2 +guid: f1aad09b4bf42ba4aa13a9fa1d97f01c +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + 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 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + 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: 2 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: fb43f50872fe9b242b150185ffa5335e + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index e5ecd0a00..ecbfc9733 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -50,7 +50,6 @@ LightmapSettings: m_BounceScale: 1 m_IndirectOutputScale: 1 m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 m_EnvironmentLightingMode: 0 m_EnableBakedLightmaps: 0 m_EnableRealtimeLightmaps: 0 @@ -113,40 +112,64 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &519420028 +--- !u!1 &408552537 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - - component: {fileID: 519420032} - - component: {fileID: 519420031} - - component: {fileID: 519420029} + - component: {fileID: 408552541} + - component: {fileID: 408552540} + - component: {fileID: 408552539} + - component: {fileID: 408552538} m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera + m_Name: Gravity Camera + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!81 &519420029 +--- !u!114 &408552538 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408552537} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 04277e392af12204397c334ea824f957, type: 3} + m_Name: + m_EditorClassIdentifier: + BackgroundMaterial: {fileID: 2100000, guid: 90cead50364300d47bb35194fb52c117, type: 2} + GravityTexture: {fileID: 0} + GravityRenderer: {fileID: 1956833085} +--- !u!81 &408552539 AudioListener: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 519420028} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408552537} m_Enabled: 1 ---- !u!20 &519420031 +--- !u!20 &408552540 Camera: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 519420028} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408552537} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 2 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -161,7 +184,89 @@ Camera: m_Depth: -1 m_CullingMask: serializedVersion: 2 - m_Bits: 4294967295 + m_Bits: 256 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 0 + m_HDR: 1 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &408552541 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408552537} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &519420028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 519420032} + - component: {fileID: 519420031} + - component: {fileID: 519420029} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &519420029 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519420028} + m_Enabled: 1 +--- !u!20 &519420031 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519420028} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 512 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -176,8 +281,9 @@ Camera: --- !u!4 &519420032 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 519420028} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: -10} @@ -186,3 +292,187 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1496237818 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1496237822} + - component: {fileID: 1496237821} + - component: {fileID: 1496237820} + - component: {fileID: 1496237819} + m_Layer: 8 + m_Name: Gravity Well + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &1496237819 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1496237818} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Convex: 0 + m_CookingOptions: 14 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1496237820 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1496237818} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 44a8bbb89acb4e34c9f41a9da5842bb4, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1496237821 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1496237818} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1496237822 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1496237818} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.5, y: -0.01, z: 0} + m_LocalScale: {x: 10, y: 10, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1956833083 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1956833087} + - component: {fileID: 1956833086} + - component: {fileID: 1956833085} + - component: {fileID: 1956833084} + m_Layer: 9 + m_Name: Zone BG + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &1956833084 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1956833083} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Convex: 0 + m_CookingOptions: 14 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1956833085 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1956833083} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 90cead50364300d47bb35194fb52c117, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1956833086 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1956833083} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1956833087 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1956833083} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -5.19, y: 0.07, z: 0.00390625} + m_LocalScale: {x: 11.261, y: 6.018, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/Behaviors.cs b/Assets/Scripts/Behaviors.cs new file mode 100644 index 000000000..5a84cc983 --- /dev/null +++ b/Assets/Scripts/Behaviors.cs @@ -0,0 +1,494 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using MessagePack; +using UniRx; +using Unity.Mathematics; +using UnityEngine; +using UnityEngine.Audio; +using static Unity.Mathematics.math; +using static Unity.Mathematics.noise; +using Object = UnityEngine.Object; + +public interface IItemBehavior +{ + void Update(float delta); + void FixedUpdate(float delta); + Ship Ship { get; } + Gear Item { get; } + IItemBehaviorData Data { get; } +} + +public interface IActivatedItemBehavior : IItemBehavior +{ + void Activate(); + void Deactivate(); +} + +[Inspectable] +[Union(0, typeof(CannonBehaviorData))] +[Union(1, typeof(MissileBehaviorData))] +[Union(2, typeof(ReactorBehaviorData))] +// [Union(3, typeof(PlusUltraBehaviorData))] +[Union(4, typeof(AfterburnerBehaviorData))] +[Union(5, typeof(SensorBehaviorData))] +public interface IItemBehaviorData +{ + IItemBehavior CreateInstance(Ship ship, Gear item); + // PerformanceStat[] DynamicStats { get; } + //Type ItemType { get; } +} + +[Inspectable] +[MessagePackObject] +public class SensorBehaviorData : IItemBehaviorData +{ + [Inspectable] [Key("radiance")] public PerformanceStat Radiance; + [Inspectable] [Key("masking")] public PerformanceStat RadianceMasking; + [Inspectable] [Key("sensitivity")] public PerformanceStat Sensitivity; + [Inspectable] [Key("range")] public PerformanceStat Range; + + public IItemBehavior CreateInstance(Ship ship, Gear item) + { + return new SensorBehavior(this, ship, item); + } + + [IgnoreMember] public PerformanceStat[] DynamicStats => new[] {Radiance, Sensitivity}; +} + +public class SensorBehavior : IItemBehavior +{ + private SensorBehaviorData _data; + + public Ship Ship { get; } + public Gear Item { get; } + + public IItemBehaviorData Data => _data; + + public SensorBehavior(SensorBehaviorData data, Ship ship, Gear item) + { + _data = data; + Ship = ship; + Item = item; + } + + public void Update(float delta) + { + // var ship = Hardpoint.Ship.Ship.transform; + // var contacts = + // Physics.OverlapSphere(ship.position, _data.Range.Evaluate(Hardpoint)).Where(c=>c.attachedRigidbody?.GetComponent()!=null).Select(c=>c.attachedRigidbody.GetComponent()); + // foreach (var contact in contacts) + // { + // var diff = (contact.transform.position - ship.position).Flatland(); + // var angle = acos(dot(ship.forward.Flatland().normalized, + // diff.normalized)) / (float)PI; + // var sens = _data.Sensitivity.Evaluate(Hardpoint) * + // Hardpoint.Ship.HullData.VisibilityCurve.Evaluate(saturate(angle)); + // var vis = contact.Visibility / diff.sqrMagnitude; + // if(vis > 1/sens) + // Hardpoint.Ship.Contacts[contact] = Time.time; + // } + // + // Hardpoint.Ship.VisibilitySources[this] = _data.Radiance.Evaluate(Hardpoint) / _data.RadianceMasking.Evaluate(Hardpoint); + // TODO: Handle Active Detection / Visibility From Reflected Radiance + } + + public void FixedUpdate(float delta) + { + } +} + +[Inspectable] +[MessagePackObject] +public class AfterburnerBehaviorData : IItemBehaviorData +{ + [Inspectable] [Key("thrust")] public PerformanceStat ThrustModifier; + [Inspectable] [Key("speed")] public PerformanceStat SpeedModifier; + [Inspectable] [Key("torque")] public PerformanceStat TorqueModifier; + public IItemBehavior CreateInstance(Ship ship, Gear item) + { + return new AfterburnerBehavior(this, ship, item); + } +} + +public class AfterburnerBehavior : IActivatedItemBehavior +{ + private List> _modifiers = new List>(); + private AfterburnerBehaviorData _data; + + public Ship Ship { get; } + public Gear Item { get; } + + public IItemBehaviorData Data => _data; + + public AfterburnerBehavior(AfterburnerBehaviorData data, Ship ship, Gear item) + { + _data = data; + Ship = ship; + Item = item; + } + + public void Update(float delta) + { + } + + public void FixedUpdate(float delta) + { + } + + public void Activate() + { + var thrustMod = (Ship.GetEquipped(HardpointType.Thruster).EquippedItemData as Thruster).Thrust.GetScaleModifiers(Ship); + _modifiers.Add(thrustMod); + thrustMod.Add(this,_data.ThrustModifier.Evaluate(Item, Ship)); + + var speedMod = (Ship.Hull.EquippedItemData as Hull).TopSpeed.GetScaleModifiers(Ship); + _modifiers.Add(speedMod); + speedMod.Add(this,_data.SpeedModifier.Evaluate(Item, Ship)); + + var torqueMod = (Ship.GetEquipped(HardpointType.Thruster).EquippedItemData as Thruster).Torque.GetScaleModifiers(Ship); + _modifiers.Add(torqueMod); + torqueMod.Add(this,_data.TorqueModifier.Evaluate(Item, Ship)); + + Ship.ForceThrust = true; + } + + public void Deactivate() + { + Ship.ForceThrust = false; + foreach (var mod in _modifiers) + { + mod.Remove(this); + } + _modifiers.Clear(); + } +} + +[Inspectable] +[MessagePackObject] +public class CannonBehaviorData : IItemBehaviorData +{ + [MessagePackFormatter(typeof(UnityGameObjectFormatter))] + [Inspectable] [Key("bullet")] public GameObject BulletPrefab; + // [MessagePackFormatter(typeof(ClipListFormatter))] + // [Inspectable] [Key("sounds")] public List Sounds; + [Inspectable] [Key("damageType")] public ProjectileType DamageType; + [Inspectable] [Key("burstCount")] public int BurstCount; + [Inspectable] [Key("burstTime")] public PerformanceStat BurstTime; + [Inspectable] [Key("bulletRange")] public PerformanceStat Range; + [Inspectable] [Key("spread")] public PerformanceStat Spread; + [Inspectable] [Key("bulletInherit")] public float Inherit; + [Inspectable] [Key("deflection")] public float Deflection; + [Inspectable] [Key("visibility")] public PerformanceStat Visibility; + [Inspectable] [Key("visibilityDecay")]public PerformanceStat VisibilityDecay; + [Inspectable] [Key("bulletVelocity")] public PerformanceStat Velocity; + [Inspectable] [Key("cooldown")] public PerformanceStat Cooldown; + [Inspectable] [Key("damage")] public PerformanceStat Damage; + [Inspectable] [Key("heat")] public PerformanceStat Heat; + + public IItemBehavior CreateInstance(Ship ship, Gear item) + { + return new CannonBehavior(this, ship, item); + } + + [IgnoreMember] public PerformanceStat[] DynamicStats => new[] {BurstTime, Range, Spread, Velocity, Cooldown, Damage}; +} + +public class CannonBehavior : IActivatedItemBehavior +{ + private bool _firing; + private float _cooldown; // normalized + private CannonBehaviorData _cannon; + public Ship Ship { get; } + public Gear Item { get; } + private float _firingVisibility; + + public CannonBehavior(CannonBehaviorData c, Ship ship, Gear item) + { + _cannon = c; + Ship = ship; + Item = item; + } + + public void Activate() + { +// Debug.Log("Activating Cannon"); +// _firing = true; +// Observable.EveryUpdate().TakeWhile(_ => _firing).Subscribe(_ => +// { +// // Debug.Log($"Updating Observable {_cooldown}"); +// if (_cooldown < 0) +// { +// _cooldown = 1; +// Fire(0); +// if(_cannon.BurstCount>1) +// Observable.Interval(TimeSpan.FromSeconds(_cannon.BurstTime.Evaluate(Hardpoint) / (_cannon.BurstCount-1))).Take(_cannon.BurstCount-1) +// .Subscribe(l => Fire(l+1)); +// } +// }); + } + + private void Fire(long b) + { + // _firingVisibility += _cannon.Visibility.Evaluate(Hardpoint); + // Hardpoint.Temperature += _cannon.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity; + // var inst = GameObject.Instantiate(_cannon.BulletPrefab).transform; + // Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent(), inst.GetComponent()); + // var bullet = inst.GetComponent(); + // bullet.Target = Hardpoint.Ship.Ship.Target; + // bullet.Source = Hardpoint.Ship.Ship.Hitpoints; + // bullet.Lifetime = _cannon.Range.Evaluate(Hardpoint) / _cannon.Velocity.Evaluate(Hardpoint); + // bullet.Damage = _cannon.Damage.Evaluate(Hardpoint); + // inst.position = Hardpoint.Proxy.position; + // inst.rotation = Hardpoint.Proxy.rotation; + // inst.GetComponent().velocity = _cannon.Velocity.Evaluate(Hardpoint) * Vector3.RotateTowards(-inst.forward, Hardpoint.Ship.Ship.Direction, _cannon.Deflection * Mathf.Deg2Rad, 1); + // Hardpoint.Ship.Ship.AudioSource.PlayOneShot(_cannon.Sounds.RandomElement()); +// Debug.Log($"Firing bullet {b}"); + } + + public void Deactivate() + { + _firing = false; + } + + public void Update(float delta) + { + _cooldown -= delta / _cannon.Cooldown.Evaluate(Item, Ship); + + if (_firingVisibility < 0.01f) + { + Ship.VisibilitySources.Remove(this); + } + } + + public void FixedUpdate(float delta) + { + _firingVisibility *= _cannon.VisibilityDecay.Evaluate(Item, Ship); + } + + public IItemBehaviorData Data => _cannon; +} + +[Inspectable] +[MessagePackObject] +public class MissileBehaviorData : IItemBehaviorData +{ + // [MessagePackFormatter(typeof(UnityGameObjectFormatter))] + // [Inspectable] [Key("missile")] public GameObject MissilePrefab; + // [MessagePackFormatter(typeof(ClipListFormatter))] + // [Inspectable] [Key("sounds")] public List Sounds; + // [MessagePackFormatter(typeof(UnityAudioClipFormatter))] + // [Inspectable] [Key("beepSound")] public AudioClip BeepSound; + // [Inspectable] [Key("beepCount")] public int Beeps; + [Inspectable] [Key("damageType")] public ProjectileType DamageType; + [Inspectable] [Key("burstCount")] public int BurstCount; + [Inspectable] [Key("burstTime")] public PerformanceStat BurstTime; + [Inspectable] [Key("range")] public PerformanceStat Range; + [Inspectable] [Key("guidance")] public AnimationCurve GuidanceCurve; + [Inspectable] [Key("thrustCurve")] public AnimationCurve ThrustCurve; + [Inspectable] [Key("liftCurve")] public AnimationCurve LiftCurve; + [Inspectable] [Key("thrust")] public PerformanceStat Thrust; + [Inspectable] [Key("deflection")] public float Deflection; + [Inspectable] [Key("lockOnBuffer")] public float LockOnDegrees; + [Inspectable] [Key("frequency")] public float DodgeFrequency; + [Inspectable] [Key("visibility")] public PerformanceStat Visibility; + [Inspectable] [Key("launchSpeed")] public PerformanceStat LaunchSpeed; + [Inspectable] [Key("missileSpeed")] public PerformanceStat MissileSpeed; + [Inspectable] [Key("cooldown")] public PerformanceStat Cooldown; + [Inspectable] [Key("lockOnTime")] public PerformanceStat LockOnTime; + [Inspectable] [Key("damage")] public PerformanceStat Damage; + [Inspectable] [Key("heat")] public PerformanceStat Heat; + + + public IItemBehavior CreateInstance(Ship ship, Gear item) + { + return new MissileBehavior(this, ship, item); + } + + [IgnoreMember] public PerformanceStat[] DynamicStats => new[] {BurstTime, Range, Thrust, LaunchSpeed, MissileSpeed, Cooldown, Damage}; +} + +public class MissileBehavior : IActivatedItemBehavior +{ + private bool _locking; + private float _lockingTimer; + private float _cooldown; // normalized + private bool _locked; + + private MissileBehaviorData _missile; + public Ship Ship { get; } + public Gear Item { get; } + private float _firingVisibility; + private AudioSource _audio; + + public MissileBehavior(MissileBehaviorData m, Ship ship, Gear item) + { + _missile = m; + Ship = ship; + Item = item; + // _audio = hp.Proxy.GetComponent(); + // if(_audio==null) + // _audio = hp.Proxy.gameObject.AddComponent(); + // _audio.clip = _missile.BeepSound; + // _audio.loop = true; + // _audio.volume = .5f; + } + + public void Activate() + { + _locking = true; + _lockingTimer = 1; + } + + private void Fire(long b) + { + + // _firingVisibility += _missile.Visibility.Evaluate(Hardpoint); + // Hardpoint.Temperature += _missile.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity; + // var inst = GameObject.Instantiate(_missile.MissilePrefab).transform; + // var missile = inst.GetComponent(); + // missile.Target = Hardpoint.Ship.Ship.Target; + // missile.Source = Hardpoint.Ship.Ship.Hitpoints; + // missile.Lifetime = _missile.Range.Evaluate(Hardpoint) / _missile.MissileSpeed.Evaluate(Hardpoint); + // missile.Damage = _missile.Damage.Evaluate(Hardpoint); + // inst.position = Hardpoint.Proxy.position; + // inst.rotation = Hardpoint.Proxy.rotation; + // inst.GetComponent().velocity = _missile.LaunchSpeed.Evaluate(Hardpoint) * Hardpoint.Proxy.forward; + // Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent(), inst.GetComponent()); + // var proj = inst.gameObject.AddComponent(); + // proj.GuidanceCurve = _missile.GuidanceCurve; + // proj.ThrustCurve = _missile.ThrustCurve; + // proj.LiftCurve = _missile.LiftCurve; + // proj.TopSpeed = _missile.MissileSpeed.Evaluate(Hardpoint); + // proj.Frequency = _missile.DodgeFrequency; + // proj.Target = Hardpoint.Ship.Ship.Target; + // proj.Source = Hardpoint.Ship.Ship.Hitpoints; + // proj.Thrust = _missile.Thrust.Evaluate(Hardpoint); + // _audio.PlayOneShot(_missile.Sounds.RandomElement()); +// Debug.Log($"Firing bullet {b}"); + } + + public void Deactivate() + { + // if (_lockingTimer < 0) + // { + // Fire(0); + // if(_missile.BurstCount>1) + // Observable.Interval(TimeSpan.FromSeconds(_missile.BurstTime.Evaluate(Hardpoint) / (_missile.BurstCount-1))).Take(_missile.BurstCount-1) + // .Subscribe(l => Fire(l+1)); + // _lockingTimer = _cooldown = 1; + // _locking = _locked = false; + // _audio.Stop(); + // } + // _locking = false; + // _lockingTimer = 1; + } + + public void Update(float delta) + { + // if (Ship.Target == null) + // return; + // + // if (_locking && _cooldown < 0) + // { + // //if the crosshair stays under a certain LockOnBuffer distance for a certain amount of time (LockOnTime) + // if (acos(Vector2.Dot(Ship.Direction, (Ship.Target.transform.position-Ship.transform.position).normalized)) * Mathf.Rad2Deg < _missile.LockOnDegrees) + // { + // var d = delta / _missile.LockOnTime.Evaluate(Hardpoint); + // _lockingTimer -= d; + // if (!_locked && _lockingTimer < 0) + // { + // _locked = true; + // _audio.Play(); + // } else if(Mathf.Repeat(_lockingTimer,1.0f/(_missile.Beeps+1))-d<0) + // GameManager.Instance.InterfaceAudio.PlayOneShot(_missile.BeepSound); + // } + // else + // { + // _lockingTimer = 1; + // _audio.Stop(); + // } + // } + // else + // { + // _cooldown -= delta / _missile.Cooldown.Evaluate(Hardpoint); + // } + // + // + // if (_firingVisibility > 0.01f) + // { + // Hardpoint.Ship.Visibility += _firingVisibility; + // _firingVisibility = 0; + // } + + + } + + public void FixedUpdate(float delta) + { + } + + public IItemBehaviorData Data => _missile; +} + +[MessagePackObject] +public class ReactorBehaviorData : IItemBehaviorData +{ + [Inspectable] [Key("charge")] public PerformanceStat Charge; + [Inspectable] [Key("capacitance")] public PerformanceStat Capacitance; + [Inspectable] [Key("efficiency")] public PerformanceStat Efficiency; + [Inspectable] [Key("overload")] public PerformanceStat OverloadEfficiency; + [Inspectable] [Key("underload")] public PerformanceStat UnderloadRecovery; + + public IItemBehavior CreateInstance(Ship ship, Gear item) + { + return new ReactorBehavior(this, ship, item); + } + + [IgnoreMember] public PerformanceStat[] DynamicStats => new[] {Charge, Efficiency}; +} + +public class ReactorBehavior : IItemBehavior +{ + private ReactorBehaviorData _data; + + public Ship Ship { get; } + public Gear Item { get; } + + public IItemBehaviorData Data => _data; + + public ReactorBehavior(ReactorBehaviorData data, Ship ship, Gear item) + { + _data = data; + Ship = ship; + Item = item; + } + + public void FixedUpdate(float delta) + { + var cap = _data.Capacitance.Evaluate(Item, Ship); + var charge = _data.Charge.Evaluate(Item, Ship) * delta; + var efficiency = _data.Efficiency.Evaluate(Item, Ship); + + Ship.AddHeat(charge / efficiency); + Ship.Charge += charge; + + if (Ship.Charge > cap) + { + Ship.AddHeat(-(Ship.Charge - cap) / efficiency * (1 - 1 / _data.UnderloadRecovery.Evaluate(Item, Ship))); + Ship.Charge = cap; + } + + if (Ship.Charge < 0) + { + Ship.AddHeat( -Ship.Charge / (_data.OverloadEfficiency.Evaluate(Item, Ship))); + Ship.Charge = 0; + } + + } + + public void Update(float delta) + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/NIH/FastNoise.cs.meta b/Assets/Scripts/Behaviors.cs.meta similarity index 83% rename from Assets/Scripts/NIH/FastNoise.cs.meta rename to Assets/Scripts/Behaviors.cs.meta index 305c2f947..94270ffb4 100644 --- a/Assets/Scripts/NIH/FastNoise.cs.meta +++ b/Assets/Scripts/Behaviors.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 53b469b8da6bd4e4bb62cb13d1ce301d +guid: c15c37d98e3dc844aafd0dedc16ce0ae MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Database.cs b/Assets/Scripts/Database.cs index f24e8c09f..228a761e1 100644 --- a/Assets/Scripts/Database.cs +++ b/Assets/Scripts/Database.cs @@ -128,18 +128,4 @@ public class Database }, null); watcher.EnableRaisingEvents = true; } -} - -public interface IDatabaseEntry -{ - DatabaseEntry Entry { get; } -} - -[Inspectable] -[MessagePackObject] -public class DatabaseEntry -{ - [Key("id")] public Guid ID = Guid.NewGuid(); - [Inspectable] [Key("name")] public string Name; - [Inspectable] [Key("description")] public string Description; } \ No newline at end of file diff --git a/Assets/Scripts/DatabaseItems.cs b/Assets/Scripts/DatabaseItems.cs new file mode 100644 index 000000000..50105847b --- /dev/null +++ b/Assets/Scripts/DatabaseItems.cs @@ -0,0 +1,596 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MessagePack; +using UnityEngine; +using Unity.Mathematics; +using UnityEngine.UI.Extensions; +// TODO: USE THIS EVERYWHERE +using static Unity.Mathematics.math; +#if UNITY_EDITOR +using UnityEditor; +#endif + +public class NameAttribute : Attribute +{ + public string Name; + + public NameAttribute(string name) + { + Name = name; + } +} + +public class UpdateOrderAttribute : Attribute +{ + public int Order; + + public UpdateOrderAttribute(int order) + { + Order = order; + } +} + +public class GlobalData : IDatabaseEntry +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + + [Inspectable] [Key("targetPersistenceDuration")] + public float TargetPersistenceDuration; + [Inspectable] [Key("heatRadiationPower")] + public float HeatRadiationPower; + [Inspectable] [Key("heatRadiationMultiplier")] + public float HeatRadiationMultiplier; + + [IgnoreMember] public static GlobalData Instance => Database.GetAll().FirstOrDefault(); + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + +[Union(5, typeof(Hull))] +[Union(6, typeof(Shield))] +[Union(9, typeof(Thruster))] +[Union(12, typeof(EquippableItem))] +public interface IEquippable : ICraftable +{ + HardpointType HardpointType { get; } + EquippableData Equippable { get; } +} + +[Union(5, typeof(Hull))] +[Union(6, typeof(Shield))] +[Union(9, typeof(Thruster))] +[Union(12, typeof(CraftedItem))] +[Union(13, typeof(EquippableItem))] +public interface ICraftable : IItem +{ + Dictionary CraftingIngredients { get; } +} + +[Union(5, typeof(Hull))] +[Union(6, typeof(Shield))] +[Union(9, typeof(Thruster))] +[Union(12, typeof(ItemData))] +[Union(13, typeof(CraftedItem))] +[Union(14, typeof(EquippableItem))] +public interface IItem : IDatabaseEntry +{ + ItemData Data { get; } +} + +[Union(5, typeof(Hull))] +[Union(6, typeof(Shield))] +[Union(9, typeof(Thruster))] +[Union(12, typeof(ItemData))] +[Union(13, typeof(CraftedItem))] +[Union(14, typeof(LoadoutDefinition))] +[Union(15, typeof(ZoneData))] +[Union(16, typeof(SimpleCommodity))] +[Union(17, typeof(CompoundCommodity))] +[Union(18, typeof(Gear))] +[Union(19, typeof(EquippableItem))] +//[Union(21, typeof(ContractData))] +//[Union(22, typeof(Station))] +[Union(23, typeof(Corporation))] +[Union(24, typeof(Player))] +[Union(25, typeof(GlobalData))] +public interface IDatabaseEntry +{ + DatabaseEntry Entry { get; } +} + +[Union(0, typeof(SimpleCommodity))] +[Union(1, typeof(CompoundCommodity))] +[Union(2, typeof(Gear))] +public interface IItemInstance : IDatabaseEntry +{ + Guid ItemGuid { get; } + IItem ItemData { get; } + float Mass { get; } +} + +[Union(0, typeof(Gear))] +[Union(1, typeof(CompoundCommodity))] +public interface ICraftedItemInstance : IItemInstance +{ + float CraftedQuality { get; } + IEnumerable CraftedIngredients { get; } +} + +[Inspectable] +[MessagePackObject] +public class DatabaseEntry +{ + [Key("id")] public Guid ID = Guid.NewGuid(); + [Inspectable] [Key("name")] public string Name; + [Inspectable] [Key("description")] public string Description; +} + +[Inspectable] +[MessagePackObject] +[Name("Simple Commodity")] +public class ItemData : IItem +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + [Inspectable] [Key("mass")] public float Mass; + [Inspectable] [Key("size")] public float Size; + + [RangedIntInspectable(0, 20)] [Key("level")] public int TechLevel; + + [IgnoreMember] public ItemData Data => this; + + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + +[MessagePackObject] +public class EquippableItem : IEquippable +{ + [Inspectable] [Key("hardpointType")] public HardpointType Hardpoint; + [Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData(); + [Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); + [Inspectable] [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); + + [IgnoreMember] public HardpointType HardpointType => Hardpoint; + [IgnoreMember] public EquippableData Equippable => EquippableData; + [IgnoreMember] public ItemData Data => ItemData; + [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; + [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; + +} + +[Inspectable] +[MessagePackObject] +public class EquippableData +{ + [Inspectable] [Key("draw")] public PerformanceStat EnergyDraw; + // [Inspectable] [Key("conductivity")] public float ThermalConductivity; + // [Inspectable] [Key("specificHeat")] public float SpecificHeat; + [Inspectable] [Key("performance")] public AnimationCurve HeatPerformanceCurve; + [TemperatureInspectable] [Key("minTemp")] public float MinimumTemperature; + [TemperatureInspectable] [Key("maxTemp")] public float MaximumTemperature; + [Inspectable] [Key("ruggedness")] public float Ruggedness; + [Inspectable] [Key("durability")] public float Durability; + [Inspectable] [Key("durabilityExponent")] public PerformanceStat DurabilityExponent; + [Inspectable] [Key("heatExponent")] public PerformanceStat HeatExponent; + [Inspectable] [Key("behaviors")] public List Behaviors = new List(); + + [IgnoreMember] private const int STEPS = 64; + + [IgnoreMember] private float? _optimum; + [IgnoreMember] + public float OptimalTemperature + { + get + { + if (_optimum==null) + { + var samples = Enumerable.Range(0, STEPS).Select(i => (float) i / STEPS).ToArray(); + float max = 0; + _optimum = 0; + foreach (var f in samples) + { + var p = HeatPerformanceCurve?.Evaluate(f)??0; + if (p > max) + { + max = p; + _optimum = f; + } + } + } + + return (float) (MinimumTemperature + _optimum * (MaximumTemperature - MinimumTemperature)); + } + } +} + +[MessagePackObject] +[Name("Compound Commodity")] +public class CraftedItem : ICraftable +{ + [Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData(); + [Inspectable] [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); + + [IgnoreMember] public ItemData Data => ItemData; + [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; + [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +} + +[MessagePackObject] +public class Hull : IEquippable +{ + [Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData(); + [Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); + [Inspectable] [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); + [Inspectable] [Key("hullCapacity")] public PerformanceStat Capacity; + [Inspectable] [Key("traction")] public PerformanceStat Traction; + [Inspectable] [Key("topSpeed")] public PerformanceStat TopSpeed; + [Inspectable] [Key("emissivity")] public PerformanceStat Emissivity; + [Inspectable] [Key("crossSection")] public PerformanceStat CrossSection; + [Key("schemaSprite")] [MessagePackFormatter(typeof(UnitySpriteFormatter))] + public Sprite Schematic; + [Inspectable] [Key("hardpoints")] public List Hardpoints = new List(); + [Inspectable] [Key("visibility")] public AnimationCurve VisibilityCurve; + [MessagePackFormatter(typeof(UnityGameObjectFormatter))] + [Inspectable] [Key("prefab")] public GameObject Prefab; + + [IgnoreMember] public HardpointType HardpointType => HardpointType.Hull; + [IgnoreMember] public EquippableData Equippable => EquippableData; + [IgnoreMember] public ItemData Data => ItemData; + [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; + [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +} + +//[MessagePackObject] +//public class Sensor : IEquippable +//{ +// [Key("itemData")] public ItemData ItemData = new ItemData(); +// [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); +// [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); +// [Key("radiance")] public PerformanceStat Radiance; +// [Key("masking")] public PerformanceStat RadianceMasking; +// [Key("sensitivity")] public PerformanceStat Sensitivity; +// +// [IgnoreMember] public HardpointType HardpointType => HardpointType.Sensors; +// [IgnoreMember] public EquippableData Equippable => EquippableData; +// [IgnoreMember] public ItemData Data => ItemData; +// [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; +// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +//} +// +[MessagePackObject] +public class Shield : IEquippable +{ + [Inspectable] [Key("itemData")] + public ItemData ItemData = new ItemData(); + + [Inspectable] [Key("equippableData")] + public EquippableData EquippableData = new EquippableData(); + + [Inspectable] [Key("ingredients")] + public Dictionary Ingredients = new Dictionary(); + + [Inspectable] [Key("efficiency")] + public PerformanceStat Efficiency; + + [Inspectable] [Key("shielding")] + public PerformanceStat Shielding; + + [IgnoreMember] public HardpointType HardpointType => HardpointType.Shield; + [IgnoreMember] public EquippableData Equippable => EquippableData; + [IgnoreMember] public ItemData Data => ItemData; + [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; + [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +} + +[MessagePackObject] +public class Thruster : IEquippable +{ + [Inspectable] [Key("itemData")] public ItemData ItemData = new ItemData(); + [Inspectable] [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); + [Inspectable] [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); + [Inspectable] [Key("thrust")] public PerformanceStat Thrust; + [Inspectable] [Key("torque")] public PerformanceStat Torque; + [Inspectable] [Key("visibility")] public PerformanceStat Visibility; + [Inspectable] [Key("thrusterHeat")] public PerformanceStat Heat; +// [Inspectable] [Key("minSound")] public GranularEmitterStats MinSound; +// [Inspectable] [Key("maxSound")] public GranularEmitterStats MaxSound; +// [Inspectable] [Key("time")] public float SoundTransitionTime; +// [Inspectable] [Key("perlin")] public bool OscillatorPerlin; + // [MessagePackFormatter(typeof(UnityAudioClipFormatter))] + // [Inspectable] [Key("clip")] public AudioClip Clip; + + [IgnoreMember] public HardpointType HardpointType => HardpointType.Thruster; + [IgnoreMember] public EquippableData Equippable => EquippableData; + [IgnoreMember] public ItemData Data => ItemData; + [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; + [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +} + +//[MessagePackObject] +//public class Launcher : IEquippable +//{ +// [Key("itemData")] public ItemData ItemData = new ItemData(); +// [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); +//// [Key("weaponData")] public WeaponData WeaponData = new WeaponData(); +// [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); +// [MessagePackFormatter(typeof(UnityGameObjectFormatter))] +// [Key("projectile")] public GameObject ProjectilePrefab; +// [Key("launcherCaliber")] public LauncherCaliber Caliber; +// [Key("salvoDuration")] public PerformanceStat SalvoDuration; +// [Key("salvoSize")] public int SalvoSize; +// +// [IgnoreMember] public HardpointType HardpointType => HardpointType.Launcher; +// [IgnoreMember] public EquippableData Equippable => EquippableData; +// [IgnoreMember] public ItemData Data => ItemData; +// [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; +//// [IgnoreMember] public WeaponData Weapon => WeaponData; +// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +//} + +//[MessagePackObject] +//public class Beam : IEquippable +//{ +// [Key("itemData")] public ItemData ItemData = new ItemData(); +// [Key("equippableData")] public EquippableData EquippableData = new EquippableData(); +//// [Key("weaponData")] public WeaponData WeaponData = new WeaponData(); +// [Key("ingredients")] public Dictionary Ingredients = new Dictionary(); +// [Key("duration")] public PerformanceStat Duration; +// [Key("diameter")] public PerformanceStat Diameter; +// [Key("amplitude")] public AnimationCurve Amplitude; +// [MessagePackFormatter(typeof(UnityMaterialFormatter))] +// [Key("material")] public Material BeamMaterial; +// [Key("damageType")] public ProjectileType DamageType; +// +// [IgnoreMember] public HardpointType HardpointType => DamageType==ProjectileType.Physical?HardpointType.Ballistic:HardpointType.Energy; +// [IgnoreMember] public EquippableData Equippable => EquippableData; +// [IgnoreMember] public ItemData Data => ItemData; +// [IgnoreMember] public Dictionary CraftingIngredients => Ingredients; +//// [IgnoreMember] public WeaponData Weapon => WeaponData; +// [IgnoreMember] public DatabaseEntry Entry => ItemData.Entry; +//} + +[MessagePackObject] +public struct PerformanceStat +{ + [Key("min")] + public float Min; + [Key("max")] + public float Max; + [Key("durabilityDependent")] + public bool DurabilityDependent; + [Key("heatDependent")] + public bool HeatDependent; + [Key("qualityExponent")] + public float QualityExponent; + [Key("ingredient")] + public Guid Ingredient; + + [IgnoreMember] private Dictionary> _scaleModifiers; + [IgnoreMember] private Dictionary> _constantModifiers; + + [IgnoreMember] + private Dictionary> ScaleModifiers + { + get { return _scaleModifiers ?? (_scaleModifiers = new Dictionary>()); } + } + + [IgnoreMember] + private Dictionary> ConstantModifiers + { + get { return _constantModifiers ?? (_constantModifiers = new Dictionary>()); } + } + + public Dictionary GetScaleModifiers(Ship ship) + { + if(!ScaleModifiers.ContainsKey(ship)) + ScaleModifiers[ship] = new Dictionary(); + + return ScaleModifiers[ship]; + } + + public Dictionary GetConstantModifiers(Ship ship) + { + if(!ConstantModifiers.ContainsKey(ship)) + ConstantModifiers[ship] = new Dictionary(); + + return ConstantModifiers[ship]; + } + + // Determine quality of either the item itself or the specific ingredient this stat depends on + public float Quality(Gear item) + { + Guid ingredientID = Ingredient; + float quality; + if (ingredientID == Guid.Empty) + quality = item.CompoundQuality(); + else + { + var ingredientInstance = + item.CraftedIngredients.FirstOrDefault(i => i.ItemGuid == ingredientID) as ICraftedItemInstance; + if (ingredientInstance == null) + throw new InvalidOperationException( + $"Item {item.Entry.Name} has invalid crafting ingredient set for performance stat."); + quality = ingredientInstance.CompoundQuality(); + } + + return quality; + } + + // Returns stat when not equipped + public float Evaluate(Gear item) + { + var quality = pow(Quality(item), QualityExponent); + + var result = lerp(Min, Max, quality); + + if (float.IsNaN(result)) + return Min; + + return result; + } + + // Returns stat using ship temperature and modifiers + public float Evaluate(Gear item, Ship ship) + { + var itemData = item.EquippedItemData; + + var heat = !HeatDependent ? 1 : pow(itemData.Performance(ship.Temperature), itemData.Equippable.HeatExponent.Evaluate(item)); + var durability = !DurabilityDependent ? 1 : pow(item.Durability / itemData.Equippable.Durability, itemData.Equippable.DurabilityExponent.Evaluate(item)); + var quality = pow(Quality(item), QualityExponent); + + var scaleModifier = 1.0f; + if (_scaleModifiers != null && _scaleModifiers.ContainsKey(ship)) + { + foreach (var mod in _scaleModifiers[ship].Values) + { + scaleModifier *= mod; + } + } + + var constantModifier = 0.0f; + if (_constantModifiers != null && _constantModifiers.ContainsKey(ship)) + { + foreach (var mod in _constantModifiers[ship].Values) + { + scaleModifier += mod; + } + } + + var result = lerp(Min, Max, heat * durability * quality) * scaleModifier + constantModifier; + if (float.IsNaN(result)) + return Min; + return result; + } +} + +[MessagePackObject] +public class Hardpoint +{ + [Key("item")] public Gear Item; + + // [IgnoreMember] public Ship Ship; + [IgnoreMember] public HardpointData HardpointData; + + // [IgnoreMember] + // public float HeatCapacity => Item != null + // ? Item.EquippedItemData.Data.Mass * Item.EquippedItemData.Equippable.SpecificHeat + // : Ship.Hull.EquippedItemData.Data.Mass * Ship.Hull.EquippedItemData.Equippable.SpecificHeat / Ship.HullHardpointCount; +} + + +[Name("Loadout")] +[MessagePackObject] +public class LoadoutDefinition : IDatabaseEntry +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + [InspectableDatabaseLink(typeof(Hull))] [Key("hull")] public Guid Hull; + [Key("items")] public List Items = new List(); + + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + +[MessagePackObject] +public class Player : IDatabaseEntry +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + [Key("email")] public string Email; + [Key("password")] public string Password; + + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + + +[MessagePackObject] +public class HardpointData +{ + [Key("type")] public HardpointType Type; +} + +[MessagePackObject] +public class ZoneData : IDatabaseEntry +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + [Inspectable] [Key("radius")] public float Radius = 500; + [Inspectable] [Key("radiusPower")] public float RadiusPower = 1.75f; + [Inspectable] [Key("mass")] public float Mass = 100000; + [Inspectable] [Key("massFloor")] public float MassFloor = 1; + [Inspectable] [Key("sunMass")] public float SunMass = 10000; + [Inspectable] [Key("gasGiantMass")] public float GasGiantMass = 2000; + [Inspectable] [Key("stations")] public List Stations = new List(); + + [InspectableDatabaseLink(typeof(ZoneData))] [Key("wormholes")] + public List Wormholes = new List(); + + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + +[Inspectable] +[MessagePackObject] +public class Station +{ + [Inspectable] [Key("name")] public string Name; + [InspectableDatabaseLink(typeof(Corporation))] [Key("faction")] public Guid Faction; + [Inspectable] [Key("dockingDistance")] public float DockingDistance = 10; + [Inspectable] [Key("buying")] public Dictionary BuyPrices = new Dictionary(); + [Inspectable] [Key("selling")] public Dictionary SellPrices = new Dictionary(); + [MessagePackFormatter(typeof(UnityGameObjectFormatter))] [Inspectable] [Key("prefab")] public GameObject Prefab; +} + +[MessagePackObject] +public class Corporation : IDatabaseEntry +{ + [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + [InspectableDatabaseLink(typeof(Corporation))] [Key("parent")] public Guid ParentCorporation; + [Inspectable] [MessagePackFormatter(typeof(UnitySpriteFormatter))] [Key("logo")] public Sprite Logo; + [Inspectable] [Key("livery")] public Skin Livery = new Skin(); + + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; +} + +[Inspectable] +[MessagePackObject] +public class Skin +{ + [Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("primary")] public Material Primary; + [Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("secondary")] public Material Secondary; + [Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("trim")] public Material Trim; + [Inspectable] [MessagePackFormatter(typeof(UnityMaterialFormatter))] [Key("windshield")] public Material Windshield; +} + + +public enum ProjectileType +{ + Physical, + Energy +} + +public enum LauncherCaliber +{ + Missile, + Torpedo, + Fighter +} + +public enum HardpointType +{ + Hull, + Thruster, + WarpThruster, + Reactor, + Radiator, + Shield, + Cooler, + Sensors, + Tool, + Energy, + Ballistic, + Launcher +} + +public enum DamageType +{ + Kinetic, + Energy, + Thermal, + Optical, + Ionizing +} \ No newline at end of file diff --git a/Assets/Scripts/DatabaseItems.cs.meta b/Assets/Scripts/DatabaseItems.cs.meta new file mode 100644 index 000000000..7e44aa10b --- /dev/null +++ b/Assets/Scripts/DatabaseItems.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3bb4780bed7bb544dbf6ea2223dd8f06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor.meta b/Assets/Scripts/Editor.meta new file mode 100644 index 000000000..16a350fab --- /dev/null +++ b/Assets/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e53b57c0f2cbafc4385bf8cffe68542a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/DatabaseEditor.cs b/Assets/Scripts/Editor/DatabaseEditor.cs new file mode 100644 index 000000000..fafa86db7 --- /dev/null +++ b/Assets/Scripts/Editor/DatabaseEditor.cs @@ -0,0 +1,1092 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using Unity.Mathematics; +using UnityEditor; +using UnityEngine; +using UnityEngine.Serialization; +// TODO: USE THIS EVERYWHERE +using static Unity.Mathematics.math; +using Object = UnityEngine.Object; + +public class DatabaseListView : EditorWindow +{ + // Singleton to avoid multiple instances of window. + private static DatabaseListView _instance; + public Guid SelectedItem; + public GUIStyle SelectedStyle; + + private bool[] _gearFoldouts; + private bool _itemsFoldout; + private bool _compoundFoldout; + private bool _simpleFoldout; + private bool _commoditiesFoldout; + //private bool _consumablesFoldout; + private Type[] _itemTypes; + private bool _listItemStyle; + private GUIStyle _listStyleOdd; + private GUIStyle _listStyleEven; + private static DatabaseInspector _inspector; + private Type[] _entryTypes; + private bool[] _entryFoldouts; + private const float LineHeight = 20; + + // Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...). + public DatabaseListView() + { + _instance = this; + } + + public static DatabaseListView ShowWindow() + { + if (_instance == null) + { + // "Get existing open window or if none, make a new one:" says documentation. + // But if called after script reloads a second instance will be opened! => Custom singleton required. + DatabaseListView window = EditorWindow.GetWindow(); + window.titleContent = new GUIContent("DB List"); + _instance = window; + _instance.InitStyles(); + window.Show(); + } + else + _instance.Focus(); + + return _instance; + } + + public GUIStyle ListItemStyle => + (_listItemStyle = !_listItemStyle) ? _listStyleEven : _listStyleOdd; + + [MenuItem("Window/Aetheria Database Tools")] + static void Init() + { + ShowWindow(); + } + + void OnEnable() + { + _inspector = DatabaseInspector.ShowWindow(); + _itemTypes = typeof(IItem).GetAllInterfaceClasses(); + _entryTypes = typeof(IDatabaseEntry).GetAllInterfaceClasses().Where(t => !t.GetInterfaces().Contains(typeof(IItem))&& !t.GetInterfaces().Contains(typeof(IItemInstance))).ToArray(); + _gearFoldouts = new bool[_itemTypes.Length]; + _entryFoldouts = new bool[_entryTypes.Length]; + InitStyles(); + Database.OnDataUpdate += Repaint; + } + + private void InitStyles() + { + _listStyleOdd = new GUIStyle + { + normal = {background = XKCDColors.LightGrey.ToTexture()}, + margin = new RectOffset(0, 0, 0, 0) + }; + _listStyleEven = new GUIStyle + { + normal = {background = Color.Lerp(XKCDColors.LightGrey,Color.white,.5f).ToTexture()}, + margin = new RectOffset(0, 0, 0, 0) + }; + SelectedStyle = new GUIStyle + { + normal = {background = XKCDColors.Greyblue.ToTexture()}, + margin = new RectOffset(0, 0, 0, 0) + }; + } + + public void OnGUI() + { + Event currentEvent = Event.current; + EventType currentEventType = currentEvent.type; + + if (currentEventType == EventType.DragUpdated) + // Indicate that we don't accept drags ourselves + DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; + + Action select = item => + { + SelectedItem = item.GetId(); + Repaint(); + _inspector.entry = Database.Get(SelectedItem); + _inspector.Repaint(); + }; + + using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) + { + _itemsFoldout = EditorGUILayout.Foldout(_itemsFoldout, "Items", true); + } + if (_itemsFoldout) + { + var items = Database.AllEntries.Where(item => item is IItem).Cast().ToArray(); + for (var i = 0; i < _itemTypes.Length; i++) + { + using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) + { + GUILayout.Space(10); + _gearFoldouts[i] = EditorGUILayout.Foldout(_gearFoldouts[i], + ((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _itemTypes[i].Name, + true); + } + if (_gearFoldouts[i]) + { + foreach (var item in items.Where(e=>e.GetType()==_itemTypes[i])) + { + var style = ListItemStyle; + var selected = SelectedItem == item.GetId(); + using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style)) + { + if (h.rect.Contains(currentEvent.mousePosition)) + { + if (currentEventType == EventType.MouseDrag) + { + DragAndDrop.PrepareStartDrag(); + DragAndDrop.SetGenericData("Item", item.GetId()); + DragAndDrop.StartDrag("Database Item"); + } + else if (currentEventType == EventType.MouseUp) + select(item); + } + GUILayout.Space(20); + GUILayout.Label(item.Entry.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label); + } + } + + using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) + { + if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) + CreateItem(_itemTypes[i]); + GUILayout.Space(20); + GUILayout.Label("New " + _itemTypes[i].Name); + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + } + } + } + } + + var entries = Database.AllEntries.Where(item => !(item is IItem)).ToArray(); + for (var i = 0; i < _entryTypes.Length; i++) + { + using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) + { + _entryFoldouts[i] = EditorGUILayout.Foldout(_entryFoldouts[i], + ((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _entryTypes[i].Name, + true); + } + + if (_entryFoldouts[i]) + { + foreach (var entry in entries.Where(e=>e.GetType()==_entryTypes[i])) + { + var style = ListItemStyle; + var selected = SelectedItem == entry.GetId(); + using (var h = new EditorGUILayout.HorizontalScope(selected?SelectedStyle:style)) + { + if (h.rect.Contains(currentEvent.mousePosition)) + { + if (currentEventType == EventType.MouseDrag) + { + DragAndDrop.PrepareStartDrag(); + DragAndDrop.SetGenericData("Item", entry.GetId()); + DragAndDrop.StartDrag("Database Item"); + } + else if (currentEventType == EventType.MouseUp) + select(entry); + } + GUILayout.Space(10); + GUILayout.Label(entry.Entry.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label); + } + } + + using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) + { + if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) + CreateItem(_entryTypes[i]); + GUILayout.Space(10); + GUILayout.Label("New " + _entryTypes[i].Name); + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + } + } + } + +// EditorGUILayout.BeginHorizontal(ListItemStyle); +// _commoditiesFoldout = EditorGUILayout.Foldout(_commoditiesFoldout, "Commodities", true); +// EditorGUILayout.EndHorizontal(); +// if (_commoditiesFoldout) +// { +// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) +// { +// GUILayout.Space(10); +// _simpleFoldout = EditorGUILayout.Foldout(_simpleFoldout, "Simple", true); +// } +// if (_simpleFoldout) +// { +// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(ItemData)).Cast()) +// { +// var style = ListItemStyle; +// var selected = SelectedItem == item.ID; +// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style)) +// { +// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) +// select(item); +// GUILayout.Space(20); +// GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label); +// } +// } +// +// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) +// { +// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) +// CreateItem(typeof(ItemData)); +// GUILayout.Space(20); +// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); +// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); +// GUILayout.Label("New Simple Commodity"); +// } +// } +// +// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) +// { +// GUILayout.Space(10); +// _compoundFoldout = EditorGUILayout.Foldout(_compoundFoldout, "Compound", true); +// } +// if (_compoundFoldout) +// { +// foreach (var item in Database.Items.Values.Where(e=>e.GetType()==typeof(CraftedItem)).Cast()) +// { +// var style = ListItemStyle; +// var selected = SelectedItem == item.GetId(); +// using (var h = new EditorGUILayout.HorizontalScope(selected?_selectedStyle:style)) +// { +// if (GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) +// select(item); +// GUILayout.Space(20); +// GUILayout.Label(item.Item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label); +// } +// } +// +// using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle)) +// { +// if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) +// CreateItem(typeof(CraftedItem)); +// GUILayout.Space(20); +// var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); +// GUI.DrawTexture(rect, GlobalData.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); +// GUILayout.Label("New Compound Commodity"); +// } +// } +// } +// EditorGUILayout.BeginHorizontal(ListItemStyle); +// _consumablesFoldout = EditorGUILayout.Foldout(_consumablesFoldout, "Consumables", true); +// EditorGUILayout.EndHorizontal(); +// if (_consumablesFoldout) +// { +// +// } + + // HACK: This ensures none of the controls in this window can be focused (usually from clicking foldouts) + GUI.SetNextControlName(""); + GUI.FocusControl(""); + } + + private void CreateItem(Type type) + { + var newEntry = (IDatabaseEntry) Activator.CreateInstance(type); + SelectedItem = newEntry.GetId(); + newEntry.Entry.Name = $"New {type.Name}"; + Database.Save(newEntry); + } +} + +public class DatabaseInspector : EditorWindow +{ + public IDatabaseEntry entry; + + // Singleton to avoid multiple instances of window. + private static DatabaseInspector _instance; + + private DatabaseListView _list; + private GUIStyle _labelStyle; + private Vector2 _view; + private const float IconSize = 1.0f / 16; + private static HardpointData _hardpoint; + private static float2 _dragOffset; + private bool _ctrlDown; + private string[] _hardpointTypes; + private const int width = 100; + private const int labelWidth = 20; + + // Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...). + public DatabaseInspector() + { + _instance = this; + } + + public static DatabaseInspector ShowWindow() + { + if (_instance == null) + { + // "Get existing open window or if none, make a new one:" says documentation. + // But if called after script reloads a second instance will be opened! => Custom singleton required. + DatabaseInspector window = GetWindow(); + window.titleContent = new GUIContent("DB Inspector"); + _instance = window; + window.Show(); + } + else + _instance.Focus(); + + return _instance; + } + + void OnEnable() + { + _list = DatabaseListView.ShowWindow(); + Database.OnDataUpdate += Repaint; + wantsMouseMove = true; + _hardpoint = null; + _hardpointTypes = Enum.GetNames(typeof(HardpointType)); + } + + public void Inspect(object obj, bool inspectablesOnly = false, ICraftable craftable = null) + { + foreach (var field in obj.GetType().GetFields()) + { + Inspect(obj, field, inspectablesOnly, craftable); + } + } + + public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, ICraftable craftable = null) + { + var inspectable = field.GetCustomAttribute(); + if (inspectable == null && inspectablesOnly) return; + + var type = field.FieldType; + var value = field.GetValue(obj); + + var link = inspectable as InspectableDatabaseLinkAttribute; + if (type == typeof(float)) + { + if (inspectable is RangedFloatInspectableAttribute) + { + var range = inspectable as RangedFloatInspectableAttribute; + field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (float) value, range.Min, range.Max)); + } + else if (inspectable is TemperatureInspectableAttribute) + field.SetValue(obj, InspectTemperature(field.Name.SplitCamelCase(), (float) value)); + else + field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (float) value)); + } + else if (type == typeof(int)) + { + if (inspectable is RangedIntInspectableAttribute) + { + var range = inspectable as RangedIntInspectableAttribute; + field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) value, range.Min, range.Max)); + } + else + field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) value)); + } + else if (type.IsEnum) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) field.GetValue(obj), Enum.GetNames(field.FieldType))); + //else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c)); + else if (type == typeof(bool)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (bool) value)); + else if (type == typeof(string)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (string) value, inspectable is InspectableTextAttribute)); + else if (type == typeof(GameObject)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (GameObject) value)); + else if (type == typeof(AnimationCurve)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (AnimationCurve) value)); + else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, craftable)); + else if (type == typeof(PerformanceStat[])) + { + EditorGUILayout.LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel); + using (new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + var stats = (PerformanceStat[]) value; + var damageTypes = Enum.GetNames(typeof(DamageType)); + if(stats==null || stats.Length!=damageTypes.Length) + stats = new PerformanceStat[damageTypes.Length]; + for (var i = 0; i < stats.Length; i++) + { + stats[i] = Inspect(damageTypes[i].SplitCamelCase(), stats[i], craftable); + } + field.SetValue(obj, stats); + } + } + else if (type == typeof(Dictionary)) + { + var dict = (Dictionary) field.GetValue(obj); + Inspect(field.Name.SplitCamelCase(), ref dict); + } + else if (type == typeof(Dictionary)) + { + var dict = (Dictionary) field.GetValue(obj); + Inspect(field.Name.SplitCamelCase(), ref dict); + } + else if (type == typeof(List) && link != null) + { + var list = (List) field.GetValue(obj); + if(list==null) field.SetValue(obj, (list = new List())); + Inspect(field.Name.SplitCamelCase(), ref list, link.EntryType); + } + else if (type == typeof(Guid) && link != null) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (Guid) value, link.EntryType)); + else if (type.GetCustomAttribute() != null) + { + EditorGUILayout.Space(); + using (new EditorGUILayout.HorizontalScope()) + { + EditorGUILayout.LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel); + if (type.IsInterface) + { + var subTypes = type.GetAllInterfaceClasses(); + var selected = value != null ? Array.IndexOf(subTypes, value.GetType()) + 1 : 0; + var newSelection = EditorGUILayout.Popup(selected, + subTypes.Select(t => t.Name.SplitCamelCase()).Prepend("None").ToArray()); + if(newSelection != selected) + field.SetValue(obj, value = newSelection==0?null:Activator.CreateInstance(subTypes[newSelection-1])); + } else if(value == null) field.SetValue(obj, value = Activator.CreateInstance(type)); + } + if(value != null) Inspect(field.GetValue(obj), inspectablesOnly, craftable); + } + else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) + { + var listType = field.FieldType.GenericTypeArguments[0]; + if (listType.GetCustomAttribute() != null) + { + EditorGUILayout.Space(); + using (new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + var list = (IList) field.GetValue(obj); + if (list == null) + { + list = (IList) Activator.CreateInstance(type); + field.SetValue(obj, list); + } + foreach (var o in list) + { + using (new EditorGUILayout.VerticalScope(_list.ListItemStyle)) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(o.GetType().Name.SplitCamelCase(), EditorStyles.boldLabel, GUILayout.ExpandWidth(true)); + + var rect = EditorGUILayout.GetControlRect(false, + GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, + Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + { + list.Remove(o); + break; + } + } + + EditorGUILayout.Space(); + + Inspect(o, inspectablesOnly, craftable); + } + } + using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label($"Add new {listType.Name}", GUILayout.ExpandWidth(true)); + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + { + if (listType.IsInterface) + { + var menu = new GenericMenu(); + foreach (var behaviorType in listType.GetAllInterfaceClasses()) + { + menu.AddItem(new GUIContent(behaviorType.Name), false, () => + { + list.Add(Activator.CreateInstance(behaviorType)); + Database.Save(entry); + }); + } + menu.ShowAsContext(); + } + else + { + list.Add(Activator.CreateInstance(listType)); + } + } + } + } + } + else if (typeof(Object).IsAssignableFrom(listType)) + { + EditorGUILayout.Space(); + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + var list = (IList) field.GetValue(obj); + if (list == null) + { + list = (IList) Activator.CreateInstance(type); + field.SetValue(obj, list); + } + + if(list.Count==0) + using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + GUILayout.Label($"Add a {listType.Name} by dragging from the project hierarchy."); + + foreach (var oo in list) + { + var o = (Object) oo; + using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label(o.name.SplitCamelCase(), EditorStyles.boldLabel, GUILayout.ExpandWidth(true)); + + var rect = EditorGUILayout.GetControlRect(false, + GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, + Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + { + list.Remove(o); + break; + } + } + } + + if (v.rect.Contains(Event.current.mousePosition) && (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)) + { + var dragObj = DragAndDrop.objectReferences.FirstOrDefault(); + //var dragEntry = Database.Get(guid); + if(Event.current.type == EventType.DragUpdated) + DragAndDrop.visualMode = dragObj?.GetType() == listType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; + else if(Event.current.type == EventType.DragPerform) + { + if (dragObj?.GetType() == listType) + { + DragAndDrop.AcceptDrag(); + GUI.changed = true; + list.Add(dragObj); + } + } + } + } + } + else Debug.Log($"Field \"{field.Name}\" is a list of non-Inspectable type {listType.Name}. No inspector was generated."); + } + else if (typeof(Object).IsAssignableFrom(type)) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(field.Name.SplitCamelCase(), GUILayout.Width(width)); + field.SetValue(obj, EditorGUILayout.ObjectField((Object)field.GetValue(obj),type,false)); + } + } +// else if (type == typeof(AudioClip)) +// { +// using (new EditorGUILayout.HorizontalScope()) +// { +// GUILayout.Label(field.Name.SplitCamelCase(), GUILayout.Width(width)); +// field.SetValue(obj, EditorGUILayout.ObjectField((AudioClip)field.GetValue(obj),typeof(AudioClip),false)); +// } +// } + else Debug.Log($"Field \"{field.Name}\" has unknown type {field.FieldType.Name}. No inspector was generated."); + } + + public bool Inspect(string label, bool value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.Toggle(value); + } + } + + public float Inspect(string label, float value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.DelayedFloatField(value); + } + } + + public string Inspect(string label, string value, bool area = false) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + if(area) + return EditorGUILayout.TextArea(value,GUILayout.MaxWidth(300)); + return EditorGUILayout.DelayedTextField(value); + } + } + + public float InspectTemperature(string label, float value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + GUILayout.Label("°K", _labelStyle, GUILayout.Width(labelWidth)); + value = EditorGUILayout.DelayedFloatField(value);//, GUILayout.ExpandWidth(false) + GUILayout.Label("°C", _labelStyle, GUILayout.Width(labelWidth)); + value = EditorGUILayout.DelayedFloatField(value - 273.15f) + 273.15f; + GUILayout.Label("°F", _labelStyle, GUILayout.Width(labelWidth)); + value = (EditorGUILayout.DelayedFloatField((value - 273.15f) * 1.8f + 32) - 32) / 1.8f + 273.15f; + + return value; + } + } + + public float Inspect(string label, float value, float min, float max) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.Slider(value, min, max); + } + } + + public int Inspect(string label, int value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.DelayedIntField(value); + } + } + + public int Inspect(string label, int value, int min, int max) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.IntSlider(value, min, max); + } + } + + public int Inspect(string label, int value, string[] enumOptions) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return EditorGUILayout.Popup(value, enumOptions); + } + } + + public GameObject Inspect(string label, GameObject value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + return (GameObject) EditorGUILayout.ObjectField(value, typeof(GameObject), false); + } + } + + public AnimationCurve Inspect(string label, AnimationCurve value) + { + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + if (value == null) + value = new AnimationCurve(); + value = EditorGUILayout.CurveField(value, Color.yellow, new Rect(0, 0, 1, 1)); + } + + return value; + } + + public Guid Inspect(string label, Guid value, Type entryType) + { + EditorGUILayout.LabelField(label, EditorStyles.boldLabel); + var valueEntry = Database.Get(value); + using (var h = new EditorGUILayout.HorizontalScope(GUI.skin.box)) + { + GUILayout.Label(valueEntry?.Entry.Name ?? $"Assign a {entryType.Name} by dragging from the list panel."); + + if (h.rect.Contains(Event.current.mousePosition) && (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)) + { + var guid = (Guid) DragAndDrop.GetGenericData("Item"); + var dragEntry = Database.Get(guid); + if(Event.current.type == EventType.DragUpdated) + DragAndDrop.visualMode = dragEntry != null && dragEntry.GetType()==entryType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; + else if(Event.current.type == EventType.DragPerform) + { + if (guid != Guid.Empty && dragEntry.GetType()==entryType) + { + DragAndDrop.AcceptDrag(); + GUI.changed = true; + return guid; + } + } + } + } + + return value; + } + + public void Inspect(string label, ref Dictionary value) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField(label, EditorStyles.boldLabel); + + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + if (value.Count == 0) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label("Nothing Here! Add an item by dragging from the list panel."); + } + } + foreach (var ingredient in value.ToArray()) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label(Database.Get(ingredient.Key).Entry.Name); + value[ingredient.Key] = EditorGUILayout.DelayedIntField(value[ingredient.Key], GUILayout.Width(50)); + + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none) || value[ingredient.Key]==0) + value.Remove(ingredient.Key); + } + } + + if (v.rect.Contains(Event.current.mousePosition)) + { + if(Event.current.type == EventType.DragUpdated) + DragAndDrop.visualMode = DragAndDropVisualMode.Copy; + else if(Event.current.type == EventType.DragPerform) + { + var guid = DragAndDrop.GetGenericData("Item"); + if (guid is Guid) + { + DragAndDrop.AcceptDrag(); + value[(Guid) guid] = 1; + GUI.changed = true; + } + } + } + } + } + + public void Inspect(string label, ref Dictionary value) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField(label, EditorStyles.boldLabel); + + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + if (value.Count == 0) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label("Nothing Here! Add an item by dragging from the list panel."); + } + } + foreach (var ingredient in value.ToArray()) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label(Database.Get(ingredient.Key).Entry.Name); + value[ingredient.Key] = EditorGUILayout.DelayedFloatField(value[ingredient.Key], GUILayout.Width(50)); + + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + value.Remove(ingredient.Key); + } + } + + if (v.rect.Contains(Event.current.mousePosition)) + { + if(Event.current.type == EventType.DragUpdated) + DragAndDrop.visualMode = DragAndDropVisualMode.Copy; + else if(Event.current.type == EventType.DragPerform) + { + var guid = DragAndDrop.GetGenericData("Item"); + if (guid is Guid) + { + DragAndDrop.AcceptDrag(); + value[(Guid) guid] = 1; + GUI.changed = true; + } + } + } + } + } + + public void Inspect(string label, ref List value, Type entryType) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField(label, EditorStyles.boldLabel); + + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + if (value.Count == 0) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label($"Nothing Here! Add a {entryType.Name} by dragging from the list panel."); + } + } + foreach (var ingredient in value.ToArray()) + { + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label(Database.Get(ingredient).Entry.Name); + + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + value.Remove(ingredient); + } + } + + if (v.rect.Contains(Event.current.mousePosition)) + { + var guid = DragAndDrop.GetGenericData("Item"); + var dragObj = DragAndDrop.GetGenericData("Item") is Guid ? ((Guid) guid).Get() : null; + if(Event.current.type == EventType.DragUpdated) + DragAndDrop.visualMode = entryType.IsInstanceOfType(dragObj) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; + else if(Event.current.type == EventType.DragPerform) + { + if (entryType.IsInstanceOfType(dragObj)) + { + DragAndDrop.AcceptDrag(); + value.Add((Guid) guid); + GUI.changed = true; + } + } + } + } + } + + public PerformanceStat Inspect(string label, PerformanceStat value, ICraftable craftable) + { + using (new EditorGUILayout.VerticalScope()) + { + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label(label, GUILayout.Width(width)); + GUILayout.Label("Min", _labelStyle, GUILayout.Width(labelWidth)); + value.Min = EditorGUILayout.DelayedFloatField(value.Min); + GUILayout.Label("Max", _labelStyle, GUILayout.Width(labelWidth + 5)); + value.Max = EditorGUILayout.DelayedFloatField(value.Max); + } + + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label("", GUILayout.Width(width)); + GUILayout.Label("H", _labelStyle); + value.HeatDependent = EditorGUILayout.Toggle(value.HeatDependent); + GUILayout.Label("D", _labelStyle); + value.DurabilityDependent = EditorGUILayout.Toggle(value.DurabilityDependent); + GUILayout.Label("QEx", _labelStyle, GUILayout.Width(labelWidth + 5)); + value.QualityExponent = EditorGUILayout.DelayedFloatField(value.QualityExponent); + } + + using (new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label("", GUILayout.Width(width)); + GUILayout.Label("Ingredient", GUILayout.ExpandWidth(false)); + var ingredients = craftable.CraftingIngredients.Keys.Select(Database.Get).Where(i => i is CraftedItem).Cast().ToList(); + var ingredient = Database.Get(value.Ingredient) as CraftedItem; + var names = ingredients.Select(i => i.Entry.Name).Append("None").ToArray(); + var selected = value.Ingredient == Guid.Empty || !craftable.CraftingIngredients.ContainsKey(value.Ingredient) + ? names.Length - 1 + : ingredients.IndexOf(ingredient); + var selection = EditorGUILayout.Popup(selected, names); + value.Ingredient = selection == names.Length - 1 ? Guid.Empty : ingredients[selection].GetId(); + } + + EditorGUILayout.Space(); + + return value; + } + } + + public void OnGUI() + { + _labelStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel) {normal = {textColor = Color.black}}; + + Event current = Event.current; + EventType currentEventType = current.type; + if (currentEventType == EventType.KeyDown && current.keyCode == KeyCode.LeftControl) + _ctrlDown = true; + if (currentEventType == EventType.KeyUp && current.keyCode == KeyCode.LeftControl) + _ctrlDown = false; + + if (entry==null) + { + EditorGUILayout.LabelField($"{(_list.SelectedItem==Guid.Empty?"No Entry Selected":"Selected Entry Not Found in Database")}\n{_list.SelectedItem}"); + return; + } + + _view = EditorGUILayout.BeginScrollView( + _view, + false, + false, + GUIStyle.none, + GUI.skin.verticalScrollbar, + GUI.skin.scrollView, + GUILayout.Width(EditorGUIUtility.currentViewWidth), + GUILayout.ExpandHeight(true)); + + EditorGUI.BeginChangeCheck(); + + var dataEntry = entry.Entry; + + using (new EditorGUILayout.HorizontalScope()) + { + if(GUILayout.Button("Print JSON")) + Debug.Log(entry.ToJson()); + if (GUILayout.Button("Duplicate")) + { + Database.Duplicate(entry); + } + if (GUILayout.Button("Delete Entry")) + { + Database.Delete(entry); + entry = null; + return; + } + } + + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label("ID"); + EditorGUILayout.LabelField(dataEntry.ID.ToString()); + } + + Inspect(entry, true, entry as ICraftable); + + #region Hull + var hull = entry as Hull; + if (hull != null) + { + EditorGUILayout.Space(); + + // TODO: Hull Hardpoints Inspector + + } + #endregion + + #region Loadout + var loadout = entry as LoadoutDefinition; + if (loadout != null) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Loadout Hull", EditorStyles.boldLabel); + + var loadoutHull = Database.Get(loadout.Hull) as Hull; + + if (loadoutHull != null) + { + // Reserve slots in the loadout for all equippable (non-hull) hardpoints + var hardpoints = loadoutHull.Hardpoints.Where(h => h.Type != HardpointType.Hull).ToArray(); + if (loadout.Items.Count < hardpoints.Length) + loadout.Items.AddRange(Enumerable.Repeat(Guid.Empty, hardpoints.Length - loadout.Items.Count)); + + EditorGUILayout.Space(); + using (var h = new EditorGUILayout.HorizontalScope()) + { + GUILayout.Label($"Equipped Items: {loadout.Items.Sum(i=>((IItem) Database.Get(i))?.Data.Size ?? 0)}/{loadoutHull.Capacity.Min}", EditorStyles.boldLabel); + GUILayout.Label($"Mass: {loadout.Items.Sum(i=>((IItem) Database.Get(i))?.Data.Mass ?? 0)}", EditorStyles.boldLabel, GUILayout.ExpandWidth(false)); + } + + int itemIndex = 0; + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + for (; itemIndex < hardpoints.Length; itemIndex++) + { + var hp = hardpoints[itemIndex]; + + var loadoutItem = Database.Get(loadout.Items[itemIndex]) as IEquippable; + + if (loadoutItem != null && loadoutItem.HardpointType != hp.Type) + { + loadout.Items[itemIndex] = Guid.Empty; + Debug.Log($"Invalid Item \"{loadoutItem.Entry.Name}\" in {Enum.GetName(typeof(HardpointType),hp.Type)} hardpoint for loadout \"{loadout.Entry.Name}\""); + Database.Save(entry); + } + + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + if (h.rect.Contains(current.mousePosition) && + (currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform)) + { + var guid = (Guid) DragAndDrop.GetGenericData("Item"); + var draggedEquippable = Database.Get(guid) as IEquippable; + var good = draggedEquippable != null && draggedEquippable.HardpointType == hp.Type; + if (currentEventType == EventType.DragUpdated) + DragAndDrop.visualMode = good ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; + else if (currentEventType == EventType.DragPerform && good) + { + DragAndDrop.AcceptDrag(); + loadout.Items[itemIndex] = guid; + + Database.Save(entry); + } + } + + GUILayout.Label(Enum.GetName(typeof(HardpointType), hp.Type)); + if (loadoutItem == null || loadoutItem.HardpointType != hp.Type) + GUILayout.Label("Empty Hardpoint", GUILayout.ExpandWidth(false)); + else + { + GUILayout.Label(loadoutItem.Entry.Name, GUILayout.ExpandWidth(false)); + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + loadout.Items[itemIndex] = Guid.Empty; + } + } + } + } + + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Cargo", EditorStyles.boldLabel); + + using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box)) + { + if (v.rect.Contains(current.mousePosition) && + (currentEventType == EventType.DragUpdated || currentEventType == EventType.DragPerform)) + { + var guid = (Guid) DragAndDrop.GetGenericData("Item"); + var dragItem = Database.Get(guid) as IItem; + if (currentEventType == EventType.DragUpdated) + DragAndDrop.visualMode = dragItem != null ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; + else if (currentEventType == EventType.DragPerform && dragItem != null) + { + DragAndDrop.AcceptDrag(); + + loadout.Items.Add(guid); + Database.Save(entry); + } + } + if(itemIndex == loadout.Items.Count) + GUILayout.Label("Nothing Here!"); + for (; itemIndex < loadout.Items.Count; itemIndex++) + { + var loadoutItem = Database.Get(loadout.Items[itemIndex]) as IItem; + using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle)) + { + GUILayout.Label(loadoutItem?.Entry.Name ?? "Invalid Item"); + var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); + GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0); + if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) + loadout.Items.RemoveAt(itemIndex--); + } + } + } + } + } + #endregion + + if (EditorGUI.EndChangeCheck()) + { + Database.Save(entry); + } + + EditorGUILayout.EndScrollView(); + + } +} diff --git a/Assets/Scripts/Editor/DatabaseEditor.cs.meta b/Assets/Scripts/Editor/DatabaseEditor.cs.meta new file mode 100644 index 000000000..17ec8bd15 --- /dev/null +++ b/Assets/Scripts/Editor/DatabaseEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b514fcab25f3b914b89824efbe244591 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Extensions.cs b/Assets/Scripts/Extensions.cs index 06f530ba9..e0bba961b 100644 --- a/Assets/Scripts/Extensions.cs +++ b/Assets/Scripts/Extensions.cs @@ -9,6 +9,8 @@ using Unity.Mathematics; using UnityEngine; using Random = UnityEngine.Random; +using static Unity.Mathematics.math; + public static class Extensions { public static void BroadcastMessageExt(this GameObject go, string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver) @@ -39,6 +41,15 @@ public static class Extensions } } + private static Dictionary InterfaceClasses = new Dictionary(); + public static Type[] GetAllInterfaceClasses(this Type type) + { + if (InterfaceClasses.ContainsKey(type)) + return InterfaceClasses[type]; + return InterfaceClasses[type] = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(ass => ass.GetTypes()).Where(t => t.IsClass && t.GetInterfaces().Contains(type)).ToArray(); + } + public static bool IsDefault(this T value) where T : struct { bool isDefault = value.Equals(default(T)); @@ -54,16 +65,6 @@ public static class Extensions return result; } - - public static Vector2 Flatland(this Vector3 v) - { - return new Vector2(v.x, v.z); - } - - public static Vector3 Flatland(this Vector2 v) - { - return new Vector3(v.x, 0, v.y); - } public static string SplitCamelCase( this string str ) { @@ -95,5 +96,39 @@ public static class Extensions { return baseType.GetInterfaces().Any(interfaceType.Equals); } - + + private static readonly Dictionary Quality = new Dictionary(); + public static float CompoundQuality(this ICraftedItemInstance item) + { + if (Quality.ContainsKey(item)) return Quality[item]; + + var quality = item.CraftedQuality; + + var craftedIngredients = item.CraftedIngredients.Where(i => i is ICraftedItemInstance).ToArray(); + if (craftedIngredients.Length > 0) + { + quality *= craftedIngredients.Cast().Average(CompoundQuality); + } + + Quality[item] = quality; + + return Quality[item]; + } + + private static readonly Dictionary Tier = new Dictionary(); + public static int ItemTier(this ICraftable item) + { + if (Tier.ContainsKey(item)) return Tier[item]; + + Tier[item] = item.CraftingIngredients.Keys.Max(ci => (Database.Get(ci) as ICraftable)?.ItemTier() ?? 0); + + return Tier[item]; + } + + public static float Performance(this IEquippable item, float temperature) + { + return saturate(item.Equippable.HeatPerformanceCurve.Evaluate(saturate( + (temperature - item.Equippable.MinimumTemperature) / + (item.Equippable.MaximumTemperature - item.Equippable.MinimumTemperature)))); + } } diff --git a/Assets/Scripts/Galaxy.cs b/Assets/Scripts/Galaxy.cs index 023e33311..92c5bc6aa 100644 --- a/Assets/Scripts/Galaxy.cs +++ b/Assets/Scripts/Galaxy.cs @@ -6,6 +6,10 @@ using System.Linq; using UnityEngine; using NaughtyAttributes; using JM.LinqFaster; +using Unity.Mathematics; +using static Unity.Mathematics.math; +using static Unity.Mathematics.noise; +using static NoiseFbm; [CreateAssetMenu(menuName = "Aetheria/Galaxy")] public class Galaxy : ScriptableObject @@ -77,12 +81,30 @@ public class StarData public List Names = new List(); } +public static class NoiseFbm +{ + public static float fBm(float2 p, int octaves, float frequency, float offset, float amplitude, float lacunarity, float gain) + { + float freq = frequency, amp = .5f; + float sum = 0; + for(int i = 0; i < octaves; i++) + { + sum += snoise(p * freq) * amp; + freq *= lacunarity; + amp *= gain; + } + return (sum + offset)*amplitude; + } +} + [Serializable] public class GalaxyMapLayerData { public float CoreBoost = 1.05f; public float CoreBoostOffset = .1f; public float CoreBoostPower = 2.25f; + public float SpokeScale = 1; + public float SpokeOffset = 0; public float EdgeReduction = 3; public float NoiseOffset = 0; public float NoiseAmplitude = 1.5f; @@ -90,25 +112,21 @@ public class GalaxyMapLayerData public float NoiseLacunarity = 2; public int NoiseOctaves = 7; public float NoiseFrequency = 1; - public int NoiseSeed = 1337; - - private FastNoise _noise = new FastNoise(); + public float NoisePosition = 1337; - public float Evaluate(Vector2 uv, GalaxyMapData galaxy) + public float Evaluate(float2 uv, GalaxyMapData galaxy) { - _noise.SetFractalGain(NoiseGain); - _noise.SetFractalLacunarity(NoiseLacunarity); - _noise.SetFractalOctaves(NoiseOctaves); - _noise.SetFrequency(NoiseFrequency); - _noise.SetSeed(NoiseSeed); - - Func offset = v => Vector2.one / 2 - v; - Func circle = v => (.5f - v.magnitude) * 2; - Func twist = v => v.Rotate(Mathf.Pow(v.magnitude*2,galaxy.TwistPower)*galaxy.Twist); - Func spokes = v => Mathf.Sin(Mathf.Atan2(-v.y,v.x)*galaxy.Arms); - var c = circle(offset(uv)); - return Mathf.Clamp01((Mathf.Lerp(spokes(twist(offset(uv))) - EdgeReduction * offset(uv).magnitude, 1, - Mathf.Pow(c + CoreBoostOffset, CoreBoostPower) * CoreBoost) - (_noise.GetPerlin(uv.x,uv.y)+NoiseOffset) * NoiseAmplitude) * Mathf.Clamp01(c)); + float2 offset = -float2(.5f, .5f)+uv; + float circle = (.5f-length(offset))*2; + float angle = pow(length(offset)*2,galaxy.TwistPower) * galaxy.Twist; + float2 twist = float2(offset.x*cos(angle) - offset.y*sin(angle), offset.x*sin(angle) + offset.y*cos(angle)); + float atan = atan2(twist.y,twist.x); + float spokes = sin(atan*galaxy.Arms) * SpokeScale + SpokeOffset; + float noise = fBm(uv + float2(NoisePosition), NoiseOctaves, NoiseFrequency, NoiseOffset, NoiseAmplitude, NoiseLacunarity, NoiseGain); + float shape = lerp(spokes - EdgeReduction * length(offset), 1, pow(circle + CoreBoostOffset, CoreBoostPower) * CoreBoost); + float gal = max(shape - noise * saturate(circle), 0); + + return gal; } } diff --git a/Assets/Scripts/Icons.cs b/Assets/Scripts/Icons.cs new file mode 100644 index 000000000..7a45928f4 --- /dev/null +++ b/Assets/Scripts/Icons.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(fileName = "Icons", menuName = "Aetheria/Icons")] +public class Icons : ScriptableObject +{ + public Texture2D plus; + public Texture2D minus; + + private const string AssetPath = "Icons"; + private static Icons _instance; + public static Icons Instance { + get { return _instance ?? (_instance = Resources.Load(AssetPath)); } + } +} diff --git a/Assets/Scripts/Icons.cs.meta b/Assets/Scripts/Icons.cs.meta new file mode 100644 index 000000000..e7556bb2e --- /dev/null +++ b/Assets/Scripts/Icons.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 32eff58a98b2e4c43a9a375c7db56e25 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ItemInstance.cs b/Assets/Scripts/ItemInstance.cs new file mode 100644 index 000000000..e96424dce --- /dev/null +++ b/Assets/Scripts/ItemInstance.cs @@ -0,0 +1,336 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.Remoting.Messaging; +using JM.LinqFaster; +using MessagePack; +using MessagePack.Formatters; +using MIConvexHull; +using UniRx; +using UnityEngine; +using Unity.Mathematics; +using UnityEngine.UI.Extensions; +using Object = UnityEngine.Object; +// TODO: USE THIS EVERYWHERE +using static Unity.Mathematics.math; +using Random = UnityEngine.Random; +#if UNITY_EDITOR +using UnityEditor; +#endif + +[MessagePackObject] +public class Ship +{ + [Key("hull")] + public Gear Hull; + [Key("hardpoints")] + public List Hardpoints = new List(); + [Key("cargo")] + public List Cargo = new List(); + + // [Key("bindings")] public Dictionary Bindings = new Dictionary(); + //[IgnoreMember] public int HullHardpointCount; + [IgnoreMember] public Dictionary ItemBindings; + [IgnoreMember] public IItemBehavior[] ItemBehaviors; + + [IgnoreMember] public bool ForceThrust; + //[IgnoreMember] public Ship Ship; + [IgnoreMember] public Dictionary Contacts = new Dictionary(); + [IgnoreMember] public float Temperature; + [IgnoreMember] public float Charge; + [IgnoreMember] public Targetable Target; + [IgnoreMember] public Vector2 Direction; + [IgnoreMember] public Dictionary VisibilitySources = new Dictionary(); + //[IgnoreMember] public float Visibility; + + private Hull _hullData; + private bool _hydrated = false; + + [IgnoreMember] public Hull HullData => _hullData ?? (_hullData = Hull.EquippedItemData as Hull); + + [IgnoreMember] public float Mass { get; private set; } + + //[IgnoreMember] public float Visibility => VisibilitySources.Values.Sum(); + + public Gear GetEquipped(HardpointType type) + { + return Hardpoints.FirstOrDefault(hp => hp.HardpointData.Type == type)?.Item; + } + + public T GetEquipped() where T : class, IEquippable + { + return Hardpoints.FirstOrDefault(hp => hp.Item?.EquippedItemData is T)?.Item.EquippedItemData as T; + } + + public void AddHeat(float heat) + { + Temperature += heat / Mass; + } + + public void Hydrate() + { + GenerateBehaviors(); + Mass = Hull.Mass + Hardpoints.Sum(hp => hp.Item?.Mass ?? 0) + Cargo.Sum(ii => ii.Mass); + //HullHardpointCount = Hardpoints.Count(hp => hp.HardpointData.Type == HardpointType.Hull); + _hydrated = true; + } + + private void GenerateBehaviors() + { + ItemBehaviors = Hardpoints.Where(hp=>hp.Item!=null) + .Where(hp=>hp.Item.EquippedItemData.Equippable.Behaviors?.Any()??false) + .SelectMany(hp => hp.Item.EquippedItemData.Equippable.Behaviors + .Select(bd => bd.CreateInstance(this, hp.Item))) + .OrderBy(b => b.GetType().GetCustomAttribute()?.Order ?? 0).ToArray(); + + ItemBindings = ItemBehaviors + .Where(b => b is IActivatedItemBehavior) + .GroupBy(b => b.Item.GetId(), (guid, behaviors) => new {guid, behaviors}) + .ToDictionary(g => g.guid, g => g.behaviors.Cast().ToArray()); + } + + // public void GenerateBindings() + // { + // Bindings = new Dictionary(); + // + // var bindables = + // ItemBindings.Select(id => new {id=id.Key, eq = id.Value.First().Hardpoint.Item.EquippedItemData}).ToList(); + // + // var weapons = bindables.Where(i => i.eq.HardpointType.IsWeapon()).ToArray(); + // + // var mouseButtons = Enumerable.Range((int) KeyCode.Mouse0, 3).Cast(); + // foreach (var x in weapons.Zip(mouseButtons, (binding, key) => new {binding,key})) + // { + // Bindings.Add(x.key, x.binding.id); + // bindables.Remove(x.binding); + // } + // + // var thruster = bindables.FirstOrDefault(x => x.eq.HardpointType == HardpointType.Thruster); + // if (thruster != null) + // { + // Bindings.Add(KeyCode.LeftShift, thruster.id); + // bindables.Remove(thruster); + // } + // + // var utility = bindables.FirstOrDefault(x => !x.eq.HardpointType.IsWeapon()); + // if (utility != null) + // { + // Bindings.Add(KeyCode.Space, utility.id); + // bindables.Remove(utility); + // } + // + // var numKeys = Enumerable.Range((int) KeyCode.Alpha1, 9).Cast(); + // foreach (var x in bindables.Zip(numKeys, (binding, key) => new {binding,key})) + // { + // Bindings.Add(x.key, x.binding.id); + // } + // + // } + + // public void Activate(KeyCode binding) + // { + // if (Bindings.ContainsKey(binding)) + // foreach (var behavior in ItemBindings[Bindings[binding]]) + // { + // behavior.Activate(); + // if(behavior.Hardpoint.ActionBarButton!=null) + // behavior.Hardpoint.ActionBarButton.Background.color = Color.yellow; + // } + // } + // + // public void Deactivate(KeyCode binding) + // { + // if(Bindings.ContainsKey(binding)) + // foreach (var behavior in ItemBindings[Bindings[binding]]) + // { + // behavior.Deactivate(); + // if(behavior.Hardpoint.ActionBarButton!=null) + // behavior.Hardpoint.ActionBarButton.Background.color = GlobalData.Instance.UnselectedElementColor; + // } + // } + + public void FixedUpdate(float delta) + { + foreach (var kvp in Contacts.ToArray()) + if (kvp.Key == null || Time.time - kvp.Value > GlobalData.Instance.TargetPersistenceDuration) + { + Contacts.Remove(kvp.Key); + if (kvp.Key == Target) + Target = null; + } + + if (_hydrated) + { + var hull = Database.Get(Hull.Data); + + var rad = pow(Temperature, GlobalData.Instance.HeatRadiationPower) * GlobalData.Instance.HeatRadiationMultiplier; + Temperature -= rad * delta; + VisibilitySources[this] = rad; + + foreach(var behavior in ItemBehaviors) + behavior.FixedUpdate(delta); + + foreach (var hardpoint in Hardpoints) + { + if (hardpoint.Item.EquippedItemData.Performance(Temperature) < .01f) + hardpoint.Item.Durability -= delta; + } + } + } + + public void Update(float delta) + { + foreach(var behavior in ItemBehaviors) + behavior.Update(delta); + } + + // public void UpdateInput(float delta) + // { + // foreach (var key in Bindings.Keys) + // { + // if(Input.GetKeyDown(key)) + // Activate(key); + // if(Input.GetKeyUp(key)) + // Deactivate(key); + // } + // + // } +} + +[MessagePackObject] +public class SimpleCommodity : IItemInstance +{ + [Key("data")] public Guid Data; + [Key("quantity")] public int Quantity; + [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + + [IgnoreMember] private ItemData _item; + [IgnoreMember] public Guid ItemGuid => Data; + [IgnoreMember] public IItem ItemData => _item ?? (_item = Database.Get(Data)); + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; + [IgnoreMember] public float Mass => ItemData.Data.Mass * Quantity; + + public static SimpleCommodity CreateInstance(Guid data, int count) + { + var item = Database.Get(data); + if (item != null) + return new SimpleCommodity + { + Data = data, + Quantity = count, + DatabaseEntry = new DatabaseEntry + { + ID = Guid.NewGuid(), + Name = item.Entry.Name + } + }; + + Debug.LogError("Attempted to create Simple Commodity instance using missing or incorrect item id"); + return null; + + } +} + +[MessagePackObject] +public class Gear : ICraftedItemInstance +{ + [Key("data")] public Guid Data; + [Key("durability")] public float Durability; + [Key("quality")] public float Quality; + [Key("ingredients")] public List Ingredients = new List(); + [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + + [IgnoreMember] private IEquippable _equippedItem; + + [IgnoreMember] public Guid ItemGuid => Data; + + [IgnoreMember] public IItem ItemData => EquippedItemData; + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; + + [IgnoreMember] public float CraftedQuality => Quality; + [IgnoreMember] public IEnumerable CraftedIngredients => Ingredients; + + [IgnoreMember] public IEquippable EquippedItemData => _equippedItem ?? (_equippedItem = Database.Get(Data)); + [IgnoreMember] public float Mass => ItemData.Data.Mass; + + public static Gear CreateInstance(Guid data) + { + var item = Database.Get(data); + if (item == null) + { + Debug.LogError("Attempted to create Gear instance using missing or incorrect item id"); + return null; + } + + var equippable = item.Equippable; + return new Gear + { + Data = data, + Durability = equippable.Durability, + Quality = Random.Range(.5f, 1), + Ingredients = item.CraftingIngredients.SelectMany(ci => + { + var ingredient = Database.Get(ci.Key); + return ingredient is ItemData + ? (IEnumerable) new[] {SimpleCommodity.CreateInstance(ci.Key, ci.Value)} + : Enumerable.Range(0, ci.Value).Select(i => CompoundCommodity.CreateInstance(ci.Key)); + }) + .ToList(), + DatabaseEntry = new DatabaseEntry + { + ID = Guid.NewGuid(), + Name = item.Entry.Name + } + }; + } +} + +[MessagePackObject] +public class CompoundCommodity : ICraftedItemInstance +{ + [Key("data")] public Guid Data; + [Key("quality")] public float Quality; + [Key("ingredients")] public List Ingredients = new List(); + [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); + + [IgnoreMember] private ICraftable _item; + + [IgnoreMember] public Guid ItemGuid => Data; + + [IgnoreMember] public IItem ItemData => _item ?? (_item = Database.Get(Data)); + [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; + + [IgnoreMember] public float CraftedQuality => Quality; + [IgnoreMember] public IEnumerable CraftedIngredients => Ingredients; + [IgnoreMember] public float Mass => ItemData.Data.Mass; + + public static CompoundCommodity CreateInstance(Guid data) + { + var item = Database.Get(data); + if (item != null) + return new CompoundCommodity + { + Data = data, + Quality = Random.Range(.5f, 1), + Ingredients = item.CraftingIngredients.SelectMany(ci => + { + var ingredient = Database.Get(ci.Key); + return ingredient is ItemData + ? (IEnumerable) new[] {SimpleCommodity.CreateInstance(ci.Key, ci.Value)} + : Enumerable.Range(0, ci.Value).Select(i => CreateInstance(ci.Key)); + }) + .ToList(), + DatabaseEntry = new DatabaseEntry + { + ID = Guid.NewGuid(), + Name = item.Entry.Name + } + }; + + Debug.LogError("Attempted to create Compound Commodity instance using missing or incorrect item id"); + return null; + + } +} diff --git a/Assets/Scripts/ItemInstance.cs.meta b/Assets/Scripts/ItemInstance.cs.meta new file mode 100644 index 000000000..cfa9048a0 --- /dev/null +++ b/Assets/Scripts/ItemInstance.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 99494d40ccacd2d46a84062749ed38aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/FastNoise.cs b/Assets/Scripts/NIH/FastNoise.cs deleted file mode 100644 index bc5736ca8..000000000 --- a/Assets/Scripts/NIH/FastNoise.cs +++ /dev/null @@ -1,2368 +0,0 @@ -// FastNoise.cs -// -// MIT License -// -// Copyright(c) 2017 Jordan Peck -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions : -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -// The developer's email is jorzixdan.me2@gzixmail.com (for great email, take -// off every 'zix'.) -// - -// Uncomment the line below to swap all the inputs/outputs/calculations of FastNoise to doubles instead of floats -//#define FN_USE_DOUBLES - -#if FN_USE_DOUBLES -using FN_DECIMAL = System.Double; -#else -using FN_DECIMAL = System.Single; -#endif - -using System; -using System.Runtime.CompilerServices; - -public class FastNoise -{ - private const Int16 FN_INLINE = 256; //(Int16)MethodImplOptions.AggressiveInlining; - private const int FN_CELLULAR_INDEX_MAX = 3; - - public enum NoiseType { Value, ValueFractal, Perlin, PerlinFractal, Simplex, SimplexFractal, Cellular, WhiteNoise, Cubic, CubicFractal }; - public enum Interp { Linear, Hermite, Quintic }; - public enum FractalType { FBM, Billow, RigidMulti }; - public enum CellularDistanceFunction { Euclidean, Manhattan, Natural }; - public enum CellularReturnType { CellValue, NoiseLookup, Distance, Distance2, Distance2Add, Distance2Sub, Distance2Mul, Distance2Div }; - - private int m_seed = 1337; - private FN_DECIMAL m_frequency = (FN_DECIMAL)0.01; - private Interp m_interp = Interp.Quintic; - private NoiseType m_noiseType = NoiseType.Simplex; - - private int m_octaves = 3; - private FN_DECIMAL m_lacunarity = (FN_DECIMAL)2.0; - private FN_DECIMAL m_gain = (FN_DECIMAL)0.5; - private FractalType m_fractalType = FractalType.FBM; - - private FN_DECIMAL m_fractalBounding; - - private CellularDistanceFunction m_cellularDistanceFunction = CellularDistanceFunction.Euclidean; - private CellularReturnType m_cellularReturnType = CellularReturnType.CellValue; - private FastNoise m_cellularNoiseLookup = null; - private int m_cellularDistanceIndex0 = 0; - private int m_cellularDistanceIndex1 = 1; - private float m_cellularJitter = 0.45f; - - private FN_DECIMAL m_gradientPerturbAmp = (FN_DECIMAL)1.0; - - public FastNoise(int seed = 1337) - { - m_seed = seed; - CalculateFractalBounding(); - } - - // Returns a 0 float/double - public static FN_DECIMAL GetDecimalType() { return 0; } - - // Returns the seed used by this object - public int GetSeed() { return m_seed; } - - // Sets seed used for all noise types - // Default: 1337 - public void SetSeed(int seed) { m_seed = seed; } - - // Sets frequency for all noise types - // Default: 0.01 - public void SetFrequency(FN_DECIMAL frequency) { m_frequency = frequency; } - - // Changes the interpolation method used to smooth between noise values - // Possible interpolation methods (lowest to highest quality) : - // - Linear - // - Hermite - // - Quintic - // Used in Value, Gradient Noise and Position Perturbing - // Default: Quintic - public void SetInterp(Interp interp) { m_interp = interp; } - - // Sets noise return type of GetNoise(...) - // Default: Simplex - public void SetNoiseType(NoiseType noiseType) { m_noiseType = noiseType; } - - - // Sets octave count for all fractal noise types - // Default: 3 - public void SetFractalOctaves(int octaves) { m_octaves = octaves; CalculateFractalBounding(); } - - // Sets octave lacunarity for all fractal noise types - // Default: 2.0 - public void SetFractalLacunarity(FN_DECIMAL lacunarity) { m_lacunarity = lacunarity; } - - // Sets octave gain for all fractal noise types - // Default: 0.5 - public void SetFractalGain(FN_DECIMAL gain) { m_gain = gain; CalculateFractalBounding(); } - - // Sets method for combining octaves in all fractal noise types - // Default: FBM - public void SetFractalType(FractalType fractalType) { m_fractalType = fractalType; } - - - // Sets return type from cellular noise calculations - // Note: NoiseLookup requires another FastNoise object be set with SetCellularNoiseLookup() to function - // Default: CellValue - public void SetCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) { m_cellularDistanceFunction = cellularDistanceFunction; } - - // Sets distance function used in cellular noise calculations - // Default: Euclidean - public void SetCellularReturnType(CellularReturnType cellularReturnType) { m_cellularReturnType = cellularReturnType; } - - // Sets the 2 distance indicies used for distance2 return types - // Default: 0, 1 - // Note: index0 should be lower than index1 - // Both indicies must be >= 0, index1 must be < 4 - public void SetCellularDistance2Indicies(int cellularDistanceIndex0, int cellularDistanceIndex1) - { - m_cellularDistanceIndex0 = Math.Min(cellularDistanceIndex0, cellularDistanceIndex1); - m_cellularDistanceIndex1 = Math.Max(cellularDistanceIndex0, cellularDistanceIndex1); - - m_cellularDistanceIndex0 = Math.Min(Math.Max(m_cellularDistanceIndex0, 0), FN_CELLULAR_INDEX_MAX); - m_cellularDistanceIndex1 = Math.Min(Math.Max(m_cellularDistanceIndex1, 0), FN_CELLULAR_INDEX_MAX); - } - - // Sets the maximum distance a cellular point can move from it's grid position - // Setting this high will make artifacts more common - // Default: 0.45 - public void SetCellularJitter(float cellularJitter) { m_cellularJitter = cellularJitter; } - - // Noise used to calculate a cell value if cellular return type is NoiseLookup - // The lookup value is acquired through GetNoise() so ensure you SetNoiseType() on the noise lookup, value, gradient or simplex is recommended - public void SetCellularNoiseLookup(FastNoise noise) { m_cellularNoiseLookup = noise; } - - - // Sets the maximum perturb distance from original location when using GradientPerturb{Fractal}(...) - // Default: 1.0 - public void SetGradientPerturbAmp(FN_DECIMAL gradientPerturbAmp) { m_gradientPerturbAmp = gradientPerturbAmp; } - - private struct Float2 - { - public readonly FN_DECIMAL x, y; - public Float2(FN_DECIMAL x, FN_DECIMAL y) - { - this.x = x; - this.y = y; - } - } - - private struct Float3 - { - public readonly FN_DECIMAL x, y, z; - public Float3(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - this.x = x; - this.y = y; - this.z = z; - } - } - - private static readonly Float2[] GRAD_2D = { - new Float2(-1,-1), new Float2( 1,-1), new Float2(-1, 1), new Float2( 1, 1), - new Float2( 0,-1), new Float2(-1, 0), new Float2( 0, 1), new Float2( 1, 0), - }; - - private static readonly Float3[] GRAD_3D = { - new Float3( 1, 1, 0), new Float3(-1, 1, 0), new Float3( 1,-1, 0), new Float3(-1,-1, 0), - new Float3( 1, 0, 1), new Float3(-1, 0, 1), new Float3( 1, 0,-1), new Float3(-1, 0,-1), - new Float3( 0, 1, 1), new Float3( 0,-1, 1), new Float3( 0, 1,-1), new Float3( 0,-1,-1), - new Float3( 1, 1, 0), new Float3( 0,-1, 1), new Float3(-1, 1, 0), new Float3( 0,-1,-1), - }; - - private static readonly Float2[] CELL_2D = - { - new Float2(-0.2700222198f, -0.9628540911f), new Float2(0.3863092627f, -0.9223693152f), new Float2(0.04444859006f, -0.999011673f), new Float2(-0.5992523158f, -0.8005602176f), new Float2(-0.7819280288f, 0.6233687174f), new Float2(0.9464672271f, 0.3227999196f), new Float2(-0.6514146797f, -0.7587218957f), new Float2(0.9378472289f, 0.347048376f), - new Float2(-0.8497875957f, -0.5271252623f), new Float2(-0.879042592f, 0.4767432447f), new Float2(-0.892300288f, -0.4514423508f), new Float2(-0.379844434f, -0.9250503802f), new Float2(-0.9951650832f, 0.0982163789f), new Float2(0.7724397808f, -0.6350880136f), new Float2(0.7573283322f, -0.6530343002f), new Float2(-0.9928004525f, -0.119780055f), - new Float2(-0.0532665713f, 0.9985803285f), new Float2(0.9754253726f, -0.2203300762f), new Float2(-0.7665018163f, 0.6422421394f), new Float2(0.991636706f, 0.1290606184f), new Float2(-0.994696838f, 0.1028503788f), new Float2(-0.5379205513f, -0.84299554f), new Float2(0.5022815471f, -0.8647041387f), new Float2(0.4559821461f, -0.8899889226f), - new Float2(-0.8659131224f, -0.5001944266f), new Float2(0.0879458407f, -0.9961252577f), new Float2(-0.5051684983f, 0.8630207346f), new Float2(0.7753185226f, -0.6315704146f), new Float2(-0.6921944612f, 0.7217110418f), new Float2(-0.5191659449f, -0.8546734591f), new Float2(0.8978622882f, -0.4402764035f), new Float2(-0.1706774107f, 0.9853269617f), - new Float2(-0.9353430106f, -0.3537420705f), new Float2(-0.9992404798f, 0.03896746794f), new Float2(-0.2882064021f, -0.9575683108f), new Float2(-0.9663811329f, 0.2571137995f), new Float2(-0.8759714238f, -0.4823630009f), new Float2(-0.8303123018f, -0.5572983775f), new Float2(0.05110133755f, -0.9986934731f), new Float2(-0.8558373281f, -0.5172450752f), - new Float2(0.09887025282f, 0.9951003332f), new Float2(0.9189016087f, 0.3944867976f), new Float2(-0.2439375892f, -0.9697909324f), new Float2(-0.8121409387f, -0.5834613061f), new Float2(-0.9910431363f, 0.1335421355f), new Float2(0.8492423985f, -0.5280031709f), new Float2(-0.9717838994f, -0.2358729591f), new Float2(0.9949457207f, 0.1004142068f), - new Float2(0.6241065508f, -0.7813392434f), new Float2(0.662910307f, 0.7486988212f), new Float2(-0.7197418176f, 0.6942418282f), new Float2(-0.8143370775f, -0.5803922158f), new Float2(0.104521054f, -0.9945226741f), new Float2(-0.1065926113f, -0.9943027784f), new Float2(0.445799684f, -0.8951327509f), new Float2(0.105547406f, 0.9944142724f), - new Float2(-0.992790267f, 0.1198644477f), new Float2(-0.8334366408f, 0.552615025f), new Float2(0.9115561563f, -0.4111755999f), new Float2(0.8285544909f, -0.5599084351f), new Float2(0.7217097654f, -0.6921957921f), new Float2(0.4940492677f, -0.8694339084f), new Float2(-0.3652321272f, -0.9309164803f), new Float2(-0.9696606758f, 0.2444548501f), - new Float2(0.08925509731f, -0.996008799f), new Float2(0.5354071276f, -0.8445941083f), new Float2(-0.1053576186f, 0.9944343981f), new Float2(-0.9890284586f, 0.1477251101f), new Float2(0.004856104961f, 0.9999882091f), new Float2(0.9885598478f, 0.1508291331f), new Float2(0.9286129562f, -0.3710498316f), new Float2(-0.5832393863f, -0.8123003252f), - new Float2(0.3015207509f, 0.9534596146f), new Float2(-0.9575110528f, 0.2883965738f), new Float2(0.9715802154f, -0.2367105511f), new Float2(0.229981792f, 0.9731949318f), new Float2(0.955763816f, -0.2941352207f), new Float2(0.740956116f, 0.6715534485f), new Float2(-0.9971513787f, -0.07542630764f), new Float2(0.6905710663f, -0.7232645452f), - new Float2(-0.290713703f, -0.9568100872f), new Float2(0.5912777791f, -0.8064679708f), new Float2(-0.9454592212f, -0.325740481f), new Float2(0.6664455681f, 0.74555369f), new Float2(0.6236134912f, 0.7817328275f), new Float2(0.9126993851f, -0.4086316587f), new Float2(-0.8191762011f, 0.5735419353f), new Float2(-0.8812745759f, -0.4726046147f), - new Float2(0.9953313627f, 0.09651672651f), new Float2(0.9855650846f, -0.1692969699f), new Float2(-0.8495980887f, 0.5274306472f), new Float2(0.6174853946f, -0.7865823463f), new Float2(0.8508156371f, 0.52546432f), new Float2(0.9985032451f, -0.05469249926f), new Float2(0.1971371563f, -0.9803759185f), new Float2(0.6607855748f, -0.7505747292f), - new Float2(-0.03097494063f, 0.9995201614f), new Float2(-0.6731660801f, 0.739491331f), new Float2(-0.7195018362f, -0.6944905383f), new Float2(0.9727511689f, 0.2318515979f), new Float2(0.9997059088f, -0.0242506907f), new Float2(0.4421787429f, -0.8969269532f), new Float2(0.9981350961f, -0.061043673f), new Float2(-0.9173660799f, -0.3980445648f), - new Float2(-0.8150056635f, -0.5794529907f), new Float2(-0.8789331304f, 0.4769450202f), new Float2(0.0158605829f, 0.999874213f), new Float2(-0.8095464474f, 0.5870558317f), new Float2(-0.9165898907f, -0.3998286786f), new Float2(-0.8023542565f, 0.5968480938f), new Float2(-0.5176737917f, 0.8555780767f), new Float2(-0.8154407307f, -0.5788405779f), - new Float2(0.4022010347f, -0.9155513791f), new Float2(-0.9052556868f, -0.4248672045f), new Float2(0.7317445619f, 0.6815789728f), new Float2(-0.5647632201f, -0.8252529947f), new Float2(-0.8403276335f, -0.5420788397f), new Float2(-0.9314281527f, 0.363925262f), new Float2(0.5238198472f, 0.8518290719f), new Float2(0.7432803869f, -0.6689800195f), - new Float2(-0.985371561f, -0.1704197369f), new Float2(0.4601468731f, 0.88784281f), new Float2(0.825855404f, 0.5638819483f), new Float2(0.6182366099f, 0.7859920446f), new Float2(0.8331502863f, -0.553046653f), new Float2(0.1500307506f, 0.9886813308f), new Float2(-0.662330369f, -0.7492119075f), new Float2(-0.668598664f, 0.743623444f), - new Float2(0.7025606278f, 0.7116238924f), new Float2(-0.5419389763f, -0.8404178401f), new Float2(-0.3388616456f, 0.9408362159f), new Float2(0.8331530315f, 0.5530425174f), new Float2(-0.2989720662f, -0.9542618632f), new Float2(0.2638522993f, 0.9645630949f), new Float2(0.124108739f, -0.9922686234f), new Float2(-0.7282649308f, -0.6852956957f), - new Float2(0.6962500149f, 0.7177993569f), new Float2(-0.9183535368f, 0.3957610156f), new Float2(-0.6326102274f, -0.7744703352f), new Float2(-0.9331891859f, -0.359385508f), new Float2(-0.1153779357f, -0.9933216659f), new Float2(0.9514974788f, -0.3076565421f), new Float2(-0.08987977445f, -0.9959526224f), new Float2(0.6678496916f, 0.7442961705f), - new Float2(0.7952400393f, -0.6062947138f), new Float2(-0.6462007402f, -0.7631674805f), new Float2(-0.2733598753f, 0.9619118351f), new Float2(0.9669590226f, -0.254931851f), new Float2(-0.9792894595f, 0.2024651934f), new Float2(-0.5369502995f, -0.8436138784f), new Float2(-0.270036471f, -0.9628500944f), new Float2(-0.6400277131f, 0.7683518247f), - new Float2(-0.7854537493f, -0.6189203566f), new Float2(0.06005905383f, -0.9981948257f), new Float2(-0.02455770378f, 0.9996984141f), new Float2(-0.65983623f, 0.751409442f), new Float2(-0.6253894466f, -0.7803127835f), new Float2(-0.6210408851f, -0.7837781695f), new Float2(0.8348888491f, 0.5504185768f), new Float2(-0.1592275245f, 0.9872419133f), - new Float2(0.8367622488f, 0.5475663786f), new Float2(-0.8675753916f, -0.4973056806f), new Float2(-0.2022662628f, -0.9793305667f), new Float2(0.9399189937f, 0.3413975472f), new Float2(0.9877404807f, -0.1561049093f), new Float2(-0.9034455656f, 0.4287028224f), new Float2(0.1269804218f, -0.9919052235f), new Float2(-0.3819600854f, 0.924178821f), - new Float2(0.9754625894f, 0.2201652486f), new Float2(-0.3204015856f, -0.9472818081f), new Float2(-0.9874760884f, 0.1577687387f), new Float2(0.02535348474f, -0.9996785487f), new Float2(0.4835130794f, -0.8753371362f), new Float2(-0.2850799925f, -0.9585037287f), new Float2(-0.06805516006f, -0.99768156f), new Float2(-0.7885244045f, -0.6150034663f), - new Float2(0.3185392127f, -0.9479096845f), new Float2(0.8880043089f, 0.4598351306f), new Float2(0.6476921488f, -0.7619021462f), new Float2(0.9820241299f, 0.1887554194f), new Float2(0.9357275128f, -0.3527237187f), new Float2(-0.8894895414f, 0.4569555293f), new Float2(0.7922791302f, 0.6101588153f), new Float2(0.7483818261f, 0.6632681526f), - new Float2(-0.7288929755f, -0.6846276581f), new Float2(0.8729032783f, -0.4878932944f), new Float2(0.8288345784f, 0.5594937369f), new Float2(0.08074567077f, 0.9967347374f), new Float2(0.9799148216f, -0.1994165048f), new Float2(-0.580730673f, -0.8140957471f), new Float2(-0.4700049791f, -0.8826637636f), new Float2(0.2409492979f, 0.9705377045f), - new Float2(0.9437816757f, -0.3305694308f), new Float2(-0.8927998638f, -0.4504535528f), new Float2(-0.8069622304f, 0.5906030467f), new Float2(0.06258973166f, 0.9980393407f), new Float2(-0.9312597469f, 0.3643559849f), new Float2(0.5777449785f, 0.8162173362f), new Float2(-0.3360095855f, -0.941858566f), new Float2(0.697932075f, -0.7161639607f), - new Float2(-0.002008157227f, -0.9999979837f), new Float2(-0.1827294312f, -0.9831632392f), new Float2(-0.6523911722f, 0.7578824173f), new Float2(-0.4302626911f, -0.9027037258f), new Float2(-0.9985126289f, -0.05452091251f), new Float2(-0.01028102172f, -0.9999471489f), new Float2(-0.4946071129f, 0.8691166802f), new Float2(-0.2999350194f, 0.9539596344f), - new Float2(0.8165471961f, 0.5772786819f), new Float2(0.2697460475f, 0.962931498f), new Float2(-0.7306287391f, -0.6827749597f), new Float2(-0.7590952064f, -0.6509796216f), new Float2(-0.907053853f, 0.4210146171f), new Float2(-0.5104861064f, -0.8598860013f), new Float2(0.8613350597f, 0.5080373165f), new Float2(0.5007881595f, -0.8655698812f), - new Float2(-0.654158152f, 0.7563577938f), new Float2(-0.8382755311f, -0.545246856f), new Float2(0.6940070834f, 0.7199681717f), new Float2(0.06950936031f, 0.9975812994f), new Float2(0.1702942185f, -0.9853932612f), new Float2(0.2695973274f, 0.9629731466f), new Float2(0.5519612192f, -0.8338697815f), new Float2(0.225657487f, -0.9742067022f), - new Float2(0.4215262855f, -0.9068161835f), new Float2(0.4881873305f, -0.8727388672f), new Float2(-0.3683854996f, -0.9296731273f), new Float2(-0.9825390578f, 0.1860564427f), new Float2(0.81256471f, 0.5828709909f), new Float2(0.3196460933f, -0.9475370046f), new Float2(0.9570913859f, 0.2897862643f), new Float2(-0.6876655497f, -0.7260276109f), - new Float2(-0.9988770922f, -0.047376731f), new Float2(-0.1250179027f, 0.992154486f), new Float2(-0.8280133617f, 0.560708367f), new Float2(0.9324863769f, -0.3612051451f), new Float2(0.6394653183f, 0.7688199442f), new Float2(-0.01623847064f, -0.9998681473f), new Float2(-0.9955014666f, -0.09474613458f), new Float2(-0.81453315f, 0.580117012f), - new Float2(0.4037327978f, -0.9148769469f), new Float2(0.9944263371f, 0.1054336766f), new Float2(-0.1624711654f, 0.9867132919f), new Float2(-0.9949487814f, -0.100383875f), new Float2(-0.6995302564f, 0.7146029809f), new Float2(0.5263414922f, -0.85027327f), new Float2(-0.5395221479f, 0.841971408f), new Float2(0.6579370318f, 0.7530729462f), - new Float2(0.01426758847f, -0.9998982128f), new Float2(-0.6734383991f, 0.7392433447f), new Float2(0.639412098f, -0.7688642071f), new Float2(0.9211571421f, 0.3891908523f), new Float2(-0.146637214f, -0.9891903394f), new Float2(-0.782318098f, 0.6228791163f), new Float2(-0.5039610839f, -0.8637263605f), new Float2(-0.7743120191f, -0.6328039957f), - }; - - private static readonly Float3[] CELL_3D = - { - new Float3(-0.7292736885f, -0.6618439697f, 0.1735581948f), new Float3(0.790292081f, -0.5480887466f, -0.2739291014f), new Float3(0.7217578935f, 0.6226212466f, -0.3023380997f), new Float3(0.565683137f, -0.8208298145f, -0.0790000257f), new Float3(0.760049034f, -0.5555979497f, -0.3370999617f), new Float3(0.3713945616f, 0.5011264475f, 0.7816254623f), new Float3(-0.1277062463f, -0.4254438999f, -0.8959289049f), new Float3(-0.2881560924f, -0.5815838982f, 0.7607405838f), - new Float3(0.5849561111f, -0.662820239f, -0.4674352136f), new Float3(0.3307171178f, 0.0391653737f, 0.94291689f), new Float3(0.8712121778f, -0.4113374369f, -0.2679381538f), new Float3(0.580981015f, 0.7021915846f, 0.4115677815f), new Float3(0.503756873f, 0.6330056931f, -0.5878203852f), new Float3(0.4493712205f, 0.601390195f, 0.6606022552f), new Float3(-0.6878403724f, 0.09018890807f, -0.7202371714f), new Float3(-0.5958956522f, -0.6469350577f, 0.475797649f), - new Float3(-0.5127052122f, 0.1946921978f, -0.8361987284f), new Float3(-0.9911507142f, -0.05410276466f, -0.1212153153f), new Float3(-0.2149721042f, 0.9720882117f, -0.09397607749f), new Float3(-0.7518650936f, -0.5428057603f, 0.3742469607f), new Float3(0.5237068895f, 0.8516377189f, -0.02107817834f), new Float3(0.6333504779f, 0.1926167129f, -0.7495104896f), new Float3(-0.06788241606f, 0.3998305789f, 0.9140719259f), new Float3(-0.5538628599f, -0.4729896695f, -0.6852128902f), - new Float3(-0.7261455366f, -0.5911990757f, 0.3509933228f), new Float3(-0.9229274737f, -0.1782808786f, 0.3412049336f), new Float3(-0.6968815002f, 0.6511274338f, 0.3006480328f), new Float3(0.9608044783f, -0.2098363234f, -0.1811724921f), new Float3(0.06817146062f, -0.9743405129f, 0.2145069156f), new Float3(-0.3577285196f, -0.6697087264f, -0.6507845481f), new Float3(-0.1868621131f, 0.7648617052f, -0.6164974636f), new Float3(-0.6541697588f, 0.3967914832f, 0.6439087246f), - new Float3(0.6993340405f, -0.6164538506f, 0.3618239211f), new Float3(-0.1546665739f, 0.6291283928f, 0.7617583057f), new Float3(-0.6841612949f, -0.2580482182f, -0.6821542638f), new Float3(0.5383980957f, 0.4258654885f, 0.7271630328f), new Float3(-0.5026987823f, -0.7939832935f, -0.3418836993f), new Float3(0.3202971715f, 0.2834415347f, 0.9039195862f), new Float3(0.8683227101f, -0.0003762656404f, -0.4959995258f), new Float3(0.791120031f, -0.08511045745f, 0.6057105799f), - new Float3(-0.04011016052f, -0.4397248749f, 0.8972364289f), new Float3(0.9145119872f, 0.3579346169f, -0.1885487608f), new Float3(-0.9612039066f, -0.2756484276f, 0.01024666929f), new Float3(0.6510361721f, -0.2877799159f, -0.7023778346f), new Float3(-0.2041786351f, 0.7365237271f, 0.644859585f), new Float3(-0.7718263711f, 0.3790626912f, 0.5104855816f), new Float3(-0.3060082741f, -0.7692987727f, 0.5608371729f), new Float3(0.454007341f, -0.5024843065f, 0.7357899537f), - new Float3(0.4816795475f, 0.6021208291f, -0.6367380315f), new Float3(0.6961980369f, -0.3222197429f, 0.641469197f), new Float3(-0.6532160499f, -0.6781148932f, 0.3368515753f), new Float3(0.5089301236f, -0.6154662304f, -0.6018234363f), new Float3(-0.1635919754f, -0.9133604627f, -0.372840892f), new Float3(0.52408019f, -0.8437664109f, 0.1157505864f), new Float3(0.5902587356f, 0.4983817807f, -0.6349883666f), new Float3(0.5863227872f, 0.494764745f, 0.6414307729f), - new Float3(0.6779335087f, 0.2341345225f, 0.6968408593f), new Float3(0.7177054546f, -0.6858979348f, 0.120178631f), new Float3(-0.5328819713f, -0.5205125012f, 0.6671608058f), new Float3(-0.8654874251f, -0.0700727088f, -0.4960053754f), new Float3(-0.2861810166f, 0.7952089234f, 0.5345495242f), new Float3(-0.04849529634f, 0.9810836427f, -0.1874115585f), new Float3(-0.6358521667f, 0.6058348682f, 0.4781800233f), new Float3(0.6254794696f, -0.2861619734f, 0.7258696564f), - new Float3(-0.2585259868f, 0.5061949264f, -0.8227581726f), new Float3(0.02136306781f, 0.5064016808f, -0.8620330371f), new Float3(0.200111773f, 0.8599263484f, 0.4695550591f), new Float3(0.4743561372f, 0.6014985084f, -0.6427953014f), new Float3(0.6622993731f, -0.5202474575f, -0.5391679918f), new Float3(0.08084972818f, -0.6532720452f, 0.7527940996f), new Float3(-0.6893687501f, 0.0592860349f, 0.7219805347f), new Float3(-0.1121887082f, -0.9673185067f, 0.2273952515f), - new Float3(0.7344116094f, 0.5979668656f, -0.3210532909f), new Float3(0.5789393465f, -0.2488849713f, 0.7764570201f), new Float3(0.6988182827f, 0.3557169806f, -0.6205791146f), new Float3(-0.8636845529f, -0.2748771249f, -0.4224826141f), new Float3(-0.4247027957f, -0.4640880967f, 0.777335046f), new Float3(0.5257722489f, -0.8427017621f, 0.1158329937f), new Float3(0.9343830603f, 0.316302472f, -0.1639543925f), new Float3(-0.1016836419f, -0.8057303073f, -0.5834887393f), - new Float3(-0.6529238969f, 0.50602126f, -0.5635892736f), new Float3(-0.2465286165f, -0.9668205684f, -0.06694497494f), new Float3(-0.9776897119f, -0.2099250524f, -0.007368825344f), new Float3(0.7736893337f, 0.5734244712f, 0.2694238123f), new Float3(-0.6095087895f, 0.4995678998f, 0.6155736747f), new Float3(0.5794535482f, 0.7434546771f, 0.3339292269f), new Float3(-0.8226211154f, 0.08142581855f, 0.5627293636f), new Float3(-0.510385483f, 0.4703667658f, 0.7199039967f), - new Float3(-0.5764971849f, -0.07231656274f, -0.8138926898f), new Float3(0.7250628871f, 0.3949971505f, -0.5641463116f), new Float3(-0.1525424005f, 0.4860840828f, -0.8604958341f), new Float3(-0.5550976208f, -0.4957820792f, 0.667882296f), new Float3(-0.1883614327f, 0.9145869398f, 0.357841725f), new Float3(0.7625556724f, -0.5414408243f, -0.3540489801f), new Float3(-0.5870231946f, -0.3226498013f, -0.7424963803f), new Float3(0.3051124198f, 0.2262544068f, -0.9250488391f), - new Float3(0.6379576059f, 0.577242424f, -0.5097070502f), new Float3(-0.5966775796f, 0.1454852398f, -0.7891830656f), new Float3(-0.658330573f, 0.6555487542f, -0.3699414651f), new Float3(0.7434892426f, 0.2351084581f, 0.6260573129f), new Float3(0.5562114096f, 0.8264360377f, -0.0873632843f), new Float3(-0.3028940016f, -0.8251527185f, 0.4768419182f), new Float3(0.1129343818f, -0.985888439f, -0.1235710781f), new Float3(0.5937652891f, -0.5896813806f, 0.5474656618f), - new Float3(0.6757964092f, -0.5835758614f, -0.4502648413f), new Float3(0.7242302609f, -0.1152719764f, 0.6798550586f), new Float3(-0.9511914166f, 0.0753623979f, -0.2992580792f), new Float3(0.2539470961f, -0.1886339355f, 0.9486454084f), new Float3(0.571433621f, -0.1679450851f, -0.8032795685f), new Float3(-0.06778234979f, 0.3978269256f, 0.9149531629f), new Float3(0.6074972649f, 0.733060024f, -0.3058922593f), new Float3(-0.5435478392f, 0.1675822484f, 0.8224791405f), - new Float3(-0.5876678086f, -0.3380045064f, -0.7351186982f), new Float3(-0.7967562402f, 0.04097822706f, -0.6029098428f), new Float3(-0.1996350917f, 0.8706294745f, 0.4496111079f), new Float3(-0.02787660336f, -0.9106232682f, -0.4122962022f), new Float3(-0.7797625996f, -0.6257634692f, 0.01975775581f), new Float3(-0.5211232846f, 0.7401644346f, -0.4249554471f), new Float3(0.8575424857f, 0.4053272873f, -0.3167501783f), new Float3(0.1045223322f, 0.8390195772f, -0.5339674439f), - new Float3(0.3501822831f, 0.9242524096f, -0.1520850155f), new Float3(0.1987849858f, 0.07647613266f, 0.9770547224f), new Float3(0.7845996363f, 0.6066256811f, -0.1280964233f), new Float3(0.09006737436f, -0.9750989929f, -0.2026569073f), new Float3(-0.8274343547f, -0.542299559f, 0.1458203587f), new Float3(-0.3485797732f, -0.415802277f, 0.840000362f), new Float3(-0.2471778936f, -0.7304819962f, -0.6366310879f), new Float3(-0.3700154943f, 0.8577948156f, 0.3567584454f), - new Float3(0.5913394901f, -0.548311967f, -0.5913303597f), new Float3(0.1204873514f, -0.7626472379f, -0.6354935001f), new Float3(0.616959265f, 0.03079647928f, 0.7863922953f), new Float3(0.1258156836f, -0.6640829889f, -0.7369967419f), new Float3(-0.6477565124f, -0.1740147258f, -0.7417077429f), new Float3(0.6217889313f, -0.7804430448f, -0.06547655076f), new Float3(0.6589943422f, -0.6096987708f, 0.4404473475f), new Float3(-0.2689837504f, -0.6732403169f, -0.6887635427f), - new Float3(-0.3849775103f, 0.5676542638f, 0.7277093879f), new Float3(0.5754444408f, 0.8110471154f, -0.1051963504f), new Float3(0.9141593684f, 0.3832947817f, 0.131900567f), new Float3(-0.107925319f, 0.9245493968f, 0.3654593525f), new Float3(0.377977089f, 0.3043148782f, 0.8743716458f), new Float3(-0.2142885215f, -0.8259286236f, 0.5214617324f), new Float3(0.5802544474f, 0.4148098596f, -0.7008834116f), new Float3(-0.1982660881f, 0.8567161266f, -0.4761596756f), - new Float3(-0.03381553704f, 0.3773180787f, -0.9254661404f), new Float3(-0.6867922841f, -0.6656597827f, 0.2919133642f), new Float3(0.7731742607f, -0.2875793547f, -0.5652430251f), new Float3(-0.09655941928f, 0.9193708367f, -0.3813575004f), new Float3(0.2715702457f, -0.9577909544f, -0.09426605581f), new Float3(0.2451015704f, -0.6917998565f, -0.6792188003f), new Float3(0.977700782f, -0.1753855374f, 0.1155036542f), new Float3(-0.5224739938f, 0.8521606816f, 0.02903615945f), - new Float3(-0.7734880599f, -0.5261292347f, 0.3534179531f), new Float3(-0.7134492443f, -0.269547243f, 0.6467878011f), new Float3(0.1644037271f, 0.5105846203f, -0.8439637196f), new Float3(0.6494635788f, 0.05585611296f, 0.7583384168f), new Float3(-0.4711970882f, 0.5017280509f, -0.7254255765f), new Float3(-0.6335764307f, -0.2381686273f, -0.7361091029f), new Float3(-0.9021533097f, -0.270947803f, -0.3357181763f), new Float3(-0.3793711033f, 0.872258117f, 0.3086152025f), - new Float3(-0.6855598966f, -0.3250143309f, 0.6514394162f), new Float3(0.2900942212f, -0.7799057743f, -0.5546100667f), new Float3(-0.2098319339f, 0.85037073f, 0.4825351604f), new Float3(-0.4592603758f, 0.6598504336f, -0.5947077538f), new Float3(0.8715945488f, 0.09616365406f, -0.4807031248f), new Float3(-0.6776666319f, 0.7118504878f, -0.1844907016f), new Float3(0.7044377633f, 0.312427597f, 0.637304036f), new Float3(-0.7052318886f, -0.2401093292f, -0.6670798253f), - new Float3(0.081921007f, -0.7207336136f, -0.6883545647f), new Float3(-0.6993680906f, -0.5875763221f, -0.4069869034f), new Float3(-0.1281454481f, 0.6419895885f, 0.7559286424f), new Float3(-0.6337388239f, -0.6785471501f, -0.3714146849f), new Float3(0.5565051903f, -0.2168887573f, -0.8020356851f), new Float3(-0.5791554484f, 0.7244372011f, -0.3738578718f), new Float3(0.1175779076f, -0.7096451073f, 0.6946792478f), new Float3(-0.6134619607f, 0.1323631078f, 0.7785527795f), - new Float3(0.6984635305f, -0.02980516237f, -0.715024719f), new Float3(0.8318082963f, -0.3930171956f, 0.3919597455f), new Float3(0.1469576422f, 0.05541651717f, -0.9875892167f), new Float3(0.708868575f, -0.2690503865f, 0.6520101478f), new Float3(0.2726053183f, 0.67369766f, -0.68688995f), new Float3(-0.6591295371f, 0.3035458599f, -0.6880466294f), new Float3(0.4815131379f, -0.7528270071f, 0.4487723203f), new Float3(0.9430009463f, 0.1675647412f, -0.2875261255f), - new Float3(0.434802957f, 0.7695304522f, -0.4677277752f), new Float3(0.3931996188f, 0.594473625f, 0.7014236729f), new Float3(0.7254336655f, -0.603925654f, 0.3301814672f), new Float3(0.7590235227f, -0.6506083235f, 0.02433313207f), new Float3(-0.8552768592f, -0.3430042733f, 0.3883935666f), new Float3(-0.6139746835f, 0.6981725247f, 0.3682257648f), new Float3(-0.7465905486f, -0.5752009504f, 0.3342849376f), new Float3(0.5730065677f, 0.810555537f, -0.1210916791f), - new Float3(-0.9225877367f, -0.3475211012f, -0.167514036f), new Float3(-0.7105816789f, -0.4719692027f, -0.5218416899f), new Float3(-0.08564609717f, 0.3583001386f, 0.929669703f), new Float3(-0.8279697606f, -0.2043157126f, 0.5222271202f), new Float3(0.427944023f, 0.278165994f, 0.8599346446f), new Float3(0.5399079671f, -0.7857120652f, -0.3019204161f), new Float3(0.5678404253f, -0.5495413974f, -0.6128307303f), new Float3(-0.9896071041f, 0.1365639107f, -0.04503418428f), - new Float3(-0.6154342638f, -0.6440875597f, 0.4543037336f), new Float3(0.1074204368f, -0.7946340692f, 0.5975094525f), new Float3(-0.3595449969f, -0.8885529948f, 0.28495784f), new Float3(-0.2180405296f, 0.1529888965f, 0.9638738118f), new Float3(-0.7277432317f, -0.6164050508f, -0.3007234646f), new Float3(0.7249729114f, -0.00669719484f, 0.6887448187f), new Float3(-0.5553659455f, -0.5336586252f, 0.6377908264f), new Float3(0.5137558015f, 0.7976208196f, -0.3160000073f), - new Float3(-0.3794024848f, 0.9245608561f, -0.03522751494f), new Float3(0.8229248658f, 0.2745365933f, -0.4974176556f), new Float3(-0.5404114394f, 0.6091141441f, 0.5804613989f), new Float3(0.8036581901f, -0.2703029469f, 0.5301601931f), new Float3(0.6044318879f, 0.6832968393f, 0.4095943388f), new Float3(0.06389988817f, 0.9658208605f, -0.2512108074f), new Float3(0.1087113286f, 0.7402471173f, -0.6634877936f), new Float3(-0.713427712f, -0.6926784018f, 0.1059128479f), - new Float3(0.6458897819f, -0.5724548511f, -0.5050958653f), new Float3(-0.6553931414f, 0.7381471625f, 0.159995615f), new Float3(0.3910961323f, 0.9188871375f, -0.05186755998f), new Float3(-0.4879022471f, -0.5904376907f, 0.6429111375f), new Float3(0.6014790094f, 0.7707441366f, -0.2101820095f), new Float3(-0.5677173047f, 0.7511360995f, 0.3368851762f), new Float3(0.7858573506f, 0.226674665f, 0.5753666838f), new Float3(-0.4520345543f, -0.604222686f, -0.6561857263f), - new Float3(0.002272116345f, 0.4132844051f, -0.9105991643f), new Float3(-0.5815751419f, -0.5162925989f, 0.6286591339f), new Float3(-0.03703704785f, 0.8273785755f, 0.5604221175f), new Float3(-0.5119692504f, 0.7953543429f, -0.3244980058f), new Float3(-0.2682417366f, -0.9572290247f, -0.1084387619f), new Float3(-0.2322482736f, -0.9679131102f, -0.09594243324f), new Float3(0.3554328906f, -0.8881505545f, 0.2913006227f), new Float3(0.7346520519f, -0.4371373164f, 0.5188422971f), - new Float3(0.9985120116f, 0.04659011161f, -0.02833944577f), new Float3(-0.3727687496f, -0.9082481361f, 0.1900757285f), new Float3(0.91737377f, -0.3483642108f, 0.1925298489f), new Float3(0.2714911074f, 0.4147529736f, -0.8684886582f), new Float3(0.5131763485f, -0.7116334161f, 0.4798207128f), new Float3(-0.8737353606f, 0.18886992f, -0.4482350644f), new Float3(0.8460043821f, -0.3725217914f, 0.3814499973f), new Float3(0.8978727456f, -0.1780209141f, -0.4026575304f), - new Float3(0.2178065647f, -0.9698322841f, -0.1094789531f), new Float3(-0.1518031304f, -0.7788918132f, -0.6085091231f), new Float3(-0.2600384876f, -0.4755398075f, -0.8403819825f), new Float3(0.572313509f, -0.7474340931f, -0.3373418503f), new Float3(-0.7174141009f, 0.1699017182f, -0.6756111411f), new Float3(-0.684180784f, 0.02145707593f, -0.7289967412f), new Float3(-0.2007447902f, 0.06555605789f, -0.9774476623f), new Float3(-0.1148803697f, -0.8044887315f, 0.5827524187f), - new Float3(-0.7870349638f, 0.03447489231f, 0.6159443543f), new Float3(-0.2015596421f, 0.6859872284f, 0.6991389226f), new Float3(-0.08581082512f, -0.10920836f, -0.9903080513f), new Float3(0.5532693395f, 0.7325250401f, -0.396610771f), new Float3(-0.1842489331f, -0.9777375055f, -0.1004076743f), new Float3(0.0775473789f, -0.9111505856f, 0.4047110257f), new Float3(0.1399838409f, 0.7601631212f, -0.6344734459f), new Float3(0.4484419361f, -0.845289248f, 0.2904925424f), - }; - - [MethodImplAttribute(FN_INLINE)] - private static int FastFloor(FN_DECIMAL f) { return (f >= 0 ? (int)f : (int)f - 1); } - - [MethodImplAttribute(FN_INLINE)] - private static int FastRound(FN_DECIMAL f) { return (f >= 0) ? (int)(f + (FN_DECIMAL)0.5) : (int)(f - (FN_DECIMAL)0.5); } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL Lerp(FN_DECIMAL a, FN_DECIMAL b, FN_DECIMAL t) { return a + t * (b - a); } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL InterpHermiteFunc(FN_DECIMAL t) { return t * t * (3 - 2 * t); } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL InterpQuinticFunc(FN_DECIMAL t) { return t * t * t * (t * (t * 6 - 15) + 10); } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL CubicLerp(FN_DECIMAL a, FN_DECIMAL b, FN_DECIMAL c, FN_DECIMAL d, FN_DECIMAL t) - { - FN_DECIMAL p = (d - c) - (a - b); - return t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b; - } - - private void CalculateFractalBounding() - { - FN_DECIMAL amp = m_gain; - FN_DECIMAL ampFractal = 1; - for (int i = 1; i < m_octaves; i++) - { - ampFractal += amp; - amp *= m_gain; - } - m_fractalBounding = 1 / ampFractal; - } - - // Hashing - private const int X_PRIME = 1619; - private const int Y_PRIME = 31337; - private const int Z_PRIME = 6971; - private const int W_PRIME = 1013; - - [MethodImplAttribute(FN_INLINE)] - private static int Hash2D(int seed, int x, int y) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - return hash; - } - - [MethodImplAttribute(FN_INLINE)] - private static int Hash3D(int seed, int x, int y, int z) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - hash ^= Z_PRIME * z; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - return hash; - } - - [MethodImplAttribute(FN_INLINE)] - private static int Hash4D(int seed, int x, int y, int z, int w) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - hash ^= Z_PRIME * z; - hash ^= W_PRIME * w; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - return hash; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL ValCoord2D(int seed, int x, int y) - { - int n = seed; - n ^= X_PRIME * x; - n ^= Y_PRIME * y; - - return (n * n * n * 60493) / (FN_DECIMAL)2147483648.0; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL ValCoord3D(int seed, int x, int y, int z) - { - int n = seed; - n ^= X_PRIME * x; - n ^= Y_PRIME * y; - n ^= Z_PRIME * z; - - return (n * n * n * 60493) / (FN_DECIMAL)2147483648.0; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL ValCoord4D(int seed, int x, int y, int z, int w) - { - int n = seed; - n ^= X_PRIME * x; - n ^= Y_PRIME * y; - n ^= Z_PRIME * z; - n ^= W_PRIME * w; - - return (n * n * n * 60493) / (FN_DECIMAL)2147483648.0; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL GradCoord2D(int seed, int x, int y, FN_DECIMAL xd, FN_DECIMAL yd) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - Float2 g = GRAD_2D[hash & 7]; - - return xd * g.x + yd * g.y; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL GradCoord3D(int seed, int x, int y, int z, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - hash ^= Z_PRIME * z; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - Float3 g = GRAD_3D[hash & 15]; - - return xd * g.x + yd * g.y + zd * g.z; - } - - [MethodImplAttribute(FN_INLINE)] - private static FN_DECIMAL GradCoord4D(int seed, int x, int y, int z, int w, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd, FN_DECIMAL wd) - { - int hash = seed; - hash ^= X_PRIME * x; - hash ^= Y_PRIME * y; - hash ^= Z_PRIME * z; - hash ^= W_PRIME * w; - - hash = hash * hash * hash * 60493; - hash = (hash >> 13) ^ hash; - - hash &= 31; - FN_DECIMAL a = yd, b = zd, c = wd; // X,Y,Z - switch (hash >> 3) - { // OR, DEPENDING ON HIGH ORDER 2 BITS: - case 1: a = wd; b = xd; c = yd; break; // W,X,Y - case 2: a = zd; b = wd; c = xd; break; // Z,W,X - case 3: a = yd; b = zd; c = wd; break; // Y,Z,W - } - return ((hash & 4) == 0 ? -a : a) + ((hash & 2) == 0 ? -b : b) + ((hash & 1) == 0 ? -c : c); - } - - public FN_DECIMAL GetNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_noiseType) - { - case NoiseType.Value: - return SingleValue(m_seed, x, y, z); - case NoiseType.ValueFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleValueFractalFBM(x, y, z); - case FractalType.Billow: - return SingleValueFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleValueFractalRigidMulti(x, y, z); - default: - return 0; - } - case NoiseType.Perlin: - return SinglePerlin(m_seed, x, y, z); - case NoiseType.PerlinFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SinglePerlinFractalFBM(x, y, z); - case FractalType.Billow: - return SinglePerlinFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SinglePerlinFractalRigidMulti(x, y, z); - default: - return 0; - } - case NoiseType.Simplex: - return SingleSimplex(m_seed, x, y, z); - case NoiseType.SimplexFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleSimplexFractalFBM(x, y, z); - case FractalType.Billow: - return SingleSimplexFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleSimplexFractalRigidMulti(x, y, z); - default: - return 0; - } - case NoiseType.Cellular: - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - case CellularReturnType.NoiseLookup: - case CellularReturnType.Distance: - return SingleCellular(x, y, z); - default: - return SingleCellular2Edge(x, y, z); - } - case NoiseType.WhiteNoise: - return GetWhiteNoise(x, y, z); - case NoiseType.Cubic: - return SingleCubic(m_seed, x, y, z); - case NoiseType.CubicFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleCubicFractalFBM(x, y, z); - case FractalType.Billow: - return SingleCubicFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleCubicFractalRigidMulti(x, y, z); - default: - return 0; - } - default: - return 0; - } - } - - public FN_DECIMAL GetNoise(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_noiseType) - { - case NoiseType.Value: - return SingleValue(m_seed, x, y); - case NoiseType.ValueFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleValueFractalFBM(x, y); - case FractalType.Billow: - return SingleValueFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleValueFractalRigidMulti(x, y); - default: - return 0; - } - case NoiseType.Perlin: - return SinglePerlin(m_seed, x, y); - case NoiseType.PerlinFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SinglePerlinFractalFBM(x, y); - case FractalType.Billow: - return SinglePerlinFractalBillow(x, y); - case FractalType.RigidMulti: - return SinglePerlinFractalRigidMulti(x, y); - default: - return 0; - } - case NoiseType.Simplex: - return SingleSimplex(m_seed, x, y); - case NoiseType.SimplexFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleSimplexFractalFBM(x, y); - case FractalType.Billow: - return SingleSimplexFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleSimplexFractalRigidMulti(x, y); - default: - return 0; - } - case NoiseType.Cellular: - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - case CellularReturnType.NoiseLookup: - case CellularReturnType.Distance: - return SingleCellular(x, y); - default: - return SingleCellular2Edge(x, y); - } - case NoiseType.WhiteNoise: - return GetWhiteNoise(x, y); - case NoiseType.Cubic: - return SingleCubic(m_seed, x, y); - case NoiseType.CubicFractal: - switch (m_fractalType) - { - case FractalType.FBM: - return SingleCubicFractalFBM(x, y); - case FractalType.Billow: - return SingleCubicFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleCubicFractalRigidMulti(x, y); - default: - return 0; - } - default: - return 0; - } - } - - // White Noise - [MethodImplAttribute(FN_INLINE)] - private int FloatCast2Int(FN_DECIMAL f) - { - var i = BitConverter.DoubleToInt64Bits(f); - - return (int)(i ^ (i >> 32)); - } - - public FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) - { - int xi = FloatCast2Int(x); - int yi = FloatCast2Int(y); - int zi = FloatCast2Int(z); - int wi = FloatCast2Int(w); - - return ValCoord4D(m_seed, xi, yi, zi, wi); - } - - public FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int xi = FloatCast2Int(x); - int yi = FloatCast2Int(y); - int zi = FloatCast2Int(z); - - return ValCoord3D(m_seed, xi, yi, zi); - } - - public FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y) - { - int xi = FloatCast2Int(x); - int yi = FloatCast2Int(y); - - return ValCoord2D(m_seed, xi, yi); - } - - public FN_DECIMAL GetWhiteNoiseInt(int x, int y, int z, int w) - { - return ValCoord4D(m_seed, x, y, z, w); - } - - public FN_DECIMAL GetWhiteNoiseInt(int x, int y, int z) - { - return ValCoord3D(m_seed, x, y, z); - } - - public FN_DECIMAL GetWhiteNoiseInt(int x, int y) - { - return ValCoord2D(m_seed, x, y); - } - - // Value Noise - public FN_DECIMAL GetValueFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleValueFractalFBM(x, y, z); - case FractalType.Billow: - return SingleValueFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleValueFractalRigidMulti(x, y, z); - default: - return 0; - } - } - - private FN_DECIMAL SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = SingleValue(seed, x, y, z); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += SingleValue(++seed, x, y, z) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleValue(seed, x, y, z)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SingleValue(++seed, x, y, z)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleValue(seed, x, y, z)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleValue(++seed, x, y, z))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetValue(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - return SingleValue(m_seed, x * m_frequency, y * m_frequency, z * m_frequency); - } - - private FN_DECIMAL SingleValue(int seed, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int z0 = FastFloor(z); - int x1 = x0 + 1; - int y1 = y0 + 1; - int z1 = z0 + 1; - - FN_DECIMAL xs, ys, zs; - switch (m_interp) - { - default: - case Interp.Linear: - xs = x - x0; - ys = y - y0; - zs = z - z0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - zs = InterpHermiteFunc(z - z0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - zs = InterpQuinticFunc(z - z0); - break; - } - - FN_DECIMAL xf00 = Lerp(ValCoord3D(seed, x0, y0, z0), ValCoord3D(seed, x1, y0, z0), xs); - FN_DECIMAL xf10 = Lerp(ValCoord3D(seed, x0, y1, z0), ValCoord3D(seed, x1, y1, z0), xs); - FN_DECIMAL xf01 = Lerp(ValCoord3D(seed, x0, y0, z1), ValCoord3D(seed, x1, y0, z1), xs); - FN_DECIMAL xf11 = Lerp(ValCoord3D(seed, x0, y1, z1), ValCoord3D(seed, x1, y1, z1), xs); - - FN_DECIMAL yf0 = Lerp(xf00, xf10, ys); - FN_DECIMAL yf1 = Lerp(xf01, xf11, ys); - - return Lerp(yf0, yf1, zs); - } - - public FN_DECIMAL GetValueFractal(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleValueFractalFBM(x, y); - case FractalType.Billow: - return SingleValueFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleValueFractalRigidMulti(x, y); - default: - return 0; - } - } - - private FN_DECIMAL SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = SingleValue(seed, x, y); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += SingleValue(++seed, x, y) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleValue(seed, x, y)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - amp *= m_gain; - sum += (Math.Abs(SingleValue(++seed, x, y)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleValue(seed, x, y)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleValue(++seed, x, y))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetValue(FN_DECIMAL x, FN_DECIMAL y) - { - return SingleValue(m_seed, x * m_frequency, y * m_frequency); - } - - private FN_DECIMAL SingleValue(int seed, FN_DECIMAL x, FN_DECIMAL y) - { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int x1 = x0 + 1; - int y1 = y0 + 1; - - FN_DECIMAL xs, ys; - switch (m_interp) - { - default: - case Interp.Linear: - xs = x - x0; - ys = y - y0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - break; - } - - FN_DECIMAL xf0 = Lerp(ValCoord2D(seed, x0, y0), ValCoord2D(seed, x1, y0), xs); - FN_DECIMAL xf1 = Lerp(ValCoord2D(seed, x0, y1), ValCoord2D(seed, x1, y1), xs); - - return Lerp(xf0, xf1, ys); - } - - // Gradient Noise - public FN_DECIMAL GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SinglePerlinFractalFBM(x, y, z); - case FractalType.Billow: - return SinglePerlinFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SinglePerlinFractalRigidMulti(x, y, z); - default: - return 0; - } - } - - private FN_DECIMAL SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = SinglePerlin(seed, x, y, z); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += SinglePerlin(++seed, x, y, z) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SinglePerlin(seed, x, y, z)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SinglePerlin(++seed, x, y, z)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SinglePerlin(seed, x, y, z)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SinglePerlin(++seed, x, y, z))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetPerlin(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - return SinglePerlin(m_seed, x * m_frequency, y * m_frequency, z * m_frequency); - } - - private FN_DECIMAL SinglePerlin(int seed, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int z0 = FastFloor(z); - int x1 = x0 + 1; - int y1 = y0 + 1; - int z1 = z0 + 1; - - FN_DECIMAL xs, ys, zs; - switch (m_interp) - { - default: - case Interp.Linear: - xs = x - x0; - ys = y - y0; - zs = z - z0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - zs = InterpHermiteFunc(z - z0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - zs = InterpQuinticFunc(z - z0); - break; - } - - FN_DECIMAL xd0 = x - x0; - FN_DECIMAL yd0 = y - y0; - FN_DECIMAL zd0 = z - z0; - FN_DECIMAL xd1 = xd0 - 1; - FN_DECIMAL yd1 = yd0 - 1; - FN_DECIMAL zd1 = zd0 - 1; - - FN_DECIMAL xf00 = Lerp(GradCoord3D(seed, x0, y0, z0, xd0, yd0, zd0), GradCoord3D(seed, x1, y0, z0, xd1, yd0, zd0), xs); - FN_DECIMAL xf10 = Lerp(GradCoord3D(seed, x0, y1, z0, xd0, yd1, zd0), GradCoord3D(seed, x1, y1, z0, xd1, yd1, zd0), xs); - FN_DECIMAL xf01 = Lerp(GradCoord3D(seed, x0, y0, z1, xd0, yd0, zd1), GradCoord3D(seed, x1, y0, z1, xd1, yd0, zd1), xs); - FN_DECIMAL xf11 = Lerp(GradCoord3D(seed, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(seed, x1, y1, z1, xd1, yd1, zd1), xs); - - FN_DECIMAL yf0 = Lerp(xf00, xf10, ys); - FN_DECIMAL yf1 = Lerp(xf01, xf11, ys); - - return Lerp(yf0, yf1, zs); - } - - public FN_DECIMAL GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SinglePerlinFractalFBM(x, y); - case FractalType.Billow: - return SinglePerlinFractalBillow(x, y); - case FractalType.RigidMulti: - return SinglePerlinFractalRigidMulti(x, y); - default: - return 0; - } - } - - private FN_DECIMAL SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = SinglePerlin(seed, x, y); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += SinglePerlin(++seed, x, y) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SinglePerlin(seed, x, y)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SinglePerlin(++seed, x, y)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SinglePerlin(seed, x, y)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SinglePerlin(++seed, x, y))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetPerlin(FN_DECIMAL x, FN_DECIMAL y) - { - return SinglePerlin(m_seed, x * m_frequency, y * m_frequency); - } - - private FN_DECIMAL SinglePerlin(int seed, FN_DECIMAL x, FN_DECIMAL y) - { - int x0 = FastFloor(x); - int y0 = FastFloor(y); - int x1 = x0 + 1; - int y1 = y0 + 1; - - FN_DECIMAL xs, ys; - switch (m_interp) - { - default: - case Interp.Linear: - xs = x - x0; - ys = y - y0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(x - x0); - ys = InterpHermiteFunc(y - y0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(x - x0); - ys = InterpQuinticFunc(y - y0); - break; - } - - FN_DECIMAL xd0 = x - x0; - FN_DECIMAL yd0 = y - y0; - FN_DECIMAL xd1 = xd0 - 1; - FN_DECIMAL yd1 = yd0 - 1; - - FN_DECIMAL xf0 = Lerp(GradCoord2D(seed, x0, y0, xd0, yd0), GradCoord2D(seed, x1, y0, xd1, yd0), xs); - FN_DECIMAL xf1 = Lerp(GradCoord2D(seed, x0, y1, xd0, yd1), GradCoord2D(seed, x1, y1, xd1, yd1), xs); - - return Lerp(xf0, xf1, ys); - } - - // Simplex Noise - public FN_DECIMAL GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleSimplexFractalFBM(x, y, z); - case FractalType.Billow: - return SingleSimplexFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleSimplexFractalRigidMulti(x, y, z); - default: - return 0; - } - } - - private FN_DECIMAL SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = SingleSimplex(seed, x, y, z); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += SingleSimplex(++seed, x, y, z) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleSimplex(seed, x, y, z)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SingleSimplex(++seed, x, y, z)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleSimplex(seed, x, y, z)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleSimplex(++seed, x, y, z))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - return SingleSimplex(m_seed, x * m_frequency, y * m_frequency, z * m_frequency); - } - - private const FN_DECIMAL F3 = (FN_DECIMAL)(1.0 / 3.0); - private const FN_DECIMAL G3 = (FN_DECIMAL)(1.0 / 6.0); - private const FN_DECIMAL G33 = G3 * 3 - 1; - - private FN_DECIMAL SingleSimplex(int seed, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - FN_DECIMAL t = (x + y + z) * F3; - int i = FastFloor(x + t); - int j = FastFloor(y + t); - int k = FastFloor(z + t); - - t = (i + j + k) * G3; - FN_DECIMAL x0 = x - (i - t); - FN_DECIMAL y0 = y - (j - t); - FN_DECIMAL z0 = z - (k - t); - - int i1, j1, k1; - int i2, j2, k2; - - if (x0 >= y0) - { - if (y0 >= z0) - { - i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; - } - else if (x0 >= z0) - { - i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; - } - else // x0 < z0 - { - i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; - } - } - else // x0 < y0 - { - if (y0 < z0) - { - i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; - } - else if (x0 < z0) - { - i1 = 0; j1 = 1; k1 = 0; i2 = 0; j2 = 1; k2 = 1; - } - else // x0 >= z0 - { - i1 = 0; j1 = 1; k1 = 0; i2 = 1; j2 = 1; k2 = 0; - } - } - - FN_DECIMAL x1 = x0 - i1 + G3; - FN_DECIMAL y1 = y0 - j1 + G3; - FN_DECIMAL z1 = z0 - k1 + G3; - FN_DECIMAL x2 = x0 - i2 + F3; - FN_DECIMAL y2 = y0 - j2 + F3; - FN_DECIMAL z2 = z0 - k2 + F3; - FN_DECIMAL x3 = x0 + G33; - FN_DECIMAL y3 = y0 + G33; - FN_DECIMAL z3 = z0 + G33; - - FN_DECIMAL n0, n1, n2, n3; - - t = (FN_DECIMAL)0.6 - x0 * x0 - y0 * y0 - z0 * z0; - if (t < 0) n0 = 0; - else - { - t *= t; - n0 = t * t * GradCoord3D(seed, i, j, k, x0, y0, z0); - } - - t = (FN_DECIMAL)0.6 - x1 * x1 - y1 * y1 - z1 * z1; - if (t < 0) n1 = 0; - else - { - t *= t; - n1 = t * t * GradCoord3D(seed, i + i1, j + j1, k + k1, x1, y1, z1); - } - - t = (FN_DECIMAL)0.6 - x2 * x2 - y2 * y2 - z2 * z2; - if (t < 0) n2 = 0; - else - { - t *= t; - n2 = t * t * GradCoord3D(seed, i + i2, j + j2, k + k2, x2, y2, z2); - } - - t = (FN_DECIMAL)0.6 - x3 * x3 - y3 * y3 - z3 * z3; - if (t < 0) n3 = 0; - else - { - t *= t; - n3 = t * t * GradCoord3D(seed, i + 1, j + 1, k + 1, x3, y3, z3); - } - - return 32 * (n0 + n1 + n2 + n3); - } - - public FN_DECIMAL GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleSimplexFractalFBM(x, y); - case FractalType.Billow: - return SingleSimplexFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleSimplexFractalRigidMulti(x, y); - default: - return 0; - } - } - - private FN_DECIMAL SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = SingleSimplex(seed, x, y); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += SingleSimplex(++seed, x, y) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleSimplex(seed, x, y)) * 2 - 1; - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SingleSimplex(++seed, x, y)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleSimplex(seed, x, y)); - FN_DECIMAL amp = 1; - - for (int i = 1; i < m_octaves; i++) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleSimplex(++seed, x, y))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y) - { - return SingleSimplex(m_seed, x * m_frequency, y * m_frequency); - } - - private const FN_DECIMAL F2 = (FN_DECIMAL)(1.0 / 2.0); - private const FN_DECIMAL G2 = (FN_DECIMAL)(1.0 / 4.0); - - private FN_DECIMAL SingleSimplex(int seed, FN_DECIMAL x, FN_DECIMAL y) - { - FN_DECIMAL t = (x + y) * F2; - int i = FastFloor(x + t); - int j = FastFloor(y + t); - - t = (i + j) * G2; - FN_DECIMAL X0 = i - t; - FN_DECIMAL Y0 = j - t; - - FN_DECIMAL x0 = x - X0; - FN_DECIMAL y0 = y - Y0; - - int i1, j1; - if (x0 > y0) - { - i1 = 1; j1 = 0; - } - else - { - i1 = 0; j1 = 1; - } - - FN_DECIMAL x1 = x0 - i1 + G2; - FN_DECIMAL y1 = y0 - j1 + G2; - FN_DECIMAL x2 = x0 - 1 + F2; - FN_DECIMAL y2 = y0 - 1 + F2; - - FN_DECIMAL n0, n1, n2; - - t = (FN_DECIMAL)0.5 - x0 * x0 - y0 * y0; - if (t < 0) n0 = 0; - else - { - t *= t; - n0 = t * t * GradCoord2D(seed, i, j, x0, y0); - } - - t = (FN_DECIMAL)0.5 - x1 * x1 - y1 * y1; - if (t < 0) n1 = 0; - else - { - t *= t; - n1 = t * t * GradCoord2D(seed, i + i1, j + j1, x1, y1); - } - - t = (FN_DECIMAL)0.5 - x2 * x2 - y2 * y2; - if (t < 0) n2 = 0; - else - { - t *= t; - n2 = t * t * GradCoord2D(seed, i + 1, j + 1, x2, y2); - } - - return 50 * (n0 + n1 + n2); - } - - public FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) - { - return SingleSimplex(m_seed, x * m_frequency, y * m_frequency, z * m_frequency, w * m_frequency); - } - - private static readonly byte[] SIMPLEX_4D = - { - 0,1,2,3,0,1,3,2,0,0,0,0,0,2,3,1,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,0, - 0,2,1,3,0,0,0,0,0,3,1,2,0,3,2,1,0,0,0,0,0,0,0,0,0,0,0,0,1,3,2,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,2,0,3,0,0,0,0,1,3,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,3,0,1,2,3,1,0, - 1,0,2,3,1,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,3,1,0,0,0,0,2,1,3,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 2,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,3,0,1,2,3,0,2,1,0,0,0,0,3,1,2,0, - 2,1,0,3,0,0,0,0,0,0,0,0,0,0,0,0,3,1,0,2,0,0,0,0,3,2,0,1,3,2,1,0 - }; - - private const FN_DECIMAL F4 = (FN_DECIMAL)((2.23606797 - 1.0) / 4.0); - private const FN_DECIMAL G4 = (FN_DECIMAL)((5.0 - 2.23606797) / 20.0); - - private FN_DECIMAL SingleSimplex(int seed, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) - { - FN_DECIMAL n0, n1, n2, n3, n4; - FN_DECIMAL t = (x + y + z + w) * F4; - int i = FastFloor(x + t); - int j = FastFloor(y + t); - int k = FastFloor(z + t); - int l = FastFloor(w + t); - t = (i + j + k + l) * G4; - FN_DECIMAL X0 = i - t; - FN_DECIMAL Y0 = j - t; - FN_DECIMAL Z0 = k - t; - FN_DECIMAL W0 = l - t; - FN_DECIMAL x0 = x - X0; - FN_DECIMAL y0 = y - Y0; - FN_DECIMAL z0 = z - Z0; - FN_DECIMAL w0 = w - W0; - - int c = (x0 > y0) ? 32 : 0; - c += (x0 > z0) ? 16 : 0; - c += (y0 > z0) ? 8 : 0; - c += (x0 > w0) ? 4 : 0; - c += (y0 > w0) ? 2 : 0; - c += (z0 > w0) ? 1 : 0; - c <<= 2; - - int i1 = SIMPLEX_4D[c] >= 3 ? 1 : 0; - int i2 = SIMPLEX_4D[c] >= 2 ? 1 : 0; - int i3 = SIMPLEX_4D[c++] >= 1 ? 1 : 0; - int j1 = SIMPLEX_4D[c] >= 3 ? 1 : 0; - int j2 = SIMPLEX_4D[c] >= 2 ? 1 : 0; - int j3 = SIMPLEX_4D[c++] >= 1 ? 1 : 0; - int k1 = SIMPLEX_4D[c] >= 3 ? 1 : 0; - int k2 = SIMPLEX_4D[c] >= 2 ? 1 : 0; - int k3 = SIMPLEX_4D[c++] >= 1 ? 1 : 0; - int l1 = SIMPLEX_4D[c] >= 3 ? 1 : 0; - int l2 = SIMPLEX_4D[c] >= 2 ? 1 : 0; - int l3 = SIMPLEX_4D[c] >= 1 ? 1 : 0; - - FN_DECIMAL x1 = x0 - i1 + G4; - FN_DECIMAL y1 = y0 - j1 + G4; - FN_DECIMAL z1 = z0 - k1 + G4; - FN_DECIMAL w1 = w0 - l1 + G4; - FN_DECIMAL x2 = x0 - i2 + 2 * G4; - FN_DECIMAL y2 = y0 - j2 + 2 * G4; - FN_DECIMAL z2 = z0 - k2 + 2 * G4; - FN_DECIMAL w2 = w0 - l2 + 2 * G4; - FN_DECIMAL x3 = x0 - i3 + 3 * G4; - FN_DECIMAL y3 = y0 - j3 + 3 * G4; - FN_DECIMAL z3 = z0 - k3 + 3 * G4; - FN_DECIMAL w3 = w0 - l3 + 3 * G4; - FN_DECIMAL x4 = x0 - 1 + 4 * G4; - FN_DECIMAL y4 = y0 - 1 + 4 * G4; - FN_DECIMAL z4 = z0 - 1 + 4 * G4; - FN_DECIMAL w4 = w0 - 1 + 4 * G4; - - t = (FN_DECIMAL)0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; - if (t < 0) n0 = 0; - else - { - t *= t; - n0 = t * t * GradCoord4D(seed, i, j, k, l, x0, y0, z0, w0); - } - t = (FN_DECIMAL)0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; - if (t < 0) n1 = 0; - else - { - t *= t; - n1 = t * t * GradCoord4D(seed, i + i1, j + j1, k + k1, l + l1, x1, y1, z1, w1); - } - t = (FN_DECIMAL)0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; - if (t < 0) n2 = 0; - else - { - t *= t; - n2 = t * t * GradCoord4D(seed, i + i2, j + j2, k + k2, l + l2, x2, y2, z2, w2); - } - t = (FN_DECIMAL)0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; - if (t < 0) n3 = 0; - else - { - t *= t; - n3 = t * t * GradCoord4D(seed, i + i3, j + j3, k + k3, l + l3, x3, y3, z3, w3); - } - t = (FN_DECIMAL)0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; - if (t < 0) n4 = 0; - else - { - t *= t; - n4 = t * t * GradCoord4D(seed, i + 1, j + 1, k + 1, l + 1, x4, y4, z4, w4); - } - - return 27 * (n0 + n1 + n2 + n3 + n4); - } - - // Cubic Noise - public FN_DECIMAL GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleCubicFractalFBM(x, y, z); - case FractalType.Billow: - return SingleCubicFractalBillow(x, y, z); - case FractalType.RigidMulti: - return SingleCubicFractalRigidMulti(x, y, z); - default: - return 0; - } - } - - private FN_DECIMAL SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = SingleCubic(seed, x, y, z); - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += SingleCubic(++seed, x, y, z) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleCubic(seed, x, y, z)) * 2 - 1; - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SingleCubic(++seed, x, y, z)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleCubic(seed, x, y, z)); - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - z *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleCubic(++seed, x, y, z))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetCubic(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - return SingleCubic(m_seed, x * m_frequency, y * m_frequency, z * m_frequency); - } - - private const FN_DECIMAL CUBIC_3D_BOUNDING = 1 / (FN_DECIMAL)(1.5 * 1.5 * 1.5); - - private FN_DECIMAL SingleCubic(int seed, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int x1 = FastFloor(x); - int y1 = FastFloor(y); - int z1 = FastFloor(z); - - int x0 = x1 - 1; - int y0 = y1 - 1; - int z0 = z1 - 1; - int x2 = x1 + 1; - int y2 = y1 + 1; - int z2 = z1 + 1; - int x3 = x1 + 2; - int y3 = y1 + 2; - int z3 = z1 + 2; - - FN_DECIMAL xs = x - (FN_DECIMAL)x1; - FN_DECIMAL ys = y - (FN_DECIMAL)y1; - FN_DECIMAL zs = z - (FN_DECIMAL)z1; - - return CubicLerp( - CubicLerp( - CubicLerp(ValCoord3D(seed, x0, y0, z0), ValCoord3D(seed, x1, y0, z0), ValCoord3D(seed, x2, y0, z0), ValCoord3D(seed, x3, y0, z0), xs), - CubicLerp(ValCoord3D(seed, x0, y1, z0), ValCoord3D(seed, x1, y1, z0), ValCoord3D(seed, x2, y1, z0), ValCoord3D(seed, x3, y1, z0), xs), - CubicLerp(ValCoord3D(seed, x0, y2, z0), ValCoord3D(seed, x1, y2, z0), ValCoord3D(seed, x2, y2, z0), ValCoord3D(seed, x3, y2, z0), xs), - CubicLerp(ValCoord3D(seed, x0, y3, z0), ValCoord3D(seed, x1, y3, z0), ValCoord3D(seed, x2, y3, z0), ValCoord3D(seed, x3, y3, z0), xs), - ys), - CubicLerp( - CubicLerp(ValCoord3D(seed, x0, y0, z1), ValCoord3D(seed, x1, y0, z1), ValCoord3D(seed, x2, y0, z1), ValCoord3D(seed, x3, y0, z1), xs), - CubicLerp(ValCoord3D(seed, x0, y1, z1), ValCoord3D(seed, x1, y1, z1), ValCoord3D(seed, x2, y1, z1), ValCoord3D(seed, x3, y1, z1), xs), - CubicLerp(ValCoord3D(seed, x0, y2, z1), ValCoord3D(seed, x1, y2, z1), ValCoord3D(seed, x2, y2, z1), ValCoord3D(seed, x3, y2, z1), xs), - CubicLerp(ValCoord3D(seed, x0, y3, z1), ValCoord3D(seed, x1, y3, z1), ValCoord3D(seed, x2, y3, z1), ValCoord3D(seed, x3, y3, z1), xs), - ys), - CubicLerp( - CubicLerp(ValCoord3D(seed, x0, y0, z2), ValCoord3D(seed, x1, y0, z2), ValCoord3D(seed, x2, y0, z2), ValCoord3D(seed, x3, y0, z2), xs), - CubicLerp(ValCoord3D(seed, x0, y1, z2), ValCoord3D(seed, x1, y1, z2), ValCoord3D(seed, x2, y1, z2), ValCoord3D(seed, x3, y1, z2), xs), - CubicLerp(ValCoord3D(seed, x0, y2, z2), ValCoord3D(seed, x1, y2, z2), ValCoord3D(seed, x2, y2, z2), ValCoord3D(seed, x3, y2, z2), xs), - CubicLerp(ValCoord3D(seed, x0, y3, z2), ValCoord3D(seed, x1, y3, z2), ValCoord3D(seed, x2, y3, z2), ValCoord3D(seed, x3, y3, z2), xs), - ys), - CubicLerp( - CubicLerp(ValCoord3D(seed, x0, y0, z3), ValCoord3D(seed, x1, y0, z3), ValCoord3D(seed, x2, y0, z3), ValCoord3D(seed, x3, y0, z3), xs), - CubicLerp(ValCoord3D(seed, x0, y1, z3), ValCoord3D(seed, x1, y1, z3), ValCoord3D(seed, x2, y1, z3), ValCoord3D(seed, x3, y1, z3), xs), - CubicLerp(ValCoord3D(seed, x0, y2, z3), ValCoord3D(seed, x1, y2, z3), ValCoord3D(seed, x2, y2, z3), ValCoord3D(seed, x3, y2, z3), xs), - CubicLerp(ValCoord3D(seed, x0, y3, z3), ValCoord3D(seed, x1, y3, z3), ValCoord3D(seed, x2, y3, z3), ValCoord3D(seed, x3, y3, z3), xs), - ys), - zs) * CUBIC_3D_BOUNDING; - } - - - public FN_DECIMAL GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_fractalType) - { - case FractalType.FBM: - return SingleCubicFractalFBM(x, y); - case FractalType.Billow: - return SingleCubicFractalBillow(x, y); - case FractalType.RigidMulti: - return SingleCubicFractalRigidMulti(x, y); - default: - return 0; - } - } - - private FN_DECIMAL SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = SingleCubic(seed, x, y); - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += SingleCubic(++seed, x, y) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = Math.Abs(SingleCubic(seed, x, y)) * 2 - 1; - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum += (Math.Abs(SingleCubic(++seed, x, y)) * 2 - 1) * amp; - } - - return sum * m_fractalBounding; - } - - private FN_DECIMAL SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL sum = 1 - Math.Abs(SingleCubic(seed, x, y)); - FN_DECIMAL amp = 1; - int i = 0; - - while (++i < m_octaves) - { - x *= m_lacunarity; - y *= m_lacunarity; - - amp *= m_gain; - sum -= (1 - Math.Abs(SingleCubic(++seed, x, y))) * amp; - } - - return sum; - } - - public FN_DECIMAL GetCubic(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - return SingleCubic(0, x, y); - } - - private const FN_DECIMAL CUBIC_2D_BOUNDING = 1 / (FN_DECIMAL)(1.5 * 1.5); - - private FN_DECIMAL SingleCubic(int seed, FN_DECIMAL x, FN_DECIMAL y) - { - int x1 = FastFloor(x); - int y1 = FastFloor(y); - - int x0 = x1 - 1; - int y0 = y1 - 1; - int x2 = x1 + 1; - int y2 = y1 + 1; - int x3 = x1 + 2; - int y3 = y1 + 2; - - FN_DECIMAL xs = x - (FN_DECIMAL)x1; - FN_DECIMAL ys = y - (FN_DECIMAL)y1; - - return CubicLerp( - CubicLerp(ValCoord2D(seed, x0, y0), ValCoord2D(seed, x1, y0), ValCoord2D(seed, x2, y0), ValCoord2D(seed, x3, y0), - xs), - CubicLerp(ValCoord2D(seed, x0, y1), ValCoord2D(seed, x1, y1), ValCoord2D(seed, x2, y1), ValCoord2D(seed, x3, y1), - xs), - CubicLerp(ValCoord2D(seed, x0, y2), ValCoord2D(seed, x1, y2), ValCoord2D(seed, x2, y2), ValCoord2D(seed, x3, y2), - xs), - CubicLerp(ValCoord2D(seed, x0, y3), ValCoord2D(seed, x1, y3), ValCoord2D(seed, x2, y3), ValCoord2D(seed, x3, y3), - xs), - ys) * CUBIC_2D_BOUNDING; - } - - // Cellular Noise - public FN_DECIMAL GetCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - x *= m_frequency; - y *= m_frequency; - z *= m_frequency; - - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - case CellularReturnType.NoiseLookup: - case CellularReturnType.Distance: - return SingleCellular(x, y, z); - default: - return SingleCellular2Edge(x, y, z); - } - } - - private FN_DECIMAL SingleCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int xr = FastRound(x); - int yr = FastRound(y); - int zr = FastRound(z); - - FN_DECIMAL distance = 999999; - int xc = 0, yc = 0, zc = 0; - - switch (m_cellularDistanceFunction) - { - case CellularDistanceFunction.Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - zc = zi; - } - } - } - } - break; - case CellularDistanceFunction.Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = Math.Abs(vecX) + Math.Abs(vecY) + Math.Abs(vecZ); - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - zc = zi; - } - } - } - } - break; - case CellularDistanceFunction.Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = (Math.Abs(vecX) + Math.Abs(vecY) + Math.Abs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - zc = zi; - } - } - } - } - break; - } - - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - return ValCoord3D(m_seed, xc, yc, zc); - - case CellularReturnType.NoiseLookup: - Float3 vec = CELL_3D[Hash3D(m_seed, xc, yc, zc) & 255]; - return m_cellularNoiseLookup.GetNoise(xc + vec.x * m_cellularJitter, yc + vec.y * m_cellularJitter, zc + vec.z * m_cellularJitter); - - case CellularReturnType.Distance: - return distance; - default: - return 0; - } - } - - private FN_DECIMAL SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) - { - int xr = FastRound(x); - int yr = FastRound(y); - int zr = FastRound(z); - - FN_DECIMAL[] distance = { 999999, 999999, 999999, 999999 }; - - switch (m_cellularDistanceFunction) - { - case CellularDistanceFunction.Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - } - break; - case CellularDistanceFunction.Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = Math.Abs(vecX) + Math.Abs(vecY) + Math.Abs(vecZ); - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - } - break; - case CellularDistanceFunction.Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - for (int zi = zr - 1; zi <= zr + 1; zi++) - { - Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - FN_DECIMAL vecZ = zi - z + vec.z * m_cellularJitter; - - FN_DECIMAL newDistance = (Math.Abs(vecX) + Math.Abs(vecY) + Math.Abs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - } - break; - default: - break; - } - - switch (m_cellularReturnType) - { - case CellularReturnType.Distance2: - return distance[m_cellularDistanceIndex1]; - case CellularReturnType.Distance2Add: - return distance[m_cellularDistanceIndex1] + distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Sub: - return distance[m_cellularDistanceIndex1] - distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Mul: - return distance[m_cellularDistanceIndex1] * distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Div: - return distance[m_cellularDistanceIndex0] / distance[m_cellularDistanceIndex1]; - default: - return 0; - } - } - - public FN_DECIMAL GetCellular(FN_DECIMAL x, FN_DECIMAL y) - { - x *= m_frequency; - y *= m_frequency; - - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - case CellularReturnType.NoiseLookup: - case CellularReturnType.Distance: - return SingleCellular(x, y); - default: - return SingleCellular2Edge(x, y); - } - } - - private FN_DECIMAL SingleCellular(FN_DECIMAL x, FN_DECIMAL y) - { - int xr = FastRound(x); - int yr = FastRound(y); - - FN_DECIMAL distance = 999999; - int xc = 0, yc = 0; - - switch (m_cellularDistanceFunction) - { - default: - case CellularDistanceFunction.Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = vecX * vecX + vecY * vecY; - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - } - } - } - break; - case CellularDistanceFunction.Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = (Math.Abs(vecX) + Math.Abs(vecY)); - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - } - } - } - break; - case CellularDistanceFunction.Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = (Math.Abs(vecX) + Math.Abs(vecY)) + (vecX * vecX + vecY * vecY); - - if (newDistance < distance) - { - distance = newDistance; - xc = xi; - yc = yi; - } - } - } - break; - } - - switch (m_cellularReturnType) - { - case CellularReturnType.CellValue: - return ValCoord2D(m_seed, xc, yc); - - case CellularReturnType.NoiseLookup: - Float2 vec = CELL_2D[Hash2D(m_seed, xc, yc) & 255]; - return m_cellularNoiseLookup.GetNoise(xc + vec.x * m_cellularJitter, yc + vec.y * m_cellularJitter); - - case CellularReturnType.Distance: - return distance; - default: - return 0; - } - } - - private FN_DECIMAL SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y) - { - int xr = FastRound(x); - int yr = FastRound(y); - - FN_DECIMAL[] distance = { 999999, 999999, 999999, 999999 }; - - switch (m_cellularDistanceFunction) - { - default: - case CellularDistanceFunction.Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = vecX * vecX + vecY * vecY; - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - break; - case CellularDistanceFunction.Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = Math.Abs(vecX) + Math.Abs(vecY); - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - break; - case CellularDistanceFunction.Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) - { - for (int yi = yr - 1; yi <= yr + 1; yi++) - { - Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; - - FN_DECIMAL vecX = xi - x + vec.x * m_cellularJitter; - FN_DECIMAL vecY = yi - y + vec.y * m_cellularJitter; - - FN_DECIMAL newDistance = (Math.Abs(vecX) + Math.Abs(vecY)) + (vecX * vecX + vecY * vecY); - - for (int i = m_cellularDistanceIndex1; i > 0; i--) - distance[i] = Math.Max(Math.Min(distance[i], newDistance), distance[i - 1]); - distance[0] = Math.Min(distance[0], newDistance); - } - } - break; - } - - switch (m_cellularReturnType) - { - case CellularReturnType.Distance2: - return distance[m_cellularDistanceIndex1]; - case CellularReturnType.Distance2Add: - return distance[m_cellularDistanceIndex1] + distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Sub: - return distance[m_cellularDistanceIndex1] - distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Mul: - return distance[m_cellularDistanceIndex1] * distance[m_cellularDistanceIndex0]; - case CellularReturnType.Distance2Div: - return distance[m_cellularDistanceIndex0] / distance[m_cellularDistanceIndex1]; - default: - return 0; - } - } - - public void GradientPerturb(ref FN_DECIMAL x, ref FN_DECIMAL y, ref FN_DECIMAL z) - { - SingleGradientPerturb(m_seed, m_gradientPerturbAmp, m_frequency, ref x, ref y, ref z); - } - - public void GradientPerturbFractal(ref FN_DECIMAL x, ref FN_DECIMAL y, ref FN_DECIMAL z) - { - int seed = m_seed; - FN_DECIMAL amp = m_gradientPerturbAmp * m_fractalBounding; - FN_DECIMAL freq = m_frequency; - - SingleGradientPerturb(seed, amp, m_frequency, ref x, ref y, ref z); - - for (int i = 1; i < m_octaves; i++) - { - freq *= m_lacunarity; - amp *= m_gain; - SingleGradientPerturb(++seed, amp, freq, ref x, ref y, ref z); - } - } - - private void SingleGradientPerturb(int seed, FN_DECIMAL perturbAmp, FN_DECIMAL frequency, ref FN_DECIMAL x, ref FN_DECIMAL y, ref FN_DECIMAL z) - { - FN_DECIMAL xf = x * frequency; - FN_DECIMAL yf = y * frequency; - FN_DECIMAL zf = z * frequency; - - int x0 = FastFloor(xf); - int y0 = FastFloor(yf); - int z0 = FastFloor(zf); - int x1 = x0 + 1; - int y1 = y0 + 1; - int z1 = z0 + 1; - - FN_DECIMAL xs, ys, zs; - switch (m_interp) - { - default: - case Interp.Linear: - xs = xf - x0; - ys = yf - y0; - zs = zf - z0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(xf - x0); - ys = InterpHermiteFunc(yf - y0); - zs = InterpHermiteFunc(zf - z0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(xf - x0); - ys = InterpQuinticFunc(yf - y0); - zs = InterpQuinticFunc(zf - z0); - break; - } - - Float3 vec0 = CELL_3D[Hash3D(seed, x0, y0, z0) & 255]; - Float3 vec1 = CELL_3D[Hash3D(seed, x1, y0, z0) & 255]; - - FN_DECIMAL lx0x = Lerp(vec0.x, vec1.x, xs); - FN_DECIMAL ly0x = Lerp(vec0.y, vec1.y, xs); - FN_DECIMAL lz0x = Lerp(vec0.z, vec1.z, xs); - - vec0 = CELL_3D[Hash3D(seed, x0, y1, z0) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y1, z0) & 255]; - - FN_DECIMAL lx1x = Lerp(vec0.x, vec1.x, xs); - FN_DECIMAL ly1x = Lerp(vec0.y, vec1.y, xs); - FN_DECIMAL lz1x = Lerp(vec0.z, vec1.z, xs); - - FN_DECIMAL lx0y = Lerp(lx0x, lx1x, ys); - FN_DECIMAL ly0y = Lerp(ly0x, ly1x, ys); - FN_DECIMAL lz0y = Lerp(lz0x, lz1x, ys); - - vec0 = CELL_3D[Hash3D(seed, x0, y0, z1) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y0, z1) & 255]; - - lx0x = Lerp(vec0.x, vec1.x, xs); - ly0x = Lerp(vec0.y, vec1.y, xs); - lz0x = Lerp(vec0.z, vec1.z, xs); - - vec0 = CELL_3D[Hash3D(seed, x0, y1, z1) & 255]; - vec1 = CELL_3D[Hash3D(seed, x1, y1, z1) & 255]; - - lx1x = Lerp(vec0.x, vec1.x, xs); - ly1x = Lerp(vec0.y, vec1.y, xs); - lz1x = Lerp(vec0.z, vec1.z, xs); - - x += Lerp(lx0y, Lerp(lx0x, lx1x, ys), zs) * perturbAmp; - y += Lerp(ly0y, Lerp(ly0x, ly1x, ys), zs) * perturbAmp; - z += Lerp(lz0y, Lerp(lz0x, lz1x, ys), zs) * perturbAmp; - } - - public void GradientPerturb(ref FN_DECIMAL x, ref FN_DECIMAL y) - { - SingleGradientPerturb(m_seed, m_gradientPerturbAmp, m_frequency, ref x, ref y); - } - - public void GradientPerturbFractal(ref FN_DECIMAL x, ref FN_DECIMAL y) - { - int seed = m_seed; - FN_DECIMAL amp = m_gradientPerturbAmp * m_fractalBounding; - FN_DECIMAL freq = m_frequency; - - SingleGradientPerturb(seed, amp, m_frequency, ref x, ref y); - - for (int i = 1; i < m_octaves; i++) - { - freq *= m_lacunarity; - amp *= m_gain; - SingleGradientPerturb(++seed, amp, freq, ref x, ref y); - } - } - - private void SingleGradientPerturb(int seed, FN_DECIMAL perturbAmp, FN_DECIMAL frequency, ref FN_DECIMAL x, ref FN_DECIMAL y) - { - FN_DECIMAL xf = x * frequency; - FN_DECIMAL yf = y * frequency; - - int x0 = FastFloor(xf); - int y0 = FastFloor(yf); - int x1 = x0 + 1; - int y1 = y0 + 1; - - FN_DECIMAL xs, ys; - switch (m_interp) - { - default: - case Interp.Linear: - xs = xf - x0; - ys = yf - y0; - break; - case Interp.Hermite: - xs = InterpHermiteFunc(xf - x0); - ys = InterpHermiteFunc(yf - y0); - break; - case Interp.Quintic: - xs = InterpQuinticFunc(xf - x0); - ys = InterpQuinticFunc(yf - y0); - break; - } - - Float2 vec0 = CELL_2D[Hash2D(seed, x0, y0) & 255]; - Float2 vec1 = CELL_2D[Hash2D(seed, x1, y0) & 255]; - - FN_DECIMAL lx0x = Lerp(vec0.x, vec1.x, xs); - FN_DECIMAL ly0x = Lerp(vec0.y, vec1.y, xs); - - vec0 = CELL_2D[Hash2D(seed, x0, y1) & 255]; - vec1 = CELL_2D[Hash2D(seed, x1, y1) & 255]; - - FN_DECIMAL lx1x = Lerp(vec0.x, vec1.x, xs); - FN_DECIMAL ly1x = Lerp(vec0.y, vec1.y, xs); - - x += Lerp(lx0x, lx1x, ys) * perturbAmp; - y += Lerp(ly0x, ly1x, ys) * perturbAmp; - } - -} diff --git a/Assets/Scripts/NIH/GPU Noise.meta b/Assets/Scripts/NIH/GPU Noise.meta new file mode 100644 index 000000000..3f0341b15 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 48b22515742194f478ce494a467011b0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc b/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc new file mode 100644 index 000000000..ef6b2e96c --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc @@ -0,0 +1,129 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Stefan Gustavson +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// GLSL textureless classic 2D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-08-22 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float4 mod(float4 x, float4 y) +{ + return x - y * floor(x / y); +} + +float4 mod289(float4 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 permute(float4 x) +{ + return mod289(((x*34.0)+1.0)*x); +} + +float4 taylorInvSqrt(float4 r) +{ + return (float4)1.79284291400159 - r * 0.85373472095314; +} + +float2 fade(float2 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +// Classic Perlin noise +float cnoise(float2 P) +{ + float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0); + float4 Pf = frac (P.xyxy) - float4(0.0, 0.0, 1.0, 1.0); + Pi = mod289(Pi); // To avoid truncation effects in permutation + float4 ix = Pi.xzxz; + float4 iy = Pi.yyww; + float4 fx = Pf.xzxz; + float4 fy = Pf.yyww; + + float4 i = permute(permute(ix) + iy); + + float4 gx = frac(i / 41.0) * 2.0 - 1.0 ; + float4 gy = abs(gx) - 0.5 ; + float4 tx = floor(gx + 0.5); + gx = gx - tx; + + float2 g00 = float2(gx.x,gy.x); + float2 g10 = float2(gx.y,gy.y); + float2 g01 = float2(gx.z,gy.z); + float2 g11 = float2(gx.w,gy.w); + + float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + float n00 = dot(g00, float2(fx.x, fy.x)); + float n10 = dot(g10, float2(fx.y, fy.y)); + float n01 = dot(g01, float2(fx.z, fy.z)); + float n11 = dot(g11, float2(fx.w, fy.w)); + + float2 fade_xy = fade(Pf.xy); + float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x); + float n_xy = lerp(n_x.x, n_x.y, fade_xy.y); + return 2.3 * n_xy; +} + +// Classic Perlin noise, periodic variant +float pnoise(float2 P, float2 rep) +{ + float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0); + float4 Pf = frac (P.xyxy) - float4(0.0, 0.0, 1.0, 1.0); + Pi = mod(Pi, rep.xyxy); // To create noise with explicit period + Pi = mod289(Pi); // To avoid truncation effects in permutation + float4 ix = Pi.xzxz; + float4 iy = Pi.yyww; + float4 fx = Pf.xzxz; + float4 fy = Pf.yyww; + + float4 i = permute(permute(ix) + iy); + + float4 gx = frac(i / 41.0) * 2.0 - 1.0 ; + float4 gy = abs(gx) - 0.5 ; + float4 tx = floor(gx + 0.5); + gx = gx - tx; + + float2 g00 = float2(gx.x,gy.x); + float2 g10 = float2(gx.y,gy.y); + float2 g01 = float2(gx.z,gy.z); + float2 g11 = float2(gx.w,gy.w); + + float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + float n00 = dot(g00, float2(fx.x, fy.x)); + float n10 = dot(g10, float2(fx.y, fy.y)); + float n01 = dot(g01, float2(fx.z, fy.z)); + float n11 = dot(g11, float2(fx.w, fy.w)); + + float2 fade_xy = fade(Pf.xy); + float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x); + float n_xy = lerp(n_x.x, n_x.y, fade_xy.y); + return 2.3 * n_xy; +} diff --git a/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc.meta new file mode 100644 index 000000000..ff437e70a --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/ClassicNoise2D.cginc.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e1b0b5fd6a4e44923b40d856017562e1 +ShaderImporter: + defaultTextures: [] + userData: diff --git a/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc b/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc new file mode 100644 index 000000000..738f6d12a --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc @@ -0,0 +1,194 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Stefan Gustavson +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// GLSL textureless classic 3D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-10-11 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float3 mod(float3 x, float3 y) +{ + return x - y * floor(x / y); +} + +float3 mod289(float3 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 mod289(float4 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 permute(float4 x) +{ + return mod289(((x*34.0)+1.0)*x); +} + +float4 taylorInvSqrt(float4 r) +{ + return (float4)1.79284291400159 - r * 0.85373472095314; +} + +float3 fade(float3 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); +} + +// Classic Perlin noise +float cnoise(float3 P) +{ + float3 Pi0 = floor(P); // Integer part for indexing + float3 Pi1 = Pi0 + (float3)1.0; // Integer part + 1 + Pi0 = mod289(Pi0); + Pi1 = mod289(Pi1); + float3 Pf0 = frac(P); // Fractional part for interpolation + float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 + float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + float4 iz0 = (float4)Pi0.z; + float4 iz1 = (float4)Pi1.z; + + float4 ixy = permute(permute(ix) + iy); + float4 ixy0 = permute(ixy + iz0); + float4 ixy1 = permute(ixy + iz1); + + float4 gx0 = ixy0 / 7.0; + float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; + gx0 = frac(gx0); + float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); + float4 sz0 = step(gz0, (float4)0.0); + gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); + gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); + + float4 gx1 = ixy1 / 7.0; + float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; + gx1 = frac(gx1); + float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); + float4 sz1 = step(gz1, (float4)0.0); + gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); + gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); + + float3 g000 = float3(gx0.x,gy0.x,gz0.x); + float3 g100 = float3(gx0.y,gy0.y,gz0.y); + float3 g010 = float3(gx0.z,gy0.z,gz0.z); + float3 g110 = float3(gx0.w,gy0.w,gz0.w); + float3 g001 = float3(gx1.x,gy1.x,gz1.x); + float3 g101 = float3(gx1.y,gy1.y,gz1.y); + float3 g011 = float3(gx1.z,gy1.z,gz1.z); + float3 g111 = float3(gx1.w,gy1.w,gz1.w); + + float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + + float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + float n000 = dot(g000, Pf0); + float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); + float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); + float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); + float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); + float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); + float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); + float n111 = dot(g111, Pf1); + + float3 fade_xyz = fade(Pf0); + float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); + float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); + float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); + return 2.2 * n_xyz; +} + +// Classic Perlin noise, periodic variant +float pnoise(float3 P, float3 rep) +{ + float3 Pi0 = mod(floor(P), rep); // Integer part, modulo period + float3 Pi1 = mod(Pi0 + (float3)1.0, rep); // Integer part + 1, mod period + Pi0 = mod289(Pi0); + Pi1 = mod289(Pi1); + float3 Pf0 = frac(P); // Fractional part for interpolation + float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 + float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + float4 iz0 = (float4)Pi0.z; + float4 iz1 = (float4)Pi1.z; + + float4 ixy = permute(permute(ix) + iy); + float4 ixy0 = permute(ixy + iz0); + float4 ixy1 = permute(ixy + iz1); + + float4 gx0 = ixy0 / 7.0; + float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; + gx0 = frac(gx0); + float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); + float4 sz0 = step(gz0, (float4)0.0); + gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); + gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); + + float4 gx1 = ixy1 / 7.0; + float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; + gx1 = frac(gx1); + float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); + float4 sz1 = step(gz1, (float4)0.0); + gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); + gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); + + float3 g000 = float3(gx0.x,gy0.x,gz0.x); + float3 g100 = float3(gx0.y,gy0.y,gz0.y); + float3 g010 = float3(gx0.z,gy0.z,gz0.z); + float3 g110 = float3(gx0.w,gy0.w,gz0.w); + float3 g001 = float3(gx1.x,gy1.x,gz1.x); + float3 g101 = float3(gx1.y,gy1.y,gz1.y); + float3 g011 = float3(gx1.z,gy1.z,gz1.z); + float3 g111 = float3(gx1.w,gy1.w,gz1.w); + + float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + float n000 = dot(g000, Pf0); + float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); + float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); + float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); + float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); + float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); + float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); + float n111 = dot(g111, Pf1); + + float3 fade_xyz = fade(Pf0); + float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); + float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); + float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); + return 2.2 * n_xyz; +} diff --git a/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc.meta new file mode 100644 index 000000000..b4dd551ab --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/ClassicNoise3D.cginc.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 3ba1abd1cb44c47b68fbb577c6c4ba3e +ShaderImporter: + defaultTextures: [] + userData: diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc b/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc new file mode 100644 index 000000000..e7d8bd417 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc @@ -0,0 +1,88 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// Description : Array and textureless GLSL 2D simplex noise function. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float3 mod289(float3 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float2 mod289(float2 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float3 permute(float3 x) +{ + return mod289((x * 34.0 + 1.0) * x); +} + +float3 taylorInvSqrt(float3 r) +{ + return 1.79284291400159 - 0.85373472095314 * r; +} + +float snoise(float2 v) +{ + const float4 C = float4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0 + 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) + -0.577350269189626, // -1.0 + 2.0 * C.x + 0.024390243902439); // 1.0 / 41.0 + // First corner + float2 i = floor(v + dot(v, C.yy)); + float2 x0 = v - i + dot(i, C.xx); + + // Other corners + float2 i1; + i1.x = step(x0.y, x0.x); + i1.y = 1.0 - i1.x; + + // x1 = x0 - i1 + 1.0 * C.xx; + // x2 = x0 - 1.0 + 2.0 * C.xx; + float2 x1 = x0 + C.xx - i1; + float2 x2 = x0 + C.zz; + + // Permutations + i = mod289(i); // Avoid truncation effects in permutation + float3 p = + permute(permute(i.y + float3(0.0, i1.y, 1.0)) + + i.x + float3(0.0, i1.x, 1.0)); + + float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); + m = m * m; + m = m * m; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + float3 x = 2.0 * frac(p * C.www) - 1.0; + float3 h = abs(x) - 0.5; + float3 ox = floor(x + 0.5); + float3 a0 = x - ox; + + // Normalise gradients implicitly by scaling m + m *= taylorInvSqrt(a0 * a0 + h * h); + + // Compute final noise value at P + float3 g; + g.x = a0.x * x0.x + h.x * x0.y; + g.y = a0.y * x1.x + h.y * x1.y; + g.z = a0.z * x2.x + h.z * x2.y; + return 130.0 * dot(m, g); +} diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc.meta new file mode 100644 index 000000000..22c0780d8 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0a38e0bb6f84203469f3e9cb8545ffce +timeCreated: 1448775185 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc b/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc new file mode 100644 index 000000000..0b7add240 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc @@ -0,0 +1,114 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// Description : Array and textureless GLSL 2D/3D/4D simplex +// noise functions. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float3 mod289(float3 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 mod289(float4 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 permute(float4 x) +{ + return mod289((x * 34.0 + 1.0) * x); +} + +float4 taylorInvSqrt(float4 r) +{ + return 1.79284291400159 - r * 0.85373472095314; +} + +float snoise(float3 v) +{ + const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); + + // First corner + float3 i = floor(v + dot(v, C.yyy)); + float3 x0 = v - i + dot(i, C.xxx); + + // Other corners + float3 g = step(x0.yzx, x0.xyz); + float3 l = 1.0 - g; + float3 i1 = min(g.xyz, l.zxy); + float3 i2 = max(g.xyz, l.zxy); + + // x1 = x0 - i1 + 1.0 * C.xxx; + // x2 = x0 - i2 + 2.0 * C.xxx; + // x3 = x0 - 1.0 + 3.0 * C.xxx; + float3 x1 = x0 - i1 + C.xxx; + float3 x2 = x0 - i2 + C.yyy; + float3 x3 = x0 - 0.5; + + // Permutations + i = mod289(i); // Avoid truncation effects in permutation + float4 p = + permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) + + i.y + float4(0.0, i1.y, i2.y, 1.0)) + + i.x + float4(0.0, i1.x, i2.x, 1.0)); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) + + float4 x_ = floor(j / 7.0); + float4 y_ = floor(j - 7.0 * x_); // mod(j,N) + + float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; + float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; + + float4 h = 1.0 - abs(x) - abs(y); + + float4 b0 = float4(x.xy, y.xy); + float4 b1 = float4(x.zw, y.zw); + + //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; + //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; + float4 s0 = floor(b0) * 2.0 + 1.0; + float4 s1 = floor(b1) * 2.0 + 1.0; + float4 sh = -step(h, 0.0); + + float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; + float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + + float3 g0 = float3(a0.xy, h.x); + float3 g1 = float3(a0.zw, h.y); + float3 g2 = float3(a1.xy, h.z); + float3 g3 = float3(a1.zw, h.w); + + // Normalise gradients + float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); + g0 *= norm.x; + g1 *= norm.y; + g2 *= norm.z; + g3 *= norm.w; + + // Mix final noise value + float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); + m = m * m; + m = m * m; + + float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3)); + return 42.0 * dot(m, px); +} diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc.meta new file mode 100644 index 000000000..612bd9ef0 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b577a94f58a1398409bfcfe9cd5dbf99 +timeCreated: 1448788105 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc new file mode 100644 index 000000000..ab91a6db8 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc @@ -0,0 +1,92 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// Description : Array and textureless GLSL 2D simplex noise function. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float3 mod289(float3 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float2 mod289(float2 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float3 permute(float3 x) +{ + return mod289((x * 34.0 + 1.0) * x); +} + +float3 taylorInvSqrt(float3 r) +{ + return 1.79284291400159 - 0.85373472095314 * r; +} + +float2 snoise_grad(float2 v) +{ + const float4 C = float4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0 + 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) + -0.577350269189626, // -1.0 + 2.0 * C.x + 0.024390243902439); // 1.0 / 41.0 + // First corner + float2 i = floor(v + dot(v, C.yy)); + float2 x0 = v - i + dot(i, C.xx); + + // Other corners + float2 i1; + i1.x = step(x0.y, x0.x); + i1.y = 1.0 - i1.x; + + // x1 = x0 - i1 + 1.0 * C.xx; + // x2 = x0 - 1.0 + 2.0 * C.xx; + float2 x1 = x0 + C.xx - i1; + float2 x2 = x0 + C.zz; + + // Permutations + i = mod289(i); // Avoid truncation effects in permutation + float3 p = + permute(permute(i.y + float3(0.0, i1.y, 1.0)) + + i.x + float3(0.0, i1.x, 1.0)); + + float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); + float3 m2 = m * m; + float3 m3 = m2 * m; + float3 m4 = m2 * m2; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + float3 x = 2.0 * frac(p * C.www) - 1.0; + float3 h = abs(x) - 0.5; + float3 ox = floor(x + 0.5); + float3 a0 = x - ox; + + // Normalise gradients + float3 norm = taylorInvSqrt(a0 * a0 + h * h); + float2 g0 = float2(a0.x, h.x) * norm.x; + float2 g1 = float2(a0.y, h.y) * norm.y; + float2 g2 = float2(a0.z, h.z) * norm.z; + + // Compute gradient of noise function at P + float2 grad = + -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 + + -6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 + + -6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2; + return 130.0 * grad; +} diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc.meta new file mode 100644 index 000000000..a6f725fd3 --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad2D.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 33c8157a2aca37849bc1f21250315a93 +timeCreated: 1449292284 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc new file mode 100644 index 000000000..4cfef835a --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc @@ -0,0 +1,118 @@ +// +// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader +// +// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. +// Translation and modification was made by Keijiro Takahashi. +// +// This shader is based on the webgl-noise GLSL shader. For further details +// of the original shader, please see the following description from the +// original source code. +// + +// +// Description : Array and textureless GLSL 2D/3D/4D simplex +// noise functions. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +float3 mod289(float3 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 mod289(float4 x) +{ + return x - floor(x / 289.0) * 289.0; +} + +float4 permute(float4 x) +{ + return mod289((x * 34.0 + 1.0) * x); +} + +float4 taylorInvSqrt(float4 r) +{ + return 1.79284291400159 - r * 0.85373472095314; +} + +float3 snoise_grad(float3 v) +{ + const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); + + // First corner + float3 i = floor(v + dot(v, C.yyy)); + float3 x0 = v - i + dot(i, C.xxx); + + // Other corners + float3 g = step(x0.yzx, x0.xyz); + float3 l = 1.0 - g; + float3 i1 = min(g.xyz, l.zxy); + float3 i2 = max(g.xyz, l.zxy); + + // x1 = x0 - i1 + 1.0 * C.xxx; + // x2 = x0 - i2 + 2.0 * C.xxx; + // x3 = x0 - 1.0 + 3.0 * C.xxx; + float3 x1 = x0 - i1 + C.xxx; + float3 x2 = x0 - i2 + C.yyy; + float3 x3 = x0 - 0.5; + + // Permutations + i = mod289(i); // Avoid truncation effects in permutation + float4 p = + permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) + + i.y + float4(0.0, i1.y, i2.y, 1.0)) + + i.x + float4(0.0, i1.x, i2.x, 1.0)); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) + + float4 x_ = floor(j / 7.0); + float4 y_ = floor(j - 7.0 * x_); // mod(j,N) + + float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; + float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; + + float4 h = 1.0 - abs(x) - abs(y); + + float4 b0 = float4(x.xy, y.xy); + float4 b1 = float4(x.zw, y.zw); + + //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; + //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; + float4 s0 = floor(b0) * 2.0 + 1.0; + float4 s1 = floor(b1) * 2.0 + 1.0; + float4 sh = -step(h, 0.0); + + float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; + float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + + float3 g0 = float3(a0.xy, h.x); + float3 g1 = float3(a0.zw, h.y); + float3 g2 = float3(a1.xy, h.z); + float3 g3 = float3(a1.zw, h.w); + + // Normalise gradients + float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); + g0 *= norm.x; + g1 *= norm.y; + g2 *= norm.z; + g3 *= norm.w; + + // Compute gradient of noise function at P + float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); + float4 m2 = m * m; + float4 m3 = m2 * m; + float4 m4 = m2 * m2; + float3 grad = + -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 + + -6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 + + -6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2 + + -6.0 * m3.w * x3 * dot(x3, g3) + m4.w * g3; + return 42.0 * grad; +} diff --git a/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc.meta b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc.meta new file mode 100644 index 000000000..250b646fa --- /dev/null +++ b/Assets/Scripts/NIH/GPU Noise/SimplexNoiseGrad3D.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a7111eafc2463224faacf7be3bddb9a4 +timeCreated: 1449292284 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NIH/XKCDColors.cs b/Assets/Scripts/NIH/XKCDColors.cs new file mode 100644 index 000000000..1432df8bf --- /dev/null +++ b/Assets/Scripts/NIH/XKCDColors.cs @@ -0,0 +1,966 @@ +using System; +using UnityEngine; + +public static class XKCDColors +{ + internal class ColorTranslator + { + public static Color FromHtml(string hexString) + { + return new Color(Convert.ToInt32(hexString.Substring(1, 2), 16) / 255f, + Convert.ToInt32(hexString.Substring(3, 2), 16) / 255f, + Convert.ToInt32(hexString.Substring(5, 2), 16) / 255f); + } + } + + public static Color CloudyBlue { get { return ColorTranslator.FromHtml("#acc2d9"); } } + public static Color DarkPastelGreen { get { return ColorTranslator.FromHtml("#56ae57"); } } + public static Color Dust { get { return ColorTranslator.FromHtml("#b2996e"); } } + public static Color ElectricLime { get { return ColorTranslator.FromHtml("#a8ff04"); } } + public static Color FreshGreen { get { return ColorTranslator.FromHtml("#69d84f"); } } + public static Color LightEggplant { get { return ColorTranslator.FromHtml("#894585"); } } + public static Color NastyGreen { get { return ColorTranslator.FromHtml("#70b23f"); } } + public static Color ReallyLightBlue { get { return ColorTranslator.FromHtml("#d4ffff"); } } + public static Color Tea { get { return ColorTranslator.FromHtml("#65ab7c"); } } + public static Color WarmPurple { get { return ColorTranslator.FromHtml("#952e8f"); } } + public static Color YellowishTan { get { return ColorTranslator.FromHtml("#fcfc81"); } } + public static Color Cement { get { return ColorTranslator.FromHtml("#a5a391"); } } + public static Color DarkGrassGreen { get { return ColorTranslator.FromHtml("#388004"); } } + public static Color DustyTeal { get { return ColorTranslator.FromHtml("#4c9085"); } } + public static Color GreyTeal { get { return ColorTranslator.FromHtml("#5e9b8a"); } } + public static Color MacaroniAndCheese { get { return ColorTranslator.FromHtml("#efb435"); } } + public static Color PinkishTan { get { return ColorTranslator.FromHtml("#d99b82"); } } + public static Color Spruce { get { return ColorTranslator.FromHtml("#0a5f38"); } } + public static Color StrongBlue { get { return ColorTranslator.FromHtml("#0c06f7"); } } + public static Color ToxicGreen { get { return ColorTranslator.FromHtml("#61de2a"); } } + public static Color WindowsBlue { get { return ColorTranslator.FromHtml("#3778bf"); } } + public static Color BlueBlue { get { return ColorTranslator.FromHtml("#2242c7"); } } + public static Color BlueWithAHintOfPurple { get { return ColorTranslator.FromHtml("#533cc6"); } } + public static Color Booger { get { return ColorTranslator.FromHtml("#9bb53c"); } } + public static Color BrightSeaGreen { get { return ColorTranslator.FromHtml("#05ffa6"); } } + public static Color DarkGreenBlue { get { return ColorTranslator.FromHtml("#1f6357"); } } + public static Color DeepTurquoise { get { return ColorTranslator.FromHtml("#017374"); } } + public static Color GreenTeal { get { return ColorTranslator.FromHtml("#0cb577"); } } + public static Color StrongPink { get { return ColorTranslator.FromHtml("#ff0789"); } } + public static Color Bland { get { return ColorTranslator.FromHtml("#afa88b"); } } + public static Color DeepAqua { get { return ColorTranslator.FromHtml("#08787f"); } } + public static Color LavenderPink { get { return ColorTranslator.FromHtml("#dd85d7"); } } + public static Color LightMossGreen { get { return ColorTranslator.FromHtml("#a6c875"); } } + public static Color LightSeafoamGreen { get { return ColorTranslator.FromHtml("#a7ffb5"); } } + public static Color OliveYellow { get { return ColorTranslator.FromHtml("#c2b709"); } } + public static Color PigPink { get { return ColorTranslator.FromHtml("#e78ea5"); } } + public static Color DeepLilac { get { return ColorTranslator.FromHtml("#966ebd"); } } + public static Color Desert { get { return ColorTranslator.FromHtml("#ccad60"); } } + public static Color DustyLavender { get { return ColorTranslator.FromHtml("#ac86a8"); } } + public static Color PurpleyGrey { get { return ColorTranslator.FromHtml("#947e94"); } } + public static Color Purply { get { return ColorTranslator.FromHtml("#983fb2"); } } + public static Color CandyPink { get { return ColorTranslator.FromHtml("#ff63e9"); } } + public static Color LightPastelGreen { get { return ColorTranslator.FromHtml("#b2fba5"); } } + public static Color BoringGreen { get { return ColorTranslator.FromHtml("#63b365"); } } + public static Color KiwiGreen { get { return ColorTranslator.FromHtml("#8ee53f"); } } + public static Color LightGreyGreen { get { return ColorTranslator.FromHtml("#b7e1a1"); } } + public static Color OrangePink { get { return ColorTranslator.FromHtml("#ff6f52"); } } + public static Color TeaGreen { get { return ColorTranslator.FromHtml("#bdf8a3"); } } + public static Color VeryLightBrown { get { return ColorTranslator.FromHtml("#d3b683"); } } + public static Color EggShell { get { return ColorTranslator.FromHtml("#fffcc4"); } } + public static Color EggplantPurple { get { return ColorTranslator.FromHtml("#430541"); } } + public static Color PowderPink { get { return ColorTranslator.FromHtml("#ffb2d0"); } } + public static Color ReddishGrey { get { return ColorTranslator.FromHtml("#997570"); } } + public static Color BabyShitBrown { get { return ColorTranslator.FromHtml("#ad900d"); } } + public static Color Liliac { get { return ColorTranslator.FromHtml("#c48efd"); } } + public static Color StormyBlue { get { return ColorTranslator.FromHtml("#507b9c"); } } + public static Color UglyBrown { get { return ColorTranslator.FromHtml("#7d7103"); } } + public static Color Custard { get { return ColorTranslator.FromHtml("#fffd78"); } } + public static Color DarkishPink { get { return ColorTranslator.FromHtml("#da467d"); } } + public static Color DeepBrown { get { return ColorTranslator.FromHtml("#410200"); } } + public static Color GreenishBeige { get { return ColorTranslator.FromHtml("#c9d179"); } } + public static Color Manilla { get { return ColorTranslator.FromHtml("#fffa86"); } } + public static Color OffBlue { get { return ColorTranslator.FromHtml("#5684ae"); } } + public static Color BattleshipGrey { get { return ColorTranslator.FromHtml("#6b7c85"); } } + public static Color BrownyGreen { get { return ColorTranslator.FromHtml("#6f6c0a"); } } + public static Color Bruise { get { return ColorTranslator.FromHtml("#7e4071"); } } + public static Color KelleyGreen { get { return ColorTranslator.FromHtml("#009337"); } } + public static Color SicklyYellow { get { return ColorTranslator.FromHtml("#d0e429"); } } + public static Color SunnyYellow { get { return ColorTranslator.FromHtml("#fff917"); } } + public static Color Azul { get { return ColorTranslator.FromHtml("#1d5dec"); } } + public static Color Darkgreen { get { return ColorTranslator.FromHtml("#054907"); } } + public static Color Green_Yellow { get { return ColorTranslator.FromHtml("#b5ce08"); } } + public static Color Lichen { get { return ColorTranslator.FromHtml("#8fb67b"); } } + public static Color LightLightGreen { get { return ColorTranslator.FromHtml("#c8ffb0"); } } + public static Color PaleGold { get { return ColorTranslator.FromHtml("#fdde6c"); } } + public static Color SunYellow { get { return ColorTranslator.FromHtml("#ffdf22"); } } + public static Color TanGreen { get { return ColorTranslator.FromHtml("#a9be70"); } } + public static Color Burple { get { return ColorTranslator.FromHtml("#6832e3"); } } + public static Color Butterscotch { get { return ColorTranslator.FromHtml("#fdb147"); } } + public static Color Toupe { get { return ColorTranslator.FromHtml("#c7ac7d"); } } + public static Color DarkCream { get { return ColorTranslator.FromHtml("#fff39a"); } } + public static Color IndianRed { get { return ColorTranslator.FromHtml("#850e04"); } } + public static Color LightLavendar { get { return ColorTranslator.FromHtml("#efc0fe"); } } + public static Color PoisonGreen { get { return ColorTranslator.FromHtml("#40fd14"); } } + public static Color BabyPukeGreen { get { return ColorTranslator.FromHtml("#b6c406"); } } + public static Color BrightYellowGreen { get { return ColorTranslator.FromHtml("#9dff00"); } } + public static Color CharcoalGrey { get { return ColorTranslator.FromHtml("#3c4142"); } } + public static Color Squash { get { return ColorTranslator.FromHtml("#f2ab15"); } } + public static Color Cinnamon { get { return ColorTranslator.FromHtml("#ac4f06"); } } + public static Color LightPeaGreen { get { return ColorTranslator.FromHtml("#c4fe82"); } } + public static Color RadioactiveGreen { get { return ColorTranslator.FromHtml("#2cfa1f"); } } + public static Color RawSienna { get { return ColorTranslator.FromHtml("#9a6200"); } } + public static Color BabyPurple { get { return ColorTranslator.FromHtml("#ca9bf7"); } } + public static Color Cocoa { get { return ColorTranslator.FromHtml("#875f42"); } } + public static Color LightRoyalBlue { get { return ColorTranslator.FromHtml("#3a2efe"); } } + public static Color Orangeish { get { return ColorTranslator.FromHtml("#fd8d49"); } } + public static Color RustBrown { get { return ColorTranslator.FromHtml("#8b3103"); } } + public static Color SandBrown { get { return ColorTranslator.FromHtml("#cba560"); } } + public static Color Swamp { get { return ColorTranslator.FromHtml("#698339"); } } + public static Color TealishGreen { get { return ColorTranslator.FromHtml("#0cdc73"); } } + public static Color BurntSiena { get { return ColorTranslator.FromHtml("#b75203"); } } + public static Color Camo { get { return ColorTranslator.FromHtml("#7f8f4e"); } } + public static Color DuskBlue { get { return ColorTranslator.FromHtml("#26538d"); } } + public static Color Fern { get { return ColorTranslator.FromHtml("#63a950"); } } + public static Color OldRose { get { return ColorTranslator.FromHtml("#c87f89"); } } + public static Color PaleLightGreen { get { return ColorTranslator.FromHtml("#b1fc99"); } } + public static Color PeachyPink { get { return ColorTranslator.FromHtml("#ff9a8a"); } } + public static Color RosyPink { get { return ColorTranslator.FromHtml("#f6688e"); } } + public static Color LightBluishGreen { get { return ColorTranslator.FromHtml("#76fda8"); } } + public static Color LightBrightGreen { get { return ColorTranslator.FromHtml("#53fe5c"); } } + public static Color LightNeonGreen { get { return ColorTranslator.FromHtml("#4efd54"); } } + public static Color LightSeafoam { get { return ColorTranslator.FromHtml("#a0febf"); } } + public static Color TiffanyBlue { get { return ColorTranslator.FromHtml("#7bf2da"); } } + public static Color WashedOutGreen { get { return ColorTranslator.FromHtml("#bcf5a6"); } } + public static Color BrownyOrange { get { return ColorTranslator.FromHtml("#ca6b02"); } } + public static Color NiceBlue { get { return ColorTranslator.FromHtml("#107ab0"); } } + public static Color Sapphire { get { return ColorTranslator.FromHtml("#2138ab"); } } + public static Color GreyishTeal { get { return ColorTranslator.FromHtml("#719f91"); } } + public static Color OrangeyYellow { get { return ColorTranslator.FromHtml("#fdb915"); } } + public static Color Parchment { get { return ColorTranslator.FromHtml("#fefcaf"); } } + public static Color Straw { get { return ColorTranslator.FromHtml("#fcf679"); } } + public static Color VeryDarkBrown { get { return ColorTranslator.FromHtml("#1d0200"); } } + public static Color Terracota { get { return ColorTranslator.FromHtml("#cb6843"); } } + public static Color UglyBlue { get { return ColorTranslator.FromHtml("#31668a"); } } + public static Color ClearBlue { get { return ColorTranslator.FromHtml("#247afd"); } } + public static Color Creme { get { return ColorTranslator.FromHtml("#ffffb6"); } } + public static Color FoamGreen { get { return ColorTranslator.FromHtml("#90fda9"); } } + public static Color Grey_Green { get { return ColorTranslator.FromHtml("#86a17d"); } } + public static Color LightGold { get { return ColorTranslator.FromHtml("#fddc5c"); } } + public static Color SeafoamBlue { get { return ColorTranslator.FromHtml("#78d1b6"); } } + public static Color Topaz { get { return ColorTranslator.FromHtml("#13bbaf"); } } + public static Color VioletPink { get { return ColorTranslator.FromHtml("#fb5ffc"); } } + public static Color Wintergreen { get { return ColorTranslator.FromHtml("#20f986"); } } + public static Color YellowTan { get { return ColorTranslator.FromHtml("#ffe36e"); } } + public static Color DarkFuchsia { get { return ColorTranslator.FromHtml("#9d0759"); } } + public static Color IndigoBlue { get { return ColorTranslator.FromHtml("#3a18b1"); } } + public static Color LightYellowishGreen { get { return ColorTranslator.FromHtml("#c2ff89"); } } + public static Color PaleMagenta { get { return ColorTranslator.FromHtml("#d767ad"); } } + public static Color RichPurple { get { return ColorTranslator.FromHtml("#720058"); } } + public static Color SunflowerYellow { get { return ColorTranslator.FromHtml("#ffda03"); } } + public static Color Green_Blue { get { return ColorTranslator.FromHtml("#01c08d"); } } + public static Color Leather { get { return ColorTranslator.FromHtml("#ac7434"); } } + public static Color RacingGreen { get { return ColorTranslator.FromHtml("#014600"); } } + public static Color VividPurple { get { return ColorTranslator.FromHtml("#9900fa"); } } + public static Color DarkRoyalBlue { get { return ColorTranslator.FromHtml("#02066f"); } } + public static Color Hazel { get { return ColorTranslator.FromHtml("#8e7618"); } } + public static Color MutedPink { get { return ColorTranslator.FromHtml("#d1768f"); } } + public static Color BoogerGreen { get { return ColorTranslator.FromHtml("#96b403"); } } + public static Color Canary { get { return ColorTranslator.FromHtml("#fdff63"); } } + public static Color CoolGrey { get { return ColorTranslator.FromHtml("#95a3a6"); } } + public static Color DarkTaupe { get { return ColorTranslator.FromHtml("#7f684e"); } } + public static Color DarkishPurple { get { return ColorTranslator.FromHtml("#751973"); } } + public static Color TrueGreen { get { return ColorTranslator.FromHtml("#089404"); } } + public static Color CoralPink { get { return ColorTranslator.FromHtml("#ff6163"); } } + public static Color DarkSage { get { return ColorTranslator.FromHtml("#598556"); } } + public static Color DarkSlateBlue { get { return ColorTranslator.FromHtml("#214761"); } } + public static Color FlatBlue { get { return ColorTranslator.FromHtml("#3c73a8"); } } + public static Color Mushroom { get { return ColorTranslator.FromHtml("#ba9e88"); } } + public static Color RichBlue { get { return ColorTranslator.FromHtml("#021bf9"); } } + public static Color DirtyPurple { get { return ColorTranslator.FromHtml("#734a65"); } } + public static Color Greenblue { get { return ColorTranslator.FromHtml("#23c48b"); } } + public static Color IckyGreen { get { return ColorTranslator.FromHtml("#8fae22"); } } + public static Color LightKhaki { get { return ColorTranslator.FromHtml("#e6f2a2"); } } + public static Color WarmBlue { get { return ColorTranslator.FromHtml("#4b57db"); } } + public static Color DarkHotPink { get { return ColorTranslator.FromHtml("#d90166"); } } + public static Color DeepSeaBlue { get { return ColorTranslator.FromHtml("#015482"); } } + public static Color Carmine { get { return ColorTranslator.FromHtml("#9d0216"); } } + public static Color DarkYellowGreen { get { return ColorTranslator.FromHtml("#728f02"); } } + public static Color PalePeach { get { return ColorTranslator.FromHtml("#ffe5ad"); } } + public static Color PlumPurple { get { return ColorTranslator.FromHtml("#4e0550"); } } + public static Color GoldenRod { get { return ColorTranslator.FromHtml("#f9bc08"); } } + public static Color NeonRed { get { return ColorTranslator.FromHtml("#ff073a"); } } + public static Color OldPink { get { return ColorTranslator.FromHtml("#c77986"); } } + public static Color VeryPaleBlue { get { return ColorTranslator.FromHtml("#d6fffe"); } } + public static Color BloodOrange { get { return ColorTranslator.FromHtml("#fe4b03"); } } + public static Color Grapefruit { get { return ColorTranslator.FromHtml("#fd5956"); } } + public static Color SandYellow { get { return ColorTranslator.FromHtml("#fce166"); } } + public static Color ClayBrown { get { return ColorTranslator.FromHtml("#b2713d"); } } + public static Color DarkBlueGrey { get { return ColorTranslator.FromHtml("#1f3b4d"); } } + public static Color FlatGreen { get { return ColorTranslator.FromHtml("#699d4c"); } } + public static Color LightGreenBlue { get { return ColorTranslator.FromHtml("#56fca2"); } } + public static Color WarmPink { get { return ColorTranslator.FromHtml("#fb5581"); } } + public static Color DodgerBlue { get { return ColorTranslator.FromHtml("#3e82fc"); } } + public static Color GrossGreen { get { return ColorTranslator.FromHtml("#a0bf16"); } } + public static Color Ice { get { return ColorTranslator.FromHtml("#d6fffa"); } } + public static Color MetallicBlue { get { return ColorTranslator.FromHtml("#4f738e"); } } + public static Color PaleSalmon { get { return ColorTranslator.FromHtml("#ffb19a"); } } + public static Color SapGreen { get { return ColorTranslator.FromHtml("#5c8b15"); } } + public static Color Algae { get { return ColorTranslator.FromHtml("#54ac68"); } } + public static Color BlueyGrey { get { return ColorTranslator.FromHtml("#89a0b0"); } } + public static Color GreenyGrey { get { return ColorTranslator.FromHtml("#7ea07a"); } } + public static Color HighlighterGreen { get { return ColorTranslator.FromHtml("#1bfc06"); } } + public static Color LightLightBlue { get { return ColorTranslator.FromHtml("#cafffb"); } } + public static Color LightMint { get { return ColorTranslator.FromHtml("#b6ffbb"); } } + public static Color RawUmber { get { return ColorTranslator.FromHtml("#a75e09"); } } + public static Color VividBlue { get { return ColorTranslator.FromHtml("#152eff"); } } + public static Color DeepLavender { get { return ColorTranslator.FromHtml("#8d5eb7"); } } + public static Color DullTeal { get { return ColorTranslator.FromHtml("#5f9e8f"); } } + public static Color LightGreenishBlue { get { return ColorTranslator.FromHtml("#63f7b4"); } } + public static Color MudGreen { get { return ColorTranslator.FromHtml("#606602"); } } + public static Color Pinky { get { return ColorTranslator.FromHtml("#fc86aa"); } } + public static Color RedWine { get { return ColorTranslator.FromHtml("#8c0034"); } } + public static Color ShitGreen { get { return ColorTranslator.FromHtml("#758000"); } } + public static Color TanBrown { get { return ColorTranslator.FromHtml("#ab7e4c"); } } + public static Color Darkblue { get { return ColorTranslator.FromHtml("#030764"); } } + public static Color Rosa { get { return ColorTranslator.FromHtml("#fe86a4"); } } + public static Color Lipstick { get { return ColorTranslator.FromHtml("#d5174e"); } } + public static Color PaleMauve { get { return ColorTranslator.FromHtml("#fed0fc"); } } + public static Color Claret { get { return ColorTranslator.FromHtml("#680018"); } } + public static Color Dandelion { get { return ColorTranslator.FromHtml("#fedf08"); } } + public static Color Orangered { get { return ColorTranslator.FromHtml("#fe420f"); } } + public static Color PoopGreen { get { return ColorTranslator.FromHtml("#6f7c00"); } } + public static Color Ruby { get { return ColorTranslator.FromHtml("#ca0147"); } } + public static Color Dark { get { return ColorTranslator.FromHtml("#1b2431"); } } + public static Color GreenishTurquoise { get { return ColorTranslator.FromHtml("#00fbb0"); } } + public static Color PastelRed { get { return ColorTranslator.FromHtml("#db5856"); } } + public static Color PissYellow { get { return ColorTranslator.FromHtml("#ddd618"); } } + public static Color BrightCyan { get { return ColorTranslator.FromHtml("#41fdfe"); } } + public static Color DarkCoral { get { return ColorTranslator.FromHtml("#cf524e"); } } + public static Color AlgaeGreen { get { return ColorTranslator.FromHtml("#21c36f"); } } + public static Color DarkishRed { get { return ColorTranslator.FromHtml("#a90308"); } } + public static Color ReddyBrown { get { return ColorTranslator.FromHtml("#6e1005"); } } + public static Color BlushPink { get { return ColorTranslator.FromHtml("#fe828c"); } } + public static Color CamouflageGreen { get { return ColorTranslator.FromHtml("#4b6113"); } } + public static Color LawnGreen { get { return ColorTranslator.FromHtml("#4da409"); } } + public static Color Putty { get { return ColorTranslator.FromHtml("#beae8a"); } } + public static Color VibrantBlue { get { return ColorTranslator.FromHtml("#0339f8"); } } + public static Color DarkSand { get { return ColorTranslator.FromHtml("#a88f59"); } } + public static Color Purple_Blue { get { return ColorTranslator.FromHtml("#5d21d0"); } } + public static Color Saffron { get { return ColorTranslator.FromHtml("#feb209"); } } + public static Color Twilight { get { return ColorTranslator.FromHtml("#4e518b"); } } + public static Color WarmBrown { get { return ColorTranslator.FromHtml("#964e02"); } } + public static Color Bluegrey { get { return ColorTranslator.FromHtml("#85a3b2"); } } + public static Color BubbleGumPink { get { return ColorTranslator.FromHtml("#ff69af"); } } + public static Color DuckEggBlue { get { return ColorTranslator.FromHtml("#c3fbf4"); } } + public static Color GreenishCyan { get { return ColorTranslator.FromHtml("#2afeb7"); } } + public static Color Petrol { get { return ColorTranslator.FromHtml("#005f6a"); } } + public static Color Royal { get { return ColorTranslator.FromHtml("#0c1793"); } } + public static Color Butter { get { return ColorTranslator.FromHtml("#ffff81"); } } + public static Color DustyOrange { get { return ColorTranslator.FromHtml("#f0833a"); } } + public static Color OffYellow { get { return ColorTranslator.FromHtml("#f1f33f"); } } + public static Color PaleOliveGreen { get { return ColorTranslator.FromHtml("#b1d27b"); } } + public static Color Orangish { get { return ColorTranslator.FromHtml("#fc824a"); } } + public static Color Leaf { get { return ColorTranslator.FromHtml("#71aa34"); } } + public static Color LightBlueGrey { get { return ColorTranslator.FromHtml("#b7c9e2"); } } + public static Color DriedBlood { get { return ColorTranslator.FromHtml("#4b0101"); } } + public static Color LightishPurple { get { return ColorTranslator.FromHtml("#a552e6"); } } + public static Color RustyRed { get { return ColorTranslator.FromHtml("#af2f0d"); } } + public static Color LavenderBlue { get { return ColorTranslator.FromHtml("#8b88f8"); } } + public static Color LightGrassGreen { get { return ColorTranslator.FromHtml("#9af764"); } } + public static Color LightMintGreen { get { return ColorTranslator.FromHtml("#a6fbb2"); } } + public static Color Sunflower { get { return ColorTranslator.FromHtml("#ffc512"); } } + public static Color Velvet { get { return ColorTranslator.FromHtml("#750851"); } } + public static Color BrickOrange { get { return ColorTranslator.FromHtml("#c14a09"); } } + public static Color LightishRed { get { return ColorTranslator.FromHtml("#fe2f4a"); } } + public static Color PureBlue { get { return ColorTranslator.FromHtml("#0203e2"); } } + public static Color TwilightBlue { get { return ColorTranslator.FromHtml("#0a437a"); } } + public static Color VioletRed { get { return ColorTranslator.FromHtml("#a50055"); } } + public static Color YellowyBrown { get { return ColorTranslator.FromHtml("#ae8b0c"); } } + public static Color Carnation { get { return ColorTranslator.FromHtml("#fd798f"); } } + public static Color MuddyYellow { get { return ColorTranslator.FromHtml("#bfac05"); } } + public static Color DarkSeafoamGreen { get { return ColorTranslator.FromHtml("#3eaf76"); } } + public static Color DeepRose { get { return ColorTranslator.FromHtml("#c74767"); } } + public static Color DustyRed { get { return ColorTranslator.FromHtml("#b9484e"); } } + public static Color Grey_Blue { get { return ColorTranslator.FromHtml("#647d8e"); } } + public static Color LemonLime { get { return ColorTranslator.FromHtml("#bffe28"); } } + public static Color Purple_Pink { get { return ColorTranslator.FromHtml("#d725de"); } } + public static Color BrownYellow { get { return ColorTranslator.FromHtml("#b29705"); } } + public static Color PurpleBrown { get { return ColorTranslator.FromHtml("#673a3f"); } } + public static Color Wisteria { get { return ColorTranslator.FromHtml("#a87dc2"); } } + public static Color BananaYellow { get { return ColorTranslator.FromHtml("#fafe4b"); } } + public static Color LipstickRed { get { return ColorTranslator.FromHtml("#c0022f"); } } + public static Color WaterBlue { get { return ColorTranslator.FromHtml("#0e87cc"); } } + public static Color BrownGrey { get { return ColorTranslator.FromHtml("#8d8468"); } } + public static Color VibrantPurple { get { return ColorTranslator.FromHtml("#ad03de"); } } + public static Color BabyGreen { get { return ColorTranslator.FromHtml("#8cff9e"); } } + public static Color BarfGreen { get { return ColorTranslator.FromHtml("#94ac02"); } } + public static Color EggshellBlue { get { return ColorTranslator.FromHtml("#c4fff7"); } } + public static Color SandyYellow { get { return ColorTranslator.FromHtml("#fdee73"); } } + public static Color CoolGreen { get { return ColorTranslator.FromHtml("#33b864"); } } + public static Color Pale { get { return ColorTranslator.FromHtml("#fff9d0"); } } + public static Color Blue_Grey { get { return ColorTranslator.FromHtml("#758da3"); } } + public static Color HotMagenta { get { return ColorTranslator.FromHtml("#f504c9"); } } + public static Color Greyblue { get { return ColorTranslator.FromHtml("#77a1b5"); } } + public static Color Purpley { get { return ColorTranslator.FromHtml("#8756e4"); } } + public static Color BabyShitGreen { get { return ColorTranslator.FromHtml("#889717"); } } + public static Color BrownishPink { get { return ColorTranslator.FromHtml("#c27e79"); } } + public static Color DarkAquamarine { get { return ColorTranslator.FromHtml("#017371"); } } + public static Color Diarrhea { get { return ColorTranslator.FromHtml("#9f8303"); } } + public static Color LightMustard { get { return ColorTranslator.FromHtml("#f7d560"); } } + public static Color PaleSkyBlue { get { return ColorTranslator.FromHtml("#bdf6fe"); } } + public static Color TurtleGreen { get { return ColorTranslator.FromHtml("#75b84f"); } } + public static Color BrightOlive { get { return ColorTranslator.FromHtml("#9cbb04"); } } + public static Color DarkGreyBlue { get { return ColorTranslator.FromHtml("#29465b"); } } + public static Color GreenyBrown { get { return ColorTranslator.FromHtml("#696006"); } } + public static Color LemonGreen { get { return ColorTranslator.FromHtml("#adf802"); } } + public static Color LightPeriwinkle { get { return ColorTranslator.FromHtml("#c1c6fc"); } } + public static Color SeaweedGreen { get { return ColorTranslator.FromHtml("#35ad6b"); } } + public static Color SunshineYellow { get { return ColorTranslator.FromHtml("#fffd37"); } } + public static Color UglyPurple { get { return ColorTranslator.FromHtml("#a442a0"); } } + public static Color MediumPink { get { return ColorTranslator.FromHtml("#f36196"); } } + public static Color PukeBrown { get { return ColorTranslator.FromHtml("#947706"); } } + public static Color VeryLightPink { get { return ColorTranslator.FromHtml("#fff4f2"); } } + public static Color Viridian { get { return ColorTranslator.FromHtml("#1e9167"); } } + public static Color Bile { get { return ColorTranslator.FromHtml("#b5c306"); } } + public static Color FadedYellow { get { return ColorTranslator.FromHtml("#feff7f"); } } + public static Color VeryPaleGreen { get { return ColorTranslator.FromHtml("#cffdbc"); } } + public static Color VibrantGreen { get { return ColorTranslator.FromHtml("#0add08"); } } + public static Color BrightLime { get { return ColorTranslator.FromHtml("#87fd05"); } } + public static Color Spearmint { get { return ColorTranslator.FromHtml("#1ef876"); } } + public static Color LightAquamarine { get { return ColorTranslator.FromHtml("#7bfdc7"); } } + public static Color LightSage { get { return ColorTranslator.FromHtml("#bcecac"); } } + public static Color Yellowgreen { get { return ColorTranslator.FromHtml("#bbf90f"); } } + public static Color BabyPoo { get { return ColorTranslator.FromHtml("#ab9004"); } } + public static Color DarkSeafoam { get { return ColorTranslator.FromHtml("#1fb57a"); } } + public static Color DeepTeal { get { return ColorTranslator.FromHtml("#00555a"); } } + public static Color Heather { get { return ColorTranslator.FromHtml("#a484ac"); } } + public static Color RustOrange { get { return ColorTranslator.FromHtml("#c45508"); } } + public static Color DirtyBlue { get { return ColorTranslator.FromHtml("#3f829d"); } } + public static Color FernGreen { get { return ColorTranslator.FromHtml("#548d44"); } } + public static Color BrightLilac { get { return ColorTranslator.FromHtml("#c95efb"); } } + public static Color WeirdGreen { get { return ColorTranslator.FromHtml("#3ae57f"); } } + public static Color PeacockBlue { get { return ColorTranslator.FromHtml("#016795"); } } + public static Color AvocadoGreen { get { return ColorTranslator.FromHtml("#87a922"); } } + public static Color FadedOrange { get { return ColorTranslator.FromHtml("#f0944d"); } } + public static Color GrapePurple { get { return ColorTranslator.FromHtml("#5d1451"); } } + public static Color HotGreen { get { return ColorTranslator.FromHtml("#25ff29"); } } + public static Color LimeYellow { get { return ColorTranslator.FromHtml("#d0fe1d"); } } + public static Color Mango { get { return ColorTranslator.FromHtml("#ffa62b"); } } + public static Color Shamrock { get { return ColorTranslator.FromHtml("#01b44c"); } } + public static Color Bubblegum { get { return ColorTranslator.FromHtml("#ff6cb5"); } } + public static Color PurplishBrown { get { return ColorTranslator.FromHtml("#6b4247"); } } + public static Color VomitYellow { get { return ColorTranslator.FromHtml("#c7c10c"); } } + public static Color PaleCyan { get { return ColorTranslator.FromHtml("#b7fffa"); } } + public static Color KeyLime { get { return ColorTranslator.FromHtml("#aeff6e"); } } + public static Color TomatoRed { get { return ColorTranslator.FromHtml("#ec2d01"); } } + public static Color Lightgreen { get { return ColorTranslator.FromHtml("#76ff7b"); } } + public static Color Merlot { get { return ColorTranslator.FromHtml("#730039"); } } + public static Color NightBlue { get { return ColorTranslator.FromHtml("#040348"); } } + public static Color PurpleishPink { get { return ColorTranslator.FromHtml("#df4ec8"); } } + public static Color Apple { get { return ColorTranslator.FromHtml("#6ecb3c"); } } + public static Color BabyPoopGreen { get { return ColorTranslator.FromHtml("#8f9805"); } } + public static Color GreenApple { get { return ColorTranslator.FromHtml("#5edc1f"); } } + public static Color Heliotrope { get { return ColorTranslator.FromHtml("#d94ff5"); } } + public static Color Yellow_Green { get { return ColorTranslator.FromHtml("#c8fd3d"); } } + public static Color AlmostBlack { get { return ColorTranslator.FromHtml("#070d0d"); } } + public static Color CoolBlue { get { return ColorTranslator.FromHtml("#4984b8"); } } + public static Color LeafyGreen { get { return ColorTranslator.FromHtml("#51b73b"); } } + public static Color MustardBrown { get { return ColorTranslator.FromHtml("#ac7e04"); } } + public static Color Dusk { get { return ColorTranslator.FromHtml("#4e5481"); } } + public static Color DullBrown { get { return ColorTranslator.FromHtml("#876e4b"); } } + public static Color FrogGreen { get { return ColorTranslator.FromHtml("#58bc08"); } } + public static Color VividGreen { get { return ColorTranslator.FromHtml("#2fef10"); } } + public static Color BrightLightGreen { get { return ColorTranslator.FromHtml("#2dfe54"); } } + public static Color FluroGreen { get { return ColorTranslator.FromHtml("#0aff02"); } } + public static Color Kiwi { get { return ColorTranslator.FromHtml("#9cef43"); } } + public static Color Seaweed { get { return ColorTranslator.FromHtml("#18d17b"); } } + public static Color NavyGreen { get { return ColorTranslator.FromHtml("#35530a"); } } + public static Color UltramarineBlue { get { return ColorTranslator.FromHtml("#1805db"); } } + public static Color Iris { get { return ColorTranslator.FromHtml("#6258c4"); } } + public static Color PastelOrange { get { return ColorTranslator.FromHtml("#ff964f"); } } + public static Color YellowishOrange { get { return ColorTranslator.FromHtml("#ffab0f"); } } + public static Color Perrywinkle { get { return ColorTranslator.FromHtml("#8f8ce7"); } } + public static Color Tealish { get { return ColorTranslator.FromHtml("#24bca8"); } } + public static Color DarkPlum { get { return ColorTranslator.FromHtml("#3f012c"); } } + public static Color Pear { get { return ColorTranslator.FromHtml("#cbf85f"); } } + public static Color PinkishOrange { get { return ColorTranslator.FromHtml("#ff724c"); } } + public static Color MidnightPurple { get { return ColorTranslator.FromHtml("#280137"); } } + public static Color LightUrple { get { return ColorTranslator.FromHtml("#b36ff6"); } } + public static Color DarkMint { get { return ColorTranslator.FromHtml("#48c072"); } } + public static Color GreenishTan { get { return ColorTranslator.FromHtml("#bccb7a"); } } + public static Color LightBurgundy { get { return ColorTranslator.FromHtml("#a8415b"); } } + public static Color TurquoiseBlue { get { return ColorTranslator.FromHtml("#06b1c4"); } } + public static Color UglyPink { get { return ColorTranslator.FromHtml("#cd7584"); } } + public static Color Sandy { get { return ColorTranslator.FromHtml("#f1da7a"); } } + public static Color ElectricPink { get { return ColorTranslator.FromHtml("#ff0490"); } } + public static Color MutedPurple { get { return ColorTranslator.FromHtml("#805b87"); } } + public static Color MidGreen { get { return ColorTranslator.FromHtml("#50a747"); } } + public static Color Greyish { get { return ColorTranslator.FromHtml("#a8a495"); } } + public static Color NeonYellow { get { return ColorTranslator.FromHtml("#cfff04"); } } + public static Color Banana { get { return ColorTranslator.FromHtml("#ffff7e"); } } + public static Color CarnationPink { get { return ColorTranslator.FromHtml("#ff7fa7"); } } + public static Color Tomato { get { return ColorTranslator.FromHtml("#ef4026"); } } + public static Color Sea { get { return ColorTranslator.FromHtml("#3c9992"); } } + public static Color MuddyBrown { get { return ColorTranslator.FromHtml("#886806"); } } + public static Color TurquoiseGreen { get { return ColorTranslator.FromHtml("#04f489"); } } + public static Color Buff { get { return ColorTranslator.FromHtml("#fef69e"); } } + public static Color Fawn { get { return ColorTranslator.FromHtml("#cfaf7b"); } } + public static Color MutedBlue { get { return ColorTranslator.FromHtml("#3b719f"); } } + public static Color PaleRose { get { return ColorTranslator.FromHtml("#fdc1c5"); } } + public static Color DarkMintGreen { get { return ColorTranslator.FromHtml("#20c073"); } } + public static Color Amethyst { get { return ColorTranslator.FromHtml("#9b5fc0"); } } + public static Color Blue_Green { get { return ColorTranslator.FromHtml("#0f9b8e"); } } + public static Color Chestnut { get { return ColorTranslator.FromHtml("#742802"); } } + public static Color SickGreen { get { return ColorTranslator.FromHtml("#9db92c"); } } + public static Color Pea { get { return ColorTranslator.FromHtml("#a4bf20"); } } + public static Color RustyOrange { get { return ColorTranslator.FromHtml("#cd5909"); } } + public static Color Stone { get { return ColorTranslator.FromHtml("#ada587"); } } + public static Color RoseRed { get { return ColorTranslator.FromHtml("#be013c"); } } + public static Color PaleAqua { get { return ColorTranslator.FromHtml("#b8ffeb"); } } + public static Color DeepOrange { get { return ColorTranslator.FromHtml("#dc4d01"); } } + public static Color Earth { get { return ColorTranslator.FromHtml("#a2653e"); } } + public static Color MossyGreen { get { return ColorTranslator.FromHtml("#638b27"); } } + public static Color GrassyGreen { get { return ColorTranslator.FromHtml("#419c03"); } } + public static Color PaleLimeGreen { get { return ColorTranslator.FromHtml("#b1ff65"); } } + public static Color LightGreyBlue { get { return ColorTranslator.FromHtml("#9dbcd4"); } } + public static Color PaleGrey { get { return ColorTranslator.FromHtml("#fdfdfe"); } } + public static Color Asparagus { get { return ColorTranslator.FromHtml("#77ab56"); } } + public static Color Blueberry { get { return ColorTranslator.FromHtml("#464196"); } } + public static Color PurpleRed { get { return ColorTranslator.FromHtml("#990147"); } } + public static Color PaleLime { get { return ColorTranslator.FromHtml("#befd73"); } } + public static Color GreenishTeal { get { return ColorTranslator.FromHtml("#32bf84"); } } + public static Color Caramel { get { return ColorTranslator.FromHtml("#af6f09"); } } + public static Color DeepMagenta { get { return ColorTranslator.FromHtml("#a0025c"); } } + public static Color LightPeach { get { return ColorTranslator.FromHtml("#ffd8b1"); } } + public static Color MilkChocolate { get { return ColorTranslator.FromHtml("#7f4e1e"); } } + public static Color Ocher { get { return ColorTranslator.FromHtml("#bf9b0c"); } } + public static Color OffGreen { get { return ColorTranslator.FromHtml("#6ba353"); } } + public static Color PurplyPink { get { return ColorTranslator.FromHtml("#f075e6"); } } + public static Color Lightblue { get { return ColorTranslator.FromHtml("#7bc8f6"); } } + public static Color DuskyBlue { get { return ColorTranslator.FromHtml("#475f94"); } } + public static Color Golden { get { return ColorTranslator.FromHtml("#f5bf03"); } } + public static Color LightBeige { get { return ColorTranslator.FromHtml("#fffeb6"); } } + public static Color ButterYellow { get { return ColorTranslator.FromHtml("#fffd74"); } } + public static Color DuskyPurple { get { return ColorTranslator.FromHtml("#895b7b"); } } + public static Color FrenchBlue { get { return ColorTranslator.FromHtml("#436bad"); } } + public static Color UglyYellow { get { return ColorTranslator.FromHtml("#d0c101"); } } + public static Color GreenyYellow { get { return ColorTranslator.FromHtml("#c6f808"); } } + public static Color OrangishRed { get { return ColorTranslator.FromHtml("#f43605"); } } + public static Color ShamrockGreen { get { return ColorTranslator.FromHtml("#02c14d"); } } + public static Color OrangishBrown { get { return ColorTranslator.FromHtml("#b25f03"); } } + public static Color TreeGreen { get { return ColorTranslator.FromHtml("#2a7e19"); } } + public static Color DeepViolet { get { return ColorTranslator.FromHtml("#490648"); } } + public static Color Gunmetal { get { return ColorTranslator.FromHtml("#536267"); } } + public static Color Blue_Purple { get { return ColorTranslator.FromHtml("#5a06ef"); } } + public static Color Cherry { get { return ColorTranslator.FromHtml("#cf0234"); } } + public static Color SandyBrown { get { return ColorTranslator.FromHtml("#c4a661"); } } + public static Color WarmGrey { get { return ColorTranslator.FromHtml("#978a84"); } } + public static Color DarkIndigo { get { return ColorTranslator.FromHtml("#1f0954"); } } + public static Color Midnight { get { return ColorTranslator.FromHtml("#03012d"); } } + public static Color BlueyGreen { get { return ColorTranslator.FromHtml("#2bb179"); } } + public static Color GreyPink { get { return ColorTranslator.FromHtml("#c3909b"); } } + public static Color SoftPurple { get { return ColorTranslator.FromHtml("#a66fb5"); } } + public static Color Blood { get { return ColorTranslator.FromHtml("#770001"); } } + public static Color BrownRed { get { return ColorTranslator.FromHtml("#922b05"); } } + public static Color MediumGrey { get { return ColorTranslator.FromHtml("#7d7f7c"); } } + public static Color Berry { get { return ColorTranslator.FromHtml("#990f4b"); } } + public static Color Poo { get { return ColorTranslator.FromHtml("#8f7303"); } } + public static Color PurpleyPink { get { return ColorTranslator.FromHtml("#c83cb9"); } } + public static Color LightSalmon { get { return ColorTranslator.FromHtml("#fea993"); } } + public static Color Snot { get { return ColorTranslator.FromHtml("#acbb0d"); } } + public static Color EasterPurple { get { return ColorTranslator.FromHtml("#c071fe"); } } + public static Color LightYellowGreen { get { return ColorTranslator.FromHtml("#ccfd7f"); } } + public static Color DarkNavyBlue { get { return ColorTranslator.FromHtml("#00022e"); } } + public static Color Drab { get { return ColorTranslator.FromHtml("#828344"); } } + public static Color LightRose { get { return ColorTranslator.FromHtml("#ffc5cb"); } } + public static Color Rouge { get { return ColorTranslator.FromHtml("#ab1239"); } } + public static Color PurplishRed { get { return ColorTranslator.FromHtml("#b0054b"); } } + public static Color SlimeGreen { get { return ColorTranslator.FromHtml("#99cc04"); } } + public static Color BabyPoop { get { return ColorTranslator.FromHtml("#937c00"); } } + public static Color IrishGreen { get { return ColorTranslator.FromHtml("#019529"); } } + public static Color Pink_Purple { get { return ColorTranslator.FromHtml("#ef1de7"); } } + public static Color DarkNavy { get { return ColorTranslator.FromHtml("#000435"); } } + public static Color GreenyBlue { get { return ColorTranslator.FromHtml("#42b395"); } } + public static Color LightPlum { get { return ColorTranslator.FromHtml("#9d5783"); } } + public static Color PinkishGrey { get { return ColorTranslator.FromHtml("#c8aca9"); } } + public static Color DirtyOrange { get { return ColorTranslator.FromHtml("#c87606"); } } + public static Color RustRed { get { return ColorTranslator.FromHtml("#aa2704"); } } + public static Color PaleLilac { get { return ColorTranslator.FromHtml("#e4cbff"); } } + public static Color OrangeyRed { get { return ColorTranslator.FromHtml("#fa4224"); } } + public static Color PrimaryBlue { get { return ColorTranslator.FromHtml("#0804f9"); } } + public static Color KermitGreen { get { return ColorTranslator.FromHtml("#5cb200"); } } + public static Color BrownishPurple { get { return ColorTranslator.FromHtml("#76424e"); } } + public static Color MurkyGreen { get { return ColorTranslator.FromHtml("#6c7a0e"); } } + public static Color Wheat { get { return ColorTranslator.FromHtml("#fbdd7e"); } } + public static Color VeryDarkPurple { get { return ColorTranslator.FromHtml("#2a0134"); } } + public static Color BottleGreen { get { return ColorTranslator.FromHtml("#044a05"); } } + public static Color Watermelon { get { return ColorTranslator.FromHtml("#fd4659"); } } + public static Color DeepSkyBlue { get { return ColorTranslator.FromHtml("#0d75f8"); } } + public static Color FireEngineRed { get { return ColorTranslator.FromHtml("#fe0002"); } } + public static Color YellowOchre { get { return ColorTranslator.FromHtml("#cb9d06"); } } + public static Color PumpkinOrange { get { return ColorTranslator.FromHtml("#fb7d07"); } } + public static Color PaleOlive { get { return ColorTranslator.FromHtml("#b9cc81"); } } + public static Color LightLilac { get { return ColorTranslator.FromHtml("#edc8ff"); } } + public static Color LightishGreen { get { return ColorTranslator.FromHtml("#61e160"); } } + public static Color CarolinaBlue { get { return ColorTranslator.FromHtml("#8ab8fe"); } } + public static Color Mulberry { get { return ColorTranslator.FromHtml("#920a4e"); } } + public static Color ShockingPink { get { return ColorTranslator.FromHtml("#fe02a2"); } } + public static Color Auburn { get { return ColorTranslator.FromHtml("#9a3001"); } } + public static Color BrightLimeGreen { get { return ColorTranslator.FromHtml("#65fe08"); } } + public static Color Celadon { get { return ColorTranslator.FromHtml("#befdb7"); } } + public static Color PinkishBrown { get { return ColorTranslator.FromHtml("#b17261"); } } + public static Color PooBrown { get { return ColorTranslator.FromHtml("#885f01"); } } + public static Color BrightSkyBlue { get { return ColorTranslator.FromHtml("#02ccfe"); } } + public static Color Celery { get { return ColorTranslator.FromHtml("#c1fd95"); } } + public static Color DirtBrown { get { return ColorTranslator.FromHtml("#836539"); } } + public static Color Strawberry { get { return ColorTranslator.FromHtml("#fb2943"); } } + public static Color DarkLime { get { return ColorTranslator.FromHtml("#84b701"); } } + public static Color Copper { get { return ColorTranslator.FromHtml("#b66325"); } } + public static Color MediumBrown { get { return ColorTranslator.FromHtml("#7f5112"); } } + public static Color MutedGreen { get { return ColorTranslator.FromHtml("#5fa052"); } } + public static Color RobinSEgg { get { return ColorTranslator.FromHtml("#6dedfd"); } } + public static Color BrightAqua { get { return ColorTranslator.FromHtml("#0bf9ea"); } } + public static Color BrightLavender { get { return ColorTranslator.FromHtml("#c760ff"); } } + public static Color Ivory { get { return ColorTranslator.FromHtml("#ffffcb"); } } + public static Color VeryLightPurple { get { return ColorTranslator.FromHtml("#f6cefc"); } } + public static Color LightNavy { get { return ColorTranslator.FromHtml("#155084"); } } + public static Color PinkRed { get { return ColorTranslator.FromHtml("#f5054f"); } } + public static Color OliveBrown { get { return ColorTranslator.FromHtml("#645403"); } } + public static Color PoopBrown { get { return ColorTranslator.FromHtml("#7a5901"); } } + public static Color MustardGreen { get { return ColorTranslator.FromHtml("#a8b504"); } } + public static Color OceanGreen { get { return ColorTranslator.FromHtml("#3d9973"); } } + public static Color VeryDarkBlue { get { return ColorTranslator.FromHtml("#000133"); } } + public static Color DustyGreen { get { return ColorTranslator.FromHtml("#76a973"); } } + public static Color LightNavyBlue { get { return ColorTranslator.FromHtml("#2e5a88"); } } + public static Color MintyGreen { get { return ColorTranslator.FromHtml("#0bf77d"); } } + public static Color Adobe { get { return ColorTranslator.FromHtml("#bd6c48"); } } + public static Color Barney { get { return ColorTranslator.FromHtml("#ac1db8"); } } + public static Color JadeGreen { get { return ColorTranslator.FromHtml("#2baf6a"); } } + public static Color BrightLightBlue { get { return ColorTranslator.FromHtml("#26f7fd"); } } + public static Color LightLime { get { return ColorTranslator.FromHtml("#aefd6c"); } } + public static Color DarkKhaki { get { return ColorTranslator.FromHtml("#9b8f55"); } } + public static Color OrangeYellow { get { return ColorTranslator.FromHtml("#ffad01"); } } + public static Color Ocre { get { return ColorTranslator.FromHtml("#c69c04"); } } + public static Color Maize { get { return ColorTranslator.FromHtml("#f4d054"); } } + public static Color FadedPink { get { return ColorTranslator.FromHtml("#de9dac"); } } + public static Color BritishRacingGreen { get { return ColorTranslator.FromHtml("#05480d"); } } + public static Color Sandstone { get { return ColorTranslator.FromHtml("#c9ae74"); } } + public static Color MudBrown { get { return ColorTranslator.FromHtml("#60460f"); } } + public static Color LightSeaGreen { get { return ColorTranslator.FromHtml("#98f6b0"); } } + public static Color RobinEggBlue { get { return ColorTranslator.FromHtml("#8af1fe"); } } + public static Color AquaMarine { get { return ColorTranslator.FromHtml("#2ee8bb"); } } + public static Color DarkSeaGreen { get { return ColorTranslator.FromHtml("#11875d"); } } + public static Color SoftPink { get { return ColorTranslator.FromHtml("#fdb0c0"); } } + public static Color OrangeyBrown { get { return ColorTranslator.FromHtml("#b16002"); } } + public static Color CherryRed { get { return ColorTranslator.FromHtml("#f7022a"); } } + public static Color BurntYellow { get { return ColorTranslator.FromHtml("#d5ab09"); } } + public static Color BrownishGrey { get { return ColorTranslator.FromHtml("#86775f"); } } + public static Color Camel { get { return ColorTranslator.FromHtml("#c69f59"); } } + public static Color PurplishGrey { get { return ColorTranslator.FromHtml("#7a687f"); } } + public static Color Marine { get { return ColorTranslator.FromHtml("#042e60"); } } + public static Color GreyishPink { get { return ColorTranslator.FromHtml("#c88d94"); } } + public static Color PaleTurquoise { get { return ColorTranslator.FromHtml("#a5fbd5"); } } + public static Color PastelYellow { get { return ColorTranslator.FromHtml("#fffe71"); } } + public static Color BlueyPurple { get { return ColorTranslator.FromHtml("#6241c7"); } } + public static Color CanaryYellow { get { return ColorTranslator.FromHtml("#fffe40"); } } + public static Color FadedRed { get { return ColorTranslator.FromHtml("#d3494e"); } } + public static Color Sepia { get { return ColorTranslator.FromHtml("#985e2b"); } } + public static Color Coffee { get { return ColorTranslator.FromHtml("#a6814c"); } } + public static Color BrightMagenta { get { return ColorTranslator.FromHtml("#ff08e8"); } } + public static Color Mocha { get { return ColorTranslator.FromHtml("#9d7651"); } } + public static Color Ecru { get { return ColorTranslator.FromHtml("#feffca"); } } + public static Color Purpleish { get { return ColorTranslator.FromHtml("#98568d"); } } + public static Color Cranberry { get { return ColorTranslator.FromHtml("#9e003a"); } } + public static Color DarkishGreen { get { return ColorTranslator.FromHtml("#287c37"); } } + public static Color BrownOrange { get { return ColorTranslator.FromHtml("#b96902"); } } + public static Color DuskyRose { get { return ColorTranslator.FromHtml("#ba6873"); } } + public static Color Melon { get { return ColorTranslator.FromHtml("#ff7855"); } } + public static Color SicklyGreen { get { return ColorTranslator.FromHtml("#94b21c"); } } + public static Color Silver { get { return ColorTranslator.FromHtml("#c5c9c7"); } } + public static Color PurplyBlue { get { return ColorTranslator.FromHtml("#661aee"); } } + public static Color PurpleishBlue { get { return ColorTranslator.FromHtml("#6140ef"); } } + public static Color HospitalGreen { get { return ColorTranslator.FromHtml("#9be5aa"); } } + public static Color ShitBrown { get { return ColorTranslator.FromHtml("#7b5804"); } } + public static Color MidBlue { get { return ColorTranslator.FromHtml("#276ab3"); } } + public static Color Amber { get { return ColorTranslator.FromHtml("#feb308"); } } + public static Color EasterGreen { get { return ColorTranslator.FromHtml("#8cfd7e"); } } + public static Color SoftBlue { get { return ColorTranslator.FromHtml("#6488ea"); } } + public static Color CeruleanBlue { get { return ColorTranslator.FromHtml("#056eee"); } } + public static Color GoldenBrown { get { return ColorTranslator.FromHtml("#b27a01"); } } + public static Color BrightTurquoise { get { return ColorTranslator.FromHtml("#0ffef9"); } } + public static Color RedPink { get { return ColorTranslator.FromHtml("#fa2a55"); } } + public static Color RedPurple { get { return ColorTranslator.FromHtml("#820747"); } } + public static Color GreyishBrown { get { return ColorTranslator.FromHtml("#7a6a4f"); } } + public static Color Vermillion { get { return ColorTranslator.FromHtml("#f4320c"); } } + public static Color Russet { get { return ColorTranslator.FromHtml("#a13905"); } } + public static Color SteelGrey { get { return ColorTranslator.FromHtml("#6f828a"); } } + public static Color LighterPurple { get { return ColorTranslator.FromHtml("#a55af4"); } } + public static Color BrightViolet { get { return ColorTranslator.FromHtml("#ad0afd"); } } + public static Color PrussianBlue { get { return ColorTranslator.FromHtml("#004577"); } } + public static Color SlateGreen { get { return ColorTranslator.FromHtml("#658d6d"); } } + public static Color DirtyPink { get { return ColorTranslator.FromHtml("#ca7b80"); } } + public static Color DarkBlueGreen { get { return ColorTranslator.FromHtml("#005249"); } } + public static Color Pine { get { return ColorTranslator.FromHtml("#2b5d34"); } } + public static Color YellowyGreen { get { return ColorTranslator.FromHtml("#bff128"); } } + public static Color DarkGold { get { return ColorTranslator.FromHtml("#b59410"); } } + public static Color Bluish { get { return ColorTranslator.FromHtml("#2976bb"); } } + public static Color DarkishBlue { get { return ColorTranslator.FromHtml("#014182"); } } + public static Color DullRed { get { return ColorTranslator.FromHtml("#bb3f3f"); } } + public static Color PinkyRed { get { return ColorTranslator.FromHtml("#fc2647"); } } + public static Color Bronze { get { return ColorTranslator.FromHtml("#a87900"); } } + public static Color PaleTeal { get { return ColorTranslator.FromHtml("#82cbb2"); } } + public static Color MilitaryGreen { get { return ColorTranslator.FromHtml("#667c3e"); } } + public static Color BarbiePink { get { return ColorTranslator.FromHtml("#fe46a5"); } } + public static Color BubblegumPink { get { return ColorTranslator.FromHtml("#fe83cc"); } } + public static Color PeaSoupGreen { get { return ColorTranslator.FromHtml("#94a617"); } } + public static Color DarkMustard { get { return ColorTranslator.FromHtml("#a88905"); } } + public static Color Shit { get { return ColorTranslator.FromHtml("#7f5f00"); } } + public static Color MediumPurple { get { return ColorTranslator.FromHtml("#9e43a2"); } } + public static Color VeryDarkGreen { get { return ColorTranslator.FromHtml("#062e03"); } } + public static Color Dirt { get { return ColorTranslator.FromHtml("#8a6e45"); } } + public static Color DuskyPink { get { return ColorTranslator.FromHtml("#cc7a8b"); } } + public static Color RedViolet { get { return ColorTranslator.FromHtml("#9e0168"); } } + public static Color LemonYellow { get { return ColorTranslator.FromHtml("#fdff38"); } } + public static Color Pistachio { get { return ColorTranslator.FromHtml("#c0fa8b"); } } + public static Color DullYellow { get { return ColorTranslator.FromHtml("#eedc5b"); } } + public static Color DarkLimeGreen { get { return ColorTranslator.FromHtml("#7ebd01"); } } + public static Color DenimBlue { get { return ColorTranslator.FromHtml("#3b5b92"); } } + public static Color TealBlue { get { return ColorTranslator.FromHtml("#01889f"); } } + public static Color LightishBlue { get { return ColorTranslator.FromHtml("#3d7afd"); } } + public static Color PurpleyBlue { get { return ColorTranslator.FromHtml("#5f34e7"); } } + public static Color LightIndigo { get { return ColorTranslator.FromHtml("#6d5acf"); } } + public static Color SwampGreen { get { return ColorTranslator.FromHtml("#748500"); } } + public static Color BrownGreen { get { return ColorTranslator.FromHtml("#706c11"); } } + public static Color DarkMaroon { get { return ColorTranslator.FromHtml("#3c0008"); } } + public static Color HotPurple { get { return ColorTranslator.FromHtml("#cb00f5"); } } + public static Color DarkForestGreen { get { return ColorTranslator.FromHtml("#002d04"); } } + public static Color FadedBlue { get { return ColorTranslator.FromHtml("#658cbb"); } } + public static Color DrabGreen { get { return ColorTranslator.FromHtml("#749551"); } } + public static Color LightLimeGreen { get { return ColorTranslator.FromHtml("#b9ff66"); } } + public static Color SnotGreen { get { return ColorTranslator.FromHtml("#9dc100"); } } + public static Color Yellowish { get { return ColorTranslator.FromHtml("#faee66"); } } + public static Color LightBlueGreen { get { return ColorTranslator.FromHtml("#7efbb3"); } } + public static Color Bordeaux { get { return ColorTranslator.FromHtml("#7b002c"); } } + public static Color LightMauve { get { return ColorTranslator.FromHtml("#c292a1"); } } + public static Color Ocean { get { return ColorTranslator.FromHtml("#017b92"); } } + public static Color Marigold { get { return ColorTranslator.FromHtml("#fcc006"); } } + public static Color MuddyGreen { get { return ColorTranslator.FromHtml("#657432"); } } + public static Color DullOrange { get { return ColorTranslator.FromHtml("#d8863b"); } } + public static Color Steel { get { return ColorTranslator.FromHtml("#738595"); } } + public static Color ElectricPurple { get { return ColorTranslator.FromHtml("#aa23ff"); } } + public static Color FluorescentGreen { get { return ColorTranslator.FromHtml("#08ff08"); } } + public static Color YellowishBrown { get { return ColorTranslator.FromHtml("#9b7a01"); } } + public static Color Blush { get { return ColorTranslator.FromHtml("#f29e8e"); } } + public static Color SoftGreen { get { return ColorTranslator.FromHtml("#6fc276"); } } + public static Color BrightOrange { get { return ColorTranslator.FromHtml("#ff5b00"); } } + public static Color Lemon { get { return ColorTranslator.FromHtml("#fdff52"); } } + public static Color PurpleGrey { get { return ColorTranslator.FromHtml("#866f85"); } } + public static Color AcidGreen { get { return ColorTranslator.FromHtml("#8ffe09"); } } + public static Color PaleLavender { get { return ColorTranslator.FromHtml("#eecffe"); } } + public static Color VioletBlue { get { return ColorTranslator.FromHtml("#510ac9"); } } + public static Color LightForestGreen { get { return ColorTranslator.FromHtml("#4f9153"); } } + public static Color BurntRed { get { return ColorTranslator.FromHtml("#9f2305"); } } + public static Color KhakiGreen { get { return ColorTranslator.FromHtml("#728639"); } } + public static Color Cerise { get { return ColorTranslator.FromHtml("#de0c62"); } } + public static Color FadedPurple { get { return ColorTranslator.FromHtml("#916e99"); } } + public static Color Apricot { get { return ColorTranslator.FromHtml("#ffb16d"); } } + public static Color DarkOliveGreen { get { return ColorTranslator.FromHtml("#3c4d03"); } } + public static Color GreyBrown { get { return ColorTranslator.FromHtml("#7f7053"); } } + public static Color GreenGrey { get { return ColorTranslator.FromHtml("#77926f"); } } + public static Color TrueBlue { get { return ColorTranslator.FromHtml("#010fcc"); } } + public static Color PaleViolet { get { return ColorTranslator.FromHtml("#ceaefa"); } } + public static Color PeriwinkleBlue { get { return ColorTranslator.FromHtml("#8f99fb"); } } + public static Color LightSkyBlue { get { return ColorTranslator.FromHtml("#c6fcff"); } } + public static Color Blurple { get { return ColorTranslator.FromHtml("#5539cc"); } } + public static Color GreenBrown { get { return ColorTranslator.FromHtml("#544e03"); } } + public static Color Bluegreen { get { return ColorTranslator.FromHtml("#017a79"); } } + public static Color BrightTeal { get { return ColorTranslator.FromHtml("#01f9c6"); } } + public static Color BrownishYellow { get { return ColorTranslator.FromHtml("#c9b003"); } } + public static Color PeaSoup { get { return ColorTranslator.FromHtml("#929901"); } } + public static Color Forest { get { return ColorTranslator.FromHtml("#0b5509"); } } + public static Color BarneyPurple { get { return ColorTranslator.FromHtml("#a00498"); } } + public static Color Ultramarine { get { return ColorTranslator.FromHtml("#2000b1"); } } + public static Color Purplish { get { return ColorTranslator.FromHtml("#94568c"); } } + public static Color PukeYellow { get { return ColorTranslator.FromHtml("#c2be0e"); } } + public static Color BluishGrey { get { return ColorTranslator.FromHtml("#748b97"); } } + public static Color DarkPeriwinkle { get { return ColorTranslator.FromHtml("#665fd1"); } } + public static Color DarkLilac { get { return ColorTranslator.FromHtml("#9c6da5"); } } + public static Color Reddish { get { return ColorTranslator.FromHtml("#c44240"); } } + public static Color LightMaroon { get { return ColorTranslator.FromHtml("#a24857"); } } + public static Color DustyPurple { get { return ColorTranslator.FromHtml("#825f87"); } } + public static Color TerraCotta { get { return ColorTranslator.FromHtml("#c9643b"); } } + public static Color Avocado { get { return ColorTranslator.FromHtml("#90b134"); } } + public static Color MarineBlue { get { return ColorTranslator.FromHtml("#01386a"); } } + public static Color TealGreen { get { return ColorTranslator.FromHtml("#25a36f"); } } + public static Color SlateGrey { get { return ColorTranslator.FromHtml("#59656d"); } } + public static Color LighterGreen { get { return ColorTranslator.FromHtml("#75fd63"); } } + public static Color ElectricGreen { get { return ColorTranslator.FromHtml("#21fc0d"); } } + public static Color DustyBlue { get { return ColorTranslator.FromHtml("#5a86ad"); } } + public static Color GoldenYellow { get { return ColorTranslator.FromHtml("#fec615"); } } + public static Color BrightYellow { get { return ColorTranslator.FromHtml("#fffd01"); } } + public static Color LightLavender { get { return ColorTranslator.FromHtml("#dfc5fe"); } } + public static Color Umber { get { return ColorTranslator.FromHtml("#b26400"); } } + public static Color Poop { get { return ColorTranslator.FromHtml("#7f5e00"); } } + public static Color DarkPeach { get { return ColorTranslator.FromHtml("#de7e5d"); } } + public static Color JungleGreen { get { return ColorTranslator.FromHtml("#048243"); } } + public static Color Eggshell { get { return ColorTranslator.FromHtml("#ffffd4"); } } + public static Color Denim { get { return ColorTranslator.FromHtml("#3b638c"); } } + public static Color YellowBrown { get { return ColorTranslator.FromHtml("#b79400"); } } + public static Color DullPurple { get { return ColorTranslator.FromHtml("#84597e"); } } + public static Color ChocolateBrown { get { return ColorTranslator.FromHtml("#411900"); } } + public static Color WineRed { get { return ColorTranslator.FromHtml("#7b0323"); } } + public static Color NeonBlue { get { return ColorTranslator.FromHtml("#04d9ff"); } } + public static Color DirtyGreen { get { return ColorTranslator.FromHtml("#667e2c"); } } + public static Color LightTan { get { return ColorTranslator.FromHtml("#fbeeac"); } } + public static Color IceBlue { get { return ColorTranslator.FromHtml("#d7fffe"); } } + public static Color CadetBlue { get { return ColorTranslator.FromHtml("#4e7496"); } } + public static Color DarkMauve { get { return ColorTranslator.FromHtml("#874c62"); } } + public static Color VeryLightBlue { get { return ColorTranslator.FromHtml("#d5ffff"); } } + public static Color GreyPurple { get { return ColorTranslator.FromHtml("#826d8c"); } } + public static Color PastelPink { get { return ColorTranslator.FromHtml("#ffbacd"); } } + public static Color VeryLightGreen { get { return ColorTranslator.FromHtml("#d1ffbd"); } } + public static Color DarkSkyBlue { get { return ColorTranslator.FromHtml("#448ee4"); } } + public static Color Evergreen { get { return ColorTranslator.FromHtml("#05472a"); } } + public static Color DullPink { get { return ColorTranslator.FromHtml("#d5869d"); } } + public static Color Aubergine { get { return ColorTranslator.FromHtml("#3d0734"); } } + public static Color Mahogany { get { return ColorTranslator.FromHtml("#4a0100"); } } + public static Color ReddishOrange { get { return ColorTranslator.FromHtml("#f8481c"); } } + public static Color DeepGreen { get { return ColorTranslator.FromHtml("#02590f"); } } + public static Color VomitGreen { get { return ColorTranslator.FromHtml("#89a203"); } } + public static Color PurplePink { get { return ColorTranslator.FromHtml("#e03fd8"); } } + public static Color DustyPink { get { return ColorTranslator.FromHtml("#d58a94"); } } + public static Color FadedGreen { get { return ColorTranslator.FromHtml("#7bb274"); } } + public static Color CamoGreen { get { return ColorTranslator.FromHtml("#526525"); } } + public static Color PinkyPurple { get { return ColorTranslator.FromHtml("#c94cbe"); } } + public static Color PinkPurple { get { return ColorTranslator.FromHtml("#db4bda"); } } + public static Color BrownishRed { get { return ColorTranslator.FromHtml("#9e3623"); } } + public static Color DarkRose { get { return ColorTranslator.FromHtml("#b5485d"); } } + public static Color Mud { get { return ColorTranslator.FromHtml("#735c12"); } } + public static Color Brownish { get { return ColorTranslator.FromHtml("#9c6d57"); } } + public static Color EmeraldGreen { get { return ColorTranslator.FromHtml("#028f1e"); } } + public static Color PaleBrown { get { return ColorTranslator.FromHtml("#b1916e"); } } + public static Color DullBlue { get { return ColorTranslator.FromHtml("#49759c"); } } + public static Color BurntUmber { get { return ColorTranslator.FromHtml("#a0450e"); } } + public static Color MediumGreen { get { return ColorTranslator.FromHtml("#39ad48"); } } + public static Color Clay { get { return ColorTranslator.FromHtml("#b66a50"); } } + public static Color LightAqua { get { return ColorTranslator.FromHtml("#8cffdb"); } } + public static Color LightOliveGreen { get { return ColorTranslator.FromHtml("#a4be5c"); } } + public static Color BrownishOrange { get { return ColorTranslator.FromHtml("#cb7723"); } } + public static Color DarkAqua { get { return ColorTranslator.FromHtml("#05696b"); } } + public static Color PurplishPink { get { return ColorTranslator.FromHtml("#ce5dae"); } } + public static Color DarkSalmon { get { return ColorTranslator.FromHtml("#c85a53"); } } + public static Color GreenishGrey { get { return ColorTranslator.FromHtml("#96ae8d"); } } + public static Color Jade { get { return ColorTranslator.FromHtml("#1fa774"); } } + public static Color UglyGreen { get { return ColorTranslator.FromHtml("#7a9703"); } } + public static Color DarkBeige { get { return ColorTranslator.FromHtml("#ac9362"); } } + public static Color Emerald { get { return ColorTranslator.FromHtml("#01a049"); } } + public static Color PaleRed { get { return ColorTranslator.FromHtml("#d9544d"); } } + public static Color LightMagenta { get { return ColorTranslator.FromHtml("#fa5ff7"); } } + public static Color Sky { get { return ColorTranslator.FromHtml("#82cafc"); } } + public static Color LightCyan { get { return ColorTranslator.FromHtml("#acfffc"); } } + public static Color YellowOrange { get { return ColorTranslator.FromHtml("#fcb001"); } } + public static Color ReddishPurple { get { return ColorTranslator.FromHtml("#910951"); } } + public static Color ReddishPink { get { return ColorTranslator.FromHtml("#fe2c54"); } } + public static Color Orchid { get { return ColorTranslator.FromHtml("#c875c4"); } } + public static Color DirtyYellow { get { return ColorTranslator.FromHtml("#cdc50a"); } } + public static Color OrangeRed { get { return ColorTranslator.FromHtml("#fd411e"); } } + public static Color DeepRed { get { return ColorTranslator.FromHtml("#9a0200"); } } + public static Color OrangeBrown { get { return ColorTranslator.FromHtml("#be6400"); } } + public static Color CobaltBlue { get { return ColorTranslator.FromHtml("#030aa7"); } } + public static Color NeonPink { get { return ColorTranslator.FromHtml("#fe019a"); } } + public static Color RosePink { get { return ColorTranslator.FromHtml("#f7879a"); } } + public static Color GreyishPurple { get { return ColorTranslator.FromHtml("#887191"); } } + public static Color Raspberry { get { return ColorTranslator.FromHtml("#b00149"); } } + public static Color AquaGreen { get { return ColorTranslator.FromHtml("#12e193"); } } + public static Color SalmonPink { get { return ColorTranslator.FromHtml("#fe7b7c"); } } + public static Color Tangerine { get { return ColorTranslator.FromHtml("#ff9408"); } } + public static Color BrownishGreen { get { return ColorTranslator.FromHtml("#6a6e09"); } } + public static Color RedBrown { get { return ColorTranslator.FromHtml("#8b2e16"); } } + public static Color GreenishBrown { get { return ColorTranslator.FromHtml("#696112"); } } + public static Color Pumpkin { get { return ColorTranslator.FromHtml("#e17701"); } } + public static Color PineGreen { get { return ColorTranslator.FromHtml("#0a481e"); } } + public static Color Charcoal { get { return ColorTranslator.FromHtml("#343837"); } } + public static Color BabyPink { get { return ColorTranslator.FromHtml("#ffb7ce"); } } + public static Color Cornflower { get { return ColorTranslator.FromHtml("#6a79f7"); } } + public static Color BlueViolet { get { return ColorTranslator.FromHtml("#5d06e9"); } } + public static Color Chocolate { get { return ColorTranslator.FromHtml("#3d1c02"); } } + public static Color GreyishGreen { get { return ColorTranslator.FromHtml("#82a67d"); } } + public static Color Scarlet { get { return ColorTranslator.FromHtml("#be0119"); } } + public static Color GreenYellow { get { return ColorTranslator.FromHtml("#c9ff27"); } } + public static Color DarkOlive { get { return ColorTranslator.FromHtml("#373e02"); } } + public static Color Sienna { get { return ColorTranslator.FromHtml("#a9561e"); } } + public static Color PastelPurple { get { return ColorTranslator.FromHtml("#caa0ff"); } } + public static Color Terracotta { get { return ColorTranslator.FromHtml("#ca6641"); } } + public static Color AquaBlue { get { return ColorTranslator.FromHtml("#02d8e9"); } } + public static Color SageGreen { get { return ColorTranslator.FromHtml("#88b378"); } } + public static Color BloodRed { get { return ColorTranslator.FromHtml("#980002"); } } + public static Color DeepPink { get { return ColorTranslator.FromHtml("#cb0162"); } } + public static Color Grass { get { return ColorTranslator.FromHtml("#5cac2d"); } } + public static Color Moss { get { return ColorTranslator.FromHtml("#769958"); } } + public static Color PastelBlue { get { return ColorTranslator.FromHtml("#a2bffe"); } } + public static Color BluishGreen { get { return ColorTranslator.FromHtml("#10a674"); } } + public static Color GreenBlue { get { return ColorTranslator.FromHtml("#06b48b"); } } + public static Color DarkTan { get { return ColorTranslator.FromHtml("#af884a"); } } + public static Color GreenishBlue { get { return ColorTranslator.FromHtml("#0b8b87"); } } + public static Color PaleOrange { get { return ColorTranslator.FromHtml("#ffa756"); } } + public static Color Vomit { get { return ColorTranslator.FromHtml("#a2a415"); } } + public static Color ForrestGreen { get { return ColorTranslator.FromHtml("#154406"); } } + public static Color DarkLavender { get { return ColorTranslator.FromHtml("#856798"); } } + public static Color DarkViolet { get { return ColorTranslator.FromHtml("#34013f"); } } + public static Color PurpleBlue { get { return ColorTranslator.FromHtml("#632de9"); } } + public static Color DarkCyan { get { return ColorTranslator.FromHtml("#0a888a"); } } + public static Color OliveDrab { get { return ColorTranslator.FromHtml("#6f7632"); } } + public static Color Pinkish { get { return ColorTranslator.FromHtml("#d46a7e"); } } + public static Color Cobalt { get { return ColorTranslator.FromHtml("#1e488f"); } } + public static Color NeonPurple { get { return ColorTranslator.FromHtml("#bc13fe"); } } + public static Color LightTurquoise { get { return ColorTranslator.FromHtml("#7ef4cc"); } } + public static Color AppleGreen { get { return ColorTranslator.FromHtml("#76cd26"); } } + public static Color DullGreen { get { return ColorTranslator.FromHtml("#74a662"); } } + public static Color Wine { get { return ColorTranslator.FromHtml("#80013f"); } } + public static Color PowderBlue { get { return ColorTranslator.FromHtml("#b1d1fc"); } } + public static Color OffWhite { get { return ColorTranslator.FromHtml("#ffffe4"); } } + public static Color ElectricBlue { get { return ColorTranslator.FromHtml("#0652ff"); } } + public static Color DarkTurquoise { get { return ColorTranslator.FromHtml("#045c5a"); } } + public static Color BluePurple { get { return ColorTranslator.FromHtml("#5729ce"); } } + public static Color Azure { get { return ColorTranslator.FromHtml("#069af3"); } } + public static Color BrightRed { get { return ColorTranslator.FromHtml("#ff000d"); } } + public static Color PinkishRed { get { return ColorTranslator.FromHtml("#f10c45"); } } + public static Color CornflowerBlue { get { return ColorTranslator.FromHtml("#5170d7"); } } + public static Color LightOlive { get { return ColorTranslator.FromHtml("#acbf69"); } } + public static Color Grape { get { return ColorTranslator.FromHtml("#6c3461"); } } + public static Color GreyishBlue { get { return ColorTranslator.FromHtml("#5e819d"); } } + public static Color PurplishBlue { get { return ColorTranslator.FromHtml("#601ef9"); } } + public static Color YellowishGreen { get { return ColorTranslator.FromHtml("#b0dd16"); } } + public static Color GreenishYellow { get { return ColorTranslator.FromHtml("#cdfd02"); } } + public static Color MediumBlue { get { return ColorTranslator.FromHtml("#2c6fbb"); } } + public static Color DustyRose { get { return ColorTranslator.FromHtml("#c0737a"); } } + public static Color LightViolet { get { return ColorTranslator.FromHtml("#d6b4fc"); } } + public static Color MidnightBlue { get { return ColorTranslator.FromHtml("#020035"); } } + public static Color BluishPurple { get { return ColorTranslator.FromHtml("#703be7"); } } + public static Color RedOrange { get { return ColorTranslator.FromHtml("#fd3c06"); } } + public static Color DarkMagenta { get { return ColorTranslator.FromHtml("#960056"); } } + public static Color Greenish { get { return ColorTranslator.FromHtml("#40a368"); } } + public static Color OceanBlue { get { return ColorTranslator.FromHtml("#03719c"); } } + public static Color Coral { get { return ColorTranslator.FromHtml("#fc5a50"); } } + public static Color Cream { get { return ColorTranslator.FromHtml("#ffffc2"); } } + public static Color ReddishBrown { get { return ColorTranslator.FromHtml("#7f2b0a"); } } + public static Color BurntSienna { get { return ColorTranslator.FromHtml("#b04e0f"); } } + public static Color Brick { get { return ColorTranslator.FromHtml("#a03623"); } } + public static Color Sage { get { return ColorTranslator.FromHtml("#87ae73"); } } + public static Color GreyGreen { get { return ColorTranslator.FromHtml("#789b73"); } } + public static Color White { get { return ColorTranslator.FromHtml("#ffffff"); } } + public static Color RobinSEggBlue { get { return ColorTranslator.FromHtml("#98eff9"); } } + public static Color MossGreen { get { return ColorTranslator.FromHtml("#658b38"); } } + public static Color SteelBlue { get { return ColorTranslator.FromHtml("#5a7d9a"); } } + public static Color Eggplant { get { return ColorTranslator.FromHtml("#380835"); } } + public static Color LightYellow { get { return ColorTranslator.FromHtml("#fffe7a"); } } + public static Color LeafGreen { get { return ColorTranslator.FromHtml("#5ca904"); } } + public static Color LightGrey { get { return ColorTranslator.FromHtml("#d8dcd6"); } } + public static Color Puke { get { return ColorTranslator.FromHtml("#a5a502"); } } + public static Color PinkishPurple { get { return ColorTranslator.FromHtml("#d648d7"); } } + public static Color SeaBlue { get { return ColorTranslator.FromHtml("#047495"); } } + public static Color PalePurple { get { return ColorTranslator.FromHtml("#b790d4"); } } + public static Color SlateBlue { get { return ColorTranslator.FromHtml("#5b7c99"); } } + public static Color BlueGrey { get { return ColorTranslator.FromHtml("#607c8e"); } } + public static Color HunterGreen { get { return ColorTranslator.FromHtml("#0b4008"); } } + public static Color Fuchsia { get { return ColorTranslator.FromHtml("#ed0dd9"); } } + public static Color Crimson { get { return ColorTranslator.FromHtml("#8c000f"); } } + public static Color PaleYellow { get { return ColorTranslator.FromHtml("#ffff84"); } } + public static Color Ochre { get { return ColorTranslator.FromHtml("#bf9005"); } } + public static Color MustardYellow { get { return ColorTranslator.FromHtml("#d2bd0a"); } } + public static Color LightRed { get { return ColorTranslator.FromHtml("#ff474c"); } } + public static Color Cerulean { get { return ColorTranslator.FromHtml("#0485d1"); } } + public static Color PalePink { get { return ColorTranslator.FromHtml("#ffcfdc"); } } + public static Color DeepBlue { get { return ColorTranslator.FromHtml("#040273"); } } + public static Color Rust { get { return ColorTranslator.FromHtml("#a83c09"); } } + public static Color LightTeal { get { return ColorTranslator.FromHtml("#90e4c1"); } } + public static Color Slate { get { return ColorTranslator.FromHtml("#516572"); } } + public static Color Goldenrod { get { return ColorTranslator.FromHtml("#fac205"); } } + public static Color DarkYellow { get { return ColorTranslator.FromHtml("#d5b60a"); } } + public static Color DarkGrey { get { return ColorTranslator.FromHtml("#363737"); } } + public static Color ArmyGreen { get { return ColorTranslator.FromHtml("#4b5d16"); } } + public static Color GreyBlue { get { return ColorTranslator.FromHtml("#6b8ba4"); } } + public static Color Seafoam { get { return ColorTranslator.FromHtml("#80f9ad"); } } + public static Color Puce { get { return ColorTranslator.FromHtml("#a57e52"); } } + public static Color SpringGreen { get { return ColorTranslator.FromHtml("#a9f971"); } } + public static Color DarkOrange { get { return ColorTranslator.FromHtml("#c65102"); } } + public static Color Sand { get { return ColorTranslator.FromHtml("#e2ca76"); } } + public static Color PastelGreen { get { return ColorTranslator.FromHtml("#b0ff9d"); } } + public static Color Mint { get { return ColorTranslator.FromHtml("#9ffeb0"); } } + public static Color LightOrange { get { return ColorTranslator.FromHtml("#fdaa48"); } } + public static Color BrightPink { get { return ColorTranslator.FromHtml("#fe01b1"); } } + public static Color Chartreuse { get { return ColorTranslator.FromHtml("#c1f80a"); } } + public static Color DeepPurple { get { return ColorTranslator.FromHtml("#36013f"); } } + public static Color DarkBrown { get { return ColorTranslator.FromHtml("#341c02"); } } + public static Color Taupe { get { return ColorTranslator.FromHtml("#b9a281"); } } + public static Color PeaGreen { get { return ColorTranslator.FromHtml("#8eab12"); } } + public static Color PukeGreen { get { return ColorTranslator.FromHtml("#9aae07"); } } + public static Color KellyGreen { get { return ColorTranslator.FromHtml("#02ab2e"); } } + public static Color SeafoamGreen { get { return ColorTranslator.FromHtml("#7af9ab"); } } + public static Color BlueGreen { get { return ColorTranslator.FromHtml("#137e6d"); } } + public static Color Khaki { get { return ColorTranslator.FromHtml("#aaa662"); } } + public static Color Burgundy { get { return ColorTranslator.FromHtml("#610023"); } } + public static Color DarkTeal { get { return ColorTranslator.FromHtml("#014d4e"); } } + public static Color BrickRed { get { return ColorTranslator.FromHtml("#8f1402"); } } + public static Color RoyalPurple { get { return ColorTranslator.FromHtml("#4b006e"); } } + public static Color Plum { get { return ColorTranslator.FromHtml("#580f41"); } } + public static Color MintGreen { get { return ColorTranslator.FromHtml("#8fff9f"); } } + public static Color Gold { get { return ColorTranslator.FromHtml("#dbb40c"); } } + public static Color BabyBlue { get { return ColorTranslator.FromHtml("#a2cffe"); } } + public static Color YellowGreen { get { return ColorTranslator.FromHtml("#c0fb2d"); } } + public static Color BrightPurple { get { return ColorTranslator.FromHtml("#be03fd"); } } + public static Color DarkRed { get { return ColorTranslator.FromHtml("#840000"); } } + public static Color PaleBlue { get { return ColorTranslator.FromHtml("#d0fefe"); } } + public static Color GrassGreen { get { return ColorTranslator.FromHtml("#3f9b0b"); } } + public static Color Navy { get { return ColorTranslator.FromHtml("#01153e"); } } + public static Color Aquamarine { get { return ColorTranslator.FromHtml("#04d8b2"); } } + public static Color BurntOrange { get { return ColorTranslator.FromHtml("#c04e01"); } } + public static Color NeonGreen { get { return ColorTranslator.FromHtml("#0cff0c"); } } + public static Color BrightBlue { get { return ColorTranslator.FromHtml("#0165fc"); } } + public static Color Rose { get { return ColorTranslator.FromHtml("#cf6275"); } } + public static Color LightPink { get { return ColorTranslator.FromHtml("#ffd1df"); } } + public static Color Mustard { get { return ColorTranslator.FromHtml("#ceb301"); } } + public static Color Indigo { get { return ColorTranslator.FromHtml("#380282"); } } + public static Color Lime { get { return ColorTranslator.FromHtml("#aaff32"); } } + public static Color SeaGreen { get { return ColorTranslator.FromHtml("#53fca1"); } } + public static Color Periwinkle { get { return ColorTranslator.FromHtml("#8e82fe"); } } + public static Color DarkPink { get { return ColorTranslator.FromHtml("#cb416b"); } } + public static Color OliveGreen { get { return ColorTranslator.FromHtml("#677a04"); } } + public static Color Peach { get { return ColorTranslator.FromHtml("#ffb07c"); } } + public static Color PaleGreen { get { return ColorTranslator.FromHtml("#c7fdb5"); } } + public static Color LightBrown { get { return ColorTranslator.FromHtml("#ad8150"); } } + public static Color HotPink { get { return ColorTranslator.FromHtml("#ff028d"); } } + public static Color Black { get { return ColorTranslator.FromHtml("#000000"); } } + public static Color Lilac { get { return ColorTranslator.FromHtml("#cea2fd"); } } + public static Color NavyBlue { get { return ColorTranslator.FromHtml("#001146"); } } + public static Color RoyalBlue { get { return ColorTranslator.FromHtml("#0504aa"); } } + public static Color Beige { get { return ColorTranslator.FromHtml("#e6daa6"); } } + public static Color Salmon { get { return ColorTranslator.FromHtml("#ff796c"); } } + public static Color Olive { get { return ColorTranslator.FromHtml("#6e750e"); } } + public static Color Maroon { get { return ColorTranslator.FromHtml("#650021"); } } + public static Color BrightGreen { get { return ColorTranslator.FromHtml("#01ff07"); } } + public static Color DarkPurple { get { return ColorTranslator.FromHtml("#35063e"); } } + public static Color Mauve { get { return ColorTranslator.FromHtml("#ae7181"); } } + public static Color ForestGreen { get { return ColorTranslator.FromHtml("#06470c"); } } + public static Color Aqua { get { return ColorTranslator.FromHtml("#13eac9"); } } + public static Color Cyan { get { return ColorTranslator.FromHtml("#00ffff"); } } + public static Color Tan { get { return ColorTranslator.FromHtml("#d1b26f"); } } + public static Color DarkBlue { get { return ColorTranslator.FromHtml("#00035b"); } } + public static Color Lavender { get { return ColorTranslator.FromHtml("#c79fef"); } } + public static Color Turquoise { get { return ColorTranslator.FromHtml("#06c2ac"); } } + public static Color DarkGreen { get { return ColorTranslator.FromHtml("#033500"); } } + public static Color Violet { get { return ColorTranslator.FromHtml("#9a0eea"); } } + public static Color LightPurple { get { return ColorTranslator.FromHtml("#bf77f6"); } } + public static Color LimeGreen { get { return ColorTranslator.FromHtml("#89fe05"); } } + public static Color Grey { get { return ColorTranslator.FromHtml("#929591"); } } + public static Color SkyBlue { get { return ColorTranslator.FromHtml("#75bbfd"); } } + public static Color Yellow { get { return ColorTranslator.FromHtml("#ffff14"); } } + public static Color Magenta { get { return ColorTranslator.FromHtml("#c20078"); } } + public static Color LightGreen { get { return ColorTranslator.FromHtml("#96f97b"); } } + public static Color Orange { get { return ColorTranslator.FromHtml("#f97306"); } } + public static Color Teal { get { return ColorTranslator.FromHtml("#029386"); } } + public static Color LightBlue { get { return ColorTranslator.FromHtml("#95d0fc"); } } + public static Color Red { get { return ColorTranslator.FromHtml("#e50000"); } } + public static Color Brown { get { return ColorTranslator.FromHtml("#653700"); } } + public static Color Pink { get { return ColorTranslator.FromHtml("#ff81c0"); } } + public static Color Blue { get { return ColorTranslator.FromHtml("#0343df"); } } + public static Color Green { get { return ColorTranslator.FromHtml("#15b01a"); } } + public static Color Purple { get { return ColorTranslator.FromHtml("#7e1e9c"); } } +} + diff --git a/Assets/Scripts/NIH/XKCDColors.cs.meta b/Assets/Scripts/NIH/XKCDColors.cs.meta new file mode 100644 index 000000000..aab80b98a --- /dev/null +++ b/Assets/Scripts/NIH/XKCDColors.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ef7eeddb3a8c914193bbb946c482943 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Targetable.cs b/Assets/Scripts/Targetable.cs new file mode 100644 index 000000000..ee751a263 --- /dev/null +++ b/Assets/Scripts/Targetable.cs @@ -0,0 +1,101 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using static Unity.Mathematics.math; + +public class Targetable : MonoBehaviour +{ + public float Points = 100; + public float Visibility; + public Transform ReplaceWithPrefab; + public Ship Ship; + + public IsFriendlyFoeStatus DefaultIsFriendlyFoeStatus = IsFriendlyFoeStatus.None; + + public readonly Dictionary IFF = new Dictionary(); + private Vector3 _lastPosition; + + public IsFriendlyFoeStatus IsFriendlyFoe(Targetable target) + { + if (!IFF.ContainsKey(target)) + IFF[target] = DefaultIsFriendlyFoeStatus; + + return IFF[target]; + } + + void Start() + { + Ship = GetComponent(); + } + + void Health(float health) + { + Points = health; + } + + public void Damage(float points) + { + if (Ship != null) + { + var shield = Ship.GetEquipped(HardpointType.Shield); + if (shield != null) + { + var shieldData = shield.ItemData as Shield; + var shieldedDamage = points * saturate(shieldData.Shielding.Evaluate(shield, Ship)); + Ship.AddHeat(shieldedDamage / shieldData.Efficiency.Evaluate(shield, Ship)); + Ship.Hull.Durability -= points - shieldedDamage; + } + else Ship.Hull.Durability -= points; + } + else + { + Points -= points; + + if (Points > 0) return; + + KillLocal(); + } + /* + var ent = GameManager.Instance.Entities.FirstOrDefault(kv => kv.Value == transform).Key; + if(ent>0) + GameManager.Instance.Send("Destroy", ent);*/ + + } + + public void KillLocal() + { + //GameManager.Instance.Kill(this); +// if (GetComponent()) +// { +// GameManager.Instance.KillPlayer(); +// } + + Destroy(gameObject); + + if (ReplaceWithPrefab != null) + Instantiate(ReplaceWithPrefab, transform.position, transform.rotation); + } + + private void LateUpdate() + { + _lastPosition = transform.position; + } + + void kill(string[] args) + { + if(args[0]==gameObject.name) + KillLocal(); + } +} + + +public enum IsFriendlyFoeStatus +{ + None, + Friendly, + Hostile, + Mayday, + Body, + Wormhole +} \ No newline at end of file diff --git a/Assets/Scripts/Targetable.cs.meta b/Assets/Scripts/Targetable.cs.meta new file mode 100644 index 000000000..aa5838e24 --- /dev/null +++ b/Assets/Scripts/Targetable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae4eaa5cad8b4c744a0740b1eb2e8548 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UnityFormatters.cs b/Assets/Scripts/UnityFormatters.cs new file mode 100644 index 000000000..a6a399f18 --- /dev/null +++ b/Assets/Scripts/UnityFormatters.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using MessagePack; +using MessagePack.Formatters; +using UnityEditor; +using UnityEngine; +using UnityEngine.Audio; + +public class UnityGameObjectFormatter : IMessagePackFormatter +{ +#if !UNITY_EDITOR + private static Dictionary _paths = new Dictionary(); +#endif + + public void Serialize(ref MessagePackWriter writer, GameObject value, MessagePackSerializerOptions options) + { + if(value==null) + writer.WriteNil(); + +#if UNITY_EDITOR + writer.Write(AssetDatabase.GetAssetPath(value)); +#else + string path; + if (!_paths.TryGetValue(value, out path)) + path = "RUNTIME_SERIALIZER_UNKNOWN_RESOURCE"; + return writer.Write(path); +#endif + } + + public GameObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + var path = reader.ReadString(); + if (string.IsNullOrEmpty(path)) return null; +#if UNITY_EDITOR + return AssetDatabase.LoadAssetAtPath(path); +#else + var resource = Resources.Load(path.Substring("Assets/Resources/".Length).Split('.').First()); + _paths[resource] = path; + return resource; +#endif + } +} + +public class UnityMaterialFormatter : IMessagePackFormatter +{ +#if !UNITY_EDITOR + private static Dictionary _paths = new Dictionary(); +#endif + + public void Serialize(ref MessagePackWriter writer, Material value, MessagePackSerializerOptions options) + { + if(value==null) + writer.WriteNil(); + +#if UNITY_EDITOR + writer.Write(AssetDatabase.GetAssetPath(value)); +#else + string path; + if (!_paths.TryGetValue(value, out path)) + path = "RUNTIME_SERIALIZER_UNKNOWN_RESOURCE"; + return writer.Write(path); +#endif + } + + public Material Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + var path = reader.ReadString(); + if (string.IsNullOrEmpty(path)) return null; +#if UNITY_EDITOR + return AssetDatabase.LoadAssetAtPath(path); +#else + var resource = Resources.Load(path.Substring("Assets/Resources/".Length).Split('.').First()); + _paths[resource] = path; + return resource; +#endif + } +} + +public class UnitySpriteFormatter : IMessagePackFormatter +{ +#if !UNITY_EDITOR + private static Dictionary _paths = new Dictionary(); +#endif + + public void Serialize(ref MessagePackWriter writer, Sprite value, MessagePackSerializerOptions options) + { + if(value==null) + writer.WriteNil(); + +#if UNITY_EDITOR + writer.Write(AssetDatabase.GetAssetPath(value)); +#else + string path; + if (!_paths.TryGetValue(value, out path)) + path = "RUNTIME_SERIALIZER_UNKNOWN_RESOURCE"; + return writer.Write(path); +#endif + } + + public Sprite Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + var path = reader.ReadString(); + if (string.IsNullOrEmpty(path)) return null; +#if UNITY_EDITOR + return AssetDatabase.LoadAssetAtPath(path); +#else + var resource = Resources.Load(path.Substring("Assets/Resources/".Length).Split('.').First()); + _paths[resource] = path; + return resource; +#endif + } +} + +public class UnityTexture2DFormatter : IMessagePackFormatter +{ +#if !UNITY_EDITOR + private static Dictionary _paths = new Dictionary(); +#endif + + public void Serialize(ref MessagePackWriter writer, Texture2D value, MessagePackSerializerOptions options) + { + if(value==null) + writer.WriteNil(); + +#if UNITY_EDITOR + writer.Write(AssetDatabase.GetAssetPath(value)); +#else + string path; + if (!_paths.TryGetValue(value, out path)) + path = "RUNTIME_SERIALIZER_UNKNOWN_RESOURCE"; + return writer.Write(path); +#endif + } + + public Texture2D Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + var path = reader.ReadString(); + if (string.IsNullOrEmpty(path)) return null; +#if UNITY_EDITOR + return AssetDatabase.LoadAssetAtPath(path); +#else + var resource = Resources.Load(path.Substring("Assets/Resources/".Length).Split('.').First()); + _paths[resource] = path; + return resource; +#endif + } +} \ No newline at end of file diff --git a/Assets/Scripts/UnityFormatters.cs.meta b/Assets/Scripts/UnityFormatters.cs.meta new file mode 100644 index 000000000..fee0d9805 --- /dev/null +++ b/Assets/Scripts/UnityFormatters.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0592fb576747e3443949d779d01068aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ZoneManager.cs b/Assets/Scripts/ZoneManager.cs index 6d000ecaa..54bbee3ee 100644 --- a/Assets/Scripts/ZoneManager.cs +++ b/Assets/Scripts/ZoneManager.cs @@ -217,20 +217,3 @@ public enum ExpansionType Solar, Binary } - -[MessagePackObject] -public class ZoneData : IDatabaseEntry -{ - [Inspectable] [Key("entry")] public DatabaseEntry DatabaseEntry = new DatabaseEntry(); - [Inspectable] [Key("radius")] public float Radius = 500; - [Inspectable] [Key("radiusPower")] public float RadiusPower = 1.75f; - [Inspectable] [Key("mass")] public float Mass = 100000; - [Inspectable] [Key("massFloor")] public float MassFloor = 1; - [Inspectable] [Key("sunMass")] public float SunMass = 10000; - [Inspectable] [Key("gasGiantMass")] public float GasGiantMass = 2000; - - [InspectableDatabaseLink(typeof(ZoneData))] [Key("wormholes")] - public List Wormholes = new List(); - - [IgnoreMember] public DatabaseEntry Entry => DatabaseEntry; -} diff --git a/Assets/Scripts/ZoneRenderer.cs b/Assets/Scripts/ZoneRenderer.cs new file mode 100644 index 000000000..904c281eb --- /dev/null +++ b/Assets/Scripts/ZoneRenderer.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ZoneRenderer : MonoBehaviour +{ + public Material BackgroundMaterial; + public RenderTexture GravityTexture; + public MeshRenderer GravityRenderer; + + private int _resX, _resY; + private float _ratio; + private Camera _camera; + + private void Start() + { + _camera = GetComponent(); + } + + private void OnPreRender() + { + if (Screen.width != _resX || Screen.height != _resY) + { + _resX = Screen.width; + _resY = Screen.height; + _ratio = (float) _resY / _resX; + if (GravityTexture != null) + { + GravityTexture?.Release(); + } + GravityTexture = new RenderTexture(_resX, _resY, 0, RenderTextureFormat.RFloat); + } + + BackgroundMaterial.mainTexture = GravityTexture; + + GravityRenderer.transform.position = new Vector3(transform.position.x, transform.position.y, 0); + var size = _camera.orthographicSize; + GravityRenderer.transform.localScale = new Vector3(size * 4, size * 4 * _ratio, 1); + + _camera.targetTexture = GravityTexture; + } +} diff --git a/Assets/Scripts/ZoneRenderer.cs.meta b/Assets/Scripts/ZoneRenderer.cs.meta new file mode 100644 index 000000000..1f4c1639f --- /dev/null +++ b/Assets/Scripts/ZoneRenderer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 04277e392af12204397c334ea824f957 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/GalaxyMap.shader b/Assets/Shaders/GalaxyMap.shader new file mode 100644 index 000000000..4324eb577 --- /dev/null +++ b/Assets/Shaders/GalaxyMap.shader @@ -0,0 +1,142 @@ +Shader "Unlit/GalaxyMap" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CloudColor ("CloudColor", Color) = (1,1,1,1) + _GlowColor ("GlowColor", Color) = (1,1,1,1) + Arms("Arms", Float) = 4 + Twist("Twist", Float) = 180 + TwistPower("TwistPower", Float) = 1 + SpokeOffset("SpokeOffset", Float) = 1 + SpokeScale("SpokeScale", Float) = 1 + CoreBoost("CoreBoost", Float) = 1 + CoreBoostOffset("CoreBoostOffset", Float) = 0 + CoreBoostPower("CoreBoostPower", Float) = 1 + EdgeReduction("EdgeReduction", Float) = 1 + NoisePosition("NoisePosition", Float) = 0.5 + NoiseAmplitude("NoiseAmplitude", Float) = 0.5 + NoiseOffset("NoiseOffset", Float) = 0.5 + NoiseGain("NoiseGain", Float) = 1 + NoiseLacunarity("NoiseLacunarity", Float) = 2 + NoiseFrequency("NoiseFrequency", Float) = 1 + GlowOffset("GlowOffset", Float) = 1 + GlowAmount("GlowAmount", Float) = 1 + GlowPower("GlowPower", Float) = 1 + StarBoost("StarBoost", Float) = 1 + + // required for UI.Mask + _StencilComp ("Stencil Comparison", Float) = 8 + _Stencil ("Stencil ID", Float) = 0 + _StencilOp ("Stencil Operation", Float) = 0 + _StencilWriteMask ("Stencil Write Mask", Float) = 255 + _StencilReadMask ("Stencil Read Mask", Float) = 255 + _ColorMask ("Color Mask", Float) = 15 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + // required for UI.Mask + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + ReadMask [_StencilReadMask] + WriteMask [_StencilWriteMask] + } + ColorMask [_ColorMask] + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + #include "Assets/Scripts/NIH/GPU Noise/SimplexNoise2D.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float2 uv2 : TEXCOORD1; + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + fixed4 _CloudColor; + fixed4 _GlowColor; + float Arms; + float Twist; + float TwistPower; + float SpokeOffset; + float SpokeScale; + + float CoreBoost; + float CoreBoostOffset; + float CoreBoostPower; + float EdgeReduction; + float NoisePosition; + float NoiseAmplitude; + float NoiseOffset; + float NoiseGain; + float NoiseLacunarity; + //int NoiseOctaves = 7; + float NoiseFrequency; + float GlowOffset; + float GlowAmount; + float GlowPower; + float StarBoost; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = v.uv; + o.uv2 = TRANSFORM_TEX(v.uv, _MainTex); + return o; + } + + // fractal sum, range -1.0 - 1.0 + float fBm(float2 p, int octaves) + { + float freq = NoiseFrequency, amp = .5; + float sum = 0; + for(int i = 0; i < octaves; i++) + { + sum += snoise(p * freq) * amp; + freq *= NoiseLacunarity; + amp *= NoiseGain; + } + return (sum + NoiseOffset)*NoiseAmplitude; + } + + fixed4 frag (v2f i) : SV_Target + { + float2 offset = -(.5).xx+i.uv; + float circle = (.5-length(offset))*2; + float angle = pow(length(offset)*2,TwistPower) * Twist; + float2 twist = float2(offset.x*cos(angle) - offset.y*sin(angle), offset.x*sin(angle) + offset.y*cos(angle)); + float atan = atan2(twist.y,twist.x); + float spokes = sin(atan*Arms) * SpokeScale + SpokeOffset; + float noise = fBm(i.uv + NoisePosition.xx, 7); + float shape = lerp(spokes - EdgeReduction * length(offset), 1, pow(circle + CoreBoostOffset, CoreBoostPower) * CoreBoost); + float gal = max(shape - noise * clamp(circle,0,1), 0); + float glow = (pow(circle,GlowPower) + GlowOffset) * GlowAmount; + float stars = tex2D(_MainTex, i.uv2) * clamp(shape*StarBoost, 0, 1); + fixed4 col = fixed4(gal*_CloudColor.rgb + glow*_GlowColor.rgb + stars.xxx,1); + return col; + } + ENDCG + } + } +} diff --git a/Assets/Shaders/GalaxyMap.shader.meta b/Assets/Shaders/GalaxyMap.shader.meta new file mode 100644 index 000000000..3c09d0e05 --- /dev/null +++ b/Assets/Shaders/GalaxyMap.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 73bb08f97646de94f864b995369f37c2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Isolines.shader b/Assets/Shaders/Isolines.shader index e5d3837f6..cbb9e216e 100644 --- a/Assets/Shaders/Isolines.shader +++ b/Assets/Shaders/Isolines.shader @@ -72,31 +72,41 @@ // sample the texture half h = -tex2D(_MainTex, IN.uv).r; float4 col = float4(0,0,0,0); + float blend = smoothstep(_StartHeight, _StartHeight + _HeightRange / 32, -h); + + // Calculate the direction in which the surface is facing + float2 plan = calcGrad(IN.uv, h); + + float planmag = length(plan); // Loop over isolines, computing a pseudo distance field for a number of height values float spacing = _HeightRange / 20; for (int i = 0; i < 20; i++) { float isoline = abs(h - _StartHeight + (i*spacing)); - float2 isograd = float2(ddx_fine(isoline), ddy_fine(isoline)); - float isomag = length(isograd); - col += (1-smoothstep(_LineWidth * _ScreenParams.y, _LineWidth * _ScreenParams.y * _LineFade, isoline / (isomag))) * _Color; // Isoline + //float2 isograd = float2(ddx(isoline), ddy(isoline)); + //float isomag = length(isograd); + col += (1-smoothstep(_LineWidth * _ScreenParams.y, _LineWidth * _ScreenParams.y * _LineFade, isoline / planmag)) * _Color * blend; // Isoline } - // Calculate the direction in which the surface is facing - float2 plan = normalize(calcGrad(IN.uv, h)); - - // float angle = atan2(plan.y,plan.x) / 3.1415926536 + 1; + float2 plannorm = normalize(plan); + float2 plan2uv = IN.uv + float2(-plannorm.y * _MainTex_TexelSize.x, plannorm.x * _MainTex_TexelSize.y); + float2 plan2 = calcGrad(plan2uv, -tex2D(_MainTex, plan2uv).r); + float angle2 = atan2(plan2.y,plan2.x) / 3.1415926536 + 1; + float angmag = abs(angle-angle2); + angmag = min(angmag,0.05); + //angmag = clamp(angmag,0.005,0.05); + // Loop over isoangles for (float i = 0.5; i < 13; i++) { float isoline = abs(angle - i / 6.0);// ; - float2 isograd = float2(ddx_fine(isoline), ddy_fine(isoline)); - float isomag = length(isograd); - float blend = smoothstep(-2,-10,h)*smoothstep(0.04,0.083333,angle)*smoothstep(1.96,1.916667,angle); - col += (1-smoothstep(_AngleWidth * _ScreenParams.y, _AngleWidth * _ScreenParams.y * _AngleFade, isoline / (isomag))) * _AngleColor * blend; // Isoline + //float2 isograd = float2(ddx_fine(isoline), ddy_fine(isoline)); + //float isomag = min(length(isograd),0.025); // isomag is huge over atan2 boundary so clamp it to avoid false positives + col += (1-smoothstep(_AngleWidth * _ScreenParams.y, _AngleWidth * _ScreenParams.y * _AngleFade, isoline / (angmag))) * _AngleColor * blend; // Isoline } + //return float4(1,0,0,1); return col; } ENDCG diff --git a/Assets/Shaders/PowerBrush.shader b/Assets/Shaders/PowerBrush.shader new file mode 100644 index 000000000..2f941c68c --- /dev/null +++ b/Assets/Shaders/PowerBrush.shader @@ -0,0 +1,63 @@ +Shader "Brushes/Power Brush" { +Properties { + _Depth ("Depth", Float) = 0.5 + _Power("Power", Float) = 2 +} + +Category { + Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" } + Blend One One + ColorMask RGB + Cull Off Lighting Off ZWrite Off + + SubShader { + Pass { + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma target 2.0 + + #include "UnityCG.cginc" + + float _Depth; + float _Power; + + struct appdata_t { + float4 vertex : POSITION; + fixed4 color : COLOR; + float2 texcoord : TEXCOORD0; + }; + + struct v2f { + float4 vertex : SV_POSITION; + fixed4 color : COLOR; + float2 texcoord : TEXCOORD0; + }; + + float4 _MainTex_ST; + + v2f vert (appdata_t v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.color = v.color; + o.texcoord = v.texcoord; + return o; + } + + float powerPulse( float x, float power ) + { + x = saturate(abs(x)); + return pow((x + 1.0f) * (1.0f - x), power); + } + + fixed4 frag (v2f i) : SV_Target + { + return _Depth * powerPulse(length(i.texcoord-float2(.5,.5))*2,_Power); + } + ENDCG + } + } +} +} diff --git a/Assets/Shaders/PowerBrush.shader.meta b/Assets/Shaders/PowerBrush.shader.meta new file mode 100644 index 000000000..9feaa72a7 --- /dev/null +++ b/Assets/Shaders/PowerBrush.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 105a94389fb66cf4bb41ad040d8c5fdb +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/SimplexBrush.shader b/Assets/Shaders/SimplexBrush.shader new file mode 100644 index 000000000..ade5bc4af --- /dev/null +++ b/Assets/Shaders/SimplexBrush.shader @@ -0,0 +1,78 @@ +// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' + +Shader "Brushes/Simplex Brush" +{ +Properties { + _Depth ("Depth", Float) = 0.5 + _Power("Envelope Power", Float) = 1.25 + _Frequency("Frequency", Float) = 2 + _Speed("Speed", Float) = 1 + _Constant ("Constant", Float) = 0.5 +} + +Category { + Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" } + Blend One One + ColorMask RGB + Cull Off Lighting Off ZWrite Off + + SubShader { + Pass { + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma target 2.0 + + #include "UnityCG.cginc" + #include "Assets/Scripts/NIH/GPU Noise/SimplexNoise3D.cginc" + + float _Depth; + float _Power; + float _Frequency; + float _Speed; + float _Constant; + + struct appdata_t { + float4 vertex : POSITION; + fixed4 color : COLOR; + float2 texcoord : TEXCOORD0; + }; + + struct v2f { + float4 vertex : SV_POSITION; + fixed4 color : COLOR; + float2 texcoord : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + }; + + float4 _MainTex_ST; + + v2f vert (appdata_t v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.color = v.color; + o.texcoord = v.texcoord; + o.texcoord1 = mul(unity_ObjectToWorld, v.vertex).xz; + return o; + } + + + float powerPulse( float x, float power ) + { + x = saturate(abs(x)); + return pow((x + 1.0f) * (1.0f - x), power); + } + + fixed4 frag (v2f i) : SV_Target + { + float dist = length(i.texcoord - float2(.5,.5)); + return _Depth * powerPulse(dist * 2,_Power) * (abs(snoise(float3(i.texcoord1.xy*_Frequency,_Time.y*_Speed)))+_Constant); + } + ENDCG + } + } +} +CustomEditor "CellBrushEditor" +} diff --git a/Assets/Shaders/SimplexBrush.shader.meta b/Assets/Shaders/SimplexBrush.shader.meta new file mode 100644 index 000000000..6c3f221aa --- /dev/null +++ b/Assets/Shaders/SimplexBrush.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ccdbaf77577994d46b0e61c53d5dc4a9 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.csprojAssemblyReference.cache b/Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.csprojAssemblyReference.cache index 35f7bbd49..b75ef1e1c 100644 Binary files a/Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.csprojAssemblyReference.cache and b/Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.csprojAssemblyReference.cache differ diff --git a/Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.csprojAssemblyReference.cache b/Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.csprojAssemblyReference.cache index c18410c26..ab29c14d8 100644 Binary files a/Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.csprojAssemblyReference.cache and b/Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.csprojAssemblyReference.cache differ diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset index d9008f07c..71f9c580e 100644 --- a/ProjectSettings/EditorSettings.asset +++ b/ProjectSettings/EditorSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3aea39a4d3a57a6af67d37960a06ae1019b2196a3e2af04f7cd3b9ac6887b2b -size 643 +oid sha256:56874e4e30c18bef61d8b88405901227a76ca739817ff7bb80393bb6c4adb1eb +size 715 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 8d0fed215..e51582f2c 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9234e7ac4d5cd6d4d21b26fbbb2530b754e87a147df38e852bf774ccf5179b44 -size 421 +oid sha256:6fe64a55ee38e1c0eaa197c7506e5a45a5d10604c22b86f313823198c7538918 +size 389