Merge branch 'master' into Music
This commit is contained in:
commit
737affe944
1965 changed files with 216168 additions and 16429 deletions
BIN
Assets/Fonts/Ubuntu/Montserrat-Thin SDF.asset
(Stored with Git LFS)
Normal file
BIN
Assets/Fonts/Ubuntu/Montserrat-Thin SDF.asset
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/Fonts/Ubuntu/Montserrat-Thin SDF.asset.meta
Normal file
8
Assets/Fonts/Ubuntu/Montserrat-Thin SDF.asset.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1c5e8a01819db8d4b812bf3d3eecd389
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Fonts/Ubuntu/Montserrat-Thin.ttf
(Stored with Git LFS)
Normal file
BIN
Assets/Fonts/Ubuntu/Montserrat-Thin.ttf
(Stored with Git LFS)
Normal file
Binary file not shown.
21
Assets/Fonts/Ubuntu/Montserrat-Thin.ttf.meta
Normal file
21
Assets/Fonts/Ubuntu/Montserrat-Thin.ttf.meta
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 39baae53551530c46a09203705373952
|
||||
TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
fontSize: 16
|
||||
forceTextureCase: -2
|
||||
characterSpacing: 0
|
||||
characterPadding: 1
|
||||
includeFontData: 1
|
||||
fontNames:
|
||||
- Montserrat
|
||||
fallbackFontReferences: []
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
||||
useLegacyBoundsCalculation: 0
|
||||
shouldRoundAdvanceValue: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Fonts/Ubuntu/Ubuntu-L Small SDF Stochastic.mat
Normal file
105
Assets/Fonts/Ubuntu/Ubuntu-L Small SDF Stochastic.mat
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
%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: Ubuntu-L Small SDF Stochastic
|
||||
m_Shader: {fileID: 4800000, guid: 68e6db2ebdc24f95958faec2be5558d6, type: 3}
|
||||
m_ShaderKeywords: UNDERLAY_ON
|
||||
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}
|
||||
- _Cube:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _FaceTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2985719337874870690, guid: 53555f7a2d5e745428813f1b1118734f,
|
||||
type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Ambient: 0.5
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _ColorMask: 15
|
||||
- _Diffuse: 0.5
|
||||
- _FaceDilate: 0
|
||||
- _FaceUVSpeedX: 0
|
||||
- _FaceUVSpeedY: 0
|
||||
- _GlowInner: 0.05
|
||||
- _GlowOffset: 0
|
||||
- _GlowOuter: 0.05
|
||||
- _GlowPower: 0.75
|
||||
- _GradientScale: 9
|
||||
- _LightAngle: 3.1416
|
||||
- _MaskSoftnessX: 0
|
||||
- _MaskSoftnessY: 0
|
||||
- _OutlineSoftness: 0.1
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.8888889
|
||||
- _ScaleRatioB: 0.7222222
|
||||
- _ScaleRatioC: 0.28831226
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _Sharpness: 0
|
||||
- _SpecularPower: 2
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TextureHeight: 1024
|
||||
- _TextureWidth: 1024
|
||||
- _UnderlayDilate: 1
|
||||
- _UnderlayOffsetX: 1
|
||||
- _UnderlayOffsetY: -1
|
||||
- _UnderlaySoftness: 0.505
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.75
|
||||
- _WeightNormal: 0
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
|
||||
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
|
||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 42a7a06ba69bf9645a481e0b5e3ed46a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Fonts/Ubuntu/Ubuntu-L Small SDF.asset
(Stored with Git LFS)
BIN
Assets/Fonts/Ubuntu/Ubuntu-L Small SDF.asset
(Stored with Git LFS)
Binary file not shown.
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 0.33
|
||||
- _Depth: 1.3
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
@ -70,7 +70,7 @@ Material:
|
|||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Phase: 0
|
||||
- _Power: 3
|
||||
- _Power: 8
|
||||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 20
|
||||
- _Depth: 3.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
- _Frequency: 27.43
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
|
|
|
|||
83
Assets/Materials/Brushes/Ping Light.mat
Normal file
83
Assets/Materials/Brushes/Ping Light.mat
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
%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: Ping Light
|
||||
m_Shader: {fileID: 4800000, guid: 268da230635cfb34ab4ed6ad39503fa0, 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: 0.1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Phase: 0
|
||||
- _Power: -2
|
||||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.19999999, g: 0.46133497, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/Brushes/Ping Light.mat.meta
Normal file
8
Assets/Materials/Brushes/Ping Light.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7f61d4eb8f7e684cb95b6c7e5b84bf9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 75
|
||||
- _Depth: 139.4
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
|
|
|
|||
80
Assets/Materials/Brushes/Sector Boundary Test.mat
Normal file
80
Assets/Materials/Brushes/Sector Boundary Test.mat
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
%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: Sector Boundary Test
|
||||
m_Shader: {fileID: 4800000, guid: 268da230635cfb34ab4ed6ad39503fa0, 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: 150
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Power: 0.25
|
||||
- _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}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/Brushes/Sector Boundary Test.mat.meta
Normal file
8
Assets/Materials/Brushes/Sector Boundary Test.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65e5206f4614c85449f822f5bab55199
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/Materials/Brushes/Sector Tint Test.mat
Normal file
83
Assets/Materials/Brushes/Sector Tint Test.mat
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
%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: Sector Tint Test
|
||||
m_Shader: {fileID: 4800000, guid: 268da230635cfb34ab4ed6ad39503fa0, 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: 0.4
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Phase: 0
|
||||
- _Power: 0.5
|
||||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.3726415, g: 0.70283014, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/Brushes/Sector Tint Test.mat.meta
Normal file
8
Assets/Materials/Brushes/Sector Tint Test.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7b4b425f2959c6444b35fca367641ee2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 0.1
|
||||
- _Depth: 0.25
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ Material:
|
|||
- _BumpScale: 1
|
||||
- _Constant: -2.46
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 5
|
||||
- _Depth: 2
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 0.02
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ Material:
|
|||
- _BumpScale: 1
|
||||
- _Constant: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 10
|
||||
- _Depth: 4
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 0.01
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ Material:
|
|||
- _BumpScale: 1
|
||||
- _Constant: 0
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: -10
|
||||
- _Depth: 8
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 0.005
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 4
|
||||
- _Depth: 10
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
|
|||
|
|
@ -43,23 +43,27 @@ Material:
|
|||
- _AlphaFloor: 0
|
||||
- _DepthBlend: 512
|
||||
- _DepthCeiling: 4096
|
||||
- _Gamma: 0.3
|
||||
- _Gamma: 0.25
|
||||
- _GridCeilingBlend: -300
|
||||
- _GridCeilingDensity: 0.01
|
||||
- _GridCeilingFollow: 0
|
||||
- _GridCeilingOffset: 0
|
||||
- _GridFillDensity: 0.00002
|
||||
- _GridFillDensity: 0.00001
|
||||
- _GridFloorBlend: 39.6
|
||||
- _GridFloorDensity: 1
|
||||
- _GridFloorOffset: -16.46
|
||||
- _GridFloorOffset: 27.55
|
||||
- _GridPatchBlend: 200
|
||||
- _GridPatchDensity: 3
|
||||
- _NoiseFrequency: 0.01
|
||||
- _NoiseSpeed: 0.01
|
||||
- _NoiseStrength: 150
|
||||
- _SafetyDistance: 50
|
||||
- _Scattering: 50
|
||||
- _ScatteringDensityExponent: 8
|
||||
- _ScatteringDistExponent: 0.5
|
||||
- _ScatteringMinDist: 1
|
||||
- _StepExponent: 2
|
||||
- _TintExponent: 8
|
||||
- _TintExponent: 12
|
||||
m_Colors:
|
||||
- _Tint: {r: 0.34, g: 0.34, b: 0.34, a: 1}
|
||||
- _Tint: {r: 0.3932651, g: 0.3932651, b: 0.3932651, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
65
Assets/Materials/Fog Marching Test.mat
Normal file
65
Assets/Materials/Fog Marching Test.mat
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
%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: Fog Marching Test
|
||||
m_Shader: {fileID: 4800000, guid: 7a890b6ceccf53c44bfc54b18b5daa58, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _Displacement:
|
||||
m_Texture: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2}
|
||||
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}
|
||||
- _Patch:
|
||||
m_Texture: {fileID: 8400000, guid: c618a6b20b3c7394590c59a9fa467e86, type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Surface:
|
||||
m_Texture: {fileID: 8400000, guid: 2fc21a9d3e9647948b56e384cd9378b3, type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TintTexture:
|
||||
m_Texture: {fileID: 8400000, guid: d196505464047f04a97f28689041209b, type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AlphaFloor: 0
|
||||
- _DepthBlend: 512
|
||||
- _DepthCeiling: 4096
|
||||
- _Gamma: 0.66
|
||||
- _GridCeilingBlend: -300
|
||||
- _GridCeilingDensity: 0.01
|
||||
- _GridCeilingFollow: 0
|
||||
- _GridCeilingOffset: 0
|
||||
- _GridFillDensity: 0.000025
|
||||
- _GridFloorBlend: 100
|
||||
- _GridFloorDensity: 4
|
||||
- _GridFloorOffset: 0
|
||||
- _GridPatchBlend: 5
|
||||
- _GridPatchDensity: 0.1
|
||||
- _NoiseFrequency: 0.01
|
||||
- _NoiseSpeed: 0.02
|
||||
- _NoiseStrength: 50
|
||||
- _SafetyDistance: 0
|
||||
- _StepExponent: 2
|
||||
- _TintExponent: 8
|
||||
m_Colors:
|
||||
- _Tint: {r: 2.0078435, g: 2.0078435, b: 2.0078435, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/Fog Marching Test.mat.meta
Normal file
8
Assets/Materials/Fog Marching Test.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad63650ae6d6cc542a5aad16694b3c46
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -40,7 +40,7 @@ Material:
|
|||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AlphaFloor: 0
|
||||
- _AlphaFloor: 0.01
|
||||
- _DepthBlend: 512
|
||||
- _DepthCeiling: 4096
|
||||
- _Gamma: 0.5
|
||||
|
|
@ -48,18 +48,22 @@ Material:
|
|||
- _GridCeilingDensity: 0.01
|
||||
- _GridCeilingFollow: 0
|
||||
- _GridCeilingOffset: 0
|
||||
- _GridFillDensity: 0.000006
|
||||
- _GridFloorBlend: 100
|
||||
- _GridFloorDensity: 4
|
||||
- _GridFloorOffset: 25
|
||||
- _GridPatchBlend: 200
|
||||
- _GridPatchDensity: 6
|
||||
- _GridFillDensity: 0.000002
|
||||
- _GridFloorBlend: 50
|
||||
- _GridFloorDensity: 1
|
||||
- _GridFloorOffset: 0
|
||||
- _GridPatchBlend: 5
|
||||
- _GridPatchDensity: 0.2
|
||||
- _NoiseFrequency: 0.01
|
||||
- _NoiseSpeed: 0.02
|
||||
- _NoiseStrength: 75
|
||||
- _SafetyDistance: 50
|
||||
- _NoiseStrength: 100
|
||||
- _SafetyDistance: 53.73
|
||||
- _Scattering: 1.25
|
||||
- _ScatteringDensityExponent: 0.5
|
||||
- _ScatteringDistExponent: 0.5
|
||||
- _ScatteringMinDist: 500
|
||||
- _StepExponent: 2
|
||||
- _TintExponent: 8
|
||||
m_Colors:
|
||||
- _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _Tint: {r: 0.29799998, g: 0.29799998, b: 0.29799998, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Material:
|
|||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ColorRamp:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: 4f6a7385479a85a40be0c3030504c7c5, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
|
|
@ -104,8 +104,8 @@ Material:
|
|||
- _OffsetFadePower: -0.75
|
||||
- _Parallax: 0.02
|
||||
- _RayStepSize: -0.00625
|
||||
- _SecondOffsetDepthExponent: 0
|
||||
- _SecondOffsetDistance: -0.2
|
||||
- _SecondOffsetDepthExponent: -2
|
||||
- _SecondOffsetDistance: -0.05
|
||||
- _SecondOffsetFadePower: -8
|
||||
- _SecondOffsetRotationFadePower: 0.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
|
|
|
|||
BIN
Assets/Materials/Substance/Metal/Pickup Base.sbsar
(Stored with Git LFS)
Normal file
BIN
Assets/Materials/Substance/Metal/Pickup Base.sbsar
(Stored with Git LFS)
Normal file
Binary file not shown.
382
Assets/Materials/Substance/Metal/Pickup Base.sbsar.meta
Normal file
382
Assets/Materials/Substance/Metal/Pickup Base.sbsar.meta
Normal file
|
|
@ -0,0 +1,382 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 26a894e543f3ed44893b1620707ca62c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
1: 100000
|
||||
second: metal_car_paint/metal_car_paint
|
||||
- first:
|
||||
4: 400000
|
||||
second: metal_car_paint/metal_car_paint/Transform
|
||||
- first:
|
||||
21: 2100000
|
||||
second: mat.Car paint
|
||||
- first:
|
||||
23: 2300000
|
||||
second: metal_car_paint/metal_car_paint/MeshRenderer
|
||||
- first:
|
||||
28: 2800000
|
||||
second: Car paint_baseColor
|
||||
- first:
|
||||
28: 2800002
|
||||
second: Car paint_normal
|
||||
- first:
|
||||
28: 2800004
|
||||
second: Car paint_metallic
|
||||
- first:
|
||||
28: 2800006
|
||||
second: Car paint_ambientOcclusion
|
||||
- first:
|
||||
28: 2800008
|
||||
second: Car paint_height
|
||||
- first:
|
||||
33: 3300000
|
||||
second: metal_car_paint/metal_car_paint/MeshFilter
|
||||
- first:
|
||||
114: 11400000
|
||||
second: sbsar
|
||||
- first:
|
||||
114: 11400002
|
||||
second: graph0
|
||||
- first:
|
||||
135: 13500000
|
||||
second: metal_car_paint/metal_car_paint/SphereCollider
|
||||
- first:
|
||||
1001: 100100000
|
||||
second: metal_car_paint
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 232528478, guid: 43a8bbf65be290d44ba52b94476242b9, type: 3}
|
||||
version: 29
|
||||
projectContext: 0
|
||||
mGraphInstanceData:
|
||||
- graphLabel: Car paint
|
||||
prototypeName: Car paint
|
||||
graphDescIndex: 0
|
||||
generateAllOutputs: 0
|
||||
generateMipMaps: 1
|
||||
preset: " <sbspreset pkgurl=\"pkg://metal_car_paint\" label=\"\" >\n <presetinput
|
||||
identifier=\"$outputsize\" uid=\"2092133592\" type=\"8\" value=\"11,11\" />\n
|
||||
<presetinput identifier=\"normal_intensity\" uid=\"2045651458\" type=\"0\"
|
||||
value=\"0.25\" />\n <presetinput identifier=\"age\" uid=\"2038752334\" type=\"0\"
|
||||
value=\"1\" />\n <presetinput identifier=\"flakes\" uid=\"20245147\" type=\"4\"
|
||||
value=\"1\" />\n <presetinput identifier=\"flakes_scale\" uid=\"20192266\"
|
||||
type=\"0\" value=\"0\" />\n <presetinput identifier=\"paint_scratches\" uid=\"22509202\"
|
||||
type=\"0\" value=\"1\" />\n <presetinput identifier=\"paint_peeling\" uid=\"103560714\"
|
||||
type=\"0\" value=\"0.151\" />\n <presetinput identifier=\"metal_roughness\"
|
||||
uid=\"22504787\" type=\"0\" value=\"0.33\" />\n <presetinput identifier=\"paint_color\"
|
||||
uid=\"105341618\" type=\"2\" value=\"1,0.891509,0.946396\" />\n <presetinput
|
||||
identifier=\"paint_roughness\" uid=\"22504606\" type=\"0\" value=\"0\" />\n
|
||||
<presetinput identifier=\"paint_metallic\" uid=\"22503567\" type=\"0\" value=\"0\"
|
||||
/>\n </sbspreset>\n"
|
||||
shaderName: Standard
|
||||
materialProperties:
|
||||
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
shaderKeywords: _MAINTEX _METALLICGLOSSMAP _NORMALMAP _OCCLUSIONMAP _PARALLAXMAP
|
||||
lightmapFlags: 4
|
||||
enableInstancingVariants: 0
|
||||
doubleSidedGI: 0
|
||||
customRenderQueue: -1
|
||||
texEnvs:
|
||||
- name: _BumpMap
|
||||
texture: {fileID: 3068890721646206586, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailAlbedoMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailMask
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailNormalMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _EmissionMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MainTex
|
||||
texture: {fileID: 5917659159057834157, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MetallicGlossMap
|
||||
texture: {fileID: -3552914696322007609, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _OcclusionMap
|
||||
texture: {fileID: -1242281561028671816, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _ParallaxMap
|
||||
texture: {fileID: -1652887728991447519, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
floats:
|
||||
- name: _BumpScale
|
||||
float: 1
|
||||
- name: _Cutoff
|
||||
float: 0.5
|
||||
- name: _DetailNormalMapScale
|
||||
float: 1
|
||||
- name: _DstBlend
|
||||
float: 0
|
||||
- name: _GlossMapScale
|
||||
float: 1
|
||||
- name: _Glossiness
|
||||
float: 1
|
||||
- name: _GlossyReflections
|
||||
float: 1
|
||||
- name: _Metallic
|
||||
float: 1
|
||||
- name: _Mode
|
||||
float: 0
|
||||
- name: _OcclusionStrength
|
||||
float: 1
|
||||
- name: _Parallax
|
||||
float: 0.02
|
||||
- name: _SmoothnessTextureChannel
|
||||
float: 0
|
||||
- name: _SpecularHighlights
|
||||
float: 1
|
||||
- name: _SrcBlend
|
||||
float: 1
|
||||
- name: _UVSec
|
||||
float: 0
|
||||
- name: _ZWrite
|
||||
float: 1
|
||||
colors:
|
||||
- name: _Color
|
||||
color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- name: _EmissionColor
|
||||
color: {r: 0, g: 0, b: 0, a: 1}
|
||||
outputDescList:
|
||||
- outputName: diffuse
|
||||
identifier: diffuse
|
||||
usageName: diffuse
|
||||
channelStr: diffuse
|
||||
label: Diffuse
|
||||
usage: 0
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: baseColor
|
||||
identifier: basecolor
|
||||
usageName: baseColor
|
||||
channelStr: baseColor
|
||||
label: Base Color
|
||||
usage: 1
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: normal
|
||||
identifier: normal
|
||||
usageName: normal
|
||||
channelStr: normal
|
||||
label: Normal
|
||||
usage: 7
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: specular
|
||||
identifier: specular
|
||||
usageName: specular
|
||||
channelStr: specular
|
||||
label: Specular
|
||||
usage: 11
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: glossiness
|
||||
identifier: glossiness
|
||||
usageName: glossiness
|
||||
channelStr: glossiness
|
||||
label: Glossiness
|
||||
usage: 14
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: roughness
|
||||
identifier: roughness
|
||||
usageName: roughness
|
||||
channelStr: roughness
|
||||
label: Roughness
|
||||
usage: 15
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: metallic
|
||||
identifier: metallic
|
||||
usageName: metallic
|
||||
channelStr: metallic
|
||||
label: Metallic
|
||||
usage: 34
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: ambientOcclusion
|
||||
identifier: ambient_occlusion
|
||||
usageName: ambientOcclusion
|
||||
channelStr: ambientOcclusion
|
||||
label: Ambient Occlusion
|
||||
usage: 5
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: height
|
||||
identifier: height
|
||||
usageName: height
|
||||
channelStr: height
|
||||
label: Height
|
||||
usage: 9
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
texturePackingList:
|
||||
- targetName: diffuse
|
||||
components:
|
||||
- sourceName: diffuse
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: baseColor
|
||||
components:
|
||||
- sourceName: baseColor
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: normal
|
||||
components:
|
||||
- sourceName: normal
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: specular
|
||||
components:
|
||||
- sourceName: specular
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: glossiness
|
||||
components:
|
||||
- sourceName: glossiness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: roughness
|
||||
components:
|
||||
- sourceName: roughness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: metallic
|
||||
components:
|
||||
- sourceName: smoothness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: ambientOcclusion
|
||||
components:
|
||||
- sourceName: ambientOcclusion
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: height
|
||||
components:
|
||||
- sourceName: height
|
||||
from: 0
|
||||
to: 3
|
||||
textureParameters:
|
||||
- textureName: Car paint_glossiness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_diffuse
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_baseColor
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_normal
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_specular
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_roughness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_metallic
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_ambientOcclusion
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_height
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - diffuse
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - baseColor
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - normal
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - specular
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - glossiness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - roughness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - metallic
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - ambientOcclusion
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - height
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
colorSpaceList: []
|
||||
inputTextureMap: []
|
||||
targetSettingList:
|
||||
- label: Default
|
||||
bOverride: 0
|
||||
bLockRatio: 1
|
||||
textureWidth: 2048
|
||||
textureHeight: 2048
|
||||
textureFormatMode: 0
|
||||
normalCompressed: 0
|
||||
bGenerateOnLoad: 1
|
||||
material: {fileID: 3720744386649352057, guid: 26a894e543f3ed44893b1620707ca62c,
|
||||
type: 3}
|
||||
generatedTextures:
|
||||
- {fileID: 5917659159057834157, guid: 26a894e543f3ed44893b1620707ca62c, type: 3}
|
||||
- {fileID: 3068890721646206586, guid: 26a894e543f3ed44893b1620707ca62c, type: 3}
|
||||
- {fileID: -3552914696322007609, guid: 26a894e543f3ed44893b1620707ca62c, type: 3}
|
||||
- {fileID: -1242281561028671816, guid: 26a894e543f3ed44893b1620707ca62c, type: 3}
|
||||
- {fileID: -1652887728991447519, guid: 26a894e543f3ed44893b1620707ca62c, type: 3}
|
||||
BIN
Assets/Materials/Substance/Metal/Pickup Trim.sbsar
(Stored with Git LFS)
Normal file
BIN
Assets/Materials/Substance/Metal/Pickup Trim.sbsar
(Stored with Git LFS)
Normal file
Binary file not shown.
381
Assets/Materials/Substance/Metal/Pickup Trim.sbsar.meta
Normal file
381
Assets/Materials/Substance/Metal/Pickup Trim.sbsar.meta
Normal file
|
|
@ -0,0 +1,381 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c00b5a4f1e4743a4ca59b8030251f900
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
1: 100000
|
||||
second: metal_car_paint/metal_car_paint
|
||||
- first:
|
||||
4: 400000
|
||||
second: metal_car_paint/metal_car_paint/Transform
|
||||
- first:
|
||||
21: 2100000
|
||||
second: mat.Car paint
|
||||
- first:
|
||||
23: 2300000
|
||||
second: metal_car_paint/metal_car_paint/MeshRenderer
|
||||
- first:
|
||||
28: 2800000
|
||||
second: Car paint_baseColor
|
||||
- first:
|
||||
28: 2800002
|
||||
second: Car paint_normal
|
||||
- first:
|
||||
28: 2800004
|
||||
second: Car paint_metallic
|
||||
- first:
|
||||
28: 2800006
|
||||
second: Car paint_ambientOcclusion
|
||||
- first:
|
||||
28: 2800008
|
||||
second: Car paint_height
|
||||
- first:
|
||||
33: 3300000
|
||||
second: metal_car_paint/metal_car_paint/MeshFilter
|
||||
- first:
|
||||
114: 11400000
|
||||
second: sbsar
|
||||
- first:
|
||||
114: 11400002
|
||||
second: graph0
|
||||
- first:
|
||||
135: 13500000
|
||||
second: metal_car_paint/metal_car_paint/SphereCollider
|
||||
- first:
|
||||
1001: 100100000
|
||||
second: metal_car_paint
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 232528478, guid: 43a8bbf65be290d44ba52b94476242b9, type: 3}
|
||||
version: 29
|
||||
projectContext: 0
|
||||
mGraphInstanceData:
|
||||
- graphLabel: Car paint
|
||||
prototypeName: Car paint
|
||||
graphDescIndex: 0
|
||||
generateAllOutputs: 0
|
||||
generateMipMaps: 1
|
||||
preset: " <sbspreset pkgurl=\"pkg://metal_car_paint\" label=\"\" >\n <presetinput
|
||||
identifier=\"$outputsize\" uid=\"2092133592\" type=\"8\" value=\"11,11\" />\n
|
||||
<presetinput identifier=\"normal_intensity\" uid=\"2045651458\" type=\"0\"
|
||||
value=\"0.25\" />\n <presetinput identifier=\"age\" uid=\"2038752334\" type=\"0\"
|
||||
value=\"1\" />\n <presetinput identifier=\"flakes\" uid=\"20245147\" type=\"4\"
|
||||
value=\"1\" />\n <presetinput identifier=\"flakes_scale\" uid=\"20192266\"
|
||||
type=\"0\" value=\"0.425\" />\n <presetinput identifier=\"paint_scratches\"
|
||||
uid=\"22509202\" type=\"0\" value=\"1\" />\n <presetinput identifier=\"paint_peeling\"
|
||||
uid=\"103560714\" type=\"0\" value=\"0.405\" />\n <presetinput identifier=\"metal_roughness\"
|
||||
uid=\"22504787\" type=\"0\" value=\"0.425\" />\n <presetinput identifier=\"paint_color\"
|
||||
uid=\"105341618\" type=\"2\" value=\"0,0.605881,1\" />\n <presetinput identifier=\"paint_roughness\"
|
||||
uid=\"22504606\" type=\"0\" value=\"0\" />\n <presetinput identifier=\"paint_metallic\"
|
||||
uid=\"22503567\" type=\"0\" value=\"1\" />\n </sbspreset>\n"
|
||||
shaderName: Standard
|
||||
materialProperties:
|
||||
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
shaderKeywords: _MAINTEX _METALLICGLOSSMAP _NORMALMAP _OCCLUSIONMAP _PARALLAXMAP
|
||||
lightmapFlags: 4
|
||||
enableInstancingVariants: 0
|
||||
doubleSidedGI: 0
|
||||
customRenderQueue: -1
|
||||
texEnvs:
|
||||
- name: _BumpMap
|
||||
texture: {fileID: 3068890721646206586, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailAlbedoMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailMask
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _DetailNormalMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _EmissionMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MainTex
|
||||
texture: {fileID: 5917659159057834157, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MetallicGlossMap
|
||||
texture: {fileID: -3552914696322007609, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _OcclusionMap
|
||||
texture: {fileID: -1242281561028671816, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _ParallaxMap
|
||||
texture: {fileID: -1652887728991447519, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
floats:
|
||||
- name: _BumpScale
|
||||
float: 1
|
||||
- name: _Cutoff
|
||||
float: 0.5
|
||||
- name: _DetailNormalMapScale
|
||||
float: 1
|
||||
- name: _DstBlend
|
||||
float: 0
|
||||
- name: _GlossMapScale
|
||||
float: 1
|
||||
- name: _Glossiness
|
||||
float: 0.5
|
||||
- name: _GlossyReflections
|
||||
float: 1
|
||||
- name: _Metallic
|
||||
float: 0
|
||||
- name: _Mode
|
||||
float: 0
|
||||
- name: _OcclusionStrength
|
||||
float: 1
|
||||
- name: _Parallax
|
||||
float: 0.005
|
||||
- name: _SmoothnessTextureChannel
|
||||
float: 0
|
||||
- name: _SpecularHighlights
|
||||
float: 1
|
||||
- name: _SrcBlend
|
||||
float: 1
|
||||
- name: _UVSec
|
||||
float: 0
|
||||
- name: _ZWrite
|
||||
float: 1
|
||||
colors:
|
||||
- name: _Color
|
||||
color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- name: _EmissionColor
|
||||
color: {r: 0, g: 0, b: 0, a: 1}
|
||||
outputDescList:
|
||||
- outputName: diffuse
|
||||
identifier: diffuse
|
||||
usageName: diffuse
|
||||
channelStr: diffuse
|
||||
label: Diffuse
|
||||
usage: 0
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: baseColor
|
||||
identifier: basecolor
|
||||
usageName: baseColor
|
||||
channelStr: baseColor
|
||||
label: Base Color
|
||||
usage: 1
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: normal
|
||||
identifier: normal
|
||||
usageName: normal
|
||||
channelStr: normal
|
||||
label: Normal
|
||||
usage: 7
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: specular
|
||||
identifier: specular
|
||||
usageName: specular
|
||||
channelStr: specular
|
||||
label: Specular
|
||||
usage: 11
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 0
|
||||
- outputName: glossiness
|
||||
identifier: glossiness
|
||||
usageName: glossiness
|
||||
channelStr: glossiness
|
||||
label: Glossiness
|
||||
usage: 14
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: roughness
|
||||
identifier: roughness
|
||||
usageName: roughness
|
||||
channelStr: roughness
|
||||
label: Roughness
|
||||
usage: 15
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: metallic
|
||||
identifier: metallic
|
||||
usageName: metallic
|
||||
channelStr: metallic
|
||||
label: Metallic
|
||||
usage: 34
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: ambientOcclusion
|
||||
identifier: ambient_occlusion
|
||||
usageName: ambientOcclusion
|
||||
channelStr: ambientOcclusion
|
||||
label: Ambient Occlusion
|
||||
usage: 5
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
- outputName: height
|
||||
identifier: height
|
||||
usageName: height
|
||||
channelStr: height
|
||||
label: Height
|
||||
usage: 9
|
||||
bImage: 1
|
||||
bNumerical: 0
|
||||
bLinear: 1
|
||||
texturePackingList:
|
||||
- targetName: diffuse
|
||||
components:
|
||||
- sourceName: diffuse
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: baseColor
|
||||
components:
|
||||
- sourceName: baseColor
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: normal
|
||||
components:
|
||||
- sourceName: normal
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: specular
|
||||
components:
|
||||
- sourceName: specular
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: glossiness
|
||||
components:
|
||||
- sourceName: glossiness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: roughness
|
||||
components:
|
||||
- sourceName: roughness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: metallic
|
||||
components:
|
||||
- sourceName: smoothness
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: ambientOcclusion
|
||||
components:
|
||||
- sourceName: ambientOcclusion
|
||||
from: 0
|
||||
to: 3
|
||||
- targetName: height
|
||||
components:
|
||||
- sourceName: height
|
||||
from: 0
|
||||
to: 3
|
||||
textureParameters:
|
||||
- textureName: Car paint_glossiness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_diffuse
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_baseColor
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_normal
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_specular
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_roughness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_metallic
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_ambientOcclusion
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint_height
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - diffuse
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - baseColor
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - normal
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - specular
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - glossiness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - roughness
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - metallic
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - ambientOcclusion
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
- textureName: Car paint - height
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
colorSpaceList: []
|
||||
inputTextureMap: []
|
||||
targetSettingList:
|
||||
- label: Default
|
||||
bOverride: 0
|
||||
bLockRatio: 1
|
||||
textureWidth: 2048
|
||||
textureHeight: 2048
|
||||
textureFormatMode: 0
|
||||
normalCompressed: 0
|
||||
bGenerateOnLoad: 1
|
||||
material: {fileID: 3720744386649352057, guid: c00b5a4f1e4743a4ca59b8030251f900,
|
||||
type: 3}
|
||||
generatedTextures:
|
||||
- {fileID: 5917659159057834157, guid: c00b5a4f1e4743a4ca59b8030251f900, type: 3}
|
||||
- {fileID: 3068890721646206586, guid: c00b5a4f1e4743a4ca59b8030251f900, type: 3}
|
||||
- {fileID: -3552914696322007609, guid: c00b5a4f1e4743a4ca59b8030251f900, type: 3}
|
||||
- {fileID: -1242281561028671816, guid: c00b5a4f1e4743a4ca59b8030251f900, type: 3}
|
||||
- {fileID: -1652887728991447519, guid: c00b5a4f1e4743a4ca59b8030251f900, type: 3}
|
||||
|
|
@ -99,12 +99,12 @@ ScriptedImporter:
|
|||
offset: {x: 0, y: 0}
|
||||
- name: _EmissionMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 2, y: 2}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MainTex
|
||||
texture: {fileID: 5917659159057834157, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
|
||||
type: 3}
|
||||
scale: {x: 2, y: 2}
|
||||
scale: {x: 1, y: 1}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MetallicGlossMap
|
||||
texture: {fileID: -3552914696322007609, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ ScriptedImporter:
|
|||
value=\"1\" />\n <presetinput identifier=\"flakes_scale\" uid=\"20192266\"
|
||||
type=\"0\" value=\"0\" />\n <presetinput identifier=\"paint_scratches\" uid=\"22509202\"
|
||||
type=\"0\" value=\"1\" />\n <presetinput identifier=\"paint_peeling\" uid=\"103560714\"
|
||||
type=\"0\" value=\"0.089\" />\n <presetinput identifier=\"metal_roughness\"
|
||||
type=\"0\" value=\"0.095\" />\n <presetinput identifier=\"metal_roughness\"
|
||||
uid=\"22504787\" type=\"0\" value=\"0.33\" />\n <presetinput identifier=\"paint_color\"
|
||||
uid=\"105341618\" type=\"2\" value=\"1,0.891509,0.946396\" />\n <presetinput
|
||||
identifier=\"paint_roughness\" uid=\"22504606\" type=\"0\" value=\"0\" />\n
|
||||
|
|
@ -100,12 +100,12 @@ ScriptedImporter:
|
|||
offset: {x: 0, y: 0}
|
||||
- name: _EmissionMap
|
||||
texture: {instanceID: 0}
|
||||
scale: {x: 1, y: 1}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MainTex
|
||||
texture: {fileID: 5917659159057834157, guid: b2bec4b400153d745b2915f1c43e5c96,
|
||||
type: 3}
|
||||
scale: {x: 2, y: 2}
|
||||
scale: {x: 0.5, y: 0.5}
|
||||
offset: {x: 0, y: 0}
|
||||
- name: _MetallicGlossMap
|
||||
texture: {fileID: -3552914696322007609, guid: b2bec4b400153d745b2915f1c43e5c96,
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ Material:
|
|||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 0.2924528, g: 0.2924528, b: 0.2924528, a: 1}
|
||||
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ Material:
|
|||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 6.029707
|
||||
- _Scale: 2.7380018
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
|
|
|
|||
111
Assets/Materials/UI/UI Line Material.mat
Normal file
111
Assets/Materials/UI/UI Line Material.mat
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
%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: UI Line Material
|
||||
m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 0
|
||||
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}
|
||||
- _DetailTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 1f080985c19e8014494de3ff3474d9cc, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _CameraFadingEnabled: 0
|
||||
- _CameraFarFadeDistance: 2
|
||||
- _CameraNearFadeDistance: 1
|
||||
- _ColorMask: 15
|
||||
- _ColorMode: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DistortionBlend: 0.5
|
||||
- _DistortionEnabled: 0
|
||||
- _DistortionStrength: 1
|
||||
- _DistortionStrengthScaled: 0
|
||||
- _DstBlend: 0
|
||||
- _EmissionEnabled: 0
|
||||
- _FlipbookMode: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _InvFade: 1
|
||||
- _LightingEnabled: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SoftParticlesEnabled: 0
|
||||
- _SoftParticlesFarFadeDistance: 1
|
||||
- _SoftParticlesNearFadeDistance: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _Strength: 0.2
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _TintColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/UI/UI Line Material.mat.meta
Normal file
8
Assets/Materials/UI/UI Line Material.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcfc0ffd602442f42bddf109db9d2d20
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Models/primitives.blend
(Stored with Git LFS)
BIN
Assets/Models/primitives.blend
(Stored with Git LFS)
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b4479e2dcccbdc048878a980f116a96b
|
||||
ModelImporter:
|
||||
serializedVersion: 20101
|
||||
serializedVersion: 20200
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
74: 1989289236423521904
|
||||
|
|
@ -103,6 +103,7 @@ ModelImporter:
|
|||
animationType: 2
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
|||
Binary file not shown.
213
Assets/Plugins/AutoExpandGridLayoutGroup.cs
Normal file
213
Assets/Plugins/AutoExpandGridLayoutGroup.cs
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI
|
||||
{
|
||||
[AddComponentMenu("Layout/Auto Expand Grid Layout Group", 152)]
|
||||
public class AutoExpandGridLayoutGroup : LayoutGroup
|
||||
{
|
||||
public enum Corner { UpperLeft = 0, UpperRight = 1, LowerLeft = 2, LowerRight = 3 }
|
||||
public enum Axis { Horizontal = 0, Vertical = 1 }
|
||||
public enum Constraint { Flexible = 0, FixedColumnCount = 1, FixedRowCount = 2 }
|
||||
|
||||
[SerializeField]
|
||||
protected Corner m_StartCorner = Corner.UpperLeft;
|
||||
public Corner startCorner { get { return m_StartCorner; } set { SetProperty(ref m_StartCorner, value); } }
|
||||
|
||||
[SerializeField]
|
||||
protected Axis m_StartAxis = Axis.Horizontal;
|
||||
public Axis startAxis { get { return m_StartAxis; } set { SetProperty(ref m_StartAxis, value); } }
|
||||
|
||||
[SerializeField]
|
||||
protected Vector2 m_CellSize = new Vector2(100, 100);
|
||||
public Vector2 cellSize { get { return m_CellSize; } set { SetProperty(ref m_CellSize, value); } }
|
||||
|
||||
[SerializeField]
|
||||
protected Vector2 m_Spacing = Vector2.zero;
|
||||
public Vector2 spacing { get { return m_Spacing; } set { SetProperty(ref m_Spacing, value); } }
|
||||
|
||||
[SerializeField]
|
||||
protected Constraint m_Constraint = Constraint.Flexible;
|
||||
public Constraint constraint { get { return m_Constraint; } set { SetProperty(ref m_Constraint, value); } }
|
||||
|
||||
[SerializeField]
|
||||
protected int m_ConstraintCount = 2;
|
||||
public int constraintCount { get { return m_ConstraintCount; } set { SetProperty(ref m_ConstraintCount, Mathf.Max(1, value)); } }
|
||||
|
||||
protected AutoExpandGridLayoutGroup()
|
||||
{ }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
constraintCount = constraintCount;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void CalculateLayoutInputHorizontal()
|
||||
{
|
||||
base.CalculateLayoutInputHorizontal();
|
||||
|
||||
int minColumns = 0;
|
||||
int preferredColumns = 0;
|
||||
if (m_Constraint == Constraint.FixedColumnCount)
|
||||
{
|
||||
minColumns = preferredColumns = m_ConstraintCount;
|
||||
}
|
||||
else if (m_Constraint == Constraint.FixedRowCount)
|
||||
{
|
||||
minColumns = preferredColumns = Mathf.CeilToInt(rectChildren.Count / (float)m_ConstraintCount - 0.001f);
|
||||
}
|
||||
else
|
||||
{
|
||||
minColumns = 1;
|
||||
preferredColumns = Mathf.CeilToInt(Mathf.Sqrt(rectChildren.Count));
|
||||
}
|
||||
|
||||
SetLayoutInputForAxis(
|
||||
padding.horizontal + (cellSize.x + spacing.x) * minColumns - spacing.x,
|
||||
padding.horizontal + (cellSize.x + spacing.x) * preferredColumns - spacing.x,
|
||||
-1, 0);
|
||||
}
|
||||
|
||||
public override void CalculateLayoutInputVertical()
|
||||
{
|
||||
int minRows = 0;
|
||||
if (m_Constraint == Constraint.FixedColumnCount)
|
||||
{
|
||||
minRows = Mathf.CeilToInt(rectChildren.Count / (float)m_ConstraintCount - 0.001f);
|
||||
}
|
||||
else if (m_Constraint == Constraint.FixedRowCount)
|
||||
{
|
||||
minRows = m_ConstraintCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
float width = rectTransform.rect.size.x;
|
||||
int cellCountX = Mathf.Max(1, Mathf.FloorToInt((width - padding.horizontal + spacing.x + 0.001f) / (cellSize.x + spacing.x)));
|
||||
minRows = Mathf.CeilToInt(rectChildren.Count / (float)cellCountX);
|
||||
}
|
||||
|
||||
float minSpace = padding.vertical + (cellSize.y + spacing.y) * minRows - spacing.y;
|
||||
SetLayoutInputForAxis(minSpace, minSpace, -1, 1);
|
||||
}
|
||||
|
||||
public override void SetLayoutHorizontal()
|
||||
{
|
||||
SetCellsAlongAxis(0);
|
||||
}
|
||||
|
||||
public override void SetLayoutVertical()
|
||||
{
|
||||
SetCellsAlongAxis(1);
|
||||
}
|
||||
|
||||
private void SetCellsAlongAxis(int axis)
|
||||
{
|
||||
// Normally a Layout Controller should only set horizontal values when invoked for the horizontal axis
|
||||
// and only vertical values when invoked for the vertical axis.
|
||||
// However, in this case we set both the horizontal and vertical position when invoked for the vertical axis.
|
||||
// Since we only set the horizontal position and not the size, it shouldn't affect children's layout,
|
||||
// and thus shouldn't break the rule that all horizontal layout must be calculated before all vertical layout.
|
||||
|
||||
if (axis == 0)
|
||||
{
|
||||
// Only set the sizes when invoked for horizontal axis, not the positions.
|
||||
for (int i = 0; i < rectChildren.Count; i++)
|
||||
{
|
||||
RectTransform rect = rectChildren[i];
|
||||
|
||||
m_Tracker.Add(this, rect,
|
||||
DrivenTransformProperties.Anchors |
|
||||
DrivenTransformProperties.AnchoredPosition |
|
||||
DrivenTransformProperties.SizeDelta);
|
||||
|
||||
rect.anchorMin = Vector2.up;
|
||||
rect.anchorMax = Vector2.up;
|
||||
rect.sizeDelta = cellSize;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
float width = rectTransform.rect.size.x;
|
||||
float height = rectTransform.rect.size.y;
|
||||
|
||||
int cellCountX = 1;
|
||||
int cellCountY = 1;
|
||||
if (m_Constraint == Constraint.FixedColumnCount)
|
||||
{
|
||||
cellCountX = m_ConstraintCount;
|
||||
cellCountY = Mathf.CeilToInt(rectChildren.Count / (float)cellCountX - 0.001f);
|
||||
}
|
||||
else if (m_Constraint == Constraint.FixedRowCount)
|
||||
{
|
||||
cellCountY = m_ConstraintCount;
|
||||
cellCountX = Mathf.CeilToInt(rectChildren.Count / (float)cellCountY - 0.001f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cellSize.x + spacing.x <= 0)
|
||||
cellCountX = int.MaxValue;
|
||||
else
|
||||
cellCountX = Mathf.Max(1, Mathf.FloorToInt((width - padding.horizontal + spacing.x + 0.001f) / (cellSize.x + spacing.x)));
|
||||
|
||||
if (cellSize.y + spacing.y <= 0)
|
||||
cellCountY = int.MaxValue;
|
||||
else
|
||||
cellCountY = Mathf.Max(1, Mathf.FloorToInt((height - padding.vertical + spacing.y + 0.001f) / (cellSize.y + spacing.y)));
|
||||
}
|
||||
|
||||
int cornerX = (int)startCorner % 2;
|
||||
int cornerY = (int)startCorner / 2;
|
||||
|
||||
int cellsPerMainAxis, actualCellCountX, actualCellCountY;
|
||||
if (startAxis == Axis.Horizontal)
|
||||
{
|
||||
cellsPerMainAxis = cellCountX;
|
||||
actualCellCountX = Mathf.Clamp(cellCountX, 1, rectChildren.Count);
|
||||
actualCellCountY = Mathf.Clamp(cellCountY, 1, Mathf.CeilToInt(rectChildren.Count / (float)cellsPerMainAxis));
|
||||
}
|
||||
else
|
||||
{
|
||||
cellsPerMainAxis = cellCountY;
|
||||
actualCellCountY = Mathf.Clamp(cellCountY, 1, rectChildren.Count);
|
||||
actualCellCountX = Mathf.Clamp(cellCountX, 1, Mathf.CeilToInt(rectChildren.Count / (float)cellsPerMainAxis));
|
||||
}
|
||||
|
||||
Vector2 requiredSpace = new Vector2(
|
||||
actualCellCountX * cellSize.x + (actualCellCountX - 1) * spacing.x,
|
||||
actualCellCountY * cellSize.y + (actualCellCountY - 1) * spacing.y
|
||||
);
|
||||
Vector2 startOffset = new Vector2(
|
||||
GetStartOffset(0, requiredSpace.x),
|
||||
GetStartOffset(1, requiredSpace.y)
|
||||
);
|
||||
|
||||
for (int i = 0; i < rectChildren.Count; i++)
|
||||
{
|
||||
int positionX;
|
||||
int positionY;
|
||||
if (startAxis == Axis.Horizontal)
|
||||
{
|
||||
positionX = i % cellsPerMainAxis;
|
||||
positionY = i / cellsPerMainAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
positionX = i / cellsPerMainAxis;
|
||||
positionY = i % cellsPerMainAxis;
|
||||
}
|
||||
|
||||
if (cornerX == 1)
|
||||
positionX = actualCellCountX - 1 - positionX;
|
||||
if (cornerY == 1)
|
||||
positionY = actualCellCountY - 1 - positionY;
|
||||
|
||||
float realsize = ((width - (spacing[0] * (actualCellCountX - 1))) / actualCellCountX);
|
||||
SetChildAlongAxis(rectChildren[i], 0, startOffset.x + (realsize + spacing[0]) * positionX, realsize);
|
||||
SetChildAlongAxis(rectChildren[i], 1, startOffset.y + (cellSize[1] + spacing[1]) * positionY, cellSize[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1511795bf85d6e41ab89cb05c7cec84
|
||||
guid: d29c5f8f94f596d4f8316387788ae810
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
8
Assets/Plugins/Ink.meta
Normal file
8
Assets/Plugins/Ink.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4db0e7e1caca41440b5b14f966d1b38c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Plugins/Ink/Ink.asmdef
Normal file
14
Assets/Plugins/Ink/Ink.asmdef
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "Ink",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": true
|
||||
}
|
||||
7
Assets/Plugins/Ink/Ink.asmdef.meta
Normal file
7
Assets/Plugins/Ink/Ink.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45eb7f627001369419113f62ce8e3ead
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Ink/compiler.meta
Normal file
8
Assets/Plugins/Ink/compiler.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a220efa8dba4e9d4c957cbc085eabed2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Plugins/Ink/compiler/CharacterRange.cs
Normal file
54
Assets/Plugins/Ink/compiler/CharacterRange.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing a character range. Allows for lazy-loading a corresponding <see cref="CharacterSet">character set</see>.
|
||||
/// </summary>
|
||||
public sealed class CharacterRange
|
||||
{
|
||||
public static CharacterRange Define(char start, char end, IEnumerable<char> excludes = null)
|
||||
{
|
||||
return new CharacterRange (start, end, excludes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="CharacterSet">character set</see> instance corresponding to the character range
|
||||
/// represented by the current instance.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The internal character set is created once and cached in memory.
|
||||
/// </remarks>
|
||||
/// <returns>The char set.</returns>
|
||||
public CharacterSet ToCharacterSet ()
|
||||
{
|
||||
if (_correspondingCharSet.Count == 0)
|
||||
{
|
||||
for (char c = _start; c <= _end; c++)
|
||||
{
|
||||
if (!_excludes.Contains (c))
|
||||
{
|
||||
_correspondingCharSet.Add (c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _correspondingCharSet;
|
||||
}
|
||||
|
||||
public char start { get { return _start; } }
|
||||
public char end { get { return _end; } }
|
||||
|
||||
CharacterRange (char start, char end, IEnumerable<char> excludes)
|
||||
{
|
||||
_start = start;
|
||||
_end = end;
|
||||
_excludes = excludes == null ? new HashSet<char>() : new HashSet<char> (excludes);
|
||||
}
|
||||
|
||||
char _start;
|
||||
char _end;
|
||||
ICollection<char> _excludes;
|
||||
CharacterSet _correspondingCharSet = new CharacterSet();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7f6378c7d7a9be24c9830679aabe55ba
|
||||
guid: 72ae8a113e216e342af5643382c14802
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
53
Assets/Plugins/Ink/compiler/CharacterSet.cs
Normal file
53
Assets/Plugins/Ink/compiler/CharacterSet.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
|
||||
public class CharacterSet : HashSet<char>
|
||||
{
|
||||
public static CharacterSet FromRange(char start, char end)
|
||||
{
|
||||
return new CharacterSet ().AddRange (start, end);
|
||||
}
|
||||
|
||||
public CharacterSet ()
|
||||
{
|
||||
}
|
||||
|
||||
public CharacterSet(string str)
|
||||
{
|
||||
AddCharacters (str);
|
||||
}
|
||||
|
||||
public CharacterSet(CharacterSet charSetToCopy)
|
||||
{
|
||||
AddCharacters (charSetToCopy);
|
||||
}
|
||||
|
||||
public CharacterSet AddRange(char start, char end)
|
||||
{
|
||||
for(char c=start; c<=end; ++c) {
|
||||
Add (c);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CharacterSet AddCharacters(IEnumerable<char> chars)
|
||||
{
|
||||
foreach (char c in chars) {
|
||||
Add (c);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CharacterSet AddCharacters (string chars)
|
||||
{
|
||||
foreach (char c in chars) {
|
||||
Add (c);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38e6f1535d5cf5642bd01b1ab7a34492
|
||||
guid: 61e245e371a3dd848a15f35d6e9f43ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
12
Assets/Plugins/Ink/compiler/CommandLineInput.cs
Normal file
12
Assets/Plugins/Ink/compiler/CommandLineInput.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace Ink
|
||||
{
|
||||
public class CommandLineInput
|
||||
{
|
||||
public bool isHelp;
|
||||
public bool isExit;
|
||||
public int? choiceInput;
|
||||
public int? debugSource;
|
||||
public string debugPathLookup;
|
||||
public object userImmediateModeStatement;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1fbf8a3d31de89a4aa53d43e015536c7
|
||||
guid: 9ea826b6e6cf3c04cacb8f0967c91658
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
209
Assets/Plugins/Ink/compiler/Compiler.cs
Normal file
209
Assets/Plugins/Ink/compiler/Compiler.cs
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ink;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public class Compiler
|
||||
{
|
||||
public class Options
|
||||
{
|
||||
public string sourceFilename;
|
||||
public List<string> pluginNames;
|
||||
public bool countAllVisits;
|
||||
public Ink.ErrorHandler errorHandler;
|
||||
public Ink.IFileHandler fileHandler;
|
||||
}
|
||||
|
||||
public Parsed.Story parsedStory {
|
||||
get {
|
||||
return _parsedStory;
|
||||
}
|
||||
}
|
||||
|
||||
public Compiler (string inkSource, Options options = null)
|
||||
{
|
||||
_inputString = inkSource;
|
||||
_options = options ?? new Options();
|
||||
if( _options.pluginNames != null )
|
||||
_pluginManager = new PluginManager (_options.pluginNames);
|
||||
}
|
||||
|
||||
public Parsed.Story Parse()
|
||||
{
|
||||
_parser = new InkParser(_inputString, _options.sourceFilename, OnParseError, _options.fileHandler);
|
||||
_parsedStory = _parser.Parse();
|
||||
return _parsedStory;
|
||||
}
|
||||
|
||||
public Runtime.Story Compile ()
|
||||
{
|
||||
Parse();
|
||||
|
||||
if( _pluginManager != null )
|
||||
_pluginManager.PostParse(_parsedStory);
|
||||
|
||||
if (_parsedStory != null && !_hadParseError) {
|
||||
|
||||
_parsedStory.countAllVisits = _options.countAllVisits;
|
||||
|
||||
_runtimeStory = _parsedStory.ExportRuntime (_options.errorHandler);
|
||||
|
||||
if( _pluginManager != null )
|
||||
_pluginManager.PostExport (_parsedStory, _runtimeStory);
|
||||
} else {
|
||||
_runtimeStory = null;
|
||||
}
|
||||
|
||||
return _runtimeStory;
|
||||
}
|
||||
|
||||
public class CommandLineInputResult {
|
||||
public bool requestsExit;
|
||||
public int choiceIdx = -1;
|
||||
public string divertedPath;
|
||||
public string output;
|
||||
}
|
||||
public CommandLineInputResult HandleInput (CommandLineInput inputResult)
|
||||
{
|
||||
var result = new CommandLineInputResult ();
|
||||
|
||||
// Request for debug source line number
|
||||
if (inputResult.debugSource != null) {
|
||||
var offset = (int)inputResult.debugSource;
|
||||
var dm = DebugMetadataForContentAtOffset (offset);
|
||||
if (dm != null)
|
||||
result.output = "DebugSource: " + dm.ToString ();
|
||||
else
|
||||
result.output = "DebugSource: Unknown source";
|
||||
}
|
||||
|
||||
// Request for runtime path lookup (to line number)
|
||||
else if (inputResult.debugPathLookup != null) {
|
||||
var pathStr = inputResult.debugPathLookup;
|
||||
var contentResult = _runtimeStory.ContentAtPath (new Runtime.Path (pathStr));
|
||||
var dm = contentResult.obj.debugMetadata;
|
||||
if( dm != null )
|
||||
result.output = "DebugSource: " + dm.ToString ();
|
||||
else
|
||||
result.output = "DebugSource: Unknown source";
|
||||
}
|
||||
|
||||
// User entered some ink
|
||||
else if (inputResult.userImmediateModeStatement != null) {
|
||||
var parsedObj = inputResult.userImmediateModeStatement as Parsed.Object;
|
||||
return ExecuteImmediateStatement(parsedObj);
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandLineInputResult ExecuteImmediateStatement(Parsed.Object parsedObj) {
|
||||
var result = new CommandLineInputResult ();
|
||||
|
||||
// Variable assignment: create in Parsed.Story as well as the Runtime.Story
|
||||
// so that we don't get an error message during reference resolution
|
||||
if (parsedObj is Parsed.VariableAssignment) {
|
||||
var varAssign = (Parsed.VariableAssignment)parsedObj;
|
||||
if (varAssign.isNewTemporaryDeclaration) {
|
||||
_parsedStory.TryAddNewVariableDeclaration (varAssign);
|
||||
}
|
||||
}
|
||||
|
||||
parsedObj.parent = _parsedStory;
|
||||
var runtimeObj = parsedObj.runtimeObject;
|
||||
|
||||
parsedObj.ResolveReferences (_parsedStory);
|
||||
|
||||
if (!_parsedStory.hadError) {
|
||||
|
||||
// Divert
|
||||
if (parsedObj is Parsed.Divert) {
|
||||
var parsedDivert = parsedObj as Parsed.Divert;
|
||||
result.divertedPath = parsedDivert.runtimeDivert.targetPath.ToString();
|
||||
}
|
||||
|
||||
// Expression or variable assignment
|
||||
else if (parsedObj is Parsed.Expression || parsedObj is Parsed.VariableAssignment) {
|
||||
var evalResult = _runtimeStory.EvaluateExpression ((Runtime.Container)runtimeObj);
|
||||
if (evalResult != null) {
|
||||
result.output = evalResult.ToString ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_parsedStory.ResetError ();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void RetrieveDebugSourceForLatestContent ()
|
||||
{
|
||||
foreach (var outputObj in _runtimeStory.state.outputStream) {
|
||||
var textContent = outputObj as Runtime.StringValue;
|
||||
if (textContent != null) {
|
||||
var range = new DebugSourceRange ();
|
||||
range.length = textContent.value.Length;
|
||||
range.debugMetadata = textContent.debugMetadata;
|
||||
range.text = textContent.value;
|
||||
_debugSourceRanges.Add (range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.DebugMetadata DebugMetadataForContentAtOffset (int offset)
|
||||
{
|
||||
int currOffset = 0;
|
||||
|
||||
Runtime.DebugMetadata lastValidMetadata = null;
|
||||
foreach (var range in _debugSourceRanges) {
|
||||
if (range.debugMetadata != null)
|
||||
lastValidMetadata = range.debugMetadata;
|
||||
|
||||
if (offset >= currOffset && offset < currOffset + range.length)
|
||||
return lastValidMetadata;
|
||||
|
||||
currOffset += range.length;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public struct DebugSourceRange
|
||||
{
|
||||
public int length;
|
||||
public Runtime.DebugMetadata debugMetadata;
|
||||
public string text;
|
||||
}
|
||||
|
||||
// Need to wrap the error handler so that we know
|
||||
// when there was a critical error between parse and codegen stages
|
||||
void OnParseError (string message, ErrorType errorType)
|
||||
{
|
||||
if( errorType == ErrorType.Error )
|
||||
_hadParseError = true;
|
||||
|
||||
if (_options.errorHandler != null)
|
||||
_options.errorHandler (message, errorType);
|
||||
else
|
||||
throw new System.Exception(message);
|
||||
}
|
||||
|
||||
string _inputString;
|
||||
Options _options;
|
||||
|
||||
|
||||
InkParser _parser;
|
||||
Parsed.Story _parsedStory;
|
||||
Runtime.Story _runtimeStory;
|
||||
|
||||
PluginManager _pluginManager;
|
||||
|
||||
bool _hadParseError;
|
||||
|
||||
List<DebugSourceRange> _debugSourceRanges = new List<DebugSourceRange> ();
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Ink/compiler/Compiler.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/Compiler.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 02566d14814a1194ea64f24ac13aabbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Plugins/Ink/compiler/FileHandler.cs
Normal file
24
Assets/Plugins/Ink/compiler/FileHandler.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.IO;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public interface IFileHandler
|
||||
{
|
||||
string ResolveInkFilename (string includeName);
|
||||
string LoadInkFileContents (string fullFilename);
|
||||
}
|
||||
|
||||
public class DefaultFileHandler : Ink.IFileHandler {
|
||||
public string ResolveInkFilename (string includeName)
|
||||
{
|
||||
var workingDir = Directory.GetCurrentDirectory ();
|
||||
var fullRootInkPath = Path.Combine (workingDir, includeName);
|
||||
return fullRootInkPath;
|
||||
}
|
||||
|
||||
public string LoadInkFileContents (string fullFilename)
|
||||
{
|
||||
return File.ReadAllText (fullFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Ink/compiler/FileHandler.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/FileHandler.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a4bc77a489a8348498429161a93a337a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Ink/compiler/InkParser.meta
Normal file
8
Assets/Plugins/Ink/compiler/InkParser.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ac8c073d5990034aa0cc05037439d4f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/Plugins/Ink/compiler/InkParser/CommentEliminator.cs
Normal file
93
Assets/Plugins/Ink/compiler/InkParser/CommentEliminator.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
namespace Ink
|
||||
{
|
||||
/// <summary>
|
||||
/// Pre-pass before main ink parser runs. It actually performs two main tasks:
|
||||
/// - comment elimination to simplify the parse rules in the main parser
|
||||
/// - Conversion of Windows line endings (\r\n) to the simpler Unix style (\n), so
|
||||
/// we don't have to worry about them later.
|
||||
/// </summary>
|
||||
public class CommentEliminator : StringParser
|
||||
{
|
||||
public CommentEliminator (string input) : base(input)
|
||||
{
|
||||
}
|
||||
|
||||
public string Process()
|
||||
{
|
||||
// Make both comments and non-comments optional to handle trivial empty file case (or *only* comments)
|
||||
var stringList = Interleave<string>(Optional (CommentsAndNewlines), Optional(MainInk));
|
||||
|
||||
if (stringList != null) {
|
||||
return string.Join("", stringList.ToArray());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string MainInk()
|
||||
{
|
||||
return ParseUntil (CommentsAndNewlines, _commentOrNewlineStartCharacter, null);
|
||||
}
|
||||
|
||||
string CommentsAndNewlines()
|
||||
{
|
||||
var newlines = Interleave<string> (Optional (ParseNewline), Optional (ParseSingleComment));
|
||||
|
||||
if (newlines != null) {
|
||||
return string.Join ("", newlines.ToArray());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Valid comments always return either an empty string or pure newlines,
|
||||
// which we want to keep so that line numbers stay the same
|
||||
string ParseSingleComment()
|
||||
{
|
||||
return (string) OneOf (EndOfLineComment, BlockComment);
|
||||
}
|
||||
|
||||
string EndOfLineComment()
|
||||
{
|
||||
if (ParseString ("//") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ParseUntilCharactersFromCharSet (_newlineCharacters);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
string BlockComment()
|
||||
{
|
||||
if (ParseString ("/*") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int startLineIndex = lineIndex;
|
||||
|
||||
var commentResult = ParseUntil (String("*/"), _commentBlockEndCharacter, null);
|
||||
|
||||
if (!endOfInput) {
|
||||
ParseString ("*/");
|
||||
}
|
||||
|
||||
// Count the number of lines that were inside the block, and replicate them as newlines
|
||||
// so that the line indexing still works from the original source
|
||||
if (commentResult != null) {
|
||||
return new string ('\n', lineIndex - startLineIndex);
|
||||
}
|
||||
|
||||
// No comment at all
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
CharacterSet _commentOrNewlineStartCharacter = new CharacterSet ("/\r\n");
|
||||
CharacterSet _commentBlockEndCharacter = new CharacterSet("*");
|
||||
CharacterSet _newlineCharacters = new CharacterSet ("\n\r");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e650e9d0adfa13d40a23175367324716
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
171
Assets/Plugins/Ink/compiler/InkParser/InkParser.cs
Normal file
171
Assets/Plugins/Ink/compiler/InkParser/InkParser.cs
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser : StringParser
|
||||
{
|
||||
public InkParser(string str, string filenameForMetadata = null, Ink.ErrorHandler externalErrorHandler = null, IFileHandler fileHandler = null)
|
||||
: this(str, filenameForMetadata, externalErrorHandler, null, fileHandler)
|
||||
{ }
|
||||
|
||||
InkParser(string str, string inkFilename = null, Ink.ErrorHandler externalErrorHandler = null, InkParser rootParser = null, IFileHandler fileHandler = null) : base(str) {
|
||||
_filename = inkFilename;
|
||||
RegisterExpressionOperators ();
|
||||
GenerateStatementLevelRules ();
|
||||
|
||||
// Built in handler for all standard parse errors and warnings
|
||||
this.errorHandler = OnStringParserError;
|
||||
|
||||
// The above parse errors are then formatted as strings and passed
|
||||
// to the Ink.ErrorHandler, or it throws an exception
|
||||
_externalErrorHandler = externalErrorHandler;
|
||||
|
||||
_fileHandler = fileHandler ?? new DefaultFileHandler();
|
||||
|
||||
if (rootParser == null) {
|
||||
_rootParser = this;
|
||||
|
||||
_openFilenames = new HashSet<string> ();
|
||||
|
||||
if (inkFilename != null) {
|
||||
var fullRootInkPath = _fileHandler.ResolveInkFilename (inkFilename);
|
||||
_openFilenames.Add (fullRootInkPath);
|
||||
}
|
||||
|
||||
} else {
|
||||
_rootParser = rootParser;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Main entry point
|
||||
public Parsed.Story Parse()
|
||||
{
|
||||
List<Parsed.Object> topLevelContent = StatementsAtLevel (StatementLevel.Top);
|
||||
|
||||
// Note we used to return null if there were any errors, but this would mean
|
||||
// that include files would return completely empty rather than attempting to
|
||||
// continue with errors. Returning an empty include files meant that anything
|
||||
// that *did* compile successfully would otherwise be ignored, generating way
|
||||
// more errors than necessary.
|
||||
return new Parsed.Story (topLevelContent, isInclude:_rootParser != this);
|
||||
}
|
||||
|
||||
protected List<T> SeparatedList<T> (SpecificParseRule<T> mainRule, ParseRule separatorRule) where T : class
|
||||
{
|
||||
T firstElement = Parse (mainRule);
|
||||
if (firstElement == null) return null;
|
||||
|
||||
var allElements = new List<T> ();
|
||||
allElements.Add (firstElement);
|
||||
|
||||
do {
|
||||
|
||||
int nextElementRuleId = BeginRule ();
|
||||
|
||||
var sep = separatorRule ();
|
||||
if (sep == null) {
|
||||
FailRule (nextElementRuleId);
|
||||
break;
|
||||
}
|
||||
|
||||
var nextElement = Parse (mainRule);
|
||||
if (nextElement == null) {
|
||||
FailRule (nextElementRuleId);
|
||||
break;
|
||||
}
|
||||
|
||||
SucceedRule (nextElementRuleId);
|
||||
|
||||
allElements.Add (nextElement);
|
||||
|
||||
} while (true);
|
||||
|
||||
return allElements;
|
||||
}
|
||||
|
||||
protected override string PreProcessInputString(string str)
|
||||
{
|
||||
var inputWithCommentsRemoved = (new CommentEliminator (str)).Process();
|
||||
return inputWithCommentsRemoved;
|
||||
}
|
||||
|
||||
protected Runtime.DebugMetadata CreateDebugMetadata(StringParserState.Element stateAtStart, StringParserState.Element stateAtEnd)
|
||||
{
|
||||
var md = new Runtime.DebugMetadata ();
|
||||
md.startLineNumber = stateAtStart.lineIndex + 1;
|
||||
md.endLineNumber = stateAtEnd.lineIndex + 1;
|
||||
md.startCharacterNumber = stateAtStart.characterInLineIndex + 1;
|
||||
md.endCharacterNumber = stateAtEnd.characterInLineIndex + 1;
|
||||
md.fileName = _filename;
|
||||
return md;
|
||||
}
|
||||
|
||||
protected override void RuleDidSucceed(object result, StringParserState.Element stateAtStart, StringParserState.Element stateAtEnd)
|
||||
{
|
||||
// Apply DebugMetadata based on the state at the start of the rule
|
||||
// (i.e. use line number as it was at the start of the rule)
|
||||
var parsedObj = result as Parsed.Object;
|
||||
if ( parsedObj) {
|
||||
parsedObj.debugMetadata = CreateDebugMetadata(stateAtStart, stateAtEnd);
|
||||
return;
|
||||
}
|
||||
|
||||
// A list of objects that doesn't already have metadata?
|
||||
var parsedListObjs = result as List<Parsed.Object>;
|
||||
if (parsedListObjs != null) {
|
||||
foreach (var parsedListObj in parsedListObjs) {
|
||||
if (!parsedListObj.hasOwnDebugMetadata) {
|
||||
parsedListObj.debugMetadata = CreateDebugMetadata(stateAtStart, stateAtEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var id = result as Parsed.Identifier;
|
||||
if (id != null) {
|
||||
id.debugMetadata = CreateDebugMetadata(stateAtStart, stateAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool parsingStringExpression
|
||||
{
|
||||
get {
|
||||
return GetFlag ((uint)CustomFlags.ParsingString);
|
||||
}
|
||||
set {
|
||||
SetFlag ((uint)CustomFlags.ParsingString, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected enum CustomFlags {
|
||||
ParsingString = 0x1
|
||||
}
|
||||
|
||||
void OnStringParserError(string message, int index, int lineIndex, bool isWarning)
|
||||
{
|
||||
var warningType = isWarning ? "WARNING:" : "ERROR:";
|
||||
string fullMessage;
|
||||
|
||||
if (_filename != null) {
|
||||
fullMessage = string.Format(warningType+" '{0}' line {1}: {2}", _filename, (lineIndex+1), message);
|
||||
} else {
|
||||
fullMessage = string.Format(warningType+" line {0}: {1}", (lineIndex+1), message);
|
||||
}
|
||||
|
||||
if (_externalErrorHandler != null) {
|
||||
_externalErrorHandler (fullMessage, isWarning ? ErrorType.Warning : ErrorType.Error);
|
||||
} else {
|
||||
throw new System.Exception (fullMessage);
|
||||
}
|
||||
}
|
||||
|
||||
IFileHandler _fileHandler;
|
||||
|
||||
Ink.ErrorHandler _externalErrorHandler;
|
||||
|
||||
string _filename;
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Plugins/Ink/compiler/InkParser/InkParser.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/InkParser/InkParser.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57456b83f66dcfb4dbdc06ae75d41958
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using Ink.Parsed;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected AuthorWarning AuthorWarning()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var identifier = Parse (IdentifierWithMetadata);
|
||||
if (identifier == null || identifier.name != "TODO")
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
ParseString (":");
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var message = ParseUntilCharactersFromString ("\n\r");
|
||||
|
||||
return new AuthorWarning (message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c9f8990d12640c40b17fdb3552c08f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
using Ink.Parsed;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
public static readonly CharacterRange LatinBasic =
|
||||
CharacterRange.Define ('\u0041', '\u007A', excludes: new CharacterSet().AddRange('\u005B', '\u0060'));
|
||||
public static readonly CharacterRange LatinExtendedA = CharacterRange.Define('\u0100', '\u017F'); // no excludes here
|
||||
public static readonly CharacterRange LatinExtendedB = CharacterRange.Define('\u0180', '\u024F'); // no excludes here
|
||||
public static readonly CharacterRange Greek =
|
||||
CharacterRange.Define('\u0370', '\u03FF', excludes: new CharacterSet().AddRange('\u0378','\u0385').AddCharacters("\u0374\u0375\u0378\u0387\u038B\u038D\u03A2"));
|
||||
public static readonly CharacterRange Cyrillic =
|
||||
CharacterRange.Define('\u0400', '\u04FF', excludes: new CharacterSet().AddRange('\u0482', '\u0489'));
|
||||
public static readonly CharacterRange Armenian =
|
||||
CharacterRange.Define('\u0530', '\u058F', excludes: new CharacterSet().AddCharacters("\u0530").AddRange('\u0557', '\u0560').AddRange('\u0588', '\u058E'));
|
||||
public static readonly CharacterRange Hebrew =
|
||||
CharacterRange.Define('\u0590', '\u05FF', excludes: new CharacterSet());
|
||||
public static readonly CharacterRange Arabic =
|
||||
CharacterRange.Define('\u0600', '\u06FF', excludes: new CharacterSet());
|
||||
public static readonly CharacterRange Korean =
|
||||
CharacterRange.Define('\uAC00', '\uD7AF', excludes: new CharacterSet());
|
||||
public static readonly CharacterRange Latin1Supplement =
|
||||
CharacterRange.Define('\u0080', '\u00FF', excludes: new CharacterSet());
|
||||
|
||||
private void ExtendIdentifierCharacterRanges(CharacterSet identifierCharSet)
|
||||
{
|
||||
var characterRanges = ListAllCharacterRanges();
|
||||
|
||||
foreach (var charRange in characterRanges)
|
||||
{
|
||||
identifierCharSet.AddCharacters(charRange.ToCharacterSet());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of <see cref="CharacterRange" /> representing all of the currently supported
|
||||
/// non-ASCII character ranges that can be used in identifier names.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An array of <see cref="CharacterRange" /> representing all of the currently supported
|
||||
/// non-ASCII character ranges that can be used in identifier names.
|
||||
/// </returns>
|
||||
public static CharacterRange[] ListAllCharacterRanges() {
|
||||
return new CharacterRange[] {
|
||||
LatinBasic,
|
||||
LatinExtendedA,
|
||||
LatinExtendedB,
|
||||
Arabic,
|
||||
Armenian,
|
||||
Cyrillic,
|
||||
Greek,
|
||||
Hebrew,
|
||||
Korean,
|
||||
Latin1Supplement,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1cc3ab7c74670a40936f5c282a505e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
225
Assets/Plugins/Ink/compiler/InkParser/InkParser_Choices.cs
Normal file
225
Assets/Plugins/Ink/compiler/InkParser/InkParser_Choices.cs
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
using Ink.Parsed;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected Choice Choice()
|
||||
{
|
||||
bool onceOnlyChoice = true;
|
||||
var bullets = Interleave <string>(OptionalExclude(Whitespace), String("*") );
|
||||
if (bullets == null) {
|
||||
|
||||
bullets = Interleave <string>(OptionalExclude(Whitespace), String("+") );
|
||||
if (bullets == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
onceOnlyChoice = false;
|
||||
}
|
||||
|
||||
// Optional name for the choice
|
||||
Identifier optionalName = Parse(BracketedName);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Optional condition for whether the choice should be shown to the player
|
||||
Expression conditionExpr = Parse(ChoiceCondition);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Ordinarily we avoid parser state variables like these, since
|
||||
// nesting would require us to store them in a stack. But since you should
|
||||
// never be able to nest choices within choice content, it's fine here.
|
||||
Debug.Assert(_parsingChoice == false, "Already parsing a choice - shouldn't have nested choices");
|
||||
_parsingChoice = true;
|
||||
|
||||
ContentList startContent = null;
|
||||
var startTextAndLogic = Parse (MixedTextAndLogic);
|
||||
if (startTextAndLogic != null)
|
||||
startContent = new ContentList (startTextAndLogic);
|
||||
|
||||
|
||||
ContentList optionOnlyContent = null;
|
||||
ContentList innerContent = null;
|
||||
|
||||
// Check for a the weave style format:
|
||||
// * "Hello[."]," he said.
|
||||
bool hasWeaveStyleInlineBrackets = ParseString("[") != null;
|
||||
if (hasWeaveStyleInlineBrackets) {
|
||||
|
||||
var optionOnlyTextAndLogic = Parse (MixedTextAndLogic);
|
||||
if (optionOnlyTextAndLogic != null)
|
||||
optionOnlyContent = new ContentList (optionOnlyTextAndLogic);
|
||||
|
||||
|
||||
Expect (String("]"), "closing ']' for weave-style option");
|
||||
|
||||
var innerTextAndLogic = Parse (MixedTextAndLogic);
|
||||
if( innerTextAndLogic != null )
|
||||
innerContent = new ContentList (innerTextAndLogic);
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Finally, now we know we're at the end of the main choice body, parse
|
||||
// any diverts separately.
|
||||
var diverts = Parse(MultiDivert);
|
||||
|
||||
_parsingChoice = false;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Completely empty choice without even an empty divert?
|
||||
bool emptyContent = !startContent && !innerContent && !optionOnlyContent;
|
||||
if (emptyContent && diverts == null)
|
||||
Warning ("Choice is completely empty. Interpretting as a default fallback choice. Add a divert arrow to remove this warning: * ->");
|
||||
|
||||
// * [] some text
|
||||
else if (!startContent && hasWeaveStyleInlineBrackets && !optionOnlyContent)
|
||||
Warning ("Blank choice - if you intended a default fallback choice, use the `* ->` syntax");
|
||||
|
||||
if (!innerContent) innerContent = new ContentList ();
|
||||
|
||||
var tags = Parse (Tags);
|
||||
if (tags != null) {
|
||||
innerContent.AddContent(tags);
|
||||
}
|
||||
|
||||
// Normal diverts on the end of a choice - simply add to the normal content
|
||||
if (diverts != null) {
|
||||
foreach (var divObj in diverts) {
|
||||
// may be TunnelOnwards
|
||||
var div = divObj as Divert;
|
||||
|
||||
// Empty divert serves no purpose other than to say
|
||||
// "this choice is intentionally left blank"
|
||||
// (as an invisible default choice)
|
||||
if (div && div.isEmpty) continue;
|
||||
|
||||
innerContent.AddContent (divObj);
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate main content with a newline since this is the end of the line
|
||||
// Note that this will be redundant if the diverts above definitely take
|
||||
// the flow away permanently.
|
||||
innerContent.AddContent (new Text ("\n"));
|
||||
|
||||
var choice = new Choice (startContent, optionOnlyContent, innerContent);
|
||||
choice.identifier = optionalName;
|
||||
choice.indentationDepth = bullets.Count;
|
||||
choice.hasWeaveStyleInlineBrackets = hasWeaveStyleInlineBrackets;
|
||||
choice.condition = conditionExpr;
|
||||
choice.onceOnly = onceOnlyChoice;
|
||||
choice.isInvisibleDefault = emptyContent;
|
||||
|
||||
return choice;
|
||||
|
||||
}
|
||||
|
||||
protected Expression ChoiceCondition()
|
||||
{
|
||||
var conditions = Interleave<Expression> (ChoiceSingleCondition, ChoiceConditionsSpace);
|
||||
if (conditions == null)
|
||||
return null;
|
||||
else if (conditions.Count == 1)
|
||||
return conditions [0];
|
||||
else {
|
||||
return new MultipleConditionExpression (conditions);
|
||||
}
|
||||
}
|
||||
|
||||
protected object ChoiceConditionsSpace()
|
||||
{
|
||||
// Both optional
|
||||
// Newline includes initial end of line whitespace
|
||||
Newline ();
|
||||
Whitespace ();
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
protected Expression ChoiceSingleCondition()
|
||||
{
|
||||
if (ParseString ("{") == null)
|
||||
return null;
|
||||
|
||||
var condExpr = Expect(Expression, "choice condition inside { }") as Expression;
|
||||
DisallowIncrement (condExpr);
|
||||
|
||||
Expect (String ("}"), "closing '}' for choice condition");
|
||||
|
||||
return condExpr;
|
||||
}
|
||||
|
||||
protected Gather Gather()
|
||||
{
|
||||
object gatherDashCountObj = Parse(GatherDashes);
|
||||
if (gatherDashCountObj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int gatherDashCount = (int)gatherDashCountObj;
|
||||
|
||||
// Optional name for the gather
|
||||
Identifier optionalName = Parse(BracketedName);
|
||||
|
||||
var gather = new Gather (optionalName, gatherDashCount);
|
||||
|
||||
// Optional newline before gather's content begins
|
||||
Newline ();
|
||||
|
||||
return gather;
|
||||
}
|
||||
|
||||
protected object GatherDashes()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
int gatherDashCount = 0;
|
||||
|
||||
while (ParseDashNotArrow () != null) {
|
||||
gatherDashCount++;
|
||||
Whitespace ();
|
||||
}
|
||||
|
||||
if (gatherDashCount == 0)
|
||||
return null;
|
||||
|
||||
return gatherDashCount;
|
||||
}
|
||||
|
||||
protected object ParseDashNotArrow()
|
||||
{
|
||||
var ruleId = BeginRule ();
|
||||
|
||||
if (ParseString ("->") == null && ParseSingleCharacter () == '-') {
|
||||
return SucceedRule (ruleId);
|
||||
} else {
|
||||
return FailRule (ruleId);
|
||||
}
|
||||
}
|
||||
|
||||
protected Identifier BracketedName()
|
||||
{
|
||||
if (ParseString ("(") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Identifier name = Parse(IdentifierWithMetadata);
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String (")"), "closing ')' for bracketed name");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
bool _parsingChoice;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2d978613bf868c48b75265740aad51e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
// Valid returned objects:
|
||||
// - "help"
|
||||
// - int: for choice number
|
||||
// - Parsed.Divert
|
||||
// - Variable declaration/assignment
|
||||
// - Epression
|
||||
// - Lookup debug source for character offset
|
||||
// - Lookup debug source for runtime path
|
||||
public CommandLineInput CommandLineUserInput()
|
||||
{
|
||||
CommandLineInput result = new CommandLineInput ();
|
||||
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("help") != null) {
|
||||
result.isHelp = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (ParseString ("exit") != null || ParseString ("quit") != null) {
|
||||
result.isExit = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
return (CommandLineInput) OneOf (
|
||||
DebugSource,
|
||||
DebugPathLookup,
|
||||
UserChoiceNumber,
|
||||
UserImmediateModeStatement
|
||||
);
|
||||
}
|
||||
|
||||
CommandLineInput DebugSource ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("DebugSource") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var expectMsg = "character offset in parentheses, e.g. DebugSource(5)";
|
||||
if (Expect (String ("("), expectMsg) == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
int? characterOffset = ParseInt ();
|
||||
if (characterOffset == null) {
|
||||
Error (expectMsg);
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String (")"), "closing parenthesis");
|
||||
|
||||
var inputStruct = new CommandLineInput ();
|
||||
inputStruct.debugSource = characterOffset;
|
||||
return inputStruct;
|
||||
}
|
||||
|
||||
CommandLineInput DebugPathLookup ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("DebugPath") == null)
|
||||
return null;
|
||||
|
||||
if (Whitespace () == null)
|
||||
return null;
|
||||
|
||||
var pathStr = Expect (RuntimePath, "path") as string;
|
||||
|
||||
var inputStruct = new CommandLineInput ();
|
||||
inputStruct.debugPathLookup = pathStr;
|
||||
return inputStruct;
|
||||
}
|
||||
|
||||
string RuntimePath ()
|
||||
{
|
||||
if (_runtimePathCharacterSet == null) {
|
||||
_runtimePathCharacterSet = new CharacterSet (identifierCharSet);
|
||||
_runtimePathCharacterSet.Add ('-'); // for c-0, g-0 etc
|
||||
_runtimePathCharacterSet.Add ('.');
|
||||
|
||||
}
|
||||
|
||||
return ParseCharactersFromCharSet (_runtimePathCharacterSet);
|
||||
}
|
||||
|
||||
CommandLineInput UserChoiceNumber()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
int? number = ParseInt ();
|
||||
if (number == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
if (Parse(EndOfLine) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var inputStruct = new CommandLineInput ();
|
||||
inputStruct.choiceInput = number;
|
||||
return inputStruct;
|
||||
}
|
||||
|
||||
CommandLineInput UserImmediateModeStatement()
|
||||
{
|
||||
var statement = OneOf (SingleDivert, TempDeclarationOrAssignment, Expression);
|
||||
|
||||
var inputStruct = new CommandLineInput ();
|
||||
inputStruct.userImmediateModeStatement = statement;
|
||||
return inputStruct;
|
||||
}
|
||||
|
||||
CharacterSet _runtimePathCharacterSet;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69954d17756084b4bb0c82e2238d36bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
288
Assets/Plugins/Ink/compiler/InkParser/InkParser_Conditional.cs
Normal file
288
Assets/Plugins/Ink/compiler/InkParser/InkParser_Conditional.cs
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Parsed;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected Conditional InnerConditionalContent()
|
||||
{
|
||||
var initialQueryExpression = Parse(ConditionExpression);
|
||||
var conditional = Parse(() => InnerConditionalContent (initialQueryExpression));
|
||||
if (conditional == null)
|
||||
return null;
|
||||
|
||||
return conditional;
|
||||
}
|
||||
|
||||
protected Conditional InnerConditionalContent(Expression initialQueryExpression)
|
||||
{
|
||||
List<ConditionalSingleBranch> alternatives;
|
||||
|
||||
bool canBeInline = initialQueryExpression != null;
|
||||
bool isInline = Parse(Newline) == null;
|
||||
|
||||
if (isInline && !canBeInline) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Inline innards
|
||||
if (isInline) {
|
||||
alternatives = InlineConditionalBranches ();
|
||||
}
|
||||
|
||||
// Multiline innards
|
||||
else {
|
||||
alternatives = MultilineConditionalBranches ();
|
||||
if (alternatives == null) {
|
||||
|
||||
// Allow single piece of content within multi-line expression, e.g.:
|
||||
// { true:
|
||||
// Some content that isn't preceded by '-'
|
||||
// }
|
||||
if (initialQueryExpression) {
|
||||
List<Parsed.Object> soleContent = StatementsAtLevel (StatementLevel.InnerBlock);
|
||||
if (soleContent != null) {
|
||||
var soleBranch = new ConditionalSingleBranch (soleContent);
|
||||
alternatives = new List<ConditionalSingleBranch> ();
|
||||
alternatives.Add (soleBranch);
|
||||
|
||||
// Also allow a final "- else:" clause
|
||||
var elseBranch = Parse (SingleMultilineCondition);
|
||||
if (elseBranch) {
|
||||
if (!elseBranch.isElse) {
|
||||
ErrorWithParsedObject ("Expected an '- else:' clause here rather than an extra condition", elseBranch);
|
||||
elseBranch.isElse = true;
|
||||
}
|
||||
alternatives.Add (elseBranch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Still null?
|
||||
if (alternatives == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty true branch - didn't get parsed, but should insert one for semantic correctness,
|
||||
// and to make sure that any evaluation stack values get tidied up correctly.
|
||||
else if (alternatives.Count == 1 && alternatives [0].isElse && initialQueryExpression) {
|
||||
var emptyTrueBranch = new ConditionalSingleBranch (null);
|
||||
emptyTrueBranch.isTrueBranch = true;
|
||||
alternatives.Insert (0, emptyTrueBranch);
|
||||
}
|
||||
|
||||
// Like a switch statement
|
||||
// { initialQueryExpression:
|
||||
// ... match the expression
|
||||
// }
|
||||
if (initialQueryExpression) {
|
||||
|
||||
bool earlierBranchesHaveOwnExpression = false;
|
||||
for (int i = 0; i < alternatives.Count; ++i) {
|
||||
var branch = alternatives [i];
|
||||
bool isLast = (i == alternatives.Count - 1);
|
||||
|
||||
// Matching equality with initial query expression
|
||||
// We set this flag even for the "else" clause so that
|
||||
// it knows to tidy up the evaluation stack at the end
|
||||
|
||||
// Match query
|
||||
if (branch.ownExpression) {
|
||||
branch.matchingEquality = true;
|
||||
earlierBranchesHaveOwnExpression = true;
|
||||
}
|
||||
|
||||
// Else (final branch)
|
||||
else if (earlierBranchesHaveOwnExpression && isLast) {
|
||||
branch.matchingEquality = true;
|
||||
branch.isElse = true;
|
||||
}
|
||||
|
||||
// Binary condition:
|
||||
// { trueOrFalse:
|
||||
// - when true
|
||||
// - when false
|
||||
// }
|
||||
else {
|
||||
|
||||
if (!isLast && alternatives.Count > 2) {
|
||||
ErrorWithParsedObject ("Only final branch can be an 'else'. Did you miss a ':'?", branch);
|
||||
} else {
|
||||
if (i == 0)
|
||||
branch.isTrueBranch = true;
|
||||
else
|
||||
branch.isElse = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No initial query, so just a multi-line conditional. e.g.:
|
||||
// {
|
||||
// - x > 3: greater than three
|
||||
// - x == 3: equal to three
|
||||
// - x < 3: less than three
|
||||
// }
|
||||
else {
|
||||
|
||||
for (int i = 0; i < alternatives.Count; ++i) {
|
||||
var alt = alternatives [i];
|
||||
bool isLast = (i == alternatives.Count - 1);
|
||||
if (alt.ownExpression == null) {
|
||||
if (isLast) {
|
||||
alt.isElse = true;
|
||||
} else {
|
||||
if (alt.isElse) {
|
||||
// Do we ALSO have a valid "else" at the end? Let's report the error there.
|
||||
var finalClause = alternatives [alternatives.Count - 1];
|
||||
if (finalClause.isElse) {
|
||||
ErrorWithParsedObject ("Multiple 'else' cases. Can have a maximum of one, at the end.", finalClause);
|
||||
} else {
|
||||
ErrorWithParsedObject ("'else' case in conditional should always be the final one", alt);
|
||||
}
|
||||
} else {
|
||||
ErrorWithParsedObject ("Branch doesn't have condition. Are you missing a ':'? ", alt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alternatives.Count == 1 && alternatives [0].ownExpression == null) {
|
||||
ErrorWithParsedObject ("Condition block with no conditions", alternatives [0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Come up with water-tight error conditions... it's quite a flexible system!
|
||||
// e.g.
|
||||
// - inline conditionals must have exactly 1 or 2 alternatives
|
||||
// - multiline expression shouldn't have mixed existence of branch-conditions?
|
||||
if (alternatives == null)
|
||||
return null;
|
||||
|
||||
foreach (var branch in alternatives) {
|
||||
branch.isInline = isInline;
|
||||
}
|
||||
|
||||
var cond = new Conditional (initialQueryExpression, alternatives);
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected List<ConditionalSingleBranch> InlineConditionalBranches()
|
||||
{
|
||||
var listOfLists = Interleave<List<Parsed.Object>> (MixedTextAndLogic, Exclude (String ("|")), flatten: false);
|
||||
if (listOfLists == null || listOfLists.Count == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new List<ConditionalSingleBranch> ();
|
||||
|
||||
if (listOfLists.Count > 2) {
|
||||
Error ("Expected one or two alternatives separated by '|' in inline conditional");
|
||||
} else {
|
||||
|
||||
var trueBranch = new ConditionalSingleBranch (listOfLists[0]);
|
||||
trueBranch.isTrueBranch = true;
|
||||
result.Add (trueBranch);
|
||||
|
||||
if (listOfLists.Count > 1) {
|
||||
var elseBranch = new ConditionalSingleBranch (listOfLists[1]);
|
||||
elseBranch.isElse = true;
|
||||
result.Add (elseBranch);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<ConditionalSingleBranch> MultilineConditionalBranches()
|
||||
{
|
||||
MultilineWhitespace ();
|
||||
|
||||
List<object> multipleConditions = OneOrMore (SingleMultilineCondition);
|
||||
if (multipleConditions == null)
|
||||
return null;
|
||||
|
||||
MultilineWhitespace ();
|
||||
|
||||
return multipleConditions.Cast<ConditionalSingleBranch>().ToList();
|
||||
}
|
||||
|
||||
protected ConditionalSingleBranch SingleMultilineCondition()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// Make sure we're not accidentally parsing a divert
|
||||
if (ParseString ("->") != null)
|
||||
return null;
|
||||
|
||||
if (ParseString ("-") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expression expr = null;
|
||||
bool isElse = Parse(ElseExpression) != null;
|
||||
|
||||
if( !isElse )
|
||||
expr = Parse(ConditionExpression);
|
||||
|
||||
List<Parsed.Object> content = StatementsAtLevel (StatementLevel.InnerBlock);
|
||||
if (expr == null && content == null) {
|
||||
Error ("expected content for the conditional branch following '-'");
|
||||
|
||||
// Recover
|
||||
content = new List<Ink.Parsed.Object> ();
|
||||
content.Add (new Text (""));
|
||||
}
|
||||
|
||||
// Allow additional multiline whitespace, if the statements were empty (valid)
|
||||
// then their surrounding multiline whitespacce needs to be handled manually.
|
||||
// e.g.
|
||||
// { x:
|
||||
// - 1: // intentionally left blank, but newline needs to be parsed
|
||||
// - 2: etc
|
||||
// }
|
||||
MultilineWhitespace ();
|
||||
|
||||
var branch = new ConditionalSingleBranch (content);
|
||||
branch.ownExpression = expr;
|
||||
branch.isElse = isElse;
|
||||
return branch;
|
||||
}
|
||||
|
||||
protected Expression ConditionExpression()
|
||||
{
|
||||
var expr = Parse(Expression);
|
||||
if (expr == null)
|
||||
return null;
|
||||
|
||||
DisallowIncrement (expr);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString (":") == null)
|
||||
return null;
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
protected object ElseExpression()
|
||||
{
|
||||
if (ParseString ("else") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString (":") == null)
|
||||
return null;
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a295014ccaa92c41bd194e4eecc1bd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
217
Assets/Plugins/Ink/compiler/InkParser/InkParser_Content.cs
Normal file
217
Assets/Plugins/Ink/compiler/InkParser/InkParser_Content.cs
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
using Ink.Parsed;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
void TrimEndWhitespace(List<Parsed.Object> mixedTextAndLogicResults, bool terminateWithSpace)
|
||||
{
|
||||
// Trim whitespace from end
|
||||
if (mixedTextAndLogicResults.Count > 0) {
|
||||
var lastObjIdx = mixedTextAndLogicResults.Count - 1;
|
||||
var lastObj = mixedTextAndLogicResults[lastObjIdx];
|
||||
if (lastObj is Text) {
|
||||
var text = (Text)lastObj;
|
||||
text.text = text.text.TrimEnd (' ', '\t');
|
||||
|
||||
if (terminateWithSpace)
|
||||
text.text += " ";
|
||||
|
||||
// No content left at all? trim the whole object
|
||||
else if( text.text.Length == 0 ) {
|
||||
mixedTextAndLogicResults.RemoveAt(lastObjIdx);
|
||||
|
||||
// Recurse in case there's more whitespace
|
||||
TrimEndWhitespace(mixedTextAndLogicResults, terminateWithSpace:false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Parsed.Object> LineOfMixedTextAndLogic()
|
||||
{
|
||||
// Consume any whitespace at the start of the line
|
||||
// (Except for escaped whitespace)
|
||||
Parse (Whitespace);
|
||||
|
||||
var result = Parse(MixedTextAndLogic);
|
||||
|
||||
// Terminating tag
|
||||
bool onlyTags = false;
|
||||
var tags = Parse (Tags);
|
||||
if (tags != null) {
|
||||
if (result == null) {
|
||||
result = tags.Cast<Parsed.Object> ().ToList ();
|
||||
onlyTags = true;
|
||||
} else {
|
||||
foreach (var tag in tags) {
|
||||
result.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null || result.Count == 0)
|
||||
return null;
|
||||
|
||||
// Warn about accidentally writing "return" without "~"
|
||||
var firstText = result[0] as Text;
|
||||
if (firstText) {
|
||||
if (firstText.text.StartsWith ("return")) {
|
||||
Warning ("Do you need a '~' before 'return'? If not, perhaps use a glue: <> (since it's lowercase) or rewrite somehow?");
|
||||
}
|
||||
}
|
||||
if (result.Count == 0)
|
||||
return null;
|
||||
|
||||
var lastObj = result [result.Count - 1];
|
||||
if (!(lastObj is Divert)) {
|
||||
TrimEndWhitespace (result, terminateWithSpace:false);
|
||||
}
|
||||
|
||||
// Add newline since it's the end of the line
|
||||
// (so long as it's a line with only tags)
|
||||
if( !onlyTags )
|
||||
result.Add (new Text ("\n"));
|
||||
|
||||
Expect(EndOfLine, "end of line", recoveryRule: SkipToNextLine);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<Parsed.Object> MixedTextAndLogic()
|
||||
{
|
||||
// Check for disallowed "~" within this context
|
||||
var disallowedTilda = ParseObject(Spaced(String("~")));
|
||||
if (disallowedTilda != null)
|
||||
Error ("You shouldn't use a '~' here - tildas are for logic that's on its own line. To do inline logic, use { curly braces } instead");
|
||||
|
||||
// Either, or both interleaved
|
||||
var results = Interleave<Parsed.Object>(Optional (ContentText), Optional (InlineLogicOrGlue));
|
||||
|
||||
// Terminating divert?
|
||||
// (When parsing content for the text of a choice, diverts aren't allowed.
|
||||
// The divert on the end of the body of a choice is handled specially.)
|
||||
if (!_parsingChoice) {
|
||||
|
||||
var diverts = Parse (MultiDivert);
|
||||
if (diverts != null) {
|
||||
|
||||
// May not have had any results at all if there's *only* a divert!
|
||||
if (results == null)
|
||||
results = new List<Parsed.Object> ();
|
||||
|
||||
TrimEndWhitespace (results, terminateWithSpace:true);
|
||||
|
||||
results.AddRange (diverts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (results == null)
|
||||
return null;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
protected Parsed.Text ContentText()
|
||||
{
|
||||
return ContentTextAllowingEcapeChar ();
|
||||
}
|
||||
|
||||
protected Parsed.Text ContentTextAllowingEcapeChar()
|
||||
{
|
||||
StringBuilder sb = null;
|
||||
|
||||
do {
|
||||
var str = Parse(ContentTextNoEscape);
|
||||
bool gotEscapeChar = ParseString(@"\") != null;
|
||||
|
||||
if( gotEscapeChar || str != null ) {
|
||||
if( sb == null ) {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
|
||||
if( str != null ) {
|
||||
sb.Append(str);
|
||||
}
|
||||
|
||||
if( gotEscapeChar ) {
|
||||
char c = ParseSingleCharacter();
|
||||
sb.Append(c);
|
||||
}
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
} while(true);
|
||||
|
||||
if (sb != null ) {
|
||||
return new Parsed.Text (sb.ToString ());
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Content text is an unusual parse rule compared with most since it's
|
||||
// less about saying "this is is the small selection of stuff that we parse"
|
||||
// and more "we parse ANYTHING except this small selection of stuff".
|
||||
protected string ContentTextNoEscape()
|
||||
{
|
||||
// Eat through text, pausing at the following characters, and
|
||||
// attempt to parse the nonTextRule.
|
||||
// "-": possible start of divert or start of gather
|
||||
// "<": possible start of glue
|
||||
if (_nonTextPauseCharacters == null) {
|
||||
_nonTextPauseCharacters = new CharacterSet ("-<");
|
||||
}
|
||||
|
||||
// If we hit any of these characters, we stop *immediately* without bothering to even check the nonTextRule
|
||||
// "{" for start of logic
|
||||
// "|" for mid logic branch
|
||||
if (_nonTextEndCharacters == null) {
|
||||
_nonTextEndCharacters = new CharacterSet ("{}|\n\r\\#");
|
||||
_notTextEndCharactersChoice = new CharacterSet (_nonTextEndCharacters);
|
||||
_notTextEndCharactersChoice.AddCharacters ("[]");
|
||||
_notTextEndCharactersString = new CharacterSet (_nonTextEndCharacters);
|
||||
_notTextEndCharactersString.AddCharacters ("\"");
|
||||
}
|
||||
|
||||
// When the ParseUntil pauses, check these rules in case they evaluate successfully
|
||||
ParseRule nonTextRule = () => OneOf (ParseDivertArrow, ParseThreadArrow, EndOfLine, Glue);
|
||||
|
||||
CharacterSet endChars = null;
|
||||
if (parsingStringExpression) {
|
||||
endChars = _notTextEndCharactersString;
|
||||
}
|
||||
else if (_parsingChoice) {
|
||||
endChars = _notTextEndCharactersChoice;
|
||||
}
|
||||
else {
|
||||
endChars = _nonTextEndCharacters;
|
||||
}
|
||||
|
||||
string pureTextContent = ParseUntil (nonTextRule, _nonTextPauseCharacters, endChars);
|
||||
if (pureTextContent != null ) {
|
||||
return pureTextContent;
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CharacterSet _nonTextPauseCharacters;
|
||||
CharacterSet _nonTextEndCharacters;
|
||||
CharacterSet _notTextEndCharactersChoice;
|
||||
CharacterSet _notTextEndCharactersString;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8c355c8ca4318ff4fa96da22c908f550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
206
Assets/Plugins/Ink/compiler/InkParser/InkParser_Divert.cs
Normal file
206
Assets/Plugins/Ink/compiler/InkParser/InkParser_Divert.cs
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
using System.Collections.Generic;
|
||||
using Ink.Parsed;
|
||||
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected List<Parsed.Object> MultiDivert()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
List<Parsed.Object> diverts = null;
|
||||
|
||||
// Try single thread first
|
||||
var threadDivert = Parse(StartThread);
|
||||
if (threadDivert) {
|
||||
diverts = new List<Object> ();
|
||||
diverts.Add (threadDivert);
|
||||
return diverts;
|
||||
}
|
||||
|
||||
// Normal diverts and tunnels
|
||||
var arrowsAndDiverts = Interleave<object> (
|
||||
ParseDivertArrowOrTunnelOnwards,
|
||||
DivertIdentifierWithArguments);
|
||||
|
||||
if (arrowsAndDiverts == null)
|
||||
return null;
|
||||
|
||||
diverts = new List<Parsed.Object> ();
|
||||
|
||||
// Possible patterns:
|
||||
// -> -- explicit gather
|
||||
// ->-> -- tunnel onwards
|
||||
// -> div -- normal divert
|
||||
// ->-> div -- tunnel onwards, followed by override divert
|
||||
// -> div -> -- normal tunnel
|
||||
// -> div ->-> -- tunnel then tunnel continue
|
||||
// -> div -> div -- tunnel then divert
|
||||
// -> div -> div -> -- tunnel then tunnel
|
||||
// -> div -> div ->->
|
||||
// -> div -> div ->-> div (etc)
|
||||
|
||||
// Look at the arrows and diverts
|
||||
for (int i = 0; i < arrowsAndDiverts.Count; ++i) {
|
||||
bool isArrow = (i % 2) == 0;
|
||||
|
||||
// Arrow string
|
||||
if (isArrow) {
|
||||
|
||||
// Tunnel onwards
|
||||
if ((string)arrowsAndDiverts [i] == "->->") {
|
||||
|
||||
bool tunnelOnwardsPlacementValid = (i == 0 || i == arrowsAndDiverts.Count - 1 || i == arrowsAndDiverts.Count - 2);
|
||||
if (!tunnelOnwardsPlacementValid)
|
||||
Error ("Tunnel onwards '->->' must only come at the begining or the start of a divert");
|
||||
|
||||
var tunnelOnwards = new TunnelOnwards ();
|
||||
if (i < arrowsAndDiverts.Count - 1) {
|
||||
var tunnelOnwardDivert = arrowsAndDiverts [i+1] as Parsed.Divert;
|
||||
tunnelOnwards.divertAfter = tunnelOnwardDivert;
|
||||
}
|
||||
|
||||
diverts.Add (tunnelOnwards);
|
||||
|
||||
// Not allowed to do anything after a tunnel onwards.
|
||||
// If we had anything left it would be caused in the above Error for
|
||||
// the positioning of a ->->
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Divert
|
||||
else {
|
||||
|
||||
var divert = arrowsAndDiverts [i] as Divert;
|
||||
|
||||
// More to come? (further arrows) Must be tunnelling.
|
||||
if (i < arrowsAndDiverts.Count - 1) {
|
||||
divert.isTunnel = true;
|
||||
}
|
||||
|
||||
diverts.Add (divert);
|
||||
}
|
||||
}
|
||||
|
||||
// Single -> (used for default choices)
|
||||
if (diverts.Count == 0 && arrowsAndDiverts.Count == 1) {
|
||||
var gatherDivert = new Divert ((Parsed.Object)null);
|
||||
gatherDivert.isEmpty = true;
|
||||
diverts.Add (gatherDivert);
|
||||
|
||||
if (!_parsingChoice)
|
||||
Error ("Empty diverts (->) are only valid on choices");
|
||||
}
|
||||
|
||||
return diverts;
|
||||
}
|
||||
|
||||
protected Divert StartThread()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseThreadArrow() == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var divert = Expect(DivertIdentifierWithArguments, "target for new thread", () => new Divert(null)) as Divert;
|
||||
divert.isThread = true;
|
||||
|
||||
return divert;
|
||||
}
|
||||
|
||||
protected Divert DivertIdentifierWithArguments()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
List<Identifier> targetComponents = Parse (DotSeparatedDivertPathComponents);
|
||||
if (targetComponents == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var optionalArguments = Parse(ExpressionFunctionCallArguments);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var targetPath = new Path (targetComponents);
|
||||
return new Divert (targetPath, optionalArguments);
|
||||
}
|
||||
|
||||
protected Divert SingleDivert()
|
||||
{
|
||||
var diverts = Parse (MultiDivert);
|
||||
if (diverts == null)
|
||||
return null;
|
||||
|
||||
// Ideally we'd report errors if we get the
|
||||
// wrong kind of divert, but unfortunately we
|
||||
// have to hack around the fact that sequences use
|
||||
// a very similar syntax.
|
||||
// i.e. if you have a multi-divert at the start
|
||||
// of a sequence, it initially tries to parse it
|
||||
// as a divert target (part of an expression of
|
||||
// a conditional) and gives errors. So instead
|
||||
// we just have to blindly reject it as a single
|
||||
// divert, and give a slightly less nice error
|
||||
// when you DO use a multi divert as a divert taret.
|
||||
|
||||
if (diverts.Count != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var singleDivert = diverts [0];
|
||||
if (singleDivert is TunnelOnwards) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var divert = diverts [0] as Divert;
|
||||
if (divert.isTunnel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return divert;
|
||||
}
|
||||
|
||||
List<Identifier> DotSeparatedDivertPathComponents()
|
||||
{
|
||||
return Interleave<Identifier> (Spaced (IdentifierWithMetadata), Exclude (String (".")));
|
||||
}
|
||||
|
||||
protected string ParseDivertArrowOrTunnelOnwards()
|
||||
{
|
||||
int numArrows = 0;
|
||||
while (ParseString ("->") != null)
|
||||
numArrows++;
|
||||
|
||||
if (numArrows == 0)
|
||||
return null;
|
||||
|
||||
else if (numArrows == 1)
|
||||
return "->";
|
||||
|
||||
else if (numArrows == 2)
|
||||
return "->->";
|
||||
|
||||
else {
|
||||
Error ("Unexpected number of arrows in divert. Should only have '->' or '->->'");
|
||||
return "->->";
|
||||
}
|
||||
}
|
||||
|
||||
protected string ParseDivertArrow()
|
||||
{
|
||||
return ParseString ("->");
|
||||
}
|
||||
|
||||
protected string ParseThreadArrow()
|
||||
{
|
||||
return ParseString ("<-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f10858a666e02754ca88946ef07d2cff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
512
Assets/Plugins/Ink/compiler/InkParser/InkParser_Expressions.cs
Normal file
512
Assets/Plugins/Ink/compiler/InkParser/InkParser_Expressions.cs
Normal file
|
|
@ -0,0 +1,512 @@
|
|||
using System;
|
||||
using Ink.Parsed;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected class InfixOperator
|
||||
{
|
||||
public string type;
|
||||
public int precedence;
|
||||
public bool requireWhitespace;
|
||||
|
||||
public InfixOperator(string type, int precedence, bool requireWhitespace) {
|
||||
this.type = type;
|
||||
this.precedence = precedence;
|
||||
this.requireWhitespace = requireWhitespace;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
protected Parsed.Object TempDeclarationOrAssignment()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
bool isNewDeclaration = ParseTempKeyword();
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Identifier varIdentifier = null;
|
||||
if (isNewDeclaration) {
|
||||
varIdentifier = (Identifier)Expect (IdentifierWithMetadata, "variable name");
|
||||
} else {
|
||||
varIdentifier = Parse(IdentifierWithMetadata);
|
||||
}
|
||||
|
||||
if (varIdentifier == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace();
|
||||
|
||||
// += -=
|
||||
bool isIncrement = ParseString ("+") != null;
|
||||
bool isDecrement = ParseString ("-") != null;
|
||||
if (isIncrement && isDecrement) Error ("Unexpected sequence '+-'");
|
||||
|
||||
if (ParseString ("=") == null) {
|
||||
// Definitely in an assignment expression?
|
||||
if (isNewDeclaration) Error ("Expected '='");
|
||||
return null;
|
||||
}
|
||||
|
||||
Expression assignedExpression = (Expression)Expect (Expression, "value expression to be assigned");
|
||||
|
||||
if (isIncrement || isDecrement) {
|
||||
var result = new IncDecExpression (varIdentifier, assignedExpression, isIncrement);
|
||||
return result;
|
||||
} else {
|
||||
var result = new VariableAssignment (varIdentifier, assignedExpression);
|
||||
result.isNewTemporaryDeclaration = isNewDeclaration;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DisallowIncrement (Parsed.Object expr)
|
||||
{
|
||||
if (expr is Parsed.IncDecExpression)
|
||||
Error ("Can't use increment/decrement here. It can only be used on a ~ line");
|
||||
}
|
||||
|
||||
protected bool ParseTempKeyword()
|
||||
{
|
||||
var ruleId = BeginRule ();
|
||||
|
||||
if (Parse (Identifier) == "temp") {
|
||||
SucceedRule (ruleId);
|
||||
return true;
|
||||
} else {
|
||||
FailRule (ruleId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected Parsed.Return ReturnStatement()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var returnOrDone = Parse(Identifier);
|
||||
if (returnOrDone != "return") {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var expr = Parse(Expression);
|
||||
|
||||
var returnObj = new Return (expr);
|
||||
return returnObj;
|
||||
}
|
||||
|
||||
protected Expression Expression() {
|
||||
return Expression(minimumPrecedence:0);
|
||||
}
|
||||
|
||||
// Pratt Parser
|
||||
// aka "Top down operator precedence parser"
|
||||
// http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
|
||||
// Algorithm overview:
|
||||
// The two types of precedence are handled in two different ways:
|
||||
// ((((a . b) . c) . d) . e) #1
|
||||
// (a . (b . (c . (d . e)))) #2
|
||||
// Where #1 is automatically handled by successive loops within the main 'while' in this function,
|
||||
// so long as continuing operators have lower (or equal) precedence (e.g. imagine some series of "*"s then "+" above.
|
||||
// ...and #2 is handled by recursion of the right hand term in the binary expression parser.
|
||||
// (see link for advice on how to extend for postfix and mixfix operators)
|
||||
protected Expression Expression(int minimumPrecedence)
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// First parse a unary expression e.g. "-a" or parethensised "(1 + 2)"
|
||||
var expr = ExpressionUnary ();
|
||||
if (expr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Attempt to parse (possibly multiple) continuing infix expressions (e.g. 1 + 2 + 3)
|
||||
while(true) {
|
||||
var ruleId = BeginRule ();
|
||||
|
||||
// Operator
|
||||
var infixOp = ParseInfixOperator ();
|
||||
if (infixOp != null && infixOp.precedence > minimumPrecedence) {
|
||||
|
||||
// Expect right hand side of operator
|
||||
var expectationMessage = string.Format("right side of '{0}' expression", infixOp.type);
|
||||
var multiaryExpr = Expect (() => ExpressionInfixRight (left: expr, op: infixOp), expectationMessage);
|
||||
if (multiaryExpr == null) {
|
||||
|
||||
// Fail for operator and right-hand side of multiary expression
|
||||
FailRule (ruleId);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
expr = SucceedRule(ruleId, multiaryExpr) as Parsed.Expression;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
FailRule (ruleId);
|
||||
break;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
protected Expression ExpressionUnary()
|
||||
{
|
||||
// Divert target is a special case - it can't have any other operators
|
||||
// applied to it, and we also want to check for it first so that we don't
|
||||
// confuse "->" for subtraction.
|
||||
var divertTarget = Parse (ExpressionDivertTarget);
|
||||
if (divertTarget != null) {
|
||||
return divertTarget;
|
||||
}
|
||||
|
||||
var prefixOp = (string) OneOf (String ("-"), String ("!"));
|
||||
|
||||
// Don't parse like the string rules above, in case its actually
|
||||
// a variable that simply starts with "not", e.g. "notable".
|
||||
// This rule uses the Identifier rule, which will scan as much text
|
||||
// as possible before returning.
|
||||
if (prefixOp == null) {
|
||||
prefixOp = Parse(ExpressionNot);
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// - Since we allow numbers at the start of variable names, variable names are checked before literals
|
||||
// - Function calls before variable names in case we see parentheses
|
||||
var expr = OneOf (ExpressionList, ExpressionParen, ExpressionFunctionCall, ExpressionVariableName, ExpressionLiteral) as Expression;
|
||||
|
||||
// Only recurse immediately if we have one of the (usually optional) unary ops
|
||||
if (expr == null && prefixOp != null) {
|
||||
expr = ExpressionUnary ();
|
||||
}
|
||||
|
||||
if (expr == null)
|
||||
return null;
|
||||
|
||||
if (prefixOp != null) {
|
||||
expr = UnaryExpression.WithInner(expr, prefixOp);
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var postfixOp = (string) OneOf (String ("++"), String ("--"));
|
||||
if (postfixOp != null) {
|
||||
bool isInc = postfixOp == "++";
|
||||
|
||||
if (!(expr is VariableReference)) {
|
||||
Error ("can only increment and decrement variables, but saw '" + expr + "'");
|
||||
|
||||
// Drop down and succeed without the increment after reporting error
|
||||
} else {
|
||||
// TODO: Language Server - (Identifier combined into one vs. list of Identifiers)
|
||||
var varRef = (VariableReference)expr;
|
||||
expr = new IncDecExpression(varRef.identifier, isInc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
protected string ExpressionNot()
|
||||
{
|
||||
var id = Identifier ();
|
||||
if (id == "not") {
|
||||
return id;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Expression ExpressionLiteral()
|
||||
{
|
||||
return (Expression) OneOf (ExpressionFloat, ExpressionInt, ExpressionBool, ExpressionString);
|
||||
}
|
||||
|
||||
protected Expression ExpressionDivertTarget()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var divert = Parse(SingleDivert);
|
||||
if (divert == null)
|
||||
return null;
|
||||
|
||||
if (divert.isThread)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
return new DivertTarget (divert);
|
||||
}
|
||||
|
||||
protected Number ExpressionInt()
|
||||
{
|
||||
int? intOrNull = ParseInt ();
|
||||
if (intOrNull == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Number (intOrNull.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected Number ExpressionFloat()
|
||||
{
|
||||
float? floatOrNull = ParseFloat ();
|
||||
if (floatOrNull == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Number (floatOrNull.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected StringExpression ExpressionString()
|
||||
{
|
||||
var openQuote = ParseString ("\"");
|
||||
if (openQuote == null)
|
||||
return null;
|
||||
|
||||
// Set custom parser state flag so that within the text parser,
|
||||
// it knows to treat the quote character (") as an end character
|
||||
parsingStringExpression = true;
|
||||
|
||||
List<Parsed.Object> textAndLogic = Parse (MixedTextAndLogic);
|
||||
|
||||
Expect (String ("\""), "close quote for string expression");
|
||||
|
||||
parsingStringExpression = false;
|
||||
|
||||
if (textAndLogic == null) {
|
||||
textAndLogic = new List<Ink.Parsed.Object> ();
|
||||
textAndLogic.Add (new Parsed.Text (""));
|
||||
}
|
||||
|
||||
else if (textAndLogic.Exists (c => c is Divert))
|
||||
Error ("String expressions cannot contain diverts (->)");
|
||||
|
||||
return new StringExpression (textAndLogic);
|
||||
}
|
||||
|
||||
protected Number ExpressionBool()
|
||||
{
|
||||
var id = Parse(Identifier);
|
||||
if (id == "true") {
|
||||
return new Number (true);
|
||||
} else if (id == "false") {
|
||||
return new Number (false);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Expression ExpressionFunctionCall()
|
||||
{
|
||||
var iden = Parse(IdentifierWithMetadata);
|
||||
if (iden == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var arguments = Parse(ExpressionFunctionCallArguments);
|
||||
if (arguments == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FunctionCall(iden, arguments);
|
||||
}
|
||||
|
||||
protected List<Expression> ExpressionFunctionCallArguments()
|
||||
{
|
||||
if (ParseString ("(") == null)
|
||||
return null;
|
||||
|
||||
// "Exclude" requires the rule to succeed, but causes actual comma string to be excluded from the list of results
|
||||
ParseRule commas = Exclude (String (","));
|
||||
var arguments = Interleave<Expression>(Expression, commas);
|
||||
if (arguments == null) {
|
||||
arguments = new List<Expression> ();
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String (")"), "closing ')' for function call");
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
protected Expression ExpressionVariableName()
|
||||
{
|
||||
List<Identifier> path = Interleave<Identifier> (IdentifierWithMetadata, Exclude (Spaced (String ("."))));
|
||||
|
||||
if (path == null || Story.IsReservedKeyword (path[0].name) )
|
||||
return null;
|
||||
|
||||
return new VariableReference (path);
|
||||
}
|
||||
|
||||
protected Expression ExpressionParen()
|
||||
{
|
||||
if (ParseString ("(") == null)
|
||||
return null;
|
||||
|
||||
var innerExpr = Parse(Expression);
|
||||
if (innerExpr == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String(")"), "closing parenthesis ')' for expression");
|
||||
|
||||
return innerExpr;
|
||||
}
|
||||
|
||||
protected Expression ExpressionInfixRight(Parsed.Expression left, InfixOperator op)
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var right = Parse(() => Expression (op.precedence));
|
||||
if (right) {
|
||||
|
||||
// We assume that the character we use for the operator's type is the same
|
||||
// as that used internally by e.g. Runtime.Expression.Add, Runtime.Expression.Multiply etc
|
||||
var expr = new BinaryExpression (left, right, op.type);
|
||||
return expr;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private InfixOperator ParseInfixOperator()
|
||||
{
|
||||
foreach (var op in _binaryOperators) {
|
||||
|
||||
int ruleId = BeginRule ();
|
||||
|
||||
if (ParseString (op.type) != null) {
|
||||
|
||||
if (op.requireWhitespace) {
|
||||
if (Whitespace () == null) {
|
||||
FailRule (ruleId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return (InfixOperator) SucceedRule(ruleId, op);
|
||||
}
|
||||
|
||||
FailRule (ruleId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Parsed.List ExpressionList ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("(") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// When list has:
|
||||
// - 0 elements (null list) - this is okay, it's an empty list: "()"
|
||||
// - 1 element - it could be confused for a single non-list related
|
||||
// identifier expression in brackets, but this is a useless thing
|
||||
// to do, so we reserve that syntax for a list with one item.
|
||||
// - 2 or more elements - normal!
|
||||
List<Identifier> memberNames = SeparatedList (ListMember, Spaced (String (",")));
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// May have failed to parse the inner list - the parentheses may
|
||||
// be for a normal expression
|
||||
if (ParseString (")") == null)
|
||||
return null;
|
||||
|
||||
return new List (memberNames);
|
||||
}
|
||||
|
||||
protected Identifier ListMember ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
Identifier identifier = Parse (IdentifierWithMetadata);
|
||||
if (identifier == null)
|
||||
return null;
|
||||
|
||||
var dot = ParseString (".");
|
||||
if (dot != null) {
|
||||
Identifier identifier2 = Expect (IdentifierWithMetadata, "element name within the set " + identifier) as Identifier;
|
||||
identifier.name = identifier.name + "." + identifier2?.name;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
void RegisterExpressionOperators()
|
||||
{
|
||||
_maxBinaryOpLength = 0;
|
||||
_binaryOperators = new List<InfixOperator> ();
|
||||
|
||||
// These will be tried in order, so we need "<=" before "<"
|
||||
// for correctness
|
||||
|
||||
RegisterBinaryOperator ("&&", precedence:1);
|
||||
RegisterBinaryOperator ("||", precedence:1);
|
||||
RegisterBinaryOperator ("and", precedence:1, requireWhitespace: true);
|
||||
RegisterBinaryOperator ("or", precedence:1, requireWhitespace: true);
|
||||
|
||||
RegisterBinaryOperator ("==", precedence:2);
|
||||
RegisterBinaryOperator (">=", precedence:2);
|
||||
RegisterBinaryOperator ("<=", precedence:2);
|
||||
RegisterBinaryOperator ("<", precedence:2);
|
||||
RegisterBinaryOperator (">", precedence:2);
|
||||
RegisterBinaryOperator ("!=", precedence:2);
|
||||
|
||||
// (apples, oranges) + cabbages has (oranges, cabbages) == true
|
||||
RegisterBinaryOperator ("?", precedence: 3);
|
||||
RegisterBinaryOperator ("has", precedence: 3, requireWhitespace:true);
|
||||
RegisterBinaryOperator ("!?", precedence: 3);
|
||||
RegisterBinaryOperator ("hasnt", precedence: 3, requireWhitespace: true);
|
||||
RegisterBinaryOperator ("^", precedence: 3);
|
||||
|
||||
RegisterBinaryOperator ("+", precedence:4);
|
||||
RegisterBinaryOperator ("-", precedence:5);
|
||||
RegisterBinaryOperator ("*", precedence:6);
|
||||
RegisterBinaryOperator ("/", precedence:7);
|
||||
|
||||
RegisterBinaryOperator ("%", precedence:8);
|
||||
RegisterBinaryOperator ("mod", precedence:8, requireWhitespace:true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RegisterBinaryOperator(string op, int precedence, bool requireWhitespace = false)
|
||||
{
|
||||
_binaryOperators.Add(new InfixOperator (op, precedence, requireWhitespace));
|
||||
_maxBinaryOpLength = Math.Max (_maxBinaryOpLength, op.Length);
|
||||
}
|
||||
|
||||
List<InfixOperator> _binaryOperators;
|
||||
int _maxBinaryOpLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57a5e7edd2434bf45ae5f950d471bf1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
76
Assets/Plugins/Ink/compiler/InkParser/InkParser_Include.cs
Normal file
76
Assets/Plugins/Ink/compiler/InkParser/InkParser_Include.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using Ink.Parsed;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected object IncludeStatement()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("INCLUDE") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var filename = (string) Expect(() => ParseUntilCharactersFromString ("\n\r"), "filename for include statement");
|
||||
filename = filename.TrimEnd (' ', '\t');
|
||||
|
||||
// Working directory should already have been set up relative to the root ink file.
|
||||
var fullFilename = _rootParser._fileHandler.ResolveInkFilename (filename);
|
||||
|
||||
if (FilenameIsAlreadyOpen (fullFilename)) {
|
||||
Error ("Recursive INCLUDE detected: '" + fullFilename + "' is already open.");
|
||||
ParseUntilCharactersFromString("\r\n");
|
||||
return new IncludedFile(null);
|
||||
} else {
|
||||
AddOpenFilename (fullFilename);
|
||||
}
|
||||
|
||||
Parsed.Story includedStory = null;
|
||||
string includedString = null;
|
||||
try {
|
||||
includedString = _rootParser._fileHandler.LoadInkFileContents(fullFilename);
|
||||
}
|
||||
catch {
|
||||
Error ("Failed to load: '"+filename+"'");
|
||||
}
|
||||
|
||||
|
||||
if (includedString != null ) {
|
||||
InkParser parser = new InkParser(includedString, filename, _externalErrorHandler, _rootParser);
|
||||
includedStory = parser.Parse();
|
||||
}
|
||||
|
||||
RemoveOpenFilename (fullFilename);
|
||||
|
||||
// Return valid IncludedFile object even if there were errors when parsing.
|
||||
// We don't want to attempt to re-parse the include line as something else,
|
||||
// and we want to include the bits that *are* valid, so we don't generate
|
||||
// more errors than necessary.
|
||||
return new IncludedFile (includedStory);
|
||||
}
|
||||
|
||||
bool FilenameIsAlreadyOpen(string fullFilename)
|
||||
{
|
||||
return _rootParser._openFilenames.Contains (fullFilename);
|
||||
}
|
||||
|
||||
void AddOpenFilename(string fullFilename)
|
||||
{
|
||||
_rootParser._openFilenames.Add (fullFilename);
|
||||
}
|
||||
|
||||
void RemoveOpenFilename(string fullFilename)
|
||||
{
|
||||
_rootParser._openFilenames.Remove (fullFilename);
|
||||
}
|
||||
|
||||
InkParser _rootParser;
|
||||
HashSet<string> _openFilenames;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0dfaba88b95d3704da16224671e24fdf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
239
Assets/Plugins/Ink/compiler/InkParser/InkParser_Knot.cs
Normal file
239
Assets/Plugins/Ink/compiler/InkParser/InkParser_Knot.cs
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
using System.Collections.Generic;
|
||||
using Ink.Parsed;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected class NameWithMetadata {
|
||||
public string name;
|
||||
public Runtime.DebugMetadata metadata;
|
||||
}
|
||||
|
||||
protected class FlowDecl
|
||||
{
|
||||
public Identifier name;
|
||||
public List<FlowBase.Argument> arguments;
|
||||
public bool isFunction;
|
||||
}
|
||||
|
||||
protected Knot KnotDefinition()
|
||||
{
|
||||
var knotDecl = Parse(KnotDeclaration);
|
||||
if (knotDecl == null)
|
||||
return null;
|
||||
|
||||
Expect(EndOfLine, "end of line after knot name definition", recoveryRule: SkipToNextLine);
|
||||
|
||||
ParseRule innerKnotStatements = () => StatementsAtLevel (StatementLevel.Knot);
|
||||
|
||||
var content = Expect (innerKnotStatements, "at least one line within the knot", recoveryRule: KnotStitchNoContentRecoveryRule) as List<Parsed.Object>;
|
||||
|
||||
return new Knot (knotDecl.name, content, knotDecl.arguments, knotDecl.isFunction);
|
||||
}
|
||||
|
||||
protected FlowDecl KnotDeclaration()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (KnotTitleEquals () == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
|
||||
Identifier identifier = Parse(IdentifierWithMetadata);
|
||||
Identifier knotName;
|
||||
|
||||
bool isFunc = identifier?.name == "function";
|
||||
if (isFunc) {
|
||||
Expect (Whitespace, "whitespace after the 'function' keyword");
|
||||
knotName = Parse(IdentifierWithMetadata);
|
||||
} else {
|
||||
knotName = identifier;
|
||||
}
|
||||
|
||||
if (knotName == null) {
|
||||
Error ("Expected the name of the " + (isFunc ? "function" : "knot"));
|
||||
knotName = new Identifier { name = "" }; // prevent later null ref
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
List<FlowBase.Argument> parameterNames = Parse (BracketedKnotDeclArguments);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Optional equals after name
|
||||
Parse(KnotTitleEquals);
|
||||
|
||||
return new FlowDecl () { name = knotName, arguments = parameterNames, isFunction = isFunc };
|
||||
}
|
||||
|
||||
protected string KnotTitleEquals()
|
||||
{
|
||||
// 2+ "=" starts a knot
|
||||
var multiEquals = ParseCharactersFromString ("=");
|
||||
if (multiEquals == null || multiEquals.Length <= 1) {
|
||||
return null;
|
||||
} else {
|
||||
return multiEquals;
|
||||
}
|
||||
}
|
||||
|
||||
protected object StitchDefinition()
|
||||
{
|
||||
var decl = Parse(StitchDeclaration);
|
||||
if (decl == null)
|
||||
return null;
|
||||
|
||||
Expect(EndOfLine, "end of line after stitch name", recoveryRule: SkipToNextLine);
|
||||
|
||||
ParseRule innerStitchStatements = () => StatementsAtLevel (StatementLevel.Stitch);
|
||||
|
||||
var content = Expect(innerStitchStatements, "at least one line within the stitch", recoveryRule: KnotStitchNoContentRecoveryRule) as List<Parsed.Object>;
|
||||
|
||||
return new Stitch (decl.name, content, decl.arguments, decl.isFunction );
|
||||
}
|
||||
|
||||
protected FlowDecl StitchDeclaration()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// Single "=" to define a stitch
|
||||
if (ParseString ("=") == null)
|
||||
return null;
|
||||
|
||||
// If there's more than one "=", that's actually a knot definition (or divert), so this rule should fail
|
||||
if (ParseString ("=") != null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Stitches aren't allowed to be functions, but we parse it anyway and report the error later
|
||||
bool isFunc = ParseString ("function") != null;
|
||||
if ( isFunc ) {
|
||||
Whitespace ();
|
||||
}
|
||||
|
||||
Identifier stitchName = Parse(IdentifierWithMetadata);
|
||||
if (stitchName == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
List<FlowBase.Argument> flowArgs = Parse(BracketedKnotDeclArguments);
|
||||
|
||||
Whitespace ();
|
||||
|
||||
return new FlowDecl () { name = stitchName, arguments = flowArgs, isFunction = isFunc };
|
||||
}
|
||||
|
||||
|
||||
protected object KnotStitchNoContentRecoveryRule()
|
||||
{
|
||||
// Jump ahead to the next knot or the end of the file
|
||||
ParseUntil (KnotDeclaration, new CharacterSet ("="), null);
|
||||
|
||||
var recoveredFlowContent = new List<Parsed.Object>();
|
||||
recoveredFlowContent.Add( new Parsed.Text("<ERROR IN FLOW>" ) );
|
||||
return recoveredFlowContent;
|
||||
}
|
||||
|
||||
protected List<FlowBase.Argument> BracketedKnotDeclArguments()
|
||||
{
|
||||
if (ParseString ("(") == null)
|
||||
return null;
|
||||
|
||||
var flowArguments = Interleave<FlowBase.Argument>(Spaced(FlowDeclArgument), Exclude (String(",")));
|
||||
|
||||
Expect (String (")"), "closing ')' for parameter list");
|
||||
|
||||
// If no parameters, create an empty list so that this method is type safe and
|
||||
// doesn't attempt to return the ParseSuccess object
|
||||
if (flowArguments == null) {
|
||||
flowArguments = new List<FlowBase.Argument> ();
|
||||
}
|
||||
|
||||
return flowArguments;
|
||||
}
|
||||
|
||||
protected FlowBase.Argument FlowDeclArgument()
|
||||
{
|
||||
// Possible forms:
|
||||
// name
|
||||
// -> name (variable divert target argument
|
||||
// ref name
|
||||
// ref -> name (variable divert target by reference)
|
||||
var firstIden = Parse(IdentifierWithMetadata);
|
||||
Whitespace ();
|
||||
var divertArrow = ParseDivertArrow ();
|
||||
Whitespace ();
|
||||
var secondIden = Parse(IdentifierWithMetadata);
|
||||
|
||||
if (firstIden == null && secondIden == null)
|
||||
return null;
|
||||
|
||||
|
||||
var flowArg = new FlowBase.Argument ();
|
||||
if (divertArrow != null) {
|
||||
flowArg.isDivertTarget = true;
|
||||
}
|
||||
|
||||
// Passing by reference
|
||||
if (firstIden != null && firstIden.name == "ref") {
|
||||
|
||||
if (secondIden == null) {
|
||||
Error ("Expected an parameter name after 'ref'");
|
||||
}
|
||||
|
||||
flowArg.identifier = secondIden;
|
||||
flowArg.isByReference = true;
|
||||
}
|
||||
|
||||
// Simple argument name
|
||||
else {
|
||||
|
||||
if (flowArg.isDivertTarget) {
|
||||
flowArg.identifier = secondIden;
|
||||
} else {
|
||||
flowArg.identifier = firstIden;
|
||||
}
|
||||
|
||||
if (flowArg.identifier == null) {
|
||||
Error ("Expected an parameter name");
|
||||
}
|
||||
|
||||
flowArg.isByReference = false;
|
||||
}
|
||||
|
||||
return flowArg;
|
||||
}
|
||||
|
||||
protected ExternalDeclaration ExternalDeclaration()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
Identifier external = Parse(IdentifierWithMetadata);
|
||||
if (external == null || external.name != "EXTERNAL")
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var funcIdentifier = Expect(IdentifierWithMetadata, "name of external function") as Identifier ?? new Identifier();
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var parameterNames = Expect (BracketedKnotDeclArguments, "declaration of arguments for EXTERNAL, even if empty, i.e. 'EXTERNAL "+funcIdentifier+"()'") as List<FlowBase.Argument>;
|
||||
if (parameterNames == null)
|
||||
parameterNames = new List<FlowBase.Argument> ();
|
||||
|
||||
var argNames = parameterNames.Select (arg => arg.identifier?.name).ToList();
|
||||
|
||||
return new ExternalDeclaration (funcIdentifier, argNames);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Plugins/Ink/compiler/InkParser/InkParser_Knot.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/InkParser/InkParser_Knot.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f1cd2f87ba9fb344abd4140557a6b551
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
421
Assets/Plugins/Ink/compiler/InkParser/InkParser_Logic.cs
Normal file
421
Assets/Plugins/Ink/compiler/InkParser/InkParser_Logic.cs
Normal file
|
|
@ -0,0 +1,421 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Parsed;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
|
||||
protected Parsed.Object LogicLine()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("~") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
// Some example lines we need to be able to distinguish between:
|
||||
// ~ temp x = 5 -- var decl + assign
|
||||
// ~ temp x -- var decl
|
||||
// ~ x = 5 -- var assign
|
||||
// ~ x -- expr (not var decl or assign)
|
||||
// ~ f() -- expr
|
||||
// We don't treat variable decl/assign as an expression since we don't want an assignment
|
||||
// to have a return value, or to be used in compound expressions.
|
||||
ParseRule afterTilda = () => OneOf (ReturnStatement, TempDeclarationOrAssignment, Expression);
|
||||
|
||||
var result = Expect(afterTilda, "expression after '~'", recoveryRule: SkipToNextLine) as Parsed.Object;
|
||||
|
||||
// Prevent further errors, already reported expected expression and have skipped to next line.
|
||||
if (result == null) return new ContentList();
|
||||
|
||||
// Parse all expressions, but tell the writer off if they did something useless like:
|
||||
// ~ 5 + 4
|
||||
// And even:
|
||||
// ~ false && myFunction()
|
||||
// ...since it's bad practice, and won't do what they expect if
|
||||
// they're expecting C's lazy evaluation.
|
||||
if (result is Expression && !(result is FunctionCall || result is IncDecExpression) ) {
|
||||
|
||||
// TODO: Remove this specific error message when it has expired in usefulness
|
||||
var varRef = result as VariableReference;
|
||||
if (varRef && varRef.name == "include") {
|
||||
Error ("'~ include' is no longer the correct syntax - please use 'INCLUDE your_filename.ink', without the tilda, and in block capitals.");
|
||||
}
|
||||
|
||||
else {
|
||||
Error ("Logic following a '~' can't be that type of expression. It can only be something like:\n\t~ return\n\t~ var x = blah\n\t~ x++\n\t~ myFunction()");
|
||||
}
|
||||
}
|
||||
|
||||
// Line is pure function call? e.g.
|
||||
// ~ f()
|
||||
// Add extra pop to make sure we tidy up after ourselves.
|
||||
// We no longer need anything on the evaluation stack.
|
||||
var funCall = result as FunctionCall;
|
||||
if (funCall) funCall.shouldPopReturnedValue = true;
|
||||
|
||||
// If the expression contains a function call, then it could produce a text side effect,
|
||||
// in which case it needs a newline on the end. e.g.
|
||||
// ~ printMyName()
|
||||
// ~ x = 1 + returnAValueAndAlsoPrintStuff()
|
||||
// If no text gets printed, then the extra newline will have to be culled later.
|
||||
// Multiple newlines on the output will be removed, so there will be no "leak" for
|
||||
// long running calculations. It's disappointingly messy though :-/
|
||||
if (result.Find<FunctionCall>() != null ) {
|
||||
result = new ContentList (result, new Parsed.Text ("\n"));
|
||||
}
|
||||
|
||||
Expect(EndOfLine, "end of line", recoveryRule: SkipToNextLine);
|
||||
|
||||
return result as Parsed.Object;
|
||||
}
|
||||
|
||||
protected Parsed.Object VariableDeclaration()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var id = Parse (Identifier);
|
||||
if (id != "VAR")
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var varName = Expect (IdentifierWithMetadata, "variable name") as Identifier;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String ("="), "the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)");
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var definition = Expect (Expression, "initial value for ");
|
||||
|
||||
var expr = definition as Parsed.Expression;
|
||||
|
||||
if (expr) {
|
||||
if (!(expr is Number || expr is StringExpression || expr is DivertTarget || expr is VariableReference || expr is List)) {
|
||||
Error ("initial value for a variable must be a number, constant, list or divert target");
|
||||
}
|
||||
|
||||
if (Parse (ListElementDefinitionSeparator) != null)
|
||||
Error ("Unexpected ','. If you're trying to declare a new list, use the LIST keyword, not VAR");
|
||||
|
||||
// Ensure string expressions are simple
|
||||
else if (expr is StringExpression) {
|
||||
var strExpr = expr as StringExpression;
|
||||
if (!strExpr.isSingleString)
|
||||
Error ("Constant strings cannot contain any logic.");
|
||||
}
|
||||
|
||||
var result = new VariableAssignment (varName, expr);
|
||||
result.isGlobalDeclaration = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Parsed.VariableAssignment ListDeclaration ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var id = Parse (Identifier);
|
||||
if (id != "LIST")
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var varName = Expect (IdentifierWithMetadata, "list name") as Identifier;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String ("="), "the '=' for an assignment of the list definition");
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var definition = Expect (ListDefinition, "list item names") as ListDefinition;
|
||||
|
||||
if (definition) {
|
||||
|
||||
definition.identifier = varName;
|
||||
|
||||
return new VariableAssignment (varName, definition);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Parsed.ListDefinition ListDefinition ()
|
||||
{
|
||||
AnyWhitespace ();
|
||||
|
||||
var allElements = SeparatedList (ListElementDefinition, ListElementDefinitionSeparator);
|
||||
if (allElements == null)
|
||||
return null;
|
||||
|
||||
return new ListDefinition (allElements);
|
||||
}
|
||||
|
||||
protected string ListElementDefinitionSeparator ()
|
||||
{
|
||||
AnyWhitespace ();
|
||||
|
||||
if (ParseString (",") == null) return null;
|
||||
|
||||
AnyWhitespace ();
|
||||
|
||||
return ",";
|
||||
}
|
||||
|
||||
protected Parsed.ListElementDefinition ListElementDefinition ()
|
||||
{
|
||||
var inInitialList = ParseString ("(") != null;
|
||||
var needsToCloseParen = inInitialList;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var name = Parse (IdentifierWithMetadata);
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
if (inInitialList) {
|
||||
if (ParseString (")") != null) {
|
||||
needsToCloseParen = false;
|
||||
Whitespace ();
|
||||
}
|
||||
}
|
||||
|
||||
int? elementValue = null;
|
||||
if (ParseString ("=") != null) {
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var elementValueNum = Expect (ExpressionInt, "value to be assigned to list item") as Number;
|
||||
if (elementValueNum != null) {
|
||||
elementValue = (int) elementValueNum.value;
|
||||
}
|
||||
|
||||
if (needsToCloseParen) {
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString (")") != null)
|
||||
needsToCloseParen = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (needsToCloseParen)
|
||||
Error("Expected closing ')'");
|
||||
|
||||
return new ListElementDefinition (name, inInitialList, elementValue);
|
||||
}
|
||||
|
||||
protected Parsed.Object ConstDeclaration()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
var id = Parse (Identifier);
|
||||
if (id != "CONST")
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var varName = Expect (IdentifierWithMetadata, "constant name") as Identifier;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String ("="), "the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)");
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var expr = Expect (Expression, "initial value for ") as Parsed.Expression;
|
||||
if (!(expr is Number || expr is DivertTarget || expr is StringExpression)) {
|
||||
Error ("initial value for a constant must be a number or divert target");
|
||||
}
|
||||
|
||||
// Ensure string expressions are simple
|
||||
else if (expr is StringExpression) {
|
||||
var strExpr = expr as StringExpression;
|
||||
if (!strExpr.isSingleString)
|
||||
Error ("Constant strings cannot contain any logic.");
|
||||
}
|
||||
|
||||
|
||||
var result = new ConstantDeclaration (varName, expr);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Parsed.Object InlineLogicOrGlue()
|
||||
{
|
||||
return (Parsed.Object) OneOf (InlineLogic, Glue);
|
||||
}
|
||||
|
||||
protected Parsed.Glue Glue()
|
||||
{
|
||||
// Don't want to parse whitespace, since it might be important
|
||||
// surrounding the glue.
|
||||
var glueStr = ParseString("<>");
|
||||
if (glueStr != null) {
|
||||
return new Parsed.Glue (new Runtime.Glue ());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected Parsed.Object InlineLogic()
|
||||
{
|
||||
if ( ParseString ("{") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var logic = (Parsed.Object) Expect(InnerLogic, "some kind of logic, conditional or sequence within braces: { ... }");
|
||||
if (logic == null)
|
||||
return null;
|
||||
|
||||
DisallowIncrement (logic);
|
||||
|
||||
ContentList contentList = logic as ContentList;
|
||||
if (!contentList) {
|
||||
contentList = new ContentList (logic);
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
Expect (String("}"), "closing brace '}' for inline logic");
|
||||
|
||||
return contentList;
|
||||
}
|
||||
|
||||
protected Parsed.Object InnerLogic()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// Explicitly try the combinations of inner logic
|
||||
// that could potentially have conflicts first.
|
||||
|
||||
// Explicit sequence annotation?
|
||||
SequenceType? explicitSeqType = (SequenceType?) ParseObject(SequenceTypeAnnotation);
|
||||
if (explicitSeqType != null) {
|
||||
var contentLists = (List<ContentList>) Expect(InnerSequenceObjects, "sequence elements (for cycle/stoping etc)");
|
||||
if (contentLists == null)
|
||||
return null;
|
||||
return new Sequence (contentLists, (SequenceType) explicitSeqType);
|
||||
}
|
||||
|
||||
// Conditional with expression?
|
||||
var initialQueryExpression = Parse(ConditionExpression);
|
||||
if (initialQueryExpression) {
|
||||
var conditional = (Conditional) Expect(() => InnerConditionalContent (initialQueryExpression), "conditional content following query");
|
||||
return conditional;
|
||||
}
|
||||
|
||||
// Now try to evaluate each of the "full" rules in turn
|
||||
ParseRule[] rules = {
|
||||
|
||||
// Conditional still necessary, since you can have a multi-line conditional
|
||||
// without an initial query expression:
|
||||
// {
|
||||
// - true: this is true
|
||||
// - false: this is false
|
||||
// }
|
||||
InnerConditionalContent,
|
||||
InnerSequence,
|
||||
InnerExpression,
|
||||
};
|
||||
|
||||
// Adapted from "OneOf" structuring rule except that in
|
||||
// order for the rule to succeed, it has to maximally
|
||||
// cover the entire string within the { }. Used to
|
||||
// differentiate between:
|
||||
// {myVar} -- Expression (try first)
|
||||
// {my content is jolly} -- sequence with single element
|
||||
foreach (ParseRule rule in rules) {
|
||||
int ruleId = BeginRule ();
|
||||
|
||||
Parsed.Object result = ParseObject(rule) as Parsed.Object;
|
||||
if (result) {
|
||||
|
||||
// Not yet at end?
|
||||
if (Peek (Spaced (String ("}"))) == null)
|
||||
FailRule (ruleId);
|
||||
|
||||
// Full parse of content within braces
|
||||
else
|
||||
return (Parsed.Object) SucceedRule (ruleId, result);
|
||||
|
||||
} else {
|
||||
FailRule (ruleId);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Parsed.Object InnerExpression()
|
||||
{
|
||||
var expr = Parse(Expression);
|
||||
if (expr) {
|
||||
expr.outputWhenComplete = true;
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
protected Identifier IdentifierWithMetadata()
|
||||
{
|
||||
var id = Identifier();
|
||||
if( id == null ) return null;
|
||||
|
||||
// InkParser.RuleDidSucceed will add DebugMetadata
|
||||
return new Identifier { name = id, debugMetadata = null };
|
||||
}
|
||||
|
||||
// Note: we allow identifiers that start with a number,
|
||||
// but not if they *only* comprise numbers
|
||||
protected string Identifier()
|
||||
{
|
||||
// Parse remaining characters (if any)
|
||||
var name = ParseCharactersFromCharSet (identifierCharSet);
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
// Reject if it's just a number
|
||||
bool isNumberCharsOnly = true;
|
||||
foreach (var c in name) {
|
||||
if ( !(c >= '0' && c <= '9') ) {
|
||||
isNumberCharsOnly = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isNumberCharsOnly) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
CharacterSet identifierCharSet {
|
||||
get {
|
||||
if (_identifierCharSet == null) {
|
||||
(_identifierCharSet = new CharacterSet ())
|
||||
.AddRange ('A', 'Z')
|
||||
.AddRange ('a', 'z')
|
||||
.AddRange ('0', '9')
|
||||
.Add ('_');
|
||||
// Enable non-ASCII characters for story identifiers.
|
||||
ExtendIdentifierCharacterRanges (_identifierCharSet);
|
||||
}
|
||||
return _identifierCharSet;
|
||||
}
|
||||
}
|
||||
|
||||
private CharacterSet _identifierCharSet;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ae50990c607b634e96436c994039bc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
231
Assets/Plugins/Ink/compiler/InkParser/InkParser_Sequences.cs
Normal file
231
Assets/Plugins/Ink/compiler/InkParser/InkParser_Sequences.cs
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Parsed;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected Sequence InnerSequence()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// Default sequence type
|
||||
SequenceType seqType = SequenceType.Stopping;
|
||||
|
||||
// Optional explicit sequence type
|
||||
SequenceType? parsedSeqType = (SequenceType?) Parse(SequenceTypeAnnotation);
|
||||
if (parsedSeqType != null)
|
||||
seqType = parsedSeqType.Value;
|
||||
|
||||
var contentLists = Parse(InnerSequenceObjects);
|
||||
if (contentLists == null || contentLists.Count <= 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Sequence (contentLists, seqType);
|
||||
}
|
||||
|
||||
protected object SequenceTypeAnnotation()
|
||||
{
|
||||
var annotation = (SequenceType?) Parse(SequenceTypeSymbolAnnotation);
|
||||
|
||||
if(annotation == null)
|
||||
annotation = (SequenceType?) Parse(SequenceTypeWordAnnotation);
|
||||
|
||||
if (annotation == null)
|
||||
return null;
|
||||
|
||||
switch (annotation.Value)
|
||||
{
|
||||
case SequenceType.Once:
|
||||
case SequenceType.Cycle:
|
||||
case SequenceType.Stopping:
|
||||
case SequenceType.Shuffle:
|
||||
case (SequenceType.Shuffle | SequenceType.Stopping):
|
||||
case (SequenceType.Shuffle | SequenceType.Once):
|
||||
break;
|
||||
|
||||
default:
|
||||
Error("Sequence type combination not supported: " + annotation.Value);
|
||||
return SequenceType.Stopping;
|
||||
}
|
||||
|
||||
return annotation;
|
||||
}
|
||||
|
||||
protected object SequenceTypeSymbolAnnotation()
|
||||
{
|
||||
if(_sequenceTypeSymbols == null )
|
||||
_sequenceTypeSymbols = new CharacterSet("!&~$ ");
|
||||
|
||||
var sequenceType = (SequenceType)0;
|
||||
var sequenceAnnotations = ParseCharactersFromCharSet(_sequenceTypeSymbols);
|
||||
if (sequenceAnnotations == null)
|
||||
return null;
|
||||
|
||||
foreach(char symbolChar in sequenceAnnotations) {
|
||||
switch(symbolChar) {
|
||||
case '!': sequenceType |= SequenceType.Once; break;
|
||||
case '&': sequenceType |= SequenceType.Cycle; break;
|
||||
case '~': sequenceType |= SequenceType.Shuffle; break;
|
||||
case '$': sequenceType |= SequenceType.Stopping; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sequenceType == (SequenceType)0)
|
||||
return null;
|
||||
|
||||
return sequenceType;
|
||||
}
|
||||
|
||||
CharacterSet _sequenceTypeSymbols = new CharacterSet("!&~$");
|
||||
|
||||
protected object SequenceTypeWordAnnotation()
|
||||
{
|
||||
var sequenceTypes = Interleave<SequenceType?>(SequenceTypeSingleWord, Exclude(Whitespace));
|
||||
if (sequenceTypes == null || sequenceTypes.Count == 0)
|
||||
return null;
|
||||
|
||||
if (ParseString (":") == null)
|
||||
return null;
|
||||
|
||||
var combinedSequenceType = (SequenceType)0;
|
||||
foreach(var seqType in sequenceTypes) {
|
||||
combinedSequenceType |= seqType.Value;
|
||||
}
|
||||
|
||||
return combinedSequenceType;
|
||||
}
|
||||
|
||||
protected object SequenceTypeSingleWord()
|
||||
{
|
||||
SequenceType? seqType = null;
|
||||
|
||||
var word = Parse(IdentifierWithMetadata);
|
||||
if (word != null)
|
||||
{
|
||||
switch (word.name)
|
||||
{
|
||||
case "once":
|
||||
seqType = SequenceType.Once;
|
||||
break;
|
||||
case "cycle":
|
||||
seqType = SequenceType.Cycle;
|
||||
break;
|
||||
case "shuffle":
|
||||
seqType = SequenceType.Shuffle;
|
||||
break;
|
||||
case "stopping":
|
||||
seqType = SequenceType.Stopping;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (seqType == null)
|
||||
return null;
|
||||
|
||||
return seqType;
|
||||
}
|
||||
|
||||
protected List<ContentList> InnerSequenceObjects()
|
||||
{
|
||||
var multiline = Parse(Newline) != null;
|
||||
|
||||
List<ContentList> result = null;
|
||||
if (multiline) {
|
||||
result = Parse(InnerMultilineSequenceObjects);
|
||||
} else {
|
||||
result = Parse(InnerInlineSequenceObjects);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<ContentList> InnerInlineSequenceObjects()
|
||||
{
|
||||
var interleavedContentAndPipes = Interleave<object> (Optional (MixedTextAndLogic), String ("|"), flatten:false);
|
||||
if (interleavedContentAndPipes == null)
|
||||
return null;
|
||||
|
||||
var result = new List<ContentList> ();
|
||||
|
||||
// The content and pipes won't necessarily be perfectly interleaved in the sense that
|
||||
// the content can be missing, but in that case it's intended that there's blank content.
|
||||
bool justHadContent = false;
|
||||
foreach (object contentOrPipe in interleavedContentAndPipes) {
|
||||
|
||||
// Pipe/separator
|
||||
if (contentOrPipe as string == "|") {
|
||||
|
||||
// Expected content, saw pipe - need blank content now
|
||||
if (!justHadContent) {
|
||||
|
||||
// Add blank content
|
||||
result.Add (new ContentList ());
|
||||
}
|
||||
|
||||
justHadContent = false;
|
||||
}
|
||||
|
||||
// Real content
|
||||
else {
|
||||
|
||||
var content = contentOrPipe as List<Parsed.Object>;
|
||||
if (content == null) {
|
||||
Error ("Expected content, but got " + contentOrPipe + " (this is an ink compiler bug!)");
|
||||
} else {
|
||||
result.Add (new ContentList (content));
|
||||
}
|
||||
|
||||
justHadContent = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ended in a pipe? Need to insert final blank content
|
||||
if (!justHadContent)
|
||||
result.Add (new ContentList ());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<ContentList> InnerMultilineSequenceObjects()
|
||||
{
|
||||
MultilineWhitespace ();
|
||||
|
||||
var contentLists = OneOrMore (SingleMultilineSequenceElement);
|
||||
if (contentLists == null)
|
||||
return null;
|
||||
|
||||
return contentLists.Cast<ContentList> ().ToList();
|
||||
}
|
||||
|
||||
protected ContentList SingleMultilineSequenceElement()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
// Make sure we're not accidentally parsing a divert
|
||||
if (ParseString ("->") != null)
|
||||
return null;
|
||||
|
||||
if (ParseString ("-") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
|
||||
List<Parsed.Object> content = StatementsAtLevel (StatementLevel.InnerBlock);
|
||||
|
||||
if (content == null)
|
||||
MultilineWhitespace ();
|
||||
|
||||
// Add newline at the start of each branch
|
||||
else {
|
||||
content.Insert (0, new Parsed.Text ("\n"));
|
||||
}
|
||||
|
||||
return new ContentList (content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 26cfb99fad990de4883b6437e5d2d6a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
163
Assets/Plugins/Ink/compiler/InkParser/InkParser_Statements.cs
Normal file
163
Assets/Plugins/Ink/compiler/InkParser/InkParser_Statements.cs
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Parsed;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected enum StatementLevel
|
||||
{
|
||||
InnerBlock,
|
||||
Stitch,
|
||||
Knot,
|
||||
Top
|
||||
}
|
||||
|
||||
protected List<Parsed.Object> StatementsAtLevel(StatementLevel level)
|
||||
{
|
||||
// Check for error: Should not be allowed gather dashes within an inner block
|
||||
if (level == StatementLevel.InnerBlock) {
|
||||
object badGatherDashCount = Parse(GatherDashes);
|
||||
if (badGatherDashCount != null) {
|
||||
Error ("You can't use a gather (the dashes) within the { curly braces } context. For multi-line sequences and conditions, you should only use one dash.");
|
||||
}
|
||||
}
|
||||
|
||||
return Interleave<Parsed.Object>(
|
||||
Optional (MultilineWhitespace),
|
||||
() => StatementAtLevel (level),
|
||||
untilTerminator: () => StatementsBreakForLevel(level));
|
||||
}
|
||||
|
||||
protected object StatementAtLevel(StatementLevel level)
|
||||
{
|
||||
ParseRule[] rulesAtLevel = _statementRulesAtLevel[(int)level];
|
||||
|
||||
var statement = OneOf (rulesAtLevel);
|
||||
|
||||
// For some statements, allow them to parse, but create errors, since
|
||||
// writers may think they can use the statement, so it's useful to have
|
||||
// the error message.
|
||||
if (level == StatementLevel.Top) {
|
||||
if( statement is Return )
|
||||
Error ("should not have return statement outside of a knot");
|
||||
}
|
||||
|
||||
return statement;
|
||||
}
|
||||
|
||||
protected object StatementsBreakForLevel(StatementLevel level)
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
ParseRule[] breakRules = _statementBreakRulesAtLevel[(int)level];
|
||||
|
||||
var breakRuleResult = OneOf (breakRules);
|
||||
if (breakRuleResult == null)
|
||||
return null;
|
||||
|
||||
return breakRuleResult;
|
||||
}
|
||||
|
||||
void GenerateStatementLevelRules()
|
||||
{
|
||||
var levels = Enum.GetValues (typeof(StatementLevel)).Cast<StatementLevel> ().ToList();
|
||||
|
||||
_statementRulesAtLevel = new ParseRule[levels.Count][];
|
||||
_statementBreakRulesAtLevel = new ParseRule[levels.Count][];
|
||||
|
||||
foreach (var level in levels) {
|
||||
List<ParseRule> rulesAtLevel = new List<ParseRule> ();
|
||||
List<ParseRule> breakingRules = new List<ParseRule> ();
|
||||
|
||||
// Diverts can go anywhere
|
||||
rulesAtLevel.Add(Line(MultiDivert));
|
||||
|
||||
// Knots can only be parsed at Top/Global scope
|
||||
if (level >= StatementLevel.Top)
|
||||
rulesAtLevel.Add (KnotDefinition);
|
||||
|
||||
rulesAtLevel.Add(Line(Choice));
|
||||
|
||||
rulesAtLevel.Add(Line(AuthorWarning));
|
||||
|
||||
// Gather lines would be confused with multi-line block separators, like
|
||||
// within a multi-line if statement
|
||||
if (level > StatementLevel.InnerBlock) {
|
||||
rulesAtLevel.Add (Gather);
|
||||
}
|
||||
|
||||
// Stitches (and gathers) can (currently) only go in Knots and top level
|
||||
if (level >= StatementLevel.Knot) {
|
||||
rulesAtLevel.Add (StitchDefinition);
|
||||
}
|
||||
|
||||
// Global variable declarations can go anywhere
|
||||
rulesAtLevel.Add(Line(ListDeclaration));
|
||||
rulesAtLevel.Add(Line(VariableDeclaration));
|
||||
rulesAtLevel.Add(Line(ConstDeclaration));
|
||||
rulesAtLevel.Add(Line(ExternalDeclaration));
|
||||
|
||||
// Global include can go anywhere
|
||||
rulesAtLevel.Add(Line(IncludeStatement));
|
||||
|
||||
// Normal logic / text can go anywhere
|
||||
rulesAtLevel.Add(LogicLine);
|
||||
rulesAtLevel.Add(LineOfMixedTextAndLogic);
|
||||
|
||||
// --------
|
||||
// Breaking rules
|
||||
|
||||
// Break current knot with a new knot
|
||||
if (level <= StatementLevel.Knot) {
|
||||
breakingRules.Add (KnotDeclaration);
|
||||
}
|
||||
|
||||
// Break current stitch with a new stitch
|
||||
if (level <= StatementLevel.Stitch) {
|
||||
breakingRules.Add (StitchDeclaration);
|
||||
}
|
||||
|
||||
// Breaking an inner block (like a multi-line condition statement)
|
||||
if (level <= StatementLevel.InnerBlock) {
|
||||
breakingRules.Add (ParseDashNotArrow);
|
||||
breakingRules.Add (String ("}"));
|
||||
}
|
||||
|
||||
_statementRulesAtLevel [(int)level] = rulesAtLevel.ToArray ();
|
||||
_statementBreakRulesAtLevel [(int)level] = breakingRules.ToArray ();
|
||||
}
|
||||
}
|
||||
|
||||
protected object SkipToNextLine()
|
||||
{
|
||||
ParseUntilCharactersFromString ("\n\r");
|
||||
ParseNewline ();
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
// Modifier to turn a rule into one that expects a newline on the end.
|
||||
// e.g. anywhere you can use "MixedTextAndLogic" as a rule, you can use
|
||||
// "Line(MixedTextAndLogic)" to specify that it expects a newline afterwards.
|
||||
protected ParseRule Line(ParseRule inlineRule)
|
||||
{
|
||||
return () => {
|
||||
object result = ParseObject(inlineRule);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Expect(EndOfLine, "end of line", recoveryRule: SkipToNextLine);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
ParseRule[][] _statementRulesAtLevel;
|
||||
ParseRule[][] _statementBreakRulesAtLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc56a52fd65ef9746ad8c635b665054a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Plugins/Ink/compiler/InkParser/InkParser_Tags.cs
Normal file
50
Assets/Plugins/Ink/compiler/InkParser/InkParser_Tags.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
protected Parsed.Tag Tag ()
|
||||
{
|
||||
Whitespace ();
|
||||
|
||||
if (ParseString ("#") == null)
|
||||
return null;
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var sb = new StringBuilder ();
|
||||
do {
|
||||
// Read up to another #, end of input or newline
|
||||
string tagText = ParseUntilCharactersFromCharSet (_endOfTagCharSet);
|
||||
sb.Append (tagText);
|
||||
|
||||
// Escape character
|
||||
if (ParseString ("\\") != null) {
|
||||
char c = ParseSingleCharacter ();
|
||||
if( c != (char)0 ) sb.Append(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
} while ( true );
|
||||
|
||||
var fullTagText = sb.ToString ().Trim();
|
||||
|
||||
return new Parsed.Tag (new Runtime.Tag (fullTagText));
|
||||
}
|
||||
|
||||
protected List<Parsed.Tag> Tags ()
|
||||
{
|
||||
var tags = OneOrMore (Tag);
|
||||
if (tags == null) return null;
|
||||
|
||||
return tags.Cast<Parsed.Tag>().ToList();
|
||||
}
|
||||
|
||||
CharacterSet _endOfTagCharSet = new CharacterSet ("#\n\r\\");
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Plugins/Ink/compiler/InkParser/InkParser_Tags.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/InkParser/InkParser_Tags.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c24086827a204b418bba51e98525480
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
112
Assets/Plugins/Ink/compiler/InkParser/InkParser_Whitespace.cs
Normal file
112
Assets/Plugins/Ink/compiler/InkParser/InkParser_Whitespace.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public partial class InkParser
|
||||
{
|
||||
// Handles both newline and endOfFile
|
||||
protected object EndOfLine()
|
||||
{
|
||||
return OneOf(Newline, EndOfFile);
|
||||
}
|
||||
|
||||
// Allow whitespace before the actual newline
|
||||
protected object Newline()
|
||||
{
|
||||
Whitespace();
|
||||
|
||||
bool gotNewline = ParseNewline () != null;
|
||||
|
||||
// Optional \r, definite \n to support Windows (\r\n) and Mac/Unix (\n)
|
||||
|
||||
if( !gotNewline ) {
|
||||
return null;
|
||||
} else {
|
||||
return ParseSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
protected object EndOfFile()
|
||||
{
|
||||
Whitespace();
|
||||
|
||||
if (!endOfInput)
|
||||
return null;
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
|
||||
// General purpose space, returns N-count newlines (fails if no newlines)
|
||||
protected object MultilineWhitespace()
|
||||
{
|
||||
List<object> newlines = OneOrMore(Newline);
|
||||
if (newlines == null)
|
||||
return null;
|
||||
|
||||
// Use content field of Token to say how many newlines there were
|
||||
// (in most circumstances it's unimportant)
|
||||
int numNewlines = newlines.Count;
|
||||
if (numNewlines >= 1) {
|
||||
return ParseSuccess;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected object Whitespace()
|
||||
{
|
||||
if( ParseCharactersFromCharSet(_inlineWhitespaceChars) != null ) {
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ParseRule Spaced(ParseRule rule)
|
||||
{
|
||||
return () => {
|
||||
|
||||
Whitespace ();
|
||||
|
||||
var result = ParseObject(rule);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Whitespace ();
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
protected object AnyWhitespace ()
|
||||
{
|
||||
bool anyWhitespace = false;
|
||||
while (OneOf (Whitespace, MultilineWhitespace) != null) {
|
||||
anyWhitespace = true;
|
||||
}
|
||||
return anyWhitespace ? ParseSuccess : null;
|
||||
}
|
||||
|
||||
protected ParseRule MultiSpaced (ParseRule rule)
|
||||
{
|
||||
return () => {
|
||||
|
||||
AnyWhitespace ();
|
||||
|
||||
var result = ParseObject (rule);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AnyWhitespace ();
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
private CharacterSet _inlineWhitespaceChars = new CharacterSet(" \t");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 970c5ebcd2579d647a72e5949b3a266b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Plugins/Ink/compiler/InkStringConversionExtensions.cs
Normal file
18
Assets/Plugins/Ink/compiler/InkStringConversionExtensions.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink
|
||||
{
|
||||
public static class InkStringConversionExtensions
|
||||
{
|
||||
public static string[] ToStringsArray<T>(this List<T> list) {
|
||||
int count = list.Count;
|
||||
var strings = new string[count];
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
strings[i] = list[i].ToString();
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a20342fd5a7af246b0d8486a9a242c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Ink/compiler/ParsedHierarchy.meta
Normal file
8
Assets/Plugins/Ink/compiler/ParsedHierarchy.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bbf30acdd181d1418263a86b8d4de36
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Plugins/Ink/compiler/ParsedHierarchy/AuthorWarning.cs
Normal file
20
Assets/Plugins/Ink/compiler/ParsedHierarchy/AuthorWarning.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
namespace Ink.Parsed
|
||||
{
|
||||
public class AuthorWarning : Parsed.Object
|
||||
{
|
||||
public string warningMessage;
|
||||
|
||||
public AuthorWarning(string message)
|
||||
{
|
||||
warningMessage = message;
|
||||
}
|
||||
|
||||
public override Runtime.Object GenerateRuntimeObject ()
|
||||
{
|
||||
Warning (warningMessage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41069d3b98c64f44180e0569b3bab64c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
290
Assets/Plugins/Ink/compiler/ParsedHierarchy/Choice.cs
Normal file
290
Assets/Plugins/Ink/compiler/ParsedHierarchy/Choice.cs
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
using System.Text;
|
||||
|
||||
namespace Ink.Parsed
|
||||
{
|
||||
public class Choice : Parsed.Object, IWeavePoint, INamedContent
|
||||
{
|
||||
public ContentList startContent { get; protected set; }
|
||||
public ContentList choiceOnlyContent { get; protected set; }
|
||||
public ContentList innerContent { get; protected set; }
|
||||
|
||||
public string name
|
||||
{
|
||||
get { return identifier?.name; }
|
||||
}
|
||||
public Identifier identifier { get; set; }
|
||||
|
||||
public Expression condition {
|
||||
get {
|
||||
return _condition;
|
||||
}
|
||||
set {
|
||||
_condition = value;
|
||||
if( _condition )
|
||||
AddContent (_condition);
|
||||
}
|
||||
}
|
||||
|
||||
public bool onceOnly { get; set; }
|
||||
public bool isInvisibleDefault { get; set; }
|
||||
|
||||
public int indentationDepth { get; set; }// = 1;
|
||||
public bool hasWeaveStyleInlineBrackets { get; set; }
|
||||
|
||||
// Required for IWeavePoint interface
|
||||
// Choice's target container. Used by weave to append any extra
|
||||
// nested weave content into.
|
||||
public Runtime.Container runtimeContainer { get { return _innerContentContainer; } }
|
||||
|
||||
|
||||
public Runtime.Container innerContentContainer {
|
||||
get {
|
||||
return _innerContentContainer;
|
||||
}
|
||||
}
|
||||
|
||||
public override Runtime.Container containerForCounting {
|
||||
get {
|
||||
return _innerContentContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Override runtimePath to point to the Choice's target content (after it's chosen),
|
||||
// as opposed to the default implementation which would point to the choice itself
|
||||
// (or it's outer container), which is what runtimeObject is.
|
||||
public override Runtime.Path runtimePath
|
||||
{
|
||||
get {
|
||||
return _innerContentContainer.path;
|
||||
}
|
||||
}
|
||||
|
||||
public Choice (ContentList startContent, ContentList choiceOnlyContent, ContentList innerContent)
|
||||
{
|
||||
this.startContent = startContent;
|
||||
this.choiceOnlyContent = choiceOnlyContent;
|
||||
this.innerContent = innerContent;
|
||||
this.indentationDepth = 1;
|
||||
|
||||
if (startContent)
|
||||
AddContent (this.startContent);
|
||||
|
||||
if (choiceOnlyContent)
|
||||
AddContent (this.choiceOnlyContent);
|
||||
|
||||
if( innerContent )
|
||||
AddContent (this.innerContent);
|
||||
|
||||
this.onceOnly = true; // default
|
||||
}
|
||||
|
||||
|
||||
public override Runtime.Object GenerateRuntimeObject ()
|
||||
{
|
||||
_outerContainer = new Runtime.Container ();
|
||||
|
||||
// Content names for different types of choice:
|
||||
// * start content [choice only content] inner content
|
||||
// * start content -> divert
|
||||
// * start content
|
||||
// * [choice only content]
|
||||
|
||||
// Hmm, this structure has become slightly insane!
|
||||
//
|
||||
// [
|
||||
// EvalStart
|
||||
// assign $r = $r1 -- return target = return label 1
|
||||
// BeginString
|
||||
// -> s
|
||||
// [(r1)] -- return label 1 (after start content)
|
||||
// EndString
|
||||
// BeginString
|
||||
// ... choice only content
|
||||
// EndEval
|
||||
// Condition expression
|
||||
// choice: -> "c-0"
|
||||
// (s) = [
|
||||
// start content
|
||||
// -> r -- goto return label 1 or 2
|
||||
// ]
|
||||
// ]
|
||||
//
|
||||
// in parent's container: (the inner content for the choice)
|
||||
//
|
||||
// (c-0) = [
|
||||
// EvalStart
|
||||
// assign $r = $r2 -- return target = return label 2
|
||||
// EndEval
|
||||
// -> s
|
||||
// [(r2)] -- return label 1 (after start content)
|
||||
// inner content
|
||||
// ]
|
||||
//
|
||||
|
||||
_runtimeChoice = new Runtime.ChoicePoint (onceOnly);
|
||||
_runtimeChoice.isInvisibleDefault = this.isInvisibleDefault;
|
||||
|
||||
if (startContent || choiceOnlyContent || condition) {
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.EvalStart ());
|
||||
}
|
||||
|
||||
// Start content is put into a named container that's referenced both
|
||||
// when displaying the choice initially, and when generating the text
|
||||
// when the choice is chosen.
|
||||
if (startContent) {
|
||||
|
||||
// Generate start content and return
|
||||
// - We can't use a function since it uses a call stack element, which would
|
||||
// put temporary values out of scope. Instead we manually divert around.
|
||||
// - $r is a variable divert target contains the return point
|
||||
_returnToR1 = new Runtime.DivertTargetValue ();
|
||||
_outerContainer.AddContent (_returnToR1);
|
||||
var varAssign = new Runtime.VariableAssignment ("$r", true);
|
||||
_outerContainer.AddContent (varAssign);
|
||||
|
||||
// Mark the start of the choice text generation, so that the runtime
|
||||
// knows where to rewind to to extract the content from the output stream.
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.BeginString ());
|
||||
|
||||
_divertToStartContentOuter = new Runtime.Divert ();
|
||||
_outerContainer.AddContent (_divertToStartContentOuter);
|
||||
|
||||
// Start content itself in a named container
|
||||
_startContentRuntimeContainer = startContent.GenerateRuntimeObject () as Runtime.Container;
|
||||
_startContentRuntimeContainer.name = "s";
|
||||
|
||||
// Effectively, the "return" statement - return to the point specified by $r
|
||||
var varDivert = new Runtime.Divert ();
|
||||
varDivert.variableDivertName = "$r";
|
||||
_startContentRuntimeContainer.AddContent (varDivert);
|
||||
|
||||
// Add the container
|
||||
_outerContainer.AddToNamedContentOnly (_startContentRuntimeContainer);
|
||||
|
||||
// This is the label to return to
|
||||
_r1Label = new Runtime.Container ();
|
||||
_r1Label.name = "$r1";
|
||||
_outerContainer.AddContent (_r1Label);
|
||||
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.EndString ());
|
||||
|
||||
_runtimeChoice.hasStartContent = true;
|
||||
}
|
||||
|
||||
// Choice only content - mark the start, then generate it directly into the outer container
|
||||
if (choiceOnlyContent) {
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.BeginString ());
|
||||
|
||||
var choiceOnlyRuntimeContent = choiceOnlyContent.GenerateRuntimeObject () as Runtime.Container;
|
||||
_outerContainer.AddContentsOfContainer (choiceOnlyRuntimeContent);
|
||||
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.EndString ());
|
||||
|
||||
_runtimeChoice.hasChoiceOnlyContent = true;
|
||||
}
|
||||
|
||||
// Generate any condition for this choice
|
||||
if (condition) {
|
||||
condition.GenerateIntoContainer (_outerContainer);
|
||||
_runtimeChoice.hasCondition = true;
|
||||
}
|
||||
|
||||
if (startContent || choiceOnlyContent || condition) {
|
||||
_outerContainer.AddContent (Runtime.ControlCommand.EvalEnd ());
|
||||
}
|
||||
|
||||
// Add choice itself
|
||||
_outerContainer.AddContent (_runtimeChoice);
|
||||
|
||||
// Container that choice points to for when it's chosen
|
||||
_innerContentContainer = new Runtime.Container ();
|
||||
|
||||
// Repeat start content by diverting to its container
|
||||
if (startContent) {
|
||||
|
||||
// Set the return point when jumping back into the start content
|
||||
// - In this case, it's the $r2 point, within the choice content "c".
|
||||
_returnToR2 = new Runtime.DivertTargetValue ();
|
||||
_innerContentContainer.AddContent (Runtime.ControlCommand.EvalStart ());
|
||||
_innerContentContainer.AddContent (_returnToR2);
|
||||
_innerContentContainer.AddContent (Runtime.ControlCommand.EvalEnd ());
|
||||
var varAssign = new Runtime.VariableAssignment ("$r", true);
|
||||
_innerContentContainer.AddContent (varAssign);
|
||||
|
||||
// Main divert into start content
|
||||
_divertToStartContentInner = new Runtime.Divert ();
|
||||
_innerContentContainer.AddContent (_divertToStartContentInner);
|
||||
|
||||
// Define label to return to
|
||||
_r2Label = new Runtime.Container ();
|
||||
_r2Label.name = "$r2";
|
||||
_innerContentContainer.AddContent (_r2Label);
|
||||
}
|
||||
|
||||
// Choice's own inner content
|
||||
if (innerContent) {
|
||||
var innerChoiceOnlyContent = innerContent.GenerateRuntimeObject () as Runtime.Container;
|
||||
_innerContentContainer.AddContentsOfContainer (innerChoiceOnlyContent);
|
||||
}
|
||||
|
||||
if (this.story.countAllVisits) {
|
||||
_innerContentContainer.visitsShouldBeCounted = true;
|
||||
}
|
||||
|
||||
_innerContentContainer.countingAtStartOnly = true;
|
||||
|
||||
return _outerContainer;
|
||||
}
|
||||
|
||||
public override void ResolveReferences(Story context)
|
||||
{
|
||||
// Weave style choice - target own content container
|
||||
if (_innerContentContainer) {
|
||||
_runtimeChoice.pathOnChoice = _innerContentContainer.path;
|
||||
|
||||
if (onceOnly)
|
||||
_innerContentContainer.visitsShouldBeCounted = true;
|
||||
}
|
||||
|
||||
if (_returnToR1)
|
||||
_returnToR1.targetPath = _r1Label.path;
|
||||
|
||||
if (_returnToR2)
|
||||
_returnToR2.targetPath = _r2Label.path;
|
||||
|
||||
if( _divertToStartContentOuter )
|
||||
_divertToStartContentOuter.targetPath = _startContentRuntimeContainer.path;
|
||||
|
||||
if( _divertToStartContentInner )
|
||||
_divertToStartContentInner.targetPath = _startContentRuntimeContainer.path;
|
||||
|
||||
base.ResolveReferences (context);
|
||||
|
||||
if( identifier != null && identifier.name.Length > 0 )
|
||||
context.CheckForNamingCollisions (this, identifier, Story.SymbolType.SubFlowAndWeave);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (choiceOnlyContent != null) {
|
||||
return string.Format ("* {0}[{1}]...", startContent, choiceOnlyContent);
|
||||
} else {
|
||||
return string.Format ("* {0}...", startContent);
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.ChoicePoint _runtimeChoice;
|
||||
Runtime.Container _innerContentContainer;
|
||||
Runtime.Container _outerContainer;
|
||||
Runtime.Container _startContentRuntimeContainer;
|
||||
Runtime.Divert _divertToStartContentOuter;
|
||||
Runtime.Divert _divertToStartContentInner;
|
||||
Runtime.Container _r1Label;
|
||||
Runtime.Container _r2Label;
|
||||
Runtime.DivertTargetValue _returnToR1;
|
||||
Runtime.DivertTargetValue _returnToR2;
|
||||
Expression _condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
11
Assets/Plugins/Ink/compiler/ParsedHierarchy/Choice.cs.meta
Normal file
11
Assets/Plugins/Ink/compiler/ParsedHierarchy/Choice.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c1c1a3eaa8256641a14fc27fca420d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Plugins/Ink/compiler/ParsedHierarchy/Conditional.cs
Normal file
71
Assets/Plugins/Ink/compiler/ParsedHierarchy/Conditional.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Runtime;
|
||||
|
||||
namespace Ink.Parsed
|
||||
{
|
||||
public class Conditional : Parsed.Object
|
||||
{
|
||||
public Expression initialCondition { get; private set; }
|
||||
public List<ConditionalSingleBranch> branches { get; private set; }
|
||||
|
||||
public Conditional (Expression condition, List<ConditionalSingleBranch> branches)
|
||||
{
|
||||
this.initialCondition = condition;
|
||||
if (this.initialCondition) {
|
||||
AddContent (condition);
|
||||
}
|
||||
|
||||
this.branches = branches;
|
||||
if (this.branches != null) {
|
||||
AddContent (this.branches.Cast<Parsed.Object> ().ToList ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override Runtime.Object GenerateRuntimeObject ()
|
||||
{
|
||||
var container = new Runtime.Container ();
|
||||
|
||||
// Initial condition
|
||||
if (this.initialCondition) {
|
||||
container.AddContent (initialCondition.runtimeObject);
|
||||
}
|
||||
|
||||
// Individual branches
|
||||
foreach (var branch in branches) {
|
||||
var branchContainer = (Container) branch.runtimeObject;
|
||||
container.AddContent (branchContainer);
|
||||
}
|
||||
|
||||
// If it's a switch-like conditional, each branch
|
||||
// will have a "duplicate" operation for the original
|
||||
// switched value. If there's no final else clause
|
||||
// and we fall all the way through, we need to clean up.
|
||||
// (An else clause doesn't dup but it *does* pop)
|
||||
if (this.initialCondition != null && branches [0].ownExpression != null && !branches [branches.Count - 1].isElse) {
|
||||
container.AddContent (Runtime.ControlCommand.PopEvaluatedValue ());
|
||||
}
|
||||
|
||||
// Target for branches to rejoin to
|
||||
_reJoinTarget = Runtime.ControlCommand.NoOp ();
|
||||
container.AddContent (_reJoinTarget);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
public override void ResolveReferences (Story context)
|
||||
{
|
||||
var pathToReJoin = _reJoinTarget.path;
|
||||
|
||||
foreach (var branch in branches) {
|
||||
branch.returnDivert.targetPath = pathToReJoin;
|
||||
}
|
||||
|
||||
base.ResolveReferences (context);
|
||||
}
|
||||
|
||||
Runtime.ControlCommand _reJoinTarget;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0563dff86f800ea4b9ee7f4474aadca4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink.Parsed
|
||||
{
|
||||
public class ConditionalSingleBranch : Parsed.Object
|
||||
{
|
||||
// bool condition, e.g.:
|
||||
// { 5 == 4:
|
||||
// - the true branch
|
||||
// - the false branch
|
||||
// }
|
||||
public bool isTrueBranch { get; set; }
|
||||
|
||||
// When each branch has its own expression like a switch statement,
|
||||
// this is non-null. e.g.
|
||||
// { x:
|
||||
// - 4: the value of x is four (ownExpression is the value 4)
|
||||
// - 3: the value of x is three
|
||||
// }
|
||||
public Expression ownExpression {
|
||||
get {
|
||||
return _ownExpression;
|
||||
}
|
||||
set {
|
||||
_ownExpression = value;
|
||||
if (_ownExpression) {
|
||||
AddContent (_ownExpression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In the above example, match equality of x with 4 for the first branch.
|
||||
// This is as opposed to simply evaluating boolean equality for each branch,
|
||||
// example when shouldMatchEqualtity is FALSE:
|
||||
// {
|
||||
// 3 > 2: This will happen
|
||||
// 2 > 3: This won't happen
|
||||
// }
|
||||
public bool matchingEquality { get; set; }
|
||||
|
||||
public bool isElse { get; set; }
|
||||
|
||||
public bool isInline { get; set; }
|
||||
|
||||
public Runtime.Divert returnDivert { get; protected set; }
|
||||
|
||||
public ConditionalSingleBranch (List<Parsed.Object> content)
|
||||
{
|
||||
// Branches are allowed to be empty
|
||||
if (content != null) {
|
||||
_innerWeave = new Weave (content);
|
||||
AddContent (_innerWeave);
|
||||
}
|
||||
}
|
||||
|
||||
// Runtime content can be summarised as follows:
|
||||
// - Evaluate an expression if necessary to branch on
|
||||
// - Branch to a named container if true
|
||||
// - Divert back to main flow
|
||||
// (owner Conditional is in control of this target point)
|
||||
public override Runtime.Object GenerateRuntimeObject ()
|
||||
{
|
||||
// Check for common mistake, of putting "else:" instead of "- else:"
|
||||
if (_innerWeave) {
|
||||
foreach (var c in _innerWeave.content) {
|
||||
var text = c as Parsed.Text;
|
||||
if (text) {
|
||||
// Don't need to trim at the start since the parser handles that already
|
||||
if (text.text.StartsWith ("else:")) {
|
||||
Warning ("Saw the text 'else:' which is being treated as content. Did you mean '- else:'?", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var container = new Runtime.Container ();
|
||||
|
||||
// Are we testing against a condition that's used for more than just this
|
||||
// branch? If so, the first thing we need to do is replicate the value that's
|
||||
// on the evaluation stack so that we don't fully consume it, in case other
|
||||
// branches need to use it.
|
||||
bool duplicatesStackValue = matchingEquality && !isElse;
|
||||
if ( duplicatesStackValue )
|
||||
container.AddContent (Runtime.ControlCommand.Duplicate ());
|
||||
|
||||
_conditionalDivert = new Runtime.Divert ();
|
||||
|
||||
// else clause is unconditional catch-all, otherwise the divert is conditional
|
||||
_conditionalDivert.isConditional = !isElse;
|
||||
|
||||
// Need extra evaluation?
|
||||
if( !isTrueBranch && !isElse ) {
|
||||
|
||||
bool needsEval = ownExpression != null;
|
||||
if( needsEval )
|
||||
container.AddContent (Runtime.ControlCommand.EvalStart ());
|
||||
|
||||
if (ownExpression)
|
||||
ownExpression.GenerateIntoContainer (container);
|
||||
|
||||
// Uses existing duplicated value
|
||||
if (matchingEquality)
|
||||
container.AddContent (Runtime.NativeFunctionCall.CallWithName ("=="));
|
||||
|
||||
if( needsEval )
|
||||
container.AddContent (Runtime.ControlCommand.EvalEnd ());
|
||||
}
|
||||
|
||||
// Will pop from stack if conditional
|
||||
container.AddContent (_conditionalDivert);
|
||||
|
||||
_contentContainer = GenerateRuntimeForContent ();
|
||||
_contentContainer.name = "b";
|
||||
|
||||
// Multi-line conditionals get a newline at the start of each branch
|
||||
// (as opposed to the start of the multi-line conditional since the condition
|
||||
// may evaluate to false.)
|
||||
if (!isInline) {
|
||||
_contentContainer.InsertContent (new Runtime.StringValue ("\n"), 0);
|
||||
}
|
||||
|
||||
if( duplicatesStackValue || (isElse && matchingEquality) )
|
||||
_contentContainer.InsertContent (Runtime.ControlCommand.PopEvaluatedValue (), 0);
|
||||
|
||||
container.AddToNamedContentOnly (_contentContainer);
|
||||
|
||||
returnDivert = new Runtime.Divert ();
|
||||
_contentContainer.AddContent (returnDivert);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
Runtime.Container GenerateRuntimeForContent()
|
||||
{
|
||||
// Empty branch - create empty container
|
||||
if (_innerWeave == null) {
|
||||
return new Runtime.Container ();
|
||||
}
|
||||
|
||||
return _innerWeave.rootContainer;
|
||||
}
|
||||
|
||||
public override void ResolveReferences (Story context)
|
||||
{
|
||||
_conditionalDivert.targetPath = _contentContainer.path;
|
||||
|
||||
base.ResolveReferences (context);
|
||||
}
|
||||
|
||||
Runtime.Container _contentContainer;
|
||||
Runtime.Divert _conditionalDivert;
|
||||
Expression _ownExpression;
|
||||
|
||||
Weave _innerWeave;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue