From 6ce8b9e22fc13be34b442c7b6af48b42cd44275a Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Wed, 13 Mar 2024 11:00:58 +0800
Subject: +init
---
.gitignore | 399 ++++
ADS.cs | 49 +
AddCameraMovementByRig.cs | 31 +
AddForceByCollision.cs | 34 +
AddForceToTarget.cs | 26 +
AddScreenShake.cs | 29 +
AmplifyOcclusion/VersionInfo.cs | 61 +
AmplifyOcclusionBase.cs | 951 ++++++++
AmplifyOcclusionEffect.cs | 7 +
AnimationHandler.cs | 14 +
AnimationObject.cs | 140 ++
ArchiveScript.cs | 61 +
ArmLeft.cs | 12 +
ArmRight.cs | 12 +
AvaragePosition.cs | 26 +
Balance.cs | 101 +
CameraMovement.cs | 136 ++
CameraRecoil.cs | 49 +
CameraWobble.cs | 18 +
Car.cs | 143 ++
CenterOfMass.cs | 14 +
ChatController.cs | 34 +
CodeAnimation.cs | 63 +
CollisionChecker.cs | 85 +
ConfigurableJointExtensions.cs | 41 +
ContextSwitcher.cs | 31 +
Controls.cs | 85 +
CreepyRobots.csproj | 183 ++
Damagable.cs | 54 +
DamageEffects.cs | 84 +
DebugPosition.cs | 13 +
DeepSky.Haze.Demo/BasicMouseLookControl.cs | 52 +
DeepSky.Haze/DS_HazeContext.cs | 154 ++
DeepSky.Haze/DS_HazeContextAsset.cs | 14 +
DeepSky.Haze/DS_HazeContextItem.cs | 173 ++
DeepSky.Haze/DS_HazeCore.cs | 218 ++
DeepSky.Haze/DS_HazeLightVolume.cs | 604 +++++
DeepSky.Haze/DS_HazeView.cs | 1120 ++++++++++
DeepSky.Haze/DS_HazeZone.cs | 105 +
DeepSky.Haze/DS_LightFalloff.cs | 7 +
DeepSky.Haze/DS_SamplingQuality.cs | 9 +
DoggoMovement.cs | 43 +
DragHandler.cs | 25 +
EnemyAI.cs | 103 +
EnemyGroup.cs | 15 +
EnemyWave.cs | 8 +
EnvMapAnimator.cs | 29 +
ExampleWheelController.cs | 38 +
FPSCarCam.cs | 42 +
FPSmeter.cs | 40 +
FollowRotation.cs | 15 +
FollowTransform.cs | 17 +
FollowTransformVelocity.cs | 16 +
FootHandler.cs | 75 +
FootLeft.cs | 12 +
FootRenderer.cs | 26 +
FootRight.cs | 12 +
ForceLerp.cs | 59 +
ForcePosition.cs | 12 +
GameMode.cs | 124 ++
GenericForceMovement.cs | 40 +
GenericInputHandler.cs | 40 +
GeometryVsTerrainBlend.cs | 215 ++
Gravity.cs | 47 +
Gun.cs | 94 +
GunSFX.cs | 23 +
HandLeft.cs | 12 +
HandRight.cs | 12 +
HardAnimation.cs | 61 +
HardAnimations.cs | 64 +
HardPhysicsAnimation.cs | 16 +
HasControl.cs | 28 +
Head.cs | 12 +
HeadCollisionHandler.cs | 31 +
Hip.cs | 12 +
HoldableObject.cs | 88 +
Holding.cs | 288 +++
HoldingBaseTransform.cs | 12 +
InfoBubble.cs | 26 +
InputHandler.cs | 120 +
KneeLeft.cs | 12 +
KneeRight.cs | 12 +
Landfall.Network/LoginInformation.cs | 6 +
Landfall.Network/NetworkController.cs | 65 +
Landfall.Network/NetworkManager.cs | 213 ++
Landfall.Network/PacketType.cs | 10 +
Landfall.Network/Player.cs | 13 +
LeftHandPos.cs | 12 +
LegLeft.cs | 12 +
LegRight.cs | 12 +
LookAtVelocity.cs | 19 +
MipTexMap.cs | 119 +
MouseLook.cs | 117 +
MouseOrbitCS.cs | 64 +
MoveRig.cs | 20 +
MoveTransform.cs | 21 +
MovementDataHandler.cs | 92 +
MovementHandler.cs | 85 +
MovementRig.cs | 10 +
Neck.cs | 12 +
NetPlayer.cs | 8 +
PID.cs | 104 +
ParticleParent.cs | 39 +
PhysicsAnimation.cs | 36 +
PhysicsLerpBackToStart.cs | 12 +
Pickup.cs | 12 +
PickupHandler.cs | 63 +
Player.cs | 18 +
PlayerDeath.cs | 125 ++
PlayerKnockback.cs | 52 +
ProjectileHit.cs | 75 +
ProjectileHitSpawn.cs | 18 +
Properties/AssemblyInfo.cs | 7 +
RTPColorChannels.cs | 7 +
RTPFogType.cs | 7 +
RTPLodLevel.cs | 8 +
RTPObjExporter.cs | 52 +
RTPTangentSolver.cs | 59 +
RTP_DeferredParams.cs | 151 ++
RTP_LODmanager.cs | 378 ++++
RTP_MouseOrbit_DynamicDistance.cs | 234 ++
RTP_TintDielectricColor.cs | 24 +
RagdollHandler.cs | 21 +
RandomTable.cs | 109 +
RandomizeRotation.cs | 11 +
RaycastTrail.cs | 29 +
Recoil.cs | 64 +
ReliefShaders_applyLightForDeferred.cs | 54 +
ReliefTerrain.cs | 451 ++++
ReliefTerrainControlTexturesItems.cs | 6 +
ReliefTerrainDerivedTexturesItems.cs | 7 +
ReliefTerrainGlobalSettingsHolder.cs | 2309 ++++++++++++++++++++
ReliefTerrainMenuItems.cs | 7 +
ReliefTerrainPresetHolder.cs | 418 ++++
ReliefTerrainSettingsItems.cs | 13 +
ReliefTerrainVertexBlendTriplanar.cs | 138 ++
RemoveAfterSeconds.cs | 19 +
RemoveMouse.cs | 17 +
ResolveHoleCollision.cs | 97 +
ResolveHoleCollisionMultiple.cs | 110 +
RestartOnR.cs | 16 +
RightHandPos.cs | 12 +
RigidbodyHolder.cs | 44 +
RigidbodyMovment.cs | 10 +
RotateByKeyboardInput.cs | 103 +
RotateByMouseInput.cs | 121 +
RotationHandler.cs | 73 +
RotationTarget.cs | 12 +
RuntimeDecalCombiner.cs | 68 +
SFXPlayer.cs | 23 +
ScreenShakeByCollision.cs | 34 +
SelectorHelperClass.cs | 5 +
SetAnimationByInput.cs | 40 +
SetAnimationByVelocity.cs | 12 +
SetInertiaTension.cs | 43 +
SetMainCamera.cs | 18 +
SetRigidbodySettings.cs | 20 +
SetWobblerIfHeld.cs | 29 +
ShootPosition.cs | 12 +
Slither.cs | 29 +
SnakeAI.cs | 23 +
SparksExecutioner.cs | 16 +
SpawnerHolder.cs | 7 +
SquaredDrag.cs | 22 +
StabilizeRigidbody.cs | 16 +
Standing.cs | 55 +
StandingDataHandler.cs | 69 +
StartRotation.cs | 18 +
StayInPlace.cs | 50 +
Step.cs | 11 +
StepHandler.cs | 53 +
Strength.cs | 21 +
SyncCausticsWaterLevel.cs | 22 +
TMPro/TMP_DigitValidator.cs | 17 +
TMPro/TMP_TextEventHandler.cs | 208 ++
TerrainShaderLod.cs | 6 +
TimeTrail.cs | 69 +
Torso.cs | 12 +
TransformVelocity.cs | 19 +
.../AmbientOcclusionComponent.cs | 160 ++
.../AmbientOcclusionModel.cs | 78 +
UnityEngine.PostProcessing/AntialiasingModel.cs | 222 ++
UnityEngine.PostProcessing/BloomComponent.cs | 106 +
UnityEngine.PostProcessing/BloomModel.cs | 117 +
.../BuiltinDebugViewsComponent.cs | 223 ++
.../BuiltinDebugViewsModel.cs | 131 ++
.../ChromaticAberrationComponent.cs | 53 +
.../ChromaticAberrationModel.cs | 49 +
.../ColorGradingComponent.cs | 341 +++
UnityEngine.PostProcessing/ColorGradingCurve.cs | 64 +
UnityEngine.PostProcessing/ColorGradingModel.cs | 319 +++
.../DepthOfFieldComponent.cs | 141 ++
UnityEngine.PostProcessing/DepthOfFieldModel.cs | 71 +
UnityEngine.PostProcessing/DitheringComponent.cs | 51 +
UnityEngine.PostProcessing/DitheringModel.cs | 35 +
.../EyeAdaptationComponent.cs | 168 ++
UnityEngine.PostProcessing/EyeAdaptationModel.cs | 97 +
UnityEngine.PostProcessing/FogComponent.cs | 67 +
UnityEngine.PostProcessing/FogModel.cs | 44 +
UnityEngine.PostProcessing/FxaaComponent.cs | 24 +
UnityEngine.PostProcessing/GetSetAttribute.cs | 13 +
UnityEngine.PostProcessing/GrainComponent.cs | 52 +
UnityEngine.PostProcessing/GrainModel.cs | 59 +
UnityEngine.PostProcessing/GraphicsUtils.cs | 115 +
UnityEngine.PostProcessing/MaterialFactory.cs | 43 +
UnityEngine.PostProcessing/MinAttribute.cs | 11 +
UnityEngine.PostProcessing/MotionBlurComponent.cs | 421 ++++
UnityEngine.PostProcessing/MotionBlurModel.cs | 55 +
.../PostProcessingBehaviour.cs | 405 ++++
.../PostProcessingComponent.cs | 17 +
.../PostProcessingComponentBase.cs | 23 +
.../PostProcessingComponentCommandBuffer.cs | 12 +
.../PostProcessingComponentRenderTexture.cs | 8 +
.../PostProcessingContext.cs | 39 +
UnityEngine.PostProcessing/PostProcessingModel.cs | 33 +
.../PostProcessingProfile.cs | 34 +
UnityEngine.PostProcessing/RenderTextureFactory.cs | 57 +
.../ScreenSpaceReflectionComponent.cs | 217 ++
.../ScreenSpaceReflectionModel.cs | 141 ++
UnityEngine.PostProcessing/TaaComponent.cs | 176 ++
UnityEngine.PostProcessing/TrackballAttribute.cs | 11 +
.../TrackballGroupAttribute.cs | 5 +
UnityEngine.PostProcessing/UserLutComponent.cs | 35 +
UnityEngine.PostProcessing/UserLutModel.cs | 49 +
UnityEngine.PostProcessing/VignetteComponent.cs | 38 +
UnityEngine.PostProcessing/VignetteModel.cs | 87 +
UnitySA.Characters.FirstPerson/FPCtrl.cs | 202 ++
UnitySA.Characters.FirstPerson/MLook.cs | 111 +
UnitySA.Utility/CurveCtrlBob.cs | 50 +
UnitySA.Utility/FOVZoom.cs | 69 +
UnitySA.Utility/LerpCtrlBob.cs | 39 +
Weapon.cs | 12 +
WeaponHandler.cs | 75 +
Wheel.cs | 24 +
WheelVisualizer.cs | 37 +
WobbleShake.cs | 50 +
_appControlerShaderOnTriplanarMesh.cs | 45 +
_appControlerTerrain.cs | 179 ++
_appControlerTerrain2Geometry.cs | 179 ++
ch.sycoforge.Decal.Demo/AdvancedBulletHoles.cs | 55 +
ch.sycoforge.Decal.Demo/BasicBulletHoles.cs | 37 +
ch.sycoforge.Decal.Demo/BezierUtil.cs | 77 +
ch.sycoforge.Decal.Demo/LineUtil.cs | 50 +
ch.sycoforge.Decal.Demo/PathAgent.cs | 106 +
ch.sycoforge.Decal.Demo/ProxyRegister.cs | 13 +
ch.sycoforge.Decal.Demo/Sinoid.cs | 29 +
246 files changed, 21283 insertions(+)
create mode 100644 .gitignore
create mode 100644 ADS.cs
create mode 100644 AddCameraMovementByRig.cs
create mode 100644 AddForceByCollision.cs
create mode 100644 AddForceToTarget.cs
create mode 100644 AddScreenShake.cs
create mode 100644 AmplifyOcclusion/VersionInfo.cs
create mode 100644 AmplifyOcclusionBase.cs
create mode 100644 AmplifyOcclusionEffect.cs
create mode 100644 AnimationHandler.cs
create mode 100644 AnimationObject.cs
create mode 100644 ArchiveScript.cs
create mode 100644 ArmLeft.cs
create mode 100644 ArmRight.cs
create mode 100644 AvaragePosition.cs
create mode 100644 Balance.cs
create mode 100644 CameraMovement.cs
create mode 100644 CameraRecoil.cs
create mode 100644 CameraWobble.cs
create mode 100644 Car.cs
create mode 100644 CenterOfMass.cs
create mode 100644 ChatController.cs
create mode 100644 CodeAnimation.cs
create mode 100644 CollisionChecker.cs
create mode 100644 ConfigurableJointExtensions.cs
create mode 100644 ContextSwitcher.cs
create mode 100644 Controls.cs
create mode 100644 CreepyRobots.csproj
create mode 100644 Damagable.cs
create mode 100644 DamageEffects.cs
create mode 100644 DebugPosition.cs
create mode 100644 DeepSky.Haze.Demo/BasicMouseLookControl.cs
create mode 100644 DeepSky.Haze/DS_HazeContext.cs
create mode 100644 DeepSky.Haze/DS_HazeContextAsset.cs
create mode 100644 DeepSky.Haze/DS_HazeContextItem.cs
create mode 100644 DeepSky.Haze/DS_HazeCore.cs
create mode 100644 DeepSky.Haze/DS_HazeLightVolume.cs
create mode 100644 DeepSky.Haze/DS_HazeView.cs
create mode 100644 DeepSky.Haze/DS_HazeZone.cs
create mode 100644 DeepSky.Haze/DS_LightFalloff.cs
create mode 100644 DeepSky.Haze/DS_SamplingQuality.cs
create mode 100644 DoggoMovement.cs
create mode 100644 DragHandler.cs
create mode 100644 EnemyAI.cs
create mode 100644 EnemyGroup.cs
create mode 100644 EnemyWave.cs
create mode 100644 EnvMapAnimator.cs
create mode 100644 ExampleWheelController.cs
create mode 100644 FPSCarCam.cs
create mode 100644 FPSmeter.cs
create mode 100644 FollowRotation.cs
create mode 100644 FollowTransform.cs
create mode 100644 FollowTransformVelocity.cs
create mode 100644 FootHandler.cs
create mode 100644 FootLeft.cs
create mode 100644 FootRenderer.cs
create mode 100644 FootRight.cs
create mode 100644 ForceLerp.cs
create mode 100644 ForcePosition.cs
create mode 100644 GameMode.cs
create mode 100644 GenericForceMovement.cs
create mode 100644 GenericInputHandler.cs
create mode 100644 GeometryVsTerrainBlend.cs
create mode 100644 Gravity.cs
create mode 100644 Gun.cs
create mode 100644 GunSFX.cs
create mode 100644 HandLeft.cs
create mode 100644 HandRight.cs
create mode 100644 HardAnimation.cs
create mode 100644 HardAnimations.cs
create mode 100644 HardPhysicsAnimation.cs
create mode 100644 HasControl.cs
create mode 100644 Head.cs
create mode 100644 HeadCollisionHandler.cs
create mode 100644 Hip.cs
create mode 100644 HoldableObject.cs
create mode 100644 Holding.cs
create mode 100644 HoldingBaseTransform.cs
create mode 100644 InfoBubble.cs
create mode 100644 InputHandler.cs
create mode 100644 KneeLeft.cs
create mode 100644 KneeRight.cs
create mode 100644 Landfall.Network/LoginInformation.cs
create mode 100644 Landfall.Network/NetworkController.cs
create mode 100644 Landfall.Network/NetworkManager.cs
create mode 100644 Landfall.Network/PacketType.cs
create mode 100644 Landfall.Network/Player.cs
create mode 100644 LeftHandPos.cs
create mode 100644 LegLeft.cs
create mode 100644 LegRight.cs
create mode 100644 LookAtVelocity.cs
create mode 100644 MipTexMap.cs
create mode 100644 MouseLook.cs
create mode 100644 MouseOrbitCS.cs
create mode 100644 MoveRig.cs
create mode 100644 MoveTransform.cs
create mode 100644 MovementDataHandler.cs
create mode 100644 MovementHandler.cs
create mode 100644 MovementRig.cs
create mode 100644 Neck.cs
create mode 100644 NetPlayer.cs
create mode 100644 PID.cs
create mode 100644 ParticleParent.cs
create mode 100644 PhysicsAnimation.cs
create mode 100644 PhysicsLerpBackToStart.cs
create mode 100644 Pickup.cs
create mode 100644 PickupHandler.cs
create mode 100644 Player.cs
create mode 100644 PlayerDeath.cs
create mode 100644 PlayerKnockback.cs
create mode 100644 ProjectileHit.cs
create mode 100644 ProjectileHitSpawn.cs
create mode 100644 Properties/AssemblyInfo.cs
create mode 100644 RTPColorChannels.cs
create mode 100644 RTPFogType.cs
create mode 100644 RTPLodLevel.cs
create mode 100644 RTPObjExporter.cs
create mode 100644 RTPTangentSolver.cs
create mode 100644 RTP_DeferredParams.cs
create mode 100644 RTP_LODmanager.cs
create mode 100644 RTP_MouseOrbit_DynamicDistance.cs
create mode 100644 RTP_TintDielectricColor.cs
create mode 100644 RagdollHandler.cs
create mode 100644 RandomTable.cs
create mode 100644 RandomizeRotation.cs
create mode 100644 RaycastTrail.cs
create mode 100644 Recoil.cs
create mode 100644 ReliefShaders_applyLightForDeferred.cs
create mode 100644 ReliefTerrain.cs
create mode 100644 ReliefTerrainControlTexturesItems.cs
create mode 100644 ReliefTerrainDerivedTexturesItems.cs
create mode 100644 ReliefTerrainGlobalSettingsHolder.cs
create mode 100644 ReliefTerrainMenuItems.cs
create mode 100644 ReliefTerrainPresetHolder.cs
create mode 100644 ReliefTerrainSettingsItems.cs
create mode 100644 ReliefTerrainVertexBlendTriplanar.cs
create mode 100644 RemoveAfterSeconds.cs
create mode 100644 RemoveMouse.cs
create mode 100644 ResolveHoleCollision.cs
create mode 100644 ResolveHoleCollisionMultiple.cs
create mode 100644 RestartOnR.cs
create mode 100644 RightHandPos.cs
create mode 100644 RigidbodyHolder.cs
create mode 100644 RigidbodyMovment.cs
create mode 100644 RotateByKeyboardInput.cs
create mode 100644 RotateByMouseInput.cs
create mode 100644 RotationHandler.cs
create mode 100644 RotationTarget.cs
create mode 100644 RuntimeDecalCombiner.cs
create mode 100644 SFXPlayer.cs
create mode 100644 ScreenShakeByCollision.cs
create mode 100644 SelectorHelperClass.cs
create mode 100644 SetAnimationByInput.cs
create mode 100644 SetAnimationByVelocity.cs
create mode 100644 SetInertiaTension.cs
create mode 100644 SetMainCamera.cs
create mode 100644 SetRigidbodySettings.cs
create mode 100644 SetWobblerIfHeld.cs
create mode 100644 ShootPosition.cs
create mode 100644 Slither.cs
create mode 100644 SnakeAI.cs
create mode 100644 SparksExecutioner.cs
create mode 100644 SpawnerHolder.cs
create mode 100644 SquaredDrag.cs
create mode 100644 StabilizeRigidbody.cs
create mode 100644 Standing.cs
create mode 100644 StandingDataHandler.cs
create mode 100644 StartRotation.cs
create mode 100644 StayInPlace.cs
create mode 100644 Step.cs
create mode 100644 StepHandler.cs
create mode 100644 Strength.cs
create mode 100644 SyncCausticsWaterLevel.cs
create mode 100644 TMPro/TMP_DigitValidator.cs
create mode 100644 TMPro/TMP_TextEventHandler.cs
create mode 100644 TerrainShaderLod.cs
create mode 100644 TimeTrail.cs
create mode 100644 Torso.cs
create mode 100644 TransformVelocity.cs
create mode 100644 UnityEngine.PostProcessing/AmbientOcclusionComponent.cs
create mode 100644 UnityEngine.PostProcessing/AmbientOcclusionModel.cs
create mode 100644 UnityEngine.PostProcessing/AntialiasingModel.cs
create mode 100644 UnityEngine.PostProcessing/BloomComponent.cs
create mode 100644 UnityEngine.PostProcessing/BloomModel.cs
create mode 100644 UnityEngine.PostProcessing/BuiltinDebugViewsComponent.cs
create mode 100644 UnityEngine.PostProcessing/BuiltinDebugViewsModel.cs
create mode 100644 UnityEngine.PostProcessing/ChromaticAberrationComponent.cs
create mode 100644 UnityEngine.PostProcessing/ChromaticAberrationModel.cs
create mode 100644 UnityEngine.PostProcessing/ColorGradingComponent.cs
create mode 100644 UnityEngine.PostProcessing/ColorGradingCurve.cs
create mode 100644 UnityEngine.PostProcessing/ColorGradingModel.cs
create mode 100644 UnityEngine.PostProcessing/DepthOfFieldComponent.cs
create mode 100644 UnityEngine.PostProcessing/DepthOfFieldModel.cs
create mode 100644 UnityEngine.PostProcessing/DitheringComponent.cs
create mode 100644 UnityEngine.PostProcessing/DitheringModel.cs
create mode 100644 UnityEngine.PostProcessing/EyeAdaptationComponent.cs
create mode 100644 UnityEngine.PostProcessing/EyeAdaptationModel.cs
create mode 100644 UnityEngine.PostProcessing/FogComponent.cs
create mode 100644 UnityEngine.PostProcessing/FogModel.cs
create mode 100644 UnityEngine.PostProcessing/FxaaComponent.cs
create mode 100644 UnityEngine.PostProcessing/GetSetAttribute.cs
create mode 100644 UnityEngine.PostProcessing/GrainComponent.cs
create mode 100644 UnityEngine.PostProcessing/GrainModel.cs
create mode 100644 UnityEngine.PostProcessing/GraphicsUtils.cs
create mode 100644 UnityEngine.PostProcessing/MaterialFactory.cs
create mode 100644 UnityEngine.PostProcessing/MinAttribute.cs
create mode 100644 UnityEngine.PostProcessing/MotionBlurComponent.cs
create mode 100644 UnityEngine.PostProcessing/MotionBlurModel.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingBehaviour.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingComponent.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingComponentBase.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingComponentCommandBuffer.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingComponentRenderTexture.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingContext.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingModel.cs
create mode 100644 UnityEngine.PostProcessing/PostProcessingProfile.cs
create mode 100644 UnityEngine.PostProcessing/RenderTextureFactory.cs
create mode 100644 UnityEngine.PostProcessing/ScreenSpaceReflectionComponent.cs
create mode 100644 UnityEngine.PostProcessing/ScreenSpaceReflectionModel.cs
create mode 100644 UnityEngine.PostProcessing/TaaComponent.cs
create mode 100644 UnityEngine.PostProcessing/TrackballAttribute.cs
create mode 100644 UnityEngine.PostProcessing/TrackballGroupAttribute.cs
create mode 100644 UnityEngine.PostProcessing/UserLutComponent.cs
create mode 100644 UnityEngine.PostProcessing/UserLutModel.cs
create mode 100644 UnityEngine.PostProcessing/VignetteComponent.cs
create mode 100644 UnityEngine.PostProcessing/VignetteModel.cs
create mode 100644 UnitySA.Characters.FirstPerson/FPCtrl.cs
create mode 100644 UnitySA.Characters.FirstPerson/MLook.cs
create mode 100644 UnitySA.Utility/CurveCtrlBob.cs
create mode 100644 UnitySA.Utility/FOVZoom.cs
create mode 100644 UnitySA.Utility/LerpCtrlBob.cs
create mode 100644 Weapon.cs
create mode 100644 WeaponHandler.cs
create mode 100644 Wheel.cs
create mode 100644 WheelVisualizer.cs
create mode 100644 WobbleShake.cs
create mode 100644 _appControlerShaderOnTriplanarMesh.cs
create mode 100644 _appControlerTerrain.cs
create mode 100644 _appControlerTerrain2Geometry.cs
create mode 100644 ch.sycoforge.Decal.Demo/AdvancedBulletHoles.cs
create mode 100644 ch.sycoforge.Decal.Demo/BasicBulletHoles.cs
create mode 100644 ch.sycoforge.Decal.Demo/BezierUtil.cs
create mode 100644 ch.sycoforge.Decal.Demo/LineUtil.cs
create mode 100644 ch.sycoforge.Decal.Demo/PathAgent.cs
create mode 100644 ch.sycoforge.Decal.Demo/ProxyRegister.cs
create mode 100644 ch.sycoforge.Decal.Demo/Sinoid.cs
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a4da27a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,399 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.vs
diff --git a/ADS.cs b/ADS.cs
new file mode 100644
index 0000000..d20136e
--- /dev/null
+++ b/ADS.cs
@@ -0,0 +1,49 @@
+using System.Collections;
+using UnityEngine;
+
+public class ADS : MonoBehaviour
+{
+ public Vector3 recoilMovement;
+
+ public Vector3 randomRecoilMovement;
+
+ public AnimationCurve curve;
+
+ public float animationSpeed = 1f;
+
+ private Vector3 startPosition;
+
+ private void Start()
+ {
+ startPosition = base.transform.localPosition;
+ }
+
+ private void Update()
+ {
+ }
+
+ public void PlayRecoilAnimation()
+ {
+ StartCoroutine(ApplyRecoil());
+ }
+
+ private IEnumerator ApplyRecoil()
+ {
+ float counter = 0f;
+ float lastValue = curve.Evaluate(0f);
+ float animtionTime = curve.keys[curve.length - 1].time;
+ Vector3 v = recoilMovement + new Vector3(Random.Range(0f - randomRecoilMovement.x, randomRecoilMovement.x), Random.Range(0f - randomRecoilMovement.y, randomRecoilMovement.y), Random.Range(0f - randomRecoilMovement.z, randomRecoilMovement.z));
+ while (counter < animtionTime)
+ {
+ counter += Time.deltaTime * animationSpeed;
+ if (counter > animtionTime)
+ {
+ counter = animtionTime;
+ }
+ float deltaForce = curve.Evaluate(counter) - lastValue;
+ lastValue = curve.Evaluate(counter);
+ base.transform.localPosition += deltaForce * v * 0.001f;
+ yield return null;
+ }
+ }
+}
diff --git a/AddCameraMovementByRig.cs b/AddCameraMovementByRig.cs
new file mode 100644
index 0000000..905b69a
--- /dev/null
+++ b/AddCameraMovementByRig.cs
@@ -0,0 +1,31 @@
+using UnityEngine;
+
+public class AddCameraMovementByRig : MonoBehaviour
+{
+ public Rigidbody rig;
+
+ public float movementMultiplier = 1f;
+
+ public float returnForce;
+
+ public float rigForce;
+
+ public float friction = 0.97f;
+
+ private Vector3 velocity;
+
+ private Vector3 startPos;
+
+ private void Start()
+ {
+ startPos = base.transform.localPosition;
+ }
+
+ private void FixedUpdate()
+ {
+ velocity -= rig.velocity * rigForce;
+ velocity += (base.transform.parent.TransformPoint(startPos) - base.transform.position) * returnForce;
+ velocity *= friction;
+ base.transform.position += velocity * movementMultiplier;
+ }
+}
diff --git a/AddForceByCollision.cs b/AddForceByCollision.cs
new file mode 100644
index 0000000..8392efa
--- /dev/null
+++ b/AddForceByCollision.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+
+public class AddForceByCollision : MonoBehaviour
+{
+ public Rigidbody rig;
+
+ public float amout;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+
+ private void OnCollisionEnter(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void OnCollisionStay(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void Collide(Collision collision)
+ {
+ if (collision.gameObject.layer == 9)
+ {
+ rig.AddForce(collision.contacts[0].normal * collision.impactForceSum.magnitude * amout, ForceMode.Acceleration);
+ }
+ }
+}
diff --git a/AddForceToTarget.cs b/AddForceToTarget.cs
new file mode 100644
index 0000000..9464c97
--- /dev/null
+++ b/AddForceToTarget.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+
+public class AddForceToTarget : MonoBehaviour
+{
+ public AnimationCurve forceByRangeCurve;
+
+ public Rigidbody target;
+
+ public float force;
+
+ private Transform head;
+
+ private void Start()
+ {
+ head = GetComponentInChildren
().transform;
+ }
+
+ private void FixedUpdate()
+ {
+ float num = forceByRangeCurve.Evaluate(Vector3.Distance(head.position, target.position)) * force;
+ if (num > 0f)
+ {
+ target.AddForce((head.position - target.position).normalized * num, ForceMode.Force);
+ }
+ }
+}
diff --git a/AddScreenShake.cs b/AddScreenShake.cs
new file mode 100644
index 0000000..1d7a2a4
--- /dev/null
+++ b/AddScreenShake.cs
@@ -0,0 +1,29 @@
+using UnityEngine;
+
+public class AddScreenShake : MonoBehaviour
+{
+ public float friction = 0.75f;
+
+ public Vector3 shake = Vector2.zero;
+
+ public Vector3 additionalRandom = Vector3.zero;
+
+ [HideInInspector]
+ public WobbleShake wobbleShake;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+
+ public void DoShake()
+ {
+ if ((bool)wobbleShake)
+ {
+ wobbleShake.AddShake(new Vector3(shake.x + Random.Range(0f - additionalRandom.x, additionalRandom.x), shake.y + Random.Range(0f - additionalRandom.y, additionalRandom.y), shake.z + Random.Range(0f - additionalRandom.z, additionalRandom.z)), friction);
+ }
+ }
+}
diff --git a/AmplifyOcclusion/VersionInfo.cs b/AmplifyOcclusion/VersionInfo.cs
new file mode 100644
index 0000000..c460b70
--- /dev/null
+++ b/AmplifyOcclusion/VersionInfo.cs
@@ -0,0 +1,61 @@
+using System;
+using UnityEngine;
+
+namespace AmplifyOcclusion;
+
+[Serializable]
+public class VersionInfo
+{
+ public const byte Major = 1;
+
+ public const byte Minor = 2;
+
+ public const byte Release = 3;
+
+ private static string StageSuffix = "_dev001";
+
+ [SerializeField]
+ private int m_major;
+
+ [SerializeField]
+ private int m_minor;
+
+ [SerializeField]
+ private int m_release;
+
+ public int Number => m_major * 100 + m_minor * 10 + m_release;
+
+ private VersionInfo()
+ {
+ m_major = 1;
+ m_minor = 2;
+ m_release = 3;
+ }
+
+ private VersionInfo(byte major, byte minor, byte release)
+ {
+ m_major = major;
+ m_minor = minor;
+ m_release = release;
+ }
+
+ public static string StaticToString()
+ {
+ return $"{(byte)1}.{(byte)2}.{(byte)3}" + StageSuffix;
+ }
+
+ public override string ToString()
+ {
+ return $"{m_major}.{m_minor}.{m_release}" + StageSuffix;
+ }
+
+ public static VersionInfo Current()
+ {
+ return new VersionInfo(1, 2, 3);
+ }
+
+ public static bool Matches(VersionInfo version)
+ {
+ return version.m_major == 1 && version.m_minor == 2 && 3 == version.m_release;
+ }
+}
diff --git a/AmplifyOcclusionBase.cs b/AmplifyOcclusionBase.cs
new file mode 100644
index 0000000..e429102
--- /dev/null
+++ b/AmplifyOcclusionBase.cs
@@ -0,0 +1,951 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+[AddComponentMenu("")]
+public class AmplifyOcclusionBase : MonoBehaviour
+{
+ public enum ApplicationMethod
+ {
+ PostEffect,
+ Deferred,
+ Debug
+ }
+
+ public enum PerPixelNormalSource
+ {
+ None,
+ Camera,
+ GBuffer,
+ GBufferOctaEncoded
+ }
+
+ public enum SampleCountLevel
+ {
+ Low,
+ Medium,
+ High,
+ VeryHigh
+ }
+
+ private static class ShaderPass
+ {
+ public const int FullDepth = 0;
+
+ public const int FullNormal_None = 1;
+
+ public const int FullNormal_Camera = 2;
+
+ public const int FullNormal_GBuffer = 3;
+
+ public const int FullNormal_GBufferOctaEncoded = 4;
+
+ public const int DeinterleaveDepth1 = 5;
+
+ public const int DeinterleaveNormal1_None = 6;
+
+ public const int DeinterleaveNormal1_Camera = 7;
+
+ public const int DeinterleaveNormal1_GBuffer = 8;
+
+ public const int DeinterleaveNormal1_GBufferOctaEncoded = 9;
+
+ public const int DeinterleaveDepth4 = 10;
+
+ public const int DeinterleaveNormal4_None = 11;
+
+ public const int DeinterleaveNormal4_Camera = 12;
+
+ public const int DeinterleaveNormal4_GBuffer = 13;
+
+ public const int DeinterleaveNormal4_GBufferOctaEncoded = 14;
+
+ public const int OcclusionCache_Low = 15;
+
+ public const int OcclusionCache_Medium = 16;
+
+ public const int OcclusionCache_High = 17;
+
+ public const int OcclusionCache_VeryHigh = 18;
+
+ public const int Reinterleave = 19;
+
+ public const int OcclusionLow_None = 20;
+
+ public const int OcclusionLow_Camera = 21;
+
+ public const int OcclusionLow_GBuffer = 22;
+
+ public const int OcclusionLow_GBufferOctaEncoded = 23;
+
+ public const int OcclusionMedium_None = 24;
+
+ public const int OcclusionMedium_Camera = 25;
+
+ public const int OcclusionMedium_GBuffer = 26;
+
+ public const int OcclusionMedium_GBufferOctaEncoded = 27;
+
+ public const int OcclusionHigh_None = 28;
+
+ public const int OcclusionHigh_Camera = 29;
+
+ public const int OcclusionHigh_GBuffer = 30;
+
+ public const int OcclusionHigh_GBufferOctaEncoded = 31;
+
+ public const int OcclusionVeryHigh_None = 32;
+
+ public const int OcclusionVeryHigh_Camera = 33;
+
+ public const int OcclusionVeryHigh_GBuffer = 34;
+
+ public const int OcclusionVeryHigh_GBufferNormalEncoded = 35;
+
+ public const int ApplyDebug = 36;
+
+ public const int ApplyDeferred = 37;
+
+ public const int ApplyDeferredLog = 38;
+
+ public const int ApplyPostEffect = 39;
+
+ public const int ApplyPostEffectLog = 40;
+
+ public const int CombineDownsampledOcclusionDepth = 41;
+
+ public const int BlurHorizontal1 = 0;
+
+ public const int BlurVertical1 = 1;
+
+ public const int BlurHorizontal2 = 2;
+
+ public const int BlurVertical2 = 3;
+
+ public const int BlurHorizontal3 = 4;
+
+ public const int BlurVertical3 = 5;
+
+ public const int BlurHorizontal4 = 6;
+
+ public const int BlurVertical4 = 7;
+
+ public const int Copy = 0;
+ }
+
+ private struct TargetDesc
+ {
+ public int fullWidth;
+
+ public int fullHeight;
+
+ public RenderTextureFormat format;
+
+ public int width;
+
+ public int height;
+
+ public int quarterWidth;
+
+ public int quarterHeight;
+
+ public float padRatioWidth;
+
+ public float padRatioHeight;
+ }
+
+ [Header("Ambient Occlusion")]
+ public ApplicationMethod ApplyMethod;
+
+ public SampleCountLevel SampleCount = SampleCountLevel.Medium;
+
+ public PerPixelNormalSource PerPixelNormals;
+
+ [Range(0f, 1f)]
+ public float Intensity = 1f;
+
+ public Color Tint = Color.black;
+
+ [Range(0f, 16f)]
+ public float Radius = 1f;
+
+ [Range(0f, 16f)]
+ public float PowerExponent = 1.8f;
+
+ [Range(0f, 0.99f)]
+ public float Bias = 0.05f;
+
+ public bool CacheAware;
+
+ public bool Downsample;
+
+ [Header("Distance Fade")]
+ public bool FadeEnabled;
+
+ public float FadeStart = 100f;
+
+ public float FadeLength = 50f;
+
+ [Range(0f, 1f)]
+ public float FadeToIntensity = 1f;
+
+ [Range(0f, 16f)]
+ public float FadeToRadius = 1f;
+
+ [Range(0f, 16f)]
+ public float FadeToPowerExponent = 1.8f;
+
+ [Header("Bilateral Blur")]
+ public bool BlurEnabled = true;
+
+ [Range(1f, 4f)]
+ public int BlurRadius = 2;
+
+ [Range(1f, 4f)]
+ public int BlurPasses = 1;
+
+ [Range(0f, 20f)]
+ public float BlurSharpness = 10f;
+
+ private const int PerPixelNormalSourceCount = 4;
+
+ private int prevScreenWidth;
+
+ private int prevScreenHeight;
+
+ private bool prevHDR;
+
+ private ApplicationMethod prevApplyMethod;
+
+ private SampleCountLevel prevSampleCount;
+
+ private PerPixelNormalSource prevPerPixelNormals;
+
+ private bool prevCacheAware;
+
+ private bool prevDownscale;
+
+ private bool prevFadeEnabled;
+
+ private float prevFadeToIntensity;
+
+ private float prevFadeToRadius;
+
+ private float prevFadeToPowerExponent;
+
+ private float prevFadeStart;
+
+ private float prevFadeLength;
+
+ private bool prevBlurEnabled;
+
+ private int prevBlurRadius;
+
+ private int prevBlurPasses;
+
+ private Camera m_camera;
+
+ private Material m_occlusionMat;
+
+ private Material m_blurMat;
+
+ private Material m_copyMat;
+
+ private const int RandomSize = 4;
+
+ private const int DirectionCount = 8;
+
+ private Color[] m_randomData;
+
+ private Texture2D m_randomTex;
+
+ private string[] m_layerOffsetNames;
+
+ private string[] m_layerRandomNames;
+
+ private string[] m_layerDepthNames;
+
+ private string[] m_layerNormalNames;
+
+ private string[] m_layerOcclusionNames;
+
+ private RenderTextureFormat m_depthRTFormat = RenderTextureFormat.RFloat;
+
+ private RenderTextureFormat m_normalRTFormat = RenderTextureFormat.ARGB2101010;
+
+ private RenderTextureFormat m_occlusionRTFormat = RenderTextureFormat.RGHalf;
+
+ private RenderTexture m_occlusionRT;
+
+ private int[] m_depthLayerRT;
+
+ private int[] m_normalLayerRT;
+
+ private int[] m_occlusionLayerRT;
+
+ private int m_mrtCount;
+
+ private RenderTargetIdentifier[] m_depthTargets;
+
+ private RenderTargetIdentifier[] m_normalTargets;
+
+ private int m_deinterleaveDepthPass;
+
+ private int m_deinterleaveNormalPass;
+
+ private RenderTargetIdentifier[] m_applyDeferredTargets;
+
+ private Mesh m_blitMesh;
+
+ private TargetDesc m_target = default(TargetDesc);
+
+ private Dictionary m_registeredCommandBuffers = new Dictionary();
+
+ private bool CheckParamsChanged()
+ {
+ return prevScreenWidth != m_camera.pixelWidth || prevScreenHeight != m_camera.pixelHeight || prevHDR != m_camera.allowHDR || prevApplyMethod != ApplyMethod || prevSampleCount != SampleCount || prevPerPixelNormals != PerPixelNormals || prevCacheAware != CacheAware || prevDownscale != Downsample || prevFadeEnabled != FadeEnabled || prevFadeToIntensity != FadeToIntensity || prevFadeToRadius != FadeToRadius || prevFadeToPowerExponent != FadeToPowerExponent || prevFadeStart != FadeStart || prevFadeLength != FadeLength || prevBlurEnabled != BlurEnabled || prevBlurRadius != BlurRadius || prevBlurPasses != BlurPasses;
+ }
+
+ private void UpdateParams()
+ {
+ prevScreenWidth = m_camera.pixelWidth;
+ prevScreenHeight = m_camera.pixelHeight;
+ prevHDR = m_camera.allowHDR;
+ prevApplyMethod = ApplyMethod;
+ prevSampleCount = SampleCount;
+ prevPerPixelNormals = PerPixelNormals;
+ prevCacheAware = CacheAware;
+ prevDownscale = Downsample;
+ prevFadeEnabled = FadeEnabled;
+ prevFadeToIntensity = FadeToIntensity;
+ prevFadeToRadius = FadeToRadius;
+ prevFadeToPowerExponent = FadeToPowerExponent;
+ prevFadeStart = FadeStart;
+ prevFadeLength = FadeLength;
+ prevBlurEnabled = BlurEnabled;
+ prevBlurRadius = BlurRadius;
+ prevBlurPasses = BlurPasses;
+ }
+
+ private void Warmup()
+ {
+ CheckMaterial();
+ CheckRandomData();
+ m_depthLayerRT = new int[16];
+ m_normalLayerRT = new int[16];
+ m_occlusionLayerRT = new int[16];
+ m_mrtCount = Mathf.Min(SystemInfo.supportedRenderTargetCount, 4);
+ m_layerOffsetNames = new string[m_mrtCount];
+ m_layerRandomNames = new string[m_mrtCount];
+ for (int i = 0; i < m_mrtCount; i++)
+ {
+ m_layerOffsetNames[i] = "_AO_LayerOffset" + i;
+ m_layerRandomNames[i] = "_AO_LayerRandom" + i;
+ }
+ m_layerDepthNames = new string[16];
+ m_layerNormalNames = new string[16];
+ m_layerOcclusionNames = new string[16];
+ for (int j = 0; j < 16; j++)
+ {
+ m_layerDepthNames[j] = "_AO_DepthLayer" + j;
+ m_layerNormalNames[j] = "_AO_NormalLayer" + j;
+ m_layerOcclusionNames[j] = "_AO_OcclusionLayer" + j;
+ }
+ m_depthTargets = new RenderTargetIdentifier[m_mrtCount];
+ m_normalTargets = new RenderTargetIdentifier[m_mrtCount];
+ int mrtCount = m_mrtCount;
+ if (mrtCount == 4)
+ {
+ m_deinterleaveDepthPass = 10;
+ m_deinterleaveNormalPass = 11;
+ }
+ else
+ {
+ m_deinterleaveDepthPass = 5;
+ m_deinterleaveNormalPass = 6;
+ }
+ m_applyDeferredTargets = new RenderTargetIdentifier[2];
+ if (m_blitMesh != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_blitMesh);
+ }
+ m_blitMesh = new Mesh();
+ m_blitMesh.vertices = new Vector3[4]
+ {
+ new Vector3(0f, 0f, 0f),
+ new Vector3(0f, 1f, 0f),
+ new Vector3(1f, 1f, 0f),
+ new Vector3(1f, 0f, 0f)
+ };
+ m_blitMesh.uv = new Vector2[4]
+ {
+ new Vector2(0f, 0f),
+ new Vector2(0f, 1f),
+ new Vector2(1f, 1f),
+ new Vector2(1f, 0f)
+ };
+ m_blitMesh.triangles = new int[6] { 0, 1, 2, 0, 2, 3 };
+ }
+
+ private void Shutdown()
+ {
+ CommandBuffer_UnregisterAll();
+ SafeReleaseRT(ref m_occlusionRT);
+ if (m_occlusionMat != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_occlusionMat);
+ }
+ if (m_blurMat != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_blurMat);
+ }
+ if (m_copyMat != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_copyMat);
+ }
+ if (m_blitMesh != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_blitMesh);
+ }
+ }
+
+ private bool CheckRenderTextureFormats()
+ {
+ if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB32) && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
+ {
+ m_depthRTFormat = RenderTextureFormat.RFloat;
+ if (!SystemInfo.SupportsRenderTextureFormat(m_depthRTFormat))
+ {
+ m_depthRTFormat = RenderTextureFormat.RHalf;
+ if (!SystemInfo.SupportsRenderTextureFormat(m_depthRTFormat))
+ {
+ m_depthRTFormat = RenderTextureFormat.ARGBHalf;
+ }
+ }
+ m_normalRTFormat = RenderTextureFormat.ARGB2101010;
+ if (!SystemInfo.SupportsRenderTextureFormat(m_normalRTFormat))
+ {
+ m_normalRTFormat = RenderTextureFormat.ARGB32;
+ }
+ m_occlusionRTFormat = RenderTextureFormat.RGHalf;
+ if (!SystemInfo.SupportsRenderTextureFormat(m_occlusionRTFormat))
+ {
+ m_occlusionRTFormat = RenderTextureFormat.RGFloat;
+ if (!SystemInfo.SupportsRenderTextureFormat(m_occlusionRTFormat))
+ {
+ m_occlusionRTFormat = RenderTextureFormat.ARGBHalf;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private void OnEnable()
+ {
+ if (!CheckRenderTextureFormats())
+ {
+ Debug.LogError("[AmplifyOcclusion] Target platform does not meet the minimum requirements for this effect to work properly.");
+ base.enabled = false;
+ }
+ else
+ {
+ m_camera = GetComponent();
+ Warmup();
+ CommandBuffer_UnregisterAll();
+ }
+ }
+
+ private void OnDisable()
+ {
+ Shutdown();
+ }
+
+ private void OnDestroy()
+ {
+ Shutdown();
+ }
+
+ private void Update()
+ {
+ if (m_camera.actualRenderingPath != RenderingPath.DeferredShading)
+ {
+ if (PerPixelNormals != 0 && PerPixelNormals != PerPixelNormalSource.Camera)
+ {
+ PerPixelNormals = PerPixelNormalSource.Camera;
+ Debug.LogWarning("[AmplifyOcclusion] GBuffer Normals only available in Camera Deferred Shading mode. Switched to Camera source.");
+ }
+ if (ApplyMethod == ApplicationMethod.Deferred)
+ {
+ ApplyMethod = ApplicationMethod.PostEffect;
+ Debug.LogWarning("[AmplifyOcclusion] Deferred Method requires a Deferred Shading path. Switching to Post Effect Method.");
+ }
+ }
+ if (ApplyMethod == ApplicationMethod.Deferred && PerPixelNormals == PerPixelNormalSource.Camera)
+ {
+ PerPixelNormals = PerPixelNormalSource.GBuffer;
+ Debug.LogWarning("[AmplifyOcclusion] Camera Normals not supported for Deferred Method. Switching to GBuffer Normals.");
+ }
+ if ((m_camera.depthTextureMode & DepthTextureMode.Depth) == 0)
+ {
+ m_camera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+ if (PerPixelNormals == PerPixelNormalSource.Camera && (m_camera.depthTextureMode & DepthTextureMode.DepthNormals) == 0)
+ {
+ m_camera.depthTextureMode |= DepthTextureMode.DepthNormals;
+ }
+ CheckMaterial();
+ CheckRandomData();
+ }
+
+ private void CheckMaterial()
+ {
+ if (m_occlusionMat == null)
+ {
+ m_occlusionMat = new Material(Shader.Find("Hidden/Amplify Occlusion/Occlusion"))
+ {
+ hideFlags = HideFlags.DontSave
+ };
+ }
+ if (m_blurMat == null)
+ {
+ m_blurMat = new Material(Shader.Find("Hidden/Amplify Occlusion/Blur"))
+ {
+ hideFlags = HideFlags.DontSave
+ };
+ }
+ if (m_copyMat == null)
+ {
+ m_copyMat = new Material(Shader.Find("Hidden/Amplify Occlusion/Copy"))
+ {
+ hideFlags = HideFlags.DontSave
+ };
+ }
+ }
+
+ private void CheckRandomData()
+ {
+ if (m_randomData == null)
+ {
+ m_randomData = GenerateRandomizationData();
+ }
+ if (m_randomTex == null)
+ {
+ m_randomTex = Resources.Load("Random4x4");
+ }
+ }
+
+ public static Color[] GenerateRandomizationData()
+ {
+ Color[] array = new Color[16];
+ int i = 0;
+ int num = 0;
+ for (; i < 16; i++)
+ {
+ float num2 = RandomTable.Values[num++];
+ float b = RandomTable.Values[num++];
+ float f = (float)Math.PI * 2f * num2 / 8f;
+ array[i].r = Mathf.Cos(f);
+ array[i].g = Mathf.Sin(f);
+ array[i].b = b;
+ array[i].a = 0f;
+ }
+ return array;
+ }
+
+ public static Texture2D GenerateRandomizationTexture(Color[] randomPixels)
+ {
+ Texture2D texture2D = new Texture2D(4, 4, TextureFormat.ARGB32, mipmap: false, linear: true);
+ texture2D.hideFlags = HideFlags.DontSave;
+ Texture2D texture2D2 = texture2D;
+ texture2D2.name = "RandomTexture";
+ texture2D2.filterMode = FilterMode.Point;
+ texture2D2.wrapMode = TextureWrapMode.Repeat;
+ texture2D2.SetPixels(randomPixels);
+ texture2D2.Apply();
+ return texture2D2;
+ }
+
+ private RenderTexture SafeAllocateRT(string name, int width, int height, RenderTextureFormat format, RenderTextureReadWrite readWrite)
+ {
+ width = Mathf.Max(width, 1);
+ height = Mathf.Max(height, 1);
+ RenderTexture renderTexture = new RenderTexture(width, height, 0, format, readWrite);
+ renderTexture.hideFlags = HideFlags.DontSave;
+ RenderTexture renderTexture2 = renderTexture;
+ renderTexture2.name = name;
+ renderTexture2.filterMode = FilterMode.Point;
+ renderTexture2.wrapMode = TextureWrapMode.Clamp;
+ renderTexture2.Create();
+ return renderTexture2;
+ }
+
+ private void SafeReleaseRT(ref RenderTexture rt)
+ {
+ if (rt != null)
+ {
+ RenderTexture.active = null;
+ rt.Release();
+ UnityEngine.Object.DestroyImmediate(rt);
+ rt = null;
+ }
+ }
+
+ private int SafeAllocateTemporaryRT(CommandBuffer cb, string propertyName, int width, int height, RenderTextureFormat format = RenderTextureFormat.Default, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default, FilterMode filterMode = FilterMode.Point)
+ {
+ int num = Shader.PropertyToID(propertyName);
+ cb.GetTemporaryRT(num, width, height, 0, filterMode, format, readWrite);
+ return num;
+ }
+
+ private void SafeReleaseTemporaryRT(CommandBuffer cb, int id)
+ {
+ cb.ReleaseTemporaryRT(id);
+ }
+
+ private void SetBlitTarget(CommandBuffer cb, RenderTargetIdentifier[] targets, int targetWidth, int targetHeight)
+ {
+ cb.SetGlobalVector("_AO_Target_TexelSize", new Vector4(1f / (float)targetWidth, 1f / (float)targetHeight, targetWidth, targetHeight));
+ cb.SetGlobalVector("_AO_Target_Position", Vector2.zero);
+ cb.SetRenderTarget(targets, targets[0]);
+ }
+
+ private void SetBlitTarget(CommandBuffer cb, RenderTargetIdentifier target, int targetWidth, int targetHeight)
+ {
+ cb.SetGlobalVector("_AO_Target_TexelSize", new Vector4(1f / (float)targetWidth, 1f / (float)targetHeight, targetWidth, targetHeight));
+ cb.SetRenderTarget(target);
+ }
+
+ private void PerformBlit(CommandBuffer cb, Material mat, int pass)
+ {
+ cb.DrawMesh(m_blitMesh, Matrix4x4.identity, mat, 0, pass);
+ }
+
+ private void PerformBlit(CommandBuffer cb, Material mat, int pass, int x, int y)
+ {
+ cb.SetGlobalVector("_AO_Target_Position", new Vector2(x, y));
+ PerformBlit(cb, mat, pass);
+ }
+
+ private void PerformBlit(CommandBuffer cb, RenderTargetIdentifier source, int sourceWidth, int sourceHeight, Material mat, int pass)
+ {
+ cb.SetGlobalTexture("_AO_Source", source);
+ cb.SetGlobalVector("_AO_Source_TexelSize", new Vector4(1f / (float)sourceWidth, 1f / (float)sourceHeight, sourceWidth, sourceHeight));
+ PerformBlit(cb, mat, pass);
+ }
+
+ private void PerformBlit(CommandBuffer cb, RenderTargetIdentifier source, int sourceWidth, int sourceHeight, Material mat, int pass, int x, int y)
+ {
+ cb.SetGlobalVector("_AO_Target_Position", new Vector2(x, y));
+ PerformBlit(cb, source, sourceWidth, sourceHeight, mat, pass);
+ }
+
+ private CommandBuffer CommandBuffer_Allocate(string name)
+ {
+ CommandBuffer commandBuffer = new CommandBuffer();
+ commandBuffer.name = name;
+ return commandBuffer;
+ }
+
+ private void CommandBuffer_Register(CameraEvent cameraEvent, CommandBuffer commandBuffer)
+ {
+ m_camera.AddCommandBuffer(cameraEvent, commandBuffer);
+ m_registeredCommandBuffers.Add(cameraEvent, commandBuffer);
+ }
+
+ private void CommandBuffer_Unregister(CameraEvent cameraEvent, CommandBuffer commandBuffer)
+ {
+ if (!(m_camera != null))
+ {
+ return;
+ }
+ CommandBuffer[] commandBuffers = m_camera.GetCommandBuffers(cameraEvent);
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer2 in array)
+ {
+ if (commandBuffer2.name == commandBuffer.name)
+ {
+ m_camera.RemoveCommandBuffer(cameraEvent, commandBuffer2);
+ }
+ }
+ }
+
+ private CommandBuffer CommandBuffer_AllocateRegister(CameraEvent cameraEvent)
+ {
+ string text = string.Empty;
+ switch (cameraEvent)
+ {
+ case CameraEvent.BeforeReflections:
+ text = "AO-BeforeRefl";
+ break;
+ case CameraEvent.AfterLighting:
+ text = "AO-AfterLighting";
+ break;
+ case CameraEvent.BeforeImageEffectsOpaque:
+ text = "AO-BeforePostOpaque";
+ break;
+ default:
+ Debug.LogError("[AmplifyOcclusion] Unsupported CameraEvent. Please contact support.");
+ break;
+ }
+ CommandBuffer commandBuffer = CommandBuffer_Allocate(text);
+ CommandBuffer_Register(cameraEvent, commandBuffer);
+ return commandBuffer;
+ }
+
+ private void CommandBuffer_UnregisterAll()
+ {
+ foreach (KeyValuePair registeredCommandBuffer in m_registeredCommandBuffers)
+ {
+ CommandBuffer_Unregister(registeredCommandBuffer.Key, registeredCommandBuffer.Value);
+ }
+ m_registeredCommandBuffers.Clear();
+ }
+
+ private void UpdateLocalMaterialConstants()
+ {
+ if (m_occlusionMat != null)
+ {
+ m_occlusionMat.SetTexture("_AO_RandomTexture", m_randomTex);
+ }
+ }
+
+ private void UpdateGlobalShaderConstants(TargetDesc target)
+ {
+ float num = m_camera.fieldOfView * ((float)Math.PI / 180f);
+ Vector2 vector = new Vector2(1f / Mathf.Tan(num * 0.5f) * ((float)target.height / (float)target.width), 1f / Mathf.Tan(num * 0.5f));
+ Vector2 vector2 = new Vector2(1f / vector.x, 1f / vector.y);
+ float num2 = ((!m_camera.orthographic) ? ((float)target.height / (Mathf.Tan(num * 0.5f) * 2f)) : ((float)target.height / m_camera.orthographicSize));
+ float num3 = Mathf.Clamp(Bias, 0f, 1f);
+ FadeStart = Mathf.Max(0f, FadeStart);
+ FadeLength = Mathf.Max(0.01f, FadeLength);
+ float y = ((!FadeEnabled) ? 0f : (1f / FadeLength));
+ Shader.SetGlobalMatrix("_AO_CameraProj", GL.GetGPUProjectionMatrix(Matrix4x4.Ortho(0f, 1f, 0f, 1f, -1f, 100f), renderIntoTexture: false));
+ Shader.SetGlobalMatrix("_AO_CameraView", m_camera.worldToCameraMatrix);
+ Shader.SetGlobalVector("_AO_UVToView", new Vector4(2f * vector2.x, -2f * vector2.y, -1f * vector2.x, 1f * vector2.y));
+ Shader.SetGlobalFloat("_AO_HalfProjScale", 0.5f * num2);
+ Shader.SetGlobalFloat("_AO_Radius", Radius);
+ Shader.SetGlobalFloat("_AO_PowExponent", PowerExponent);
+ Shader.SetGlobalFloat("_AO_Bias", num3);
+ Shader.SetGlobalFloat("_AO_Multiplier", 1f / (1f - num3));
+ Shader.SetGlobalFloat("_AO_BlurSharpness", BlurSharpness);
+ Shader.SetGlobalColor("_AO_Levels", new Color(Tint.r, Tint.g, Tint.b, Intensity));
+ Shader.SetGlobalVector("_AO_FadeParams", new Vector2(FadeStart, y));
+ Shader.SetGlobalVector("_AO_FadeValues", new Vector3(FadeToIntensity, FadeToRadius, FadeToPowerExponent));
+ }
+
+ private void CommandBuffer_FillComputeOcclusion(CommandBuffer cb, TargetDesc target)
+ {
+ CheckMaterial();
+ CheckRandomData();
+ cb.SetGlobalVector("_AO_Buffer_PadScale", new Vector4(target.padRatioWidth, target.padRatioHeight, 1f / target.padRatioWidth, 1f / target.padRatioHeight));
+ cb.SetGlobalVector("_AO_Buffer_TexelSize", new Vector4(1f / (float)target.width, 1f / (float)target.height, target.width, target.height));
+ cb.SetGlobalVector("_AO_QuarterBuffer_TexelSize", new Vector4(1f / (float)target.quarterWidth, 1f / (float)target.quarterHeight, target.quarterWidth, target.quarterHeight));
+ cb.SetGlobalFloat("_AO_MaxRadiusPixels", Mathf.Min(target.width, target.height));
+ if (m_occlusionRT == null || m_occlusionRT.width != target.width || m_occlusionRT.height != target.height || !m_occlusionRT.IsCreated())
+ {
+ SafeReleaseRT(ref m_occlusionRT);
+ m_occlusionRT = SafeAllocateRT("_AO_OcclusionTexture", target.width, target.height, m_occlusionRTFormat, RenderTextureReadWrite.Linear);
+ }
+ int num = -1;
+ if (Downsample)
+ {
+ num = SafeAllocateTemporaryRT(cb, "_AO_SmallOcclusionTexture", target.width / 2, target.height / 2, m_occlusionRTFormat, RenderTextureReadWrite.Linear, FilterMode.Bilinear);
+ }
+ if (CacheAware && !Downsample)
+ {
+ int num2 = SafeAllocateTemporaryRT(cb, "_AO_OcclusionAtlas", target.width, target.height, m_occlusionRTFormat, RenderTextureReadWrite.Linear);
+ for (int i = 0; i < 16; i++)
+ {
+ m_depthLayerRT[i] = SafeAllocateTemporaryRT(cb, m_layerDepthNames[i], target.quarterWidth, target.quarterHeight, m_depthRTFormat, RenderTextureReadWrite.Linear);
+ m_normalLayerRT[i] = SafeAllocateTemporaryRT(cb, m_layerNormalNames[i], target.quarterWidth, target.quarterHeight, m_normalRTFormat, RenderTextureReadWrite.Linear);
+ m_occlusionLayerRT[i] = SafeAllocateTemporaryRT(cb, m_layerOcclusionNames[i], target.quarterWidth, target.quarterHeight, m_occlusionRTFormat, RenderTextureReadWrite.Linear);
+ }
+ for (int j = 0; j < 16; j += m_mrtCount)
+ {
+ for (int k = 0; k < m_mrtCount; k++)
+ {
+ int num3 = k + j;
+ int num4 = num3 & 3;
+ int num5 = num3 >> 2;
+ cb.SetGlobalVector(m_layerOffsetNames[k], new Vector2((float)num4 + 0.5f, (float)num5 + 0.5f));
+ ref RenderTargetIdentifier reference = ref m_depthTargets[k];
+ reference = m_depthLayerRT[num3];
+ ref RenderTargetIdentifier reference2 = ref m_normalTargets[k];
+ reference2 = m_normalLayerRT[num3];
+ }
+ SetBlitTarget(cb, m_depthTargets, target.quarterWidth, target.quarterHeight);
+ PerformBlit(cb, m_occlusionMat, m_deinterleaveDepthPass);
+ SetBlitTarget(cb, m_normalTargets, target.quarterWidth, target.quarterHeight);
+ PerformBlit(cb, m_occlusionMat, (int)(m_deinterleaveNormalPass + PerPixelNormals));
+ }
+ for (int l = 0; l < 16; l++)
+ {
+ cb.SetGlobalVector("_AO_LayerOffset", new Vector2((float)(l & 3) + 0.5f, (float)(l >> 2) + 0.5f));
+ cb.SetGlobalVector("_AO_LayerRandom", m_randomData[l]);
+ cb.SetGlobalTexture("_AO_NormalTexture", m_normalLayerRT[l]);
+ cb.SetGlobalTexture("_AO_DepthTexture", m_depthLayerRT[l]);
+ SetBlitTarget(cb, m_occlusionLayerRT[l], target.quarterWidth, target.quarterHeight);
+ PerformBlit(cb, m_occlusionMat, (int)(15 + SampleCount));
+ }
+ SetBlitTarget(cb, num2, target.width, target.height);
+ for (int m = 0; m < 16; m++)
+ {
+ int x = (m & 3) * target.quarterWidth;
+ int y = (m >> 2) * target.quarterHeight;
+ PerformBlit(cb, m_occlusionLayerRT[m], target.quarterWidth, target.quarterHeight, m_copyMat, 0, x, y);
+ }
+ cb.SetGlobalTexture("_AO_OcclusionAtlas", num2);
+ SetBlitTarget(cb, m_occlusionRT, target.width, target.height);
+ PerformBlit(cb, m_occlusionMat, 19);
+ for (int n = 0; n < 16; n++)
+ {
+ SafeReleaseTemporaryRT(cb, m_occlusionLayerRT[n]);
+ SafeReleaseTemporaryRT(cb, m_normalLayerRT[n]);
+ SafeReleaseTemporaryRT(cb, m_depthLayerRT[n]);
+ }
+ SafeReleaseTemporaryRT(cb, num2);
+ }
+ else
+ {
+ int pass = (int)(20 + (int)SampleCount * 4 + PerPixelNormals);
+ if (Downsample)
+ {
+ cb.Blit(null, new RenderTargetIdentifier(num), m_occlusionMat, pass);
+ SetBlitTarget(cb, m_occlusionRT, target.width, target.height);
+ PerformBlit(cb, num, target.width / 2, target.height / 2, m_occlusionMat, 41);
+ }
+ else
+ {
+ cb.Blit(null, m_occlusionRT, m_occlusionMat, pass);
+ }
+ }
+ if (BlurEnabled)
+ {
+ int num6 = SafeAllocateTemporaryRT(cb, "_AO_TEMP", target.width, target.height, m_occlusionRTFormat, RenderTextureReadWrite.Linear);
+ for (int num7 = 0; num7 < BlurPasses; num7++)
+ {
+ SetBlitTarget(cb, num6, target.width, target.height);
+ PerformBlit(cb, m_occlusionRT, target.width, target.height, m_blurMat, (BlurRadius - 1) * 2);
+ SetBlitTarget(cb, m_occlusionRT, target.width, target.height);
+ PerformBlit(cb, num6, target.width, target.height, m_blurMat, 1 + (BlurRadius - 1) * 2);
+ }
+ SafeReleaseTemporaryRT(cb, num6);
+ }
+ if (Downsample && num >= 0)
+ {
+ SafeReleaseTemporaryRT(cb, num);
+ }
+ cb.SetRenderTarget((Texture)null);
+ }
+
+ private void CommandBuffer_FillApplyDeferred(CommandBuffer cb, TargetDesc target, bool logTarget)
+ {
+ cb.SetGlobalTexture("_AO_OcclusionTexture", m_occlusionRT);
+ ref RenderTargetIdentifier reference = ref m_applyDeferredTargets[0];
+ reference = BuiltinRenderTextureType.GBuffer0;
+ ref RenderTargetIdentifier reference2 = ref m_applyDeferredTargets[1];
+ reference2 = ((!logTarget) ? BuiltinRenderTextureType.CameraTarget : BuiltinRenderTextureType.GBuffer3);
+ if (!logTarget)
+ {
+ SetBlitTarget(cb, m_applyDeferredTargets, target.fullWidth, target.fullHeight);
+ PerformBlit(cb, m_occlusionMat, 37);
+ }
+ else
+ {
+ int num = SafeAllocateTemporaryRT(cb, "_AO_GBufferAlbedo", target.fullWidth, target.fullHeight, RenderTextureFormat.ARGB32);
+ int num2 = SafeAllocateTemporaryRT(cb, "_AO_GBufferEmission", target.fullWidth, target.fullHeight, RenderTextureFormat.ARGB32);
+ cb.Blit(m_applyDeferredTargets[0], num);
+ cb.Blit(m_applyDeferredTargets[1], num2);
+ cb.SetGlobalTexture("_AO_GBufferAlbedo", num);
+ cb.SetGlobalTexture("_AO_GBufferEmission", num2);
+ SetBlitTarget(cb, m_applyDeferredTargets, target.fullWidth, target.fullHeight);
+ PerformBlit(cb, m_occlusionMat, 38);
+ SafeReleaseTemporaryRT(cb, num);
+ SafeReleaseTemporaryRT(cb, num2);
+ }
+ cb.SetRenderTarget((Texture)null);
+ }
+
+ private void CommandBuffer_FillApplyPostEffect(CommandBuffer cb, TargetDesc target, bool logTarget)
+ {
+ cb.SetGlobalTexture("_AO_OcclusionTexture", m_occlusionRT);
+ if (!logTarget)
+ {
+ SetBlitTarget(cb, BuiltinRenderTextureType.CameraTarget, target.fullWidth, target.fullHeight);
+ PerformBlit(cb, m_occlusionMat, 39);
+ }
+ else
+ {
+ int num = SafeAllocateTemporaryRT(cb, "_AO_GBufferEmission", target.fullWidth, target.fullHeight, RenderTextureFormat.ARGB32);
+ cb.Blit(BuiltinRenderTextureType.GBuffer3, num);
+ cb.SetGlobalTexture("_AO_GBufferEmission", num);
+ SetBlitTarget(cb, BuiltinRenderTextureType.GBuffer3, target.fullWidth, target.fullHeight);
+ PerformBlit(cb, m_occlusionMat, 40);
+ SafeReleaseTemporaryRT(cb, num);
+ }
+ cb.SetRenderTarget((Texture)null);
+ }
+
+ private void CommandBuffer_FillApplyDebug(CommandBuffer cb, TargetDesc target)
+ {
+ cb.SetGlobalTexture("_AO_OcclusionTexture", m_occlusionRT);
+ SetBlitTarget(cb, BuiltinRenderTextureType.CameraTarget, target.fullWidth, target.fullHeight);
+ PerformBlit(cb, m_occlusionMat, 36);
+ cb.SetRenderTarget((Texture)null);
+ }
+
+ private void CommandBuffer_Rebuild(TargetDesc target)
+ {
+ bool flag = PerPixelNormals == PerPixelNormalSource.GBuffer || PerPixelNormals == PerPixelNormalSource.GBufferOctaEncoded;
+ CommandBuffer commandBuffer = null;
+ CameraEvent cameraEvent = ((!flag) ? CameraEvent.BeforeImageEffectsOpaque : CameraEvent.AfterLighting);
+ if (ApplyMethod == ApplicationMethod.Debug)
+ {
+ commandBuffer = CommandBuffer_AllocateRegister(cameraEvent);
+ CommandBuffer_FillComputeOcclusion(commandBuffer, target);
+ CommandBuffer_FillApplyDebug(commandBuffer, target);
+ return;
+ }
+ bool logTarget = !m_camera.allowHDR && flag;
+ cameraEvent = ((ApplyMethod != ApplicationMethod.Deferred) ? cameraEvent : CameraEvent.BeforeReflections);
+ commandBuffer = CommandBuffer_AllocateRegister(cameraEvent);
+ CommandBuffer_FillComputeOcclusion(commandBuffer, target);
+ if (ApplyMethod == ApplicationMethod.PostEffect)
+ {
+ CommandBuffer_FillApplyPostEffect(commandBuffer, target, logTarget);
+ }
+ else if (ApplyMethod == ApplicationMethod.Deferred)
+ {
+ CommandBuffer_FillApplyDeferred(commandBuffer, target, logTarget);
+ }
+ }
+
+ private void OnPreRender()
+ {
+ bool allowHDR = m_camera.allowHDR;
+ m_target.fullWidth = m_camera.pixelWidth;
+ m_target.fullHeight = m_camera.pixelHeight;
+ m_target.format = (allowHDR ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
+ m_target.width = ((!CacheAware) ? m_target.fullWidth : ((m_target.fullWidth + 3) & -4));
+ m_target.height = ((!CacheAware) ? m_target.fullHeight : ((m_target.fullHeight + 3) & -4));
+ m_target.quarterWidth = m_target.width / 4;
+ m_target.quarterHeight = m_target.height / 4;
+ m_target.padRatioWidth = (float)m_target.width / (float)m_target.fullWidth;
+ m_target.padRatioHeight = (float)m_target.height / (float)m_target.fullHeight;
+ UpdateLocalMaterialConstants();
+ UpdateGlobalShaderConstants(m_target);
+ if (CheckParamsChanged() || m_registeredCommandBuffers.Count == 0)
+ {
+ CommandBuffer_UnregisterAll();
+ CommandBuffer_Rebuild(m_target);
+ UpdateParams();
+ }
+ }
+
+ private void OnPostRender()
+ {
+ m_occlusionRT.MarkRestoreExpected();
+ }
+}
diff --git a/AmplifyOcclusionEffect.cs b/AmplifyOcclusionEffect.cs
new file mode 100644
index 0000000..302526c
--- /dev/null
+++ b/AmplifyOcclusionEffect.cs
@@ -0,0 +1,7 @@
+using UnityEngine;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Amplify Occlusion")]
+public class AmplifyOcclusionEffect : AmplifyOcclusionBase
+{
+}
diff --git a/AnimationHandler.cs b/AnimationHandler.cs
new file mode 100644
index 0000000..6011e47
--- /dev/null
+++ b/AnimationHandler.cs
@@ -0,0 +1,14 @@
+using UnityEngine;
+
+public class AnimationHandler : MonoBehaviour
+{
+ public int animationState;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/AnimationObject.cs b/AnimationObject.cs
new file mode 100644
index 0000000..0c2d636
--- /dev/null
+++ b/AnimationObject.cs
@@ -0,0 +1,140 @@
+using UnityEngine;
+using UnityEngine.Events;
+
+public class AnimationObject : MonoBehaviour
+{
+ public PhysicsAnimation[] animations;
+
+ private Rigidbody rig;
+
+ private StepHandler stepHandler;
+
+ private Transform hip;
+
+ public float smoothing;
+
+ public float multiplier = 1f;
+
+ private bool isCurrentlyLeft;
+
+ public bool isLeft;
+
+ public UnityEvent switchToForwardEvent;
+
+ public UnityEvent switchToBackwardsEvent;
+
+ public bool dontAnimateIfHoldingSomething;
+
+ private Holding holding;
+
+ private AnimationHandler animationHandler;
+
+ private PlayerDeath death;
+
+ private float muscleMultiplier = 1f;
+
+ private void Start()
+ {
+ animationHandler = base.transform.root.GetComponent();
+ rig = GetComponent();
+ stepHandler = base.transform.root.GetComponent();
+ holding = base.transform.root.GetComponent();
+ death = base.transform.root.GetComponent();
+ Hip componentInChildren = base.transform.root.GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ hip = componentInChildren.transform;
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ if ((bool)death)
+ {
+ if (death.muscleFunction < 0f)
+ {
+ return;
+ }
+ muscleMultiplier = death.muscleFunction;
+ }
+ if ((!holding || !dontAnimateIfHoldingSomething || !holding.heldObject) && animationHandler.animationState < animations.Length)
+ {
+ SetMultiplier();
+ AddTorque();
+ AddForce();
+ }
+ }
+
+ private void AddForce()
+ {
+ Vector3 vector = Vector3.zero;
+ if (isCurrentlyLeft == isLeft)
+ {
+ Vector3 forwardForce = animations[animationHandler.animationState].forwardForce;
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
+ {
+ vector = forwardForce;
+ }
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
+ {
+ vector = hip.TransformDirection(forwardForce);
+ }
+ }
+ else
+ {
+ Vector3 backwardsForce = animations[animationHandler.animationState].backwardsForce;
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.World)
+ {
+ vector = backwardsForce;
+ }
+ if (animations[animationHandler.animationState].forceSpace == PhysicsAnimation.ForceSpace.Hip)
+ {
+ vector = hip.TransformDirection(backwardsForce);
+ }
+ }
+ rig.AddForce(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
+ }
+
+ private void AddTorque()
+ {
+ Vector3 vector = ((isCurrentlyLeft != isLeft) ? hip.TransformDirection(animations[animationHandler.animationState].backwardsTorque) : hip.TransformDirection(animations[animationHandler.animationState].forwardTorque));
+ rig.AddTorque(vector * muscleMultiplier * multiplier, ForceMode.Acceleration);
+ }
+
+ private void SetMultiplier()
+ {
+ if (smoothing != 0f)
+ {
+ float b = 1f;
+ if (isCurrentlyLeft != stepHandler.isLeft)
+ {
+ b = 0f;
+ }
+ multiplier = Mathf.Lerp(multiplier, b, 1f / smoothing);
+ if (multiplier < 0.1f)
+ {
+ ChangeStep();
+ }
+ }
+ else
+ {
+ ChangeStep();
+ }
+ }
+
+ private void ChangeStep()
+ {
+ if (isCurrentlyLeft != stepHandler.isLeft)
+ {
+ if (stepHandler.isLeft == isLeft)
+ {
+ switchToForwardEvent.Invoke();
+ }
+ else
+ {
+ switchToBackwardsEvent.Invoke();
+ }
+ isCurrentlyLeft = stepHandler.isLeft;
+ }
+ }
+}
diff --git a/ArchiveScript.cs b/ArchiveScript.cs
new file mode 100644
index 0000000..1f23c24
--- /dev/null
+++ b/ArchiveScript.cs
@@ -0,0 +1,61 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class ArchiveScript : MonoBehaviour
+{
+ private static ArchiveScript intance;
+
+ public Image bar;
+
+ public CanvasGroup escapeCG;
+
+ public CanvasGroup wholeCG;
+
+ private bool hide;
+
+ private float escapeCounter;
+
+ private void Start()
+ {
+ if (intance == null)
+ {
+ intance = this;
+ Object.DontDestroyOnLoad(base.gameObject);
+ }
+ else
+ {
+ Object.Destroy(intance.gameObject);
+ }
+ }
+
+ private void Update()
+ {
+ if (Input.GetKeyDown(KeyCode.H))
+ {
+ hide = !hide;
+ if (hide)
+ {
+ wholeCG.alpha = 0f;
+ }
+ else
+ {
+ wholeCG.alpha = 1f;
+ }
+ }
+ if (Input.GetKey(KeyCode.Escape))
+ {
+ escapeCounter += Time.deltaTime;
+ if (escapeCounter > 1f)
+ {
+ Application.Quit();
+ }
+ }
+ else
+ {
+ escapeCounter -= Time.deltaTime;
+ }
+ escapeCounter = Mathf.Clamp(escapeCounter, 0f, 2f);
+ escapeCG.alpha = escapeCounter * 2f;
+ bar.fillAmount = escapeCounter;
+ }
+}
diff --git a/ArmLeft.cs b/ArmLeft.cs
new file mode 100644
index 0000000..b7ee14c
--- /dev/null
+++ b/ArmLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class ArmLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/ArmRight.cs b/ArmRight.cs
new file mode 100644
index 0000000..735d646
--- /dev/null
+++ b/ArmRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class ArmRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/AvaragePosition.cs b/AvaragePosition.cs
new file mode 100644
index 0000000..cea74d6
--- /dev/null
+++ b/AvaragePosition.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+
+public class AvaragePosition : MonoBehaviour
+{
+ public Transform[] transforms;
+
+ private Transform rotationHelper;
+
+ public Vector3 offset;
+
+ private void Start()
+ {
+ rotationHelper = base.transform.root.GetComponentInChildren().transform;
+ }
+
+ private void LateUpdate()
+ {
+ Vector3 zero = Vector3.zero;
+ for (int i = 0; i < transforms.Length; i++)
+ {
+ zero += transforms[i].position;
+ }
+ zero /= (float)transforms.Length;
+ base.transform.position = zero + rotationHelper.TransformDirection(offset);
+ }
+}
diff --git a/Balance.cs b/Balance.cs
new file mode 100644
index 0000000..dc9ae60
--- /dev/null
+++ b/Balance.cs
@@ -0,0 +1,101 @@
+using UnityEngine;
+
+public class Balance : MonoBehaviour
+{
+ private Rigidbody handLeft;
+
+ private Rigidbody handRight;
+
+ private Rigidbody footLeft;
+
+ private Rigidbody footRight;
+
+ private Rigidbody hip;
+
+ private Vector3 centerOfMass;
+
+ private Rigidbody[] allRigs;
+
+ public float[] balanceForce;
+
+ public float[] footCenterForces;
+
+ private AnimationHandler animationHandler;
+
+ private PlayerDeath death;
+
+ private Strength str;
+
+ private float muscleMultiplier;
+
+ private void Start()
+ {
+ death = GetComponent();
+ str = GetComponent();
+ allRigs = GetComponentsInChildren();
+ HandLeft componentInChildren = GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ handLeft = componentInChildren.GetComponent();
+ }
+ HandRight componentInChildren2 = GetComponentInChildren();
+ if ((bool)componentInChildren2)
+ {
+ handRight = componentInChildren2.GetComponent();
+ }
+ footLeft = GetComponentInChildren().GetComponent();
+ footRight = GetComponentInChildren().GetComponent();
+ hip = GetComponentInChildren().GetComponent();
+ animationHandler = GetComponent();
+ }
+
+ private void FixedUpdate()
+ {
+ if (!death.dead)
+ {
+ muscleMultiplier = str.strength;
+ centerOfMass = Vector3.zero;
+ Rigidbody[] array = allRigs;
+ foreach (Rigidbody rigidbody in array)
+ {
+ centerOfMass += rigidbody.worldCenterOfMass;
+ }
+ centerOfMass /= (float)allRigs.Length;
+ centerOfMass.y = 0f;
+ BalanceLegs();
+ CenterLegs();
+ }
+ }
+
+ private void CenterLegs()
+ {
+ Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f;
+ Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f;
+ Vector3 vector3 = vector;
+ if (vector.y + 0.3f < hip.worldCenterOfMass.y)
+ {
+ vector3.y = 0f;
+ footLeft.AddForceAtPosition((centerOfMass - vector3) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector, ForceMode.Acceleration);
+ }
+ Vector3 vector4 = vector2;
+ if (vector4.y + 0.3f < hip.worldCenterOfMass.y)
+ {
+ vector4.y = 0f;
+ footRight.AddForceAtPosition((centerOfMass - vector4) * muscleMultiplier * footCenterForces[animationHandler.animationState], vector2, ForceMode.Acceleration);
+ }
+ }
+
+ private void BalanceLegs()
+ {
+ Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f;
+ Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f;
+ Vector3 vector3 = (vector + vector2) / 2f;
+ if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y))
+ {
+ vector3.y = 0f;
+ Vector3 vector4 = centerOfMass - vector3;
+ footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration);
+ footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration);
+ }
+ }
+}
diff --git a/CameraMovement.cs b/CameraMovement.cs
new file mode 100644
index 0000000..a94012a
--- /dev/null
+++ b/CameraMovement.cs
@@ -0,0 +1,136 @@
+using UnityEngine;
+
+public class CameraMovement : MonoBehaviour
+{
+ public Camera camera;
+
+ public Transform positionTarget;
+
+ public Transform headPosition;
+
+ public Transform rotationTarget;
+
+ public Transform bobberTarget;
+
+ private StandingDataHandler standingData;
+
+ private float fallingValue;
+
+ private float fallingEffectValue;
+
+ private float minBobble = 0.02f;
+
+ public bool ADS;
+
+ public DamageEffects effects;
+
+ private WeaponHandler weaponHandler;
+
+ private Rigidbody hip;
+
+ private HasControl hasControl;
+
+ private HeadCollisionHandler headCollisionHandler;
+
+ private MovementDataHandler movementData;
+
+ private Rigidbody torso;
+
+ private PlayerDeath death;
+
+ private Strength str;
+
+ private Vector3 cameraCurrentRelativeADSPosition = Vector3.zero;
+
+ private Vector3 movementADSVelocity = Vector3.zero;
+
+ private Vector3 ADSMovementPosition = Vector3.zero;
+
+ private void Start()
+ {
+ torso = base.transform.root.GetComponentInChildren().GetComponent();
+ headCollisionHandler = base.transform.root.GetComponentInChildren();
+ standingData = base.transform.GetComponentInParent();
+ movementData = base.transform.GetComponentInParent();
+ weaponHandler = base.transform.GetComponentInParent();
+ camera = GetComponentInChildren();
+ hip = base.transform.root.GetComponentInChildren().GetComponent();
+ hasControl = base.transform.root.GetComponent();
+ death = base.transform.root.GetComponent();
+ str = base.transform.root.GetComponent();
+ effects = base.transform.root.GetComponent();
+ }
+
+ private void LateUpdate()
+ {
+ if (hasControl.hasControl)
+ {
+ headCollisionHandler.collisionValue = 0f;
+ if (standingData.sinceLanded > 1f)
+ {
+ fallingValue = Mathf.Clamp(standingData.sinceGrounded - 0.5f, 0f, 10f) * 0.5f;
+ }
+ if (standingData.sinceGrounded > 0.5f || standingData.sinceLanded < 0.5f)
+ {
+ fallingEffectValue = Mathf.Lerp(fallingEffectValue, fallingValue, Time.smoothDeltaTime * 15f);
+ }
+ else
+ {
+ fallingEffectValue = Mathf.Lerp(fallingEffectValue, minBobble, Time.smoothDeltaTime * 3f);
+ }
+ float physicsValue = GetPhysicsValue();
+ Vector3 vector = Vector3.Lerp(positionTarget.position, bobberTarget.position, Mathf.Clamp(physicsValue + headCollisionHandler.collisionValue, 0f, 1f));
+ Vector3 position = vector;
+ position.y = base.transform.position.y;
+ base.transform.position = position;
+ base.transform.position = vector;
+ base.transform.rotation = Quaternion.Lerp(rotationTarget.rotation, bobberTarget.rotation, Mathf.Clamp(physicsValue + Mathf.Clamp(headCollisionHandler.collisionValue, 0f, 0.4f), 0f, 1f));
+ SetCameraPosition();
+ }
+ }
+
+ private void SetCameraPosition()
+ {
+ if (ADS && (bool)weaponHandler.gunADS)
+ {
+ cameraCurrentRelativeADSPosition = Vector3.Lerp(cameraCurrentRelativeADSPosition, Vector3.zero, Time.deltaTime * 20f);
+ camera.transform.position = weaponHandler.gunADS.TransformPoint(cameraCurrentRelativeADSPosition) + ADSMovementPosition;
+ camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, weaponHandler.ADSFOV, Time.deltaTime * 20f);
+ return;
+ }
+ if ((bool)weaponHandler && (bool)weaponHandler.gunADS)
+ {
+ cameraCurrentRelativeADSPosition = weaponHandler.gunADS.InverseTransformPoint(camera.transform.position);
+ }
+ camera.transform.localPosition = Vector3.Lerp(camera.transform.localPosition, Vector3.zero, Time.deltaTime * 20f);
+ camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, 90f, Time.deltaTime * 20f);
+ }
+
+ private void FixedUpdate()
+ {
+ if (hasControl.hasControl && (bool)weaponHandler && (bool)weaponHandler.rightGun)
+ {
+ movementADSVelocity += (weaponHandler.rightGun.rig.velocity - hip.velocity) * 0.01f;
+ movementADSVelocity += -ADSMovementPosition * 3f;
+ movementADSVelocity *= 0.8f;
+ }
+ }
+
+ private void Update()
+ {
+ if (hasControl.hasControl)
+ {
+ ADSMovementPosition += movementADSVelocity * Time.deltaTime;
+ }
+ }
+
+ private float GetPhysicsValue()
+ {
+ float result = fallingEffectValue * 0.3f + (1f - str.strength) + effects.damageValue;
+ if (death.dead)
+ {
+ result = 1f;
+ }
+ return result;
+ }
+}
diff --git a/CameraRecoil.cs b/CameraRecoil.cs
new file mode 100644
index 0000000..e82532a
--- /dev/null
+++ b/CameraRecoil.cs
@@ -0,0 +1,49 @@
+using UnityEngine;
+
+public class CameraRecoil : MonoBehaviour
+{
+ public Transform yRotation;
+
+ public Transform xRotation;
+
+ private float counter;
+
+ private float lastValue;
+
+ private AnimationCurve usedCurve;
+
+ private float deltaValue;
+
+ private float xRecoil;
+
+ private float yRecoil;
+
+ private bool hasCurve;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ if (hasCurve && counter < usedCurve.keys[usedCurve.length - 1].time)
+ {
+ float num = usedCurve.Evaluate(counter);
+ counter += Time.deltaTime;
+ deltaValue = num - lastValue;
+ lastValue = num;
+ xRotation.Rotate(Vector3.up * Time.deltaTime * xRecoil * deltaValue, Space.World);
+ yRotation.Rotate(Vector3.right * Time.deltaTime * yRecoil * deltaValue, Space.Self);
+ }
+ }
+
+ public void AddRecoil(Vector2 recoil, AnimationCurve curve)
+ {
+ counter = 0f;
+ lastValue = curve.Evaluate(0f);
+ usedCurve = curve;
+ xRecoil = recoil.x * 30f;
+ yRecoil = recoil.y * -30f;
+ hasCurve = true;
+ }
+}
diff --git a/CameraWobble.cs b/CameraWobble.cs
new file mode 100644
index 0000000..2bd1236
--- /dev/null
+++ b/CameraWobble.cs
@@ -0,0 +1,18 @@
+using UnityEngine;
+
+public class CameraWobble : MonoBehaviour
+{
+ public Transform target;
+
+ private void Start()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ if ((bool)target)
+ {
+ base.transform.localRotation = target.rotation;
+ }
+ }
+}
diff --git a/Car.cs b/Car.cs
new file mode 100644
index 0000000..1cdab6c
--- /dev/null
+++ b/Car.cs
@@ -0,0 +1,143 @@
+using UnityEngine;
+
+public class Car : MonoBehaviour
+{
+ public float forwardForceMultiplier = 1f;
+
+ public float breakForce = 1f;
+
+ public float glide = 1f;
+
+ private float thrust;
+
+ public AnimationCurve driftCurveGas;
+
+ public AnimationCurve driftBreakForceCurve;
+
+ public AnimationCurve driftVecloityForceCurve;
+
+ public AnimationCurve driftTurnCurve;
+
+ public AnimationCurve lowSpeedGripCurve;
+
+ public AnimationCurve speedTurnCurve;
+
+ public AnimationCurve useWheelToTurnCurve;
+
+ private float driftAmount;
+
+ private WobbleShake shake;
+
+ public Rigidbody mainRig;
+
+ public float turnTorque = 1f;
+
+ public float downwardsForce;
+
+ private GenericInputHandler input;
+
+ private CollisionChecker[] checkers;
+
+ private Collider[] wheelColliders;
+
+ private float sinceGrounded;
+
+ private Wheel[] wheels;
+
+ private void Start()
+ {
+ checkers = GetComponentsInChildren();
+ wheels = GetComponentsInChildren();
+ input = GetComponent();
+ shake = base.transform.root.GetComponentInChildren();
+ Transform parent = GetComponentInChildren().transform.parent;
+ wheelColliders = parent.GetComponentsInChildren();
+ }
+
+ private void FixedUpdate()
+ {
+ float num = 1f;
+ if (mainRig.transform.InverseTransformDirection(mainRig.velocity).z < 0f)
+ {
+ num = -1f;
+ }
+ float num2 = Mathf.Clamp(Vector3.Angle(mainRig.velocity, mainRig.transform.forward * num), 10f, 90f);
+ float num3 = Mathf.Clamp(Vector3.Angle(mainRig.velocity, mainRig.transform.forward * num), 1f, 90f);
+ float z = mainRig.transform.InverseTransformDirection(mainRig.velocity).z;
+ thrust = Mathf.Clamp(input.inputDirection.z, -0.7f, 1f);
+ float num4 = speedTurnCurve.Evaluate(z);
+ float num5 = 1f;
+ num5 = 0f;
+ for (int i = 0; i < checkers.Length; i++)
+ {
+ if (checkers[i].sinceGrounded < 0.1f)
+ {
+ num5 += 1f / (float)checkers.Length;
+ }
+ }
+ if (num5 == 0f)
+ {
+ sinceGrounded += Time.deltaTime;
+ }
+ else
+ {
+ if ((double)sinceGrounded > 0.5)
+ {
+ shake.AddShake(base.transform.forward * 0.5f * Mathf.Clamp(sinceGrounded, 0f, 5f), 0.9f);
+ }
+ sinceGrounded = 0f;
+ }
+ if (num5 > 0f)
+ {
+ mainRig.angularVelocity *= 0.98f;
+ if (input.space)
+ {
+ driftAmount = Mathf.Lerp(driftAmount, 1f, Time.fixedDeltaTime * 2f);
+ if (driftAmount > 0.7f)
+ {
+ mainRig.angularVelocity *= 0.98f;
+ }
+ }
+ else
+ {
+ driftAmount = Mathf.Lerp(driftAmount, 0f, Time.fixedDeltaTime * 3f);
+ }
+ }
+ float num6 = driftCurveGas.Evaluate(Mathf.Clamp(num3, driftAmount * 45f, 999f) / 10f);
+ Collider[] array = wheelColliders;
+ foreach (Collider collider in array)
+ {
+ collider.material.dynamicFriction = Mathf.Clamp(5f / mainRig.velocity.magnitude - 0.2f, 0f, 0.5f);
+ }
+ if (mainRig.velocity.magnitude > 10f)
+ {
+ shake.AddShakeWorld(Random.insideUnitSphere * (Mathf.Clamp(num3 / 10f - 1f, 0f, 40f) * mainRig.velocity.magnitude * 0.01f) * 0.5f, 0.8f);
+ shake.AddShake(Vector3.up * (Mathf.Clamp(num3 / 10f - 1f, 0f, 90f) * mainRig.velocity.magnitude * -0.03f) * 0.1f, 0.8f);
+ }
+ Wheel[] array2 = wheels;
+ foreach (Wheel wheel in array2)
+ {
+ if (wheel.isActive)
+ {
+ mainRig.AddForce(-mainRig.transform.up * mainRig.velocity.magnitude * downwardsForce * num5, ForceMode.Acceleration);
+ mainRig.AddTorque(mainRig.transform.up * (1f + driftAmount * 0.5f) * input.inputDirection.x * driftTurnCurve.Evaluate(num3 / 90f) * num4 * turnTorque * num5, ForceMode.Acceleration);
+ Vector3 normalized = Vector3.Lerp(mainRig.transform.forward, wheel.forward, useWheelToTurnCurve.Evaluate(mainRig.velocity.magnitude)).normalized;
+ Vector3 vector = normalized * forwardForceMultiplier * num5 * (1f + Mathf.Clamp(Vector3.Angle(mainRig.transform.forward, mainRig.velocity), 0f, 20f) * 0.01f);
+ if (thrust != 0f)
+ {
+ vector *= thrust;
+ }
+ Vector3 vector2 = Vector3.ProjectOnPlane(vector, mainRig.velocity);
+ Vector3 force = vector - vector2;
+ mainRig.AddForceAtPosition(vector2, wheel.transform.position, ForceMode.Acceleration);
+ if (thrust != 0f)
+ {
+ mainRig.AddForceAtPosition(force, wheel.transform.position, ForceMode.Acceleration);
+ }
+ mainRig.AddForceAtPosition(-mainRig.velocity * forwardForceMultiplier * 0.02f * num5, wheel.transform.position, ForceMode.Acceleration);
+ mainRig.AddForce(mainRig.velocity * breakForce * -1f * driftBreakForceCurve.Evaluate(num3 / 10f) * num5, ForceMode.Acceleration);
+ mainRig.AddForce(-mainRig.transform.right * mainRig.transform.InverseTransformDirection(mainRig.velocity).x * 0.2f * num5 * glide * 10f / num6, ForceMode.Acceleration);
+ }
+ }
+ }
+}
diff --git a/CenterOfMass.cs b/CenterOfMass.cs
new file mode 100644
index 0000000..9acb727
--- /dev/null
+++ b/CenterOfMass.cs
@@ -0,0 +1,14 @@
+using UnityEngine;
+
+public class CenterOfMass : MonoBehaviour
+{
+ private void Start()
+ {
+ Rigidbody componentInParent = GetComponentInParent();
+ componentInParent.centerOfMass = componentInParent.transform.InverseTransformPoint(base.transform.position);
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/ChatController.cs b/ChatController.cs
new file mode 100644
index 0000000..d98a965
--- /dev/null
+++ b/ChatController.cs
@@ -0,0 +1,34 @@
+using System;
+using TMPro;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class ChatController : MonoBehaviour
+{
+ public TMP_InputField TMP_ChatInput;
+
+ public TMP_Text TMP_ChatOutput;
+
+ public Scrollbar ChatScrollbar;
+
+ private void OnEnable()
+ {
+ TMP_ChatInput.onSubmit.AddListener(AddToChatOutput);
+ }
+
+ private void OnDisable()
+ {
+ TMP_ChatInput.onSubmit.RemoveListener(AddToChatOutput);
+ }
+
+ private void AddToChatOutput(string newText)
+ {
+ TMP_ChatInput.text = string.Empty;
+ DateTime now = DateTime.Now;
+ TMP_Text tMP_ChatOutput = TMP_ChatOutput;
+ string text = tMP_ChatOutput.text;
+ tMP_ChatOutput.text = text + "[<#FFFF80>" + now.Hour.ToString("d2") + ":" + now.Minute.ToString("d2") + ":" + now.Second.ToString("d2") + "] " + newText + "\n";
+ TMP_ChatInput.ActivateInputField();
+ ChatScrollbar.value = 0f;
+ }
+}
diff --git a/CodeAnimation.cs b/CodeAnimation.cs
new file mode 100644
index 0000000..a4d6244
--- /dev/null
+++ b/CodeAnimation.cs
@@ -0,0 +1,63 @@
+using System.Collections;
+using UnityEngine;
+
+public class CodeAnimation : MonoBehaviour
+{
+ public bool x = true;
+
+ public bool y = true;
+
+ public bool z = true;
+
+ public AnimationCurve curve;
+
+ public bool loop;
+
+ public bool playOnAwake;
+
+ private void Start()
+ {
+ if (playOnAwake)
+ {
+ Play();
+ }
+ }
+
+ private void Update()
+ {
+ }
+
+ public void Play()
+ {
+ StartCoroutine(PlayAnimation());
+ }
+
+ private IEnumerator PlayAnimation()
+ {
+ float t = 0f;
+ float lastFrameValue = curve.Evaluate(0f);
+ while (t < curve.keys[curve.length - 1].time)
+ {
+ t += Time.deltaTime;
+ float deltaValue = curve.Evaluate(t) - lastFrameValue;
+ lastFrameValue = curve.Evaluate(t);
+ if (x)
+ {
+ base.transform.localScale = new Vector3(base.transform.localScale.x + deltaValue, base.transform.localScale.y, base.transform.localScale.z);
+ }
+ if (y)
+ {
+ base.transform.localScale = new Vector3(base.transform.localScale.x, base.transform.localScale.y + deltaValue, base.transform.localScale.z);
+ }
+ if (z)
+ {
+ base.transform.localScale = new Vector3(base.transform.localScale.x, base.transform.localScale.y, base.transform.localScale.z + deltaValue);
+ }
+ yield return null;
+ }
+ if (loop)
+ {
+ Play();
+ }
+ }
+}
diff --git a/CollisionChecker.cs b/CollisionChecker.cs
new file mode 100644
index 0000000..83c247a
--- /dev/null
+++ b/CollisionChecker.cs
@@ -0,0 +1,85 @@
+using UnityEngine;
+
+public class CollisionChecker : MonoBehaviour
+{
+ private Transform head;
+
+ private Transform hip;
+
+ private StandingDataHandler data;
+
+ public bool active = true;
+
+ public float sinceGrounded;
+
+ private PickupHandler pickupHandler;
+
+ private HasControl hasControl;
+
+ public float allowedSteepnesAngle = 60f;
+
+ private void Start()
+ {
+ pickupHandler = base.transform.root.GetComponent();
+ hasControl = base.transform.root.GetComponent();
+ data = GetComponentInParent();
+ Head componentInChildren = base.transform.root.GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ head = componentInChildren.transform;
+ }
+ Hip componentInChildren2 = base.transform.root.GetComponentInChildren();
+ if ((bool)componentInChildren2)
+ {
+ hip = componentInChildren2.transform;
+ }
+ }
+
+ private void Update()
+ {
+ sinceGrounded += Time.deltaTime;
+ }
+
+ private void OnCollisionStay(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void OnCollisionEnter(Collision collision)
+ {
+ Collide(collision);
+ }
+
+ private void Collide(Collision collision)
+ {
+ if (collision.transform.root == base.transform.root)
+ {
+ return;
+ }
+ if ((bool)collision.rigidbody)
+ {
+ Pickup component = collision.gameObject.GetComponent();
+ if ((bool)component && !component.GetComponent().isHeld && hasControl.hasControl)
+ {
+ pickupHandler.PickUp(component);
+ }
+ if (collision.rigidbody.mass < 100f || collision.rigidbody.velocity.magnitude > 1f)
+ {
+ return;
+ }
+ }
+ if (active && Vector3.Angle(Vector3.up, collision.contacts[0].normal) < allowedSteepnesAngle)
+ {
+ if ((bool)data)
+ {
+ data.TouchGround(Mathf.Abs(hip.position.y - collision.contacts[0].point.y), collision.contacts[0].normal);
+ }
+ sinceGrounded = 0f;
+ }
+ }
+
+ public void SwitchActive(bool setActive)
+ {
+ active = setActive;
+ }
+}
diff --git a/ConfigurableJointExtensions.cs b/ConfigurableJointExtensions.cs
new file mode 100644
index 0000000..1fcbf91
--- /dev/null
+++ b/ConfigurableJointExtensions.cs
@@ -0,0 +1,41 @@
+using UnityEngine;
+
+public static class ConfigurableJointExtensions
+{
+ public static void SetTargetRotationLocal(this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
+ {
+ if (joint.configuredInWorldSpace)
+ {
+ Debug.LogError("SetTargetRotationLocal should not be used with joints that are configured in world space. For world space joints, use SetTargetRotation.", joint);
+ }
+ joint.SetTargetRotationInternal(targetLocalRotation, startLocalRotation, Space.Self);
+ }
+
+ public static void SetTargetRotation(this ConfigurableJoint joint, Quaternion targetWorldRotation, Quaternion startWorldRotation)
+ {
+ if (!joint.configuredInWorldSpace)
+ {
+ Debug.LogError("SetTargetRotation must be used with joints that are configured in world space. For local space joints, use SetTargetRotationLocal.", joint);
+ }
+ joint.SetTargetRotationInternal(targetWorldRotation, startWorldRotation, Space.World);
+ }
+
+ private static void SetTargetRotationInternal(this ConfigurableJoint joint, Quaternion targetRotation, Quaternion startRotation, Space space)
+ {
+ Vector3 axis = joint.axis;
+ Vector3 normalized = Vector3.Cross(joint.axis, joint.secondaryAxis).normalized;
+ Vector3 normalized2 = Vector3.Cross(normalized, axis).normalized;
+ Quaternion quaternion = Quaternion.LookRotation(normalized, normalized2);
+ Quaternion targetRotation2 = Quaternion.Inverse(quaternion);
+ if (space == Space.World)
+ {
+ targetRotation2 *= startRotation * Quaternion.Inverse(targetRotation);
+ }
+ else
+ {
+ targetRotation2 *= Quaternion.Inverse(targetRotation) * startRotation;
+ }
+ targetRotation2 *= quaternion;
+ joint.targetRotation = targetRotation2;
+ }
+}
diff --git a/ContextSwitcher.cs b/ContextSwitcher.cs
new file mode 100644
index 0000000..592c809
--- /dev/null
+++ b/ContextSwitcher.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using DeepSky.Haze;
+using UnityEngine;
+
+public class ContextSwitcher : MonoBehaviour
+{
+ public List contexts = new List();
+
+ private DS_HazeView _view;
+
+ private int _contextIndex;
+
+ private void Start()
+ {
+ _view = GetComponent();
+ }
+
+ private void Update()
+ {
+ if (contexts.Count > 0 && _view != null && Input.GetKeyUp(KeyCode.C))
+ {
+ _contextIndex++;
+ if (_contextIndex == contexts.Count)
+ {
+ _contextIndex = 0;
+ }
+ _view.ContextAsset = contexts[_contextIndex];
+ _view.OverrideContextAsset = true;
+ }
+ }
+}
diff --git a/Controls.cs b/Controls.cs
new file mode 100644
index 0000000..bce2325
--- /dev/null
+++ b/Controls.cs
@@ -0,0 +1,85 @@
+using UnityEngine;
+
+[ExecuteInEditMode]
+public class Controls : MonoBehaviour
+{
+ public AmplifyOcclusionEffect occlusion;
+
+ private const AmplifyOcclusionBase.ApplicationMethod POST = AmplifyOcclusionBase.ApplicationMethod.PostEffect;
+
+ private const AmplifyOcclusionBase.ApplicationMethod DEFERRED = AmplifyOcclusionBase.ApplicationMethod.Deferred;
+
+ private const AmplifyOcclusionBase.ApplicationMethod DEBUG = AmplifyOcclusionBase.ApplicationMethod.Debug;
+
+ private void OnGUI()
+ {
+ GUILayout.BeginArea(new Rect(0f, 0f, Screen.width, Screen.height));
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(5f);
+ GUILayout.BeginVertical();
+ occlusion.enabled = GUILayout.Toggle(occlusion.enabled, " Amplify Occlusion Enabled");
+ GUILayout.Space(5f);
+ occlusion.ApplyMethod = ((!GUILayout.Toggle(occlusion.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.PostEffect, " Standard Post-effect")) ? occlusion.ApplyMethod : AmplifyOcclusionBase.ApplicationMethod.PostEffect);
+ occlusion.ApplyMethod = (GUILayout.Toggle(occlusion.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.Deferred, " Deferred Injection") ? AmplifyOcclusionBase.ApplicationMethod.Deferred : occlusion.ApplyMethod);
+ occlusion.ApplyMethod = ((!GUILayout.Toggle(occlusion.ApplyMethod == AmplifyOcclusionBase.ApplicationMethod.Debug, " Debug Mode")) ? occlusion.ApplyMethod : AmplifyOcclusionBase.ApplicationMethod.Debug);
+ GUILayout.EndVertical();
+ GUILayout.FlexibleSpace();
+ GUILayout.BeginVertical();
+ GUILayout.Space(5f);
+ GUILayout.BeginHorizontal();
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label("Intensity ");
+ GUILayout.EndVertical();
+ occlusion.Intensity = GUILayout.HorizontalSlider(occlusion.Intensity, 0f, 1f, GUILayout.Width(100f));
+ GUILayout.Space(5f);
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label(" " + occlusion.Intensity.ToString("0.00"));
+ GUILayout.EndVertical();
+ GUILayout.Space(5f);
+ GUILayout.EndHorizontal();
+ GUILayout.BeginHorizontal();
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label("Power Exp. ");
+ GUILayout.EndVertical();
+ occlusion.PowerExponent = GUILayout.HorizontalSlider(occlusion.PowerExponent, 0.0001f, 6f, GUILayout.Width(100f));
+ GUILayout.Space(5f);
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label(" " + occlusion.PowerExponent.ToString("0.00"));
+ GUILayout.EndVertical();
+ GUILayout.Space(5f);
+ GUILayout.EndHorizontal();
+ GUILayout.BeginHorizontal();
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label("Radius ");
+ GUILayout.EndVertical();
+ occlusion.Radius = GUILayout.HorizontalSlider(occlusion.Radius, 0.1f, 10f, GUILayout.Width(100f));
+ GUILayout.Space(5f);
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label(" " + occlusion.Radius.ToString("0.00"));
+ GUILayout.EndVertical();
+ GUILayout.Space(5f);
+ GUILayout.EndHorizontal();
+ GUILayout.BeginHorizontal();
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label("Quality ");
+ GUILayout.EndVertical();
+ occlusion.SampleCount = (AmplifyOcclusionBase.SampleCountLevel)GUILayout.HorizontalSlider((float)occlusion.SampleCount, 0f, 3f, GUILayout.Width(100f));
+ GUILayout.Space(5f);
+ GUILayout.BeginVertical();
+ GUILayout.Space(-3f);
+ GUILayout.Label(" ");
+ GUILayout.EndVertical();
+ GUILayout.Space(5f);
+ GUILayout.EndHorizontal();
+ GUILayout.EndVertical();
+ GUILayout.EndHorizontal();
+ GUILayout.EndArea();
+ }
+}
diff --git a/CreepyRobots.csproj b/CreepyRobots.csproj
new file mode 100644
index 0000000..9d5de2a
--- /dev/null
+++ b/CreepyRobots.csproj
@@ -0,0 +1,183 @@
+
+
+ Assembly-CSharp
+ False
+ net35
+
+
+ 11.0
+ True
+
+
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.AccessibilityModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.Analytics.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.AnimationModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ARModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.AssetBundleModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ClothModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ClusterInputModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ClusterRendererModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.CrashReportingModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.DirectorModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.GameCenterModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.GridModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ImageConversionModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.InputModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.JSONSerializeModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.Networking.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ParticlesLegacyModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.PerformanceReportingModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.Physics2DModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ScreenCaptureModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.SharedInternalsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.SpatialTracking.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.SpriteMaskModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.SpriteShapeModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.StandardEvents.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.StyleSheetsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.TilemapModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.Timeline.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UI.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UIElementsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UIModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.PhysicsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.CoreModule.dll
+
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.ParticleSystemModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.AudioModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\ch.sycoforge.Decal.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.AIModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.TerrainPhysicsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\Lidgren.Network.dll
+
+
+ ..\CreepyRobots_Data\Managed\TextMeshPro-1.0.55.2017.2.0b12.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.TextRenderingModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.IMGUIModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.TerrainModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UNETModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityAnalyticsModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityConnectModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityWebRequestModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.VehiclesModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.VideoModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.VRModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.WebModule.dll
+
+
+ ..\CreepyRobots_Data\Managed\UnityEngine.WindModule.dll
+
+
+
\ No newline at end of file
diff --git a/Damagable.cs b/Damagable.cs
new file mode 100644
index 0000000..667cd5e
--- /dev/null
+++ b/Damagable.cs
@@ -0,0 +1,54 @@
+using UnityEngine;
+using UnityEngine.Events;
+
+public class Damagable : MonoBehaviour
+{
+ public float multiplier = 1f;
+
+ private PlayerDeath playerDeath;
+
+ public UnityEvent outOfLiveEvent;
+
+ public UnityEvent damageEvent;
+
+ public float health = 100f;
+
+ private float currentHealth;
+
+ private bool dead;
+
+ private Rigidbody rig;
+
+ private void Start()
+ {
+ rig = GetComponent();
+ currentHealth = health;
+ playerDeath = base.transform.root.GetComponent();
+ }
+
+ private void Update()
+ {
+ }
+
+ public void TakeDamage(Vector3 damage, Vector3 hitPoint)
+ {
+ damage *= multiplier;
+ if ((bool)playerDeath)
+ {
+ playerDeath.TakeDamage(damage, hitPoint, rig);
+ return;
+ }
+ damageEvent.Invoke();
+ currentHealth -= damage.magnitude;
+ if (currentHealth < 0f && !dead)
+ {
+ dead = true;
+ outOfLiveEvent.Invoke();
+ }
+ }
+
+ public void RefillHP()
+ {
+ currentHealth = health;
+ }
+}
diff --git a/DamageEffects.cs b/DamageEffects.cs
new file mode 100644
index 0000000..305c1d7
--- /dev/null
+++ b/DamageEffects.cs
@@ -0,0 +1,84 @@
+using UnityEngine;
+using UnityEngine.PostProcessing;
+
+public class DamageEffects : MonoBehaviour
+{
+ private WobbleShake screenShake;
+
+ private ParticleParent[] particleParents;
+
+ private float counter;
+
+ public AnimationCurve curve;
+
+ public AnimationCurve curve2;
+
+ public PostProcessingProfile post;
+
+ private Camera mainCam;
+
+ public float damageValue;
+
+ private Transform hip;
+
+ private void Start()
+ {
+ screenShake = base.transform.root.GetComponentInChildren();
+ particleParents = GetComponentsInChildren();
+ mainCam = base.transform.root.GetComponentInChildren();
+ hip = base.transform.root.GetComponentInChildren().transform;
+ }
+
+ private void Update()
+ {
+ VignetteModel.Settings settings = post.vignette.settings;
+ ChromaticAberrationModel.Settings settings2 = post.chromaticAberration.settings;
+ counter += Time.deltaTime;
+ if (damageValue > 0f)
+ {
+ damageValue -= Time.deltaTime * 0.3f;
+ }
+ if (counter < curve.keys[curve.length - 1].time)
+ {
+ float intensity = curve.Evaluate(counter);
+ settings.intensity = intensity;
+ }
+ settings.intensity = Mathf.Lerp(settings.intensity, 0f, Time.deltaTime * 0.5f);
+ settings.intensity = Mathf.Clamp(settings.intensity, 0f, 9f);
+ post.vignette.settings = settings;
+ if (counter < curve2.keys[curve2.length - 1].time)
+ {
+ float intensity2 = curve2.Evaluate(counter);
+ settings2.intensity = intensity2;
+ }
+ settings2.intensity = Mathf.Lerp(settings2.intensity, 0f, Time.deltaTime * 0.5f);
+ settings2.intensity = Mathf.Clamp(settings2.intensity, 0f, 9f);
+ post.chromaticAberration.settings = settings2;
+ }
+
+ public void TakeDamage(Vector3 damage, Vector3 hitPoint)
+ {
+ counter = 0f;
+ damageValue += damage.magnitude * 0.02f;
+ damageValue = Mathf.Clamp(damageValue, 0f, 0.5f);
+ GetComponentInChildren().GetComponent().AddForce(damage.normalized * (damage.magnitude * 0.3f + 3f), ForceMode.VelocityChange);
+ screenShake.AddShakeWorld(damage * 0.4f, 0.8f);
+ DirectionalParticles(mainCam.transform.InverseTransformDirection(-damage));
+ }
+
+ private void DirectionalParticles(Vector3 damage)
+ {
+ for (int i = 0; i < particleParents.Length; i++)
+ {
+ Vector3 from = particleParents[i].transform.position - particleParents[i].transform.parent.position;
+ Vector3 to = damage;
+ from.y = 0f;
+ to.y = 0f;
+ if (Vector3.Angle(from, to) < 15f + damage.magnitude * 0.5f)
+ {
+ float multi = 1f - Vector3.Angle(from, to) / damage.magnitude * 0.5f;
+ particleParents[i].Play(damage.magnitude, multi);
+ }
+ }
+ }
+}
diff --git a/DebugPosition.cs b/DebugPosition.cs
new file mode 100644
index 0000000..32cd942
--- /dev/null
+++ b/DebugPosition.cs
@@ -0,0 +1,13 @@
+using UnityEngine;
+
+public class DebugPosition : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ Debug.DrawLine(base.transform.position, base.transform.position + Vector3.up, Color.red, 5f);
+ }
+}
diff --git a/DeepSky.Haze.Demo/BasicMouseLookControl.cs b/DeepSky.Haze.Demo/BasicMouseLookControl.cs
new file mode 100644
index 0000000..8ce6d68
--- /dev/null
+++ b/DeepSky.Haze.Demo/BasicMouseLookControl.cs
@@ -0,0 +1,52 @@
+using UnityEngine;
+
+namespace DeepSky.Haze.Demo;
+
+public class BasicMouseLookControl : MonoBehaviour
+{
+ [SerializeField]
+ private float m_XSensitivity = 2.5f;
+
+ [SerializeField]
+ private float m_YSensitivity = 2.5f;
+
+ private Quaternion m_StartRotation;
+
+ private float m_X;
+
+ private float m_Y;
+
+ private void Start()
+ {
+ m_StartRotation = base.transform.localRotation;
+ }
+
+ private void Update()
+ {
+ m_X += Input.GetAxis("Mouse X") * m_XSensitivity;
+ m_Y += Input.GetAxis("Mouse Y") * m_YSensitivity;
+ if (m_X > 360f)
+ {
+ m_X = 0f;
+ }
+ else if (m_X < 0f)
+ {
+ m_X = 360f;
+ }
+ if (m_Y > 60f)
+ {
+ m_Y = 60f;
+ }
+ else if (m_Y < -60f)
+ {
+ m_Y = -60f;
+ }
+ Quaternion quaternion = Quaternion.AngleAxis(m_X, Vector3.up);
+ Quaternion quaternion2 = Quaternion.AngleAxis(m_Y, Vector3.left);
+ base.transform.localRotation = m_StartRotation * quaternion * quaternion2;
+ if (Input.GetKeyUp(KeyCode.Escape))
+ {
+ Application.Quit();
+ }
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeContext.cs b/DeepSky.Haze/DS_HazeContext.cs
new file mode 100644
index 0000000..2294526
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeContext.cs
@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace DeepSky.Haze;
+
+[Serializable]
+[AddComponentMenu("")]
+public class DS_HazeContext
+{
+ [SerializeField]
+ public List m_ContextItems;
+
+ [SerializeField]
+ private int m_SoloItem = -1;
+
+ public int Solo => m_SoloItem;
+
+ public DS_HazeContext()
+ {
+ m_ContextItems = new List();
+ DS_HazeContextItem item = new DS_HazeContextItem
+ {
+ m_Name = "Default"
+ };
+ m_ContextItems.Add(item);
+ }
+
+ public void DuplicateContextItem(int index)
+ {
+ if (index >= 0 && index < m_ContextItems.Count)
+ {
+ DS_HazeContextItem dS_HazeContextItem = new DS_HazeContextItem();
+ dS_HazeContextItem.CopyFrom(m_ContextItems[index]);
+ dS_HazeContextItem.m_Name += "_Copy";
+ m_ContextItems.Add(dS_HazeContextItem);
+ }
+ }
+
+ public void RemoveContextItem(int index)
+ {
+ if (index >= 0 && index < m_ContextItems.Count && m_ContextItems.Count != 1)
+ {
+ m_ContextItems.RemoveAt(index);
+ if (m_SoloItem != -1 && m_SoloItem == index)
+ {
+ m_SoloItem = -1;
+ }
+ }
+ }
+
+ public void MoveContextItemUp(int index)
+ {
+ if (index < 1 || index >= m_ContextItems.Count)
+ {
+ return;
+ }
+ DS_HazeContextItem item = m_ContextItems[index];
+ m_ContextItems.RemoveAt(index);
+ m_ContextItems.Insert(index - 1, item);
+ if (m_SoloItem != -1)
+ {
+ if (m_SoloItem == index)
+ {
+ m_SoloItem--;
+ }
+ else if (m_SoloItem == index - 1)
+ {
+ m_SoloItem++;
+ }
+ }
+ }
+
+ public void MoveContextItemDown(int index)
+ {
+ if (index < 0 || index >= m_ContextItems.Count - 1)
+ {
+ return;
+ }
+ DS_HazeContextItem item = m_ContextItems[index];
+ m_ContextItems.RemoveAt(index);
+ m_ContextItems.Insert(index + 1, item);
+ if (m_SoloItem != -1)
+ {
+ if (m_SoloItem == index)
+ {
+ m_SoloItem++;
+ }
+ else if (m_SoloItem == index + 1)
+ {
+ m_SoloItem--;
+ }
+ }
+ }
+
+ public DS_HazeContextItem GetContextItemBlended(float time = -1f)
+ {
+ DS_HazeContextItem dS_HazeContextItem = new DS_HazeContextItem();
+ dS_HazeContextItem.CopyFrom(m_ContextItems[0]);
+ if (m_ContextItems.Count == 1)
+ {
+ return dS_HazeContextItem;
+ }
+ time = Mathf.Clamp01(time);
+ float num = 0f;
+ for (int i = 1; i < m_ContextItems.Count; i++)
+ {
+ num = m_ContextItems[i].m_Weight.Evaluate(time);
+ dS_HazeContextItem.Lerp(m_ContextItems[i], num);
+ }
+ return dS_HazeContextItem;
+ }
+
+ public DS_HazeContextItem GetItemAtIndex(int index)
+ {
+ if (index < 0 || index >= m_ContextItems.Count)
+ {
+ return null;
+ }
+ return m_ContextItems[index];
+ }
+
+ public void CopyFrom(DS_HazeContext other)
+ {
+ if (m_ContextItems.Count > 0)
+ {
+ m_ContextItems.Clear();
+ }
+ for (int i = 0; i < other.m_ContextItems.Count; i++)
+ {
+ DS_HazeContextItem dS_HazeContextItem = new DS_HazeContextItem();
+ dS_HazeContextItem.CopyFrom(other.m_ContextItems[i]);
+ m_ContextItems.Add(dS_HazeContextItem);
+ }
+ }
+
+ public DS_HazeContextAsset GetContextAsset()
+ {
+ DS_HazeContextAsset dS_HazeContextAsset = ScriptableObject.CreateInstance();
+ dS_HazeContextAsset.Context.CopyFrom(this);
+ dS_HazeContextAsset.Context.m_SoloItem = -1;
+ return dS_HazeContextAsset;
+ }
+
+ public string[] GetItemNames()
+ {
+ string[] array = new string[m_ContextItems.Count];
+ for (int i = 0; i < m_ContextItems.Count; i++)
+ {
+ array[i] = m_ContextItems[i].m_Name;
+ }
+ return array;
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeContextAsset.cs b/DeepSky.Haze/DS_HazeContextAsset.cs
new file mode 100644
index 0000000..5e4e9da
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeContextAsset.cs
@@ -0,0 +1,14 @@
+using System;
+using UnityEngine;
+
+namespace DeepSky.Haze;
+
+[Serializable]
+[AddComponentMenu("")]
+public class DS_HazeContextAsset : ScriptableObject
+{
+ [SerializeField]
+ private DS_HazeContext m_Context = new DS_HazeContext();
+
+ public DS_HazeContext Context => m_Context;
+}
diff --git a/DeepSky.Haze/DS_HazeContextItem.cs b/DeepSky.Haze/DS_HazeContextItem.cs
new file mode 100644
index 0000000..d9208c9
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeContextItem.cs
@@ -0,0 +1,173 @@
+using System;
+using System.Reflection;
+using UnityEngine;
+
+namespace DeepSky.Haze;
+
+[Serializable]
+[AddComponentMenu("")]
+public class DS_HazeContextItem
+{
+ public enum Multiplier
+ {
+ OneTenth,
+ OneFifth,
+ OneHalf,
+ One,
+ Two,
+ Five,
+ Ten,
+ OneHundredth
+ }
+
+ [SerializeField]
+ public string m_Name;
+
+ [SerializeField]
+ public AnimationCurve m_Weight;
+
+ [SerializeField]
+ [Range(0f, 8f)]
+ public float m_AirScatteringScale = 1f;
+
+ [SerializeField]
+ public Multiplier m_AirScatteringMultiplier = Multiplier.One;
+
+ [SerializeField]
+ [Range(0.0001f, 0.1f)]
+ public float m_AirDensityHeightFalloff = 0.001f;
+
+ [SerializeField]
+ [Range(0f, 8f)]
+ public float m_HazeScatteringScale = 1f;
+
+ [SerializeField]
+ public Multiplier m_HazeScatteringMultiplier = Multiplier.One;
+
+ [SerializeField]
+ [Range(0.0001f, 0.1f)]
+ public float m_HazeDensityHeightFalloff = 0.003f;
+
+ [SerializeField]
+ [Range(-0.99f, 0.99f)]
+ public float m_HazeScatteringDirection = 0.8f;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ public float m_HazeSecondaryScatteringRatio = 0.8f;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ public float m_FogOpacity = 1f;
+
+ [SerializeField]
+ [Range(0f, 8f)]
+ public float m_FogScatteringScale = 1f;
+
+ [SerializeField]
+ [Range(0f, 8f)]
+ public float m_FogExtinctionScale = 1f;
+
+ [SerializeField]
+ public Multiplier m_FogExtinctionMultiplier = Multiplier.One;
+
+ [SerializeField]
+ [Range(0.0001f, 1f)]
+ public float m_FogDensityHeightFalloff = 0.01f;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ public float m_FogStartDistance;
+
+ [SerializeField]
+ [Range(-0.99f, 0.99f)]
+ public float m_FogScatteringDirection = 0.7f;
+
+ [SerializeField]
+ [Range(-10000f, 10000f)]
+ public float m_FogStartHeight;
+
+ [SerializeField]
+ public Color m_FogAmbientColour = Color.white;
+
+ [SerializeField]
+ public Color m_FogLightColour = Color.white;
+
+ public DS_HazeContextItem()
+ {
+ m_Name = "New";
+ m_Weight = new AnimationCurve(new Keyframe(0.25f, 0f), new Keyframe(0.5f, 1f), new Keyframe(0.75f, 0f));
+ }
+
+ public static float MultiplierAsFloat(Multiplier mult)
+ {
+ return mult switch
+ {
+ Multiplier.OneTenth => 0.1f,
+ Multiplier.OneFifth => 0.2f,
+ Multiplier.OneHalf => 0.5f,
+ Multiplier.One => 1f,
+ Multiplier.Two => 2f,
+ Multiplier.Five => 5f,
+ Multiplier.Ten => 10f,
+ Multiplier.OneHundredth => 0.01f,
+ _ => 1f,
+ };
+ }
+
+ public static float ParamWithMultiplier(float param, Multiplier mult)
+ {
+ return mult switch
+ {
+ Multiplier.OneTenth => param * 0.1f,
+ Multiplier.OneFifth => param * 0.2f,
+ Multiplier.OneHalf => param * 0.5f,
+ Multiplier.One => param * 1f,
+ Multiplier.Two => param * 2f,
+ Multiplier.Five => param * 5f,
+ Multiplier.Ten => param * 10f,
+ Multiplier.OneHundredth => param * 0.01f,
+ _ => param * 1f,
+ };
+ }
+
+ public void Lerp(DS_HazeContextItem other, float dt)
+ {
+ if (other != null)
+ {
+ dt = Mathf.Clamp01(dt);
+ float num = 1f - dt;
+ m_AirScatteringScale = m_AirScatteringScale * num + other.m_AirScatteringScale * dt;
+ m_AirDensityHeightFalloff = m_AirDensityHeightFalloff * num + other.m_AirDensityHeightFalloff * dt;
+ m_HazeScatteringScale = m_HazeScatteringScale * num + other.m_HazeScatteringScale * dt;
+ m_HazeDensityHeightFalloff = m_HazeDensityHeightFalloff * num + other.m_HazeDensityHeightFalloff * dt;
+ m_HazeScatteringDirection = m_HazeScatteringDirection * num + other.m_HazeScatteringDirection * dt;
+ m_HazeSecondaryScatteringRatio = m_HazeSecondaryScatteringRatio * num + other.m_HazeSecondaryScatteringRatio * dt;
+ m_FogOpacity = m_FogOpacity * num + other.m_FogOpacity * dt;
+ m_FogScatteringScale = m_FogScatteringScale * num + other.m_FogScatteringScale * dt;
+ m_FogExtinctionScale = m_FogExtinctionScale * num + other.m_FogExtinctionScale * dt;
+ m_FogDensityHeightFalloff = m_FogDensityHeightFalloff * num + other.m_FogDensityHeightFalloff * dt;
+ m_FogStartDistance = m_FogStartDistance * num + other.m_FogStartDistance * dt;
+ m_FogScatteringDirection = m_FogScatteringDirection * num + other.m_FogScatteringDirection * dt;
+ m_FogStartHeight = m_FogStartHeight * num + other.m_FogStartHeight * dt;
+ m_FogAmbientColour = m_FogAmbientColour * num + other.m_FogAmbientColour * dt;
+ m_FogLightColour = m_FogLightColour * num + other.m_FogLightColour * dt;
+ }
+ }
+
+ public void CopyFrom(DS_HazeContextItem other)
+ {
+ if (other != null)
+ {
+ Type type = GetType();
+ Type type2 = other.GetType();
+ FieldInfo[] fields = type.GetFields();
+ foreach (FieldInfo fieldInfo in fields)
+ {
+ FieldInfo field = type2.GetField(fieldInfo.Name);
+ fieldInfo.SetValue(this, field.GetValue(other));
+ }
+ m_Weight = new AnimationCurve(m_Weight.keys);
+ }
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeCore.cs b/DeepSky.Haze/DS_HazeCore.cs
new file mode 100644
index 0000000..30b3486
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeCore.cs
@@ -0,0 +1,218 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace DeepSky.Haze;
+
+[ExecuteInEditMode]
+[AddComponentMenu("DeepSky Haze/Controller", 51)]
+public class DS_HazeCore : MonoBehaviour
+{
+ public enum HeightFalloffType
+ {
+ Exponential,
+ None
+ }
+
+ public enum NoiseTextureSize
+ {
+ x8 = 8,
+ x16 = 0x10,
+ x32 = 0x20
+ }
+
+ public enum DebugGUIPosition
+ {
+ TopLeft,
+ TopCenter,
+ TopRight,
+ CenterLeft,
+ Center,
+ CenterRight,
+ BottomLeft,
+ BottomCenter,
+ BottomRight
+ }
+
+ public static string kVersionStr = "DeepSky Haze v1.4.0";
+
+ private static int kGUIHeight = 180;
+
+ private static DS_HazeCore instance;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ [Tooltip("The time at which Zones will evaluate their settings. Animate this or set in code to create time-of-day transitions.")]
+ private float m_Time;
+
+ [SerializeField]
+ [Tooltip("The height falloff method to use globally (default Exponential).")]
+ private HeightFalloffType m_HeightFalloff;
+
+ [SerializeField]
+ private List m_Zones = new List();
+
+ [SerializeField]
+ private DebugGUIPosition m_DebugGUIPosition;
+
+ private HashSet m_LightVolumes = new HashSet();
+
+ [SerializeField]
+ private Texture3D m_NoiseLUT;
+
+ [SerializeField]
+ private bool m_ShowDebugGUI;
+
+ private Vector2 m_GUIScrollPosition;
+
+ private int m_GUISelectedView = -1;
+
+ private bool m_GUISelectionPopup;
+
+ private DS_HazeView m_GUIDisplayedView;
+
+ public static DS_HazeCore Instance
+ {
+ get
+ {
+ if (instance == null)
+ {
+ instance = Object.FindObjectOfType();
+ }
+ return instance;
+ }
+ }
+
+ public float Time
+ {
+ get
+ {
+ return m_Time;
+ }
+ set
+ {
+ m_Time = Mathf.Clamp01(value);
+ }
+ }
+
+ public Texture3D NoiseLUT => m_NoiseLUT;
+
+ public HeightFalloffType HeightFalloff
+ {
+ get
+ {
+ return m_HeightFalloff;
+ }
+ set
+ {
+ m_HeightFalloff = value;
+ SetGlobalHeightFalloff();
+ }
+ }
+
+ private void SetGlobalHeightFalloff()
+ {
+ switch (m_HeightFalloff)
+ {
+ case HeightFalloffType.Exponential:
+ Shader.DisableKeyword("DS_HAZE_HEIGHT_FALLOFF_NONE");
+ break;
+ case HeightFalloffType.None:
+ Shader.EnableKeyword("DS_HAZE_HEIGHT_FALLOFF_NONE");
+ break;
+ }
+ }
+
+ private void OnTransformChildrenChanged()
+ {
+ m_Zones.Clear();
+ DS_HazeZone[] componentsInChildren = GetComponentsInChildren(includeInactive: true);
+ m_Zones.AddRange(componentsInChildren);
+ }
+
+ private void Awake()
+ {
+ if (instance == null)
+ {
+ instance = this;
+ }
+ else if (instance != this)
+ {
+ Debug.LogError("DeepSky::DS_HazeCore:Awake - There is more than one Haze Controller in this scene! Disabling " + base.name);
+ base.enabled = false;
+ }
+ }
+
+ private void OnEnable()
+ {
+ SetGlobalHeightFalloff();
+ Shader.SetGlobalTexture("_SamplingOffsets", m_NoiseLUT);
+ }
+
+ private void Reset()
+ {
+ OnTransformChildrenChanged();
+ }
+
+ public void SetGlobalNoiseLUT()
+ {
+ Shader.SetGlobalTexture("_SamplingOffsets", m_NoiseLUT);
+ }
+
+ public void AddLightVolume(DS_HazeLightVolume lightVolume)
+ {
+ RemoveLightVolume(lightVolume);
+ m_LightVolumes.Add(lightVolume);
+ }
+
+ public void RemoveLightVolume(DS_HazeLightVolume lightVolume)
+ {
+ m_LightVolumes.Remove(lightVolume);
+ }
+
+ public void GetRenderLightVolumes(Vector3 cameraPosition, List lightVolumes, List shadowVolumes)
+ {
+ foreach (DS_HazeLightVolume lightVolume in m_LightVolumes)
+ {
+ if (lightVolume.WillRender(cameraPosition))
+ {
+ if (lightVolume.CastShadows)
+ {
+ shadowVolumes.Add(lightVolume);
+ }
+ else
+ {
+ lightVolumes.Add(lightVolume);
+ }
+ }
+ }
+ }
+
+ public DS_HazeContextItem GetRenderContextAtPosition(Vector3 position)
+ {
+ List list = new List();
+ for (int i = 0; i < m_Zones.Count; i++)
+ {
+ if (m_Zones[i].Contains(position) && m_Zones[i].enabled)
+ {
+ list.Add(m_Zones[i]);
+ }
+ }
+ if (list.Count == 0)
+ {
+ return null;
+ }
+ if (list.Count == 1)
+ {
+ return list[0].Context.GetContextItemBlended(m_Time);
+ }
+ list.Sort((DS_HazeZone z1, DS_HazeZone z2) => (!(z1 < z2)) ? 1 : (-1));
+ DS_HazeContextItem contextItemBlended = list[0].Context.GetContextItemBlended(m_Time);
+ float num = 0f;
+ for (int j = 1; j < list.Count; j++)
+ {
+ num = list[j].GetBlendWeight(position);
+ contextItemBlended.Lerp(list[j].Context.GetContextItemBlended(m_Time), num);
+ }
+ return contextItemBlended;
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeLightVolume.cs b/DeepSky.Haze/DS_HazeLightVolume.cs
new file mode 100644
index 0000000..1a9928e
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeLightVolume.cs
@@ -0,0 +1,604 @@
+using System;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+namespace DeepSky.Haze;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Light))]
+[AddComponentMenu("DeepSky Haze/Light Volume", 2)]
+public class DS_HazeLightVolume : MonoBehaviour
+{
+ private static int kConeSubdivisions = 16;
+
+ private static Shader kLightVolumeShader;
+
+ private Light m_Light;
+
+ private Mesh m_ProxyMesh;
+
+ private Matrix4x4 m_LightVolumeTransform;
+
+ private CommandBuffer m_RenderCmd;
+
+ private Material m_VolumeMaterial;
+
+ private Vector3 m_DensityOffset = Vector3.zero;
+
+ [SerializeField]
+ private DS_SamplingQuality m_Samples = DS_SamplingQuality.x16;
+
+ [SerializeField]
+ private DS_LightFalloff m_Falloff;
+
+ [SerializeField]
+ private bool m_UseFog;
+
+ [SerializeField]
+ [Range(0f, 100f)]
+ private float m_Scattering = 1f;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ private float m_SecondaryScattering = 0.1f;
+
+ [SerializeField]
+ [Range(-1f, 1f)]
+ private float m_ScatteringDirection = 0.75f;
+
+ [SerializeField]
+ private Texture3D m_DensityTexture;
+
+ [SerializeField]
+ [Range(0.1f, 10f)]
+ private float m_DensityTextureScale = 1f;
+
+ [SerializeField]
+ [Range(0.1f, 3f)]
+ private float m_DensityTextureContrast = 1f;
+
+ [SerializeField]
+ private Vector3 m_AnimateDirection = Vector3.zero;
+
+ [SerializeField]
+ [Range(0f, 10f)]
+ private float m_AnimateSpeed = 1f;
+
+ [SerializeField]
+ private float m_StartFade = 25f;
+
+ [SerializeField]
+ private float m_EndFade = 30f;
+
+ [SerializeField]
+ [Range(0.01f, 1f)]
+ private float m_FarClip = 1f;
+
+ private LightType m_PreviousLightType = LightType.Point;
+
+ private float m_PreviousAngle = 45f;
+
+ private LightShadows m_PreviousShadowMode;
+
+ public Light LightSource => m_Light;
+
+ public LightType Type => (!(m_Light != null)) ? LightType.Point : m_Light.type;
+
+ public bool CastShadows => (m_Light.shadows != 0) ? true : false;
+
+ public CommandBuffer RenderCommandBuffer => m_RenderCmd;
+
+ public DS_SamplingQuality Samples
+ {
+ get
+ {
+ return m_Samples;
+ }
+ set
+ {
+ m_Samples = value;
+ }
+ }
+
+ public DS_LightFalloff Falloff
+ {
+ get
+ {
+ return m_Falloff;
+ }
+ set
+ {
+ m_Falloff = value;
+ }
+ }
+
+ public bool UseFog
+ {
+ get
+ {
+ return m_UseFog;
+ }
+ set
+ {
+ m_UseFog = value;
+ }
+ }
+
+ public float Scattering
+ {
+ get
+ {
+ return m_Scattering;
+ }
+ set
+ {
+ m_Scattering = Mathf.Clamp01(value);
+ }
+ }
+
+ public float ScatteringDirection
+ {
+ get
+ {
+ return m_ScatteringDirection;
+ }
+ set
+ {
+ m_ScatteringDirection = Mathf.Clamp(value, -1f, 1f);
+ }
+ }
+
+ public Texture3D DensityTexture
+ {
+ get
+ {
+ return m_DensityTexture;
+ }
+ set
+ {
+ m_DensityTexture = value;
+ }
+ }
+
+ public float DensityTextureScale
+ {
+ get
+ {
+ return m_DensityTextureScale;
+ }
+ set
+ {
+ m_DensityTextureScale = Mathf.Clamp01(m_DensityTextureScale);
+ }
+ }
+
+ public Vector3 AnimateDirection
+ {
+ get
+ {
+ return m_AnimateDirection;
+ }
+ set
+ {
+ m_AnimateDirection = value.normalized;
+ }
+ }
+
+ public float AnimateSpeed
+ {
+ get
+ {
+ return m_AnimateSpeed;
+ }
+ set
+ {
+ m_AnimateSpeed = Mathf.Clamp01(value);
+ }
+ }
+
+ public float StartFade
+ {
+ get
+ {
+ return m_StartFade;
+ }
+ set
+ {
+ m_StartFade = ((!(value > 0f)) ? 1f : value);
+ }
+ }
+
+ public float EndFade
+ {
+ get
+ {
+ return m_EndFade;
+ }
+ set
+ {
+ m_EndFade = ((!(value > m_StartFade)) ? (m_StartFade + 1f) : value);
+ }
+ }
+
+ private void CreateProxyMeshCone(Mesh proxyMesh)
+ {
+ Vector3[] array = null;
+ int[] array2 = null;
+ float num = Mathf.Tan(m_Light.spotAngle / 2f * ((float)Math.PI / 180f)) * m_FarClip;
+ array = new Vector3[kConeSubdivisions + 2];
+ array2 = new int[kConeSubdivisions * 6];
+ float num2 = (float)Math.PI * 2f / (float)kConeSubdivisions;
+ float num3 = 0f;
+ for (int i = 0; i < kConeSubdivisions; i++)
+ {
+ ref Vector3 reference = ref array[i];
+ reference = new Vector3(Mathf.Sin(num3) * num, Mathf.Cos(num3) * num, m_FarClip);
+ num3 += num2;
+ }
+ ref Vector3 reference2 = ref array[kConeSubdivisions];
+ reference2 = new Vector3(0f, 0f, m_FarClip);
+ ref Vector3 reference3 = ref array[kConeSubdivisions + 1];
+ reference3 = new Vector3(0f, 0f, -0.1f);
+ for (int j = 0; j < kConeSubdivisions; j++)
+ {
+ array2[j * 3] = kConeSubdivisions;
+ array2[j * 3 + 1] = ((j != kConeSubdivisions - 1) ? (j + 1) : 0);
+ array2[j * 3 + 2] = j;
+ array2[kConeSubdivisions * 3 + j * 3] = j;
+ array2[kConeSubdivisions * 3 + j * 3 + 1] = ((j != kConeSubdivisions - 1) ? (j + 1) : 0);
+ array2[kConeSubdivisions * 3 + j * 3 + 2] = kConeSubdivisions + 1;
+ }
+ proxyMesh.vertices = array;
+ proxyMesh.triangles = array2;
+ proxyMesh.hideFlags = HideFlags.HideAndDontSave;
+ m_PreviousAngle = m_Light.spotAngle;
+ }
+
+ public bool ProxyMeshRequiresRebuild()
+ {
+ if (m_Light == null)
+ {
+ return false;
+ }
+ if (m_ProxyMesh == null || (m_Light.type == LightType.Spot && m_Light.spotAngle != m_PreviousAngle))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public bool LightTypeChanged()
+ {
+ if (m_Light == null)
+ {
+ return false;
+ }
+ return m_Light.type != m_PreviousLightType;
+ }
+
+ public void UpdateLightType()
+ {
+ m_VolumeMaterial.DisableKeyword("POINT_COOKIE");
+ m_VolumeMaterial.DisableKeyword("SPOT_COOKIE");
+ if (m_Light.type == LightType.Point)
+ {
+ m_VolumeMaterial.EnableKeyword("POINT");
+ m_VolumeMaterial.DisableKeyword("SPOT");
+ }
+ else
+ {
+ if (m_Light.type != 0)
+ {
+ Debug.LogError("DeepSky::DS_HazeLightVolume: Unsupported light type! " + base.gameObject.name + " will not render volumetrics.");
+ base.enabled = false;
+ return;
+ }
+ m_VolumeMaterial.EnableKeyword("SPOT");
+ m_VolumeMaterial.DisableKeyword("POINT");
+ }
+ RebuildProxyMesh();
+ m_PreviousLightType = m_Light.type;
+ }
+
+ public void RebuildProxyMesh()
+ {
+ switch (m_Light.type)
+ {
+ case LightType.Point:
+ if (m_PreviousLightType != LightType.Point)
+ {
+ UnityEngine.Object.DestroyImmediate(m_ProxyMesh);
+ }
+ m_ProxyMesh = Resources.Load("DS_HazeMeshProxySphere");
+ break;
+ case LightType.Spot:
+ if (m_PreviousLightType == LightType.Point)
+ {
+ m_ProxyMesh = new Mesh();
+ }
+ else if (m_ProxyMesh != null)
+ {
+ m_ProxyMesh.Clear();
+ }
+ CreateProxyMeshCone(m_ProxyMesh);
+ break;
+ default:
+ Debug.LogError("DeepSky::DS_HazeLightVolume: Unsupported light type! " + base.gameObject.name + " will not render volumetrics.");
+ base.enabled = false;
+ break;
+ }
+ }
+
+ public bool ShadowModeChanged()
+ {
+ if (m_Light == null)
+ {
+ return false;
+ }
+ return m_Light.shadows != m_PreviousShadowMode;
+ }
+
+ public void UpdateShadowMode()
+ {
+ if (m_Light.shadows == LightShadows.None)
+ {
+ m_VolumeMaterial.DisableKeyword("SHADOWS_DEPTH");
+ m_VolumeMaterial.DisableKeyword("SHADOWS_CUBE");
+ }
+ else if (m_Light.type == LightType.Point)
+ {
+ m_VolumeMaterial.EnableKeyword("SHADOWS_CUBE");
+ m_VolumeMaterial.DisableKeyword("SHADOWS_DEPTH");
+ }
+ else if (m_Light.type == LightType.Spot)
+ {
+ m_VolumeMaterial.EnableKeyword("SHADOWS_DEPTH");
+ m_VolumeMaterial.DisableKeyword("SHADOWS_CUBE");
+ }
+ m_PreviousShadowMode = m_Light.shadows;
+ }
+
+ public void Register()
+ {
+ DS_HazeCore instance = DS_HazeCore.Instance;
+ if (instance == null)
+ {
+ Debug.LogError("DeepSky::DS_HazeLightVolume: Attempting to add a light volume but no HS_HazeCore found in scene! Please make sure there is a DS_HazeCore object.");
+ }
+ else
+ {
+ instance.AddLightVolume(this);
+ }
+ }
+
+ public void Deregister()
+ {
+ DS_HazeCore instance = DS_HazeCore.Instance;
+ if (instance != null)
+ {
+ instance.RemoveLightVolume(this);
+ }
+ }
+
+ public bool WillRender(Vector3 cameraPos)
+ {
+ return base.isActiveAndEnabled & (Vector3.Distance(cameraPos, base.transform.position) < m_EndFade);
+ }
+
+ private void Update()
+ {
+ m_DensityOffset -= m_AnimateDirection * m_AnimateSpeed * Time.deltaTime * 0.1f;
+ }
+
+ private void OnEnable()
+ {
+ m_Light = GetComponent();
+ if (m_Light == null)
+ {
+ Debug.LogError("DeepSky::DS_HazeLightVolume: No Light component found on " + base.gameObject.name);
+ base.enabled = false;
+ }
+ if (kLightVolumeShader == null)
+ {
+ kLightVolumeShader = Resources.Load("DS_HazeLightVolume");
+ }
+ if (m_VolumeMaterial == null)
+ {
+ m_VolumeMaterial = new Material(kLightVolumeShader);
+ m_VolumeMaterial.hideFlags = HideFlags.HideAndDontSave;
+ }
+ if (m_RenderCmd == null)
+ {
+ m_RenderCmd = new CommandBuffer();
+ m_RenderCmd.name = base.gameObject.name + "_DS_Haze_RenderLightVolume";
+ m_Light.AddCommandBuffer(LightEvent.AfterShadowMap, m_RenderCmd);
+ }
+ if (LightTypeChanged())
+ {
+ UpdateLightType();
+ }
+ else if (ProxyMeshRequiresRebuild())
+ {
+ RebuildProxyMesh();
+ }
+ if (ShadowModeChanged())
+ {
+ UpdateShadowMode();
+ }
+ Register();
+ }
+
+ private void OnDisable()
+ {
+ Deregister();
+ }
+
+ private void OnDestroy()
+ {
+ if (m_RenderCmd != null)
+ {
+ m_RenderCmd.Dispose();
+ }
+ Deregister();
+ if (m_ProxyMesh != null && m_Light.type != LightType.Point)
+ {
+ UnityEngine.Object.DestroyImmediate(m_ProxyMesh);
+ }
+ if (m_VolumeMaterial != null)
+ {
+ UnityEngine.Object.DestroyImmediate(m_VolumeMaterial);
+ }
+ }
+
+ private int SetShaderPassAndMatrix(Transform cameraTransform, int downSampleFactor, out Matrix4x4 worldMtx)
+ {
+ worldMtx = Matrix4x4.TRS(base.transform.position, base.transform.rotation, new Vector3(m_Light.range, m_Light.range, m_Light.range));
+ int num = 0;
+ if (m_Light.type == LightType.Spot)
+ {
+ float num2 = Mathf.Cos(m_Light.spotAngle / 2f * ((float)Math.PI / 180f));
+ Vector3 normalized = (cameraTransform.position - base.transform.position).normalized;
+ float num3 = Vector3.Dot(normalized, base.transform.forward);
+ num = ((num3 > num2) ? 1 : 2);
+ }
+ if (downSampleFactor == 4)
+ {
+ num += 3;
+ }
+ if (m_Falloff == DS_LightFalloff.Quadratic)
+ {
+ num += 6;
+ }
+ if (m_UseFog)
+ {
+ num += 12;
+ }
+ return num;
+ }
+
+ public void FillLightCommandBuffer(RenderTexture radianceTarget, Transform cameraTransform, int downSampleFactor)
+ {
+ m_RenderCmd.SetGlobalTexture("_ShadowMapTexture", BuiltinRenderTextureType.CurrentActive);
+ Matrix4x4 worldMtx;
+ int shaderPass = SetShaderPassAndMatrix(cameraTransform, downSampleFactor, out worldMtx);
+ m_RenderCmd.SetRenderTarget(radianceTarget);
+ m_RenderCmd.DrawMesh(m_ProxyMesh, worldMtx, m_VolumeMaterial, 0, shaderPass);
+ }
+
+ public void AddLightRenderCommand(Transform cameraTransform, CommandBuffer cmd, int downSampleFactor)
+ {
+ Matrix4x4 worldMtx;
+ int shaderPass = SetShaderPassAndMatrix(cameraTransform, downSampleFactor, out worldMtx);
+ cmd.DrawMesh(m_ProxyMesh, worldMtx, m_VolumeMaterial, 0, shaderPass);
+ }
+
+ public void SetupMaterialPerFrame(Matrix4x4 viewProjMtx, Matrix4x4 viewMtx, Transform cameraTransform, float offsetIndex)
+ {
+ m_VolumeMaterial.DisableKeyword("SAMPLES_4");
+ m_VolumeMaterial.DisableKeyword("SAMPLES_8");
+ m_VolumeMaterial.DisableKeyword("SAMPLES_16");
+ m_VolumeMaterial.DisableKeyword("SAMPLES_32");
+ switch (m_Samples)
+ {
+ case DS_SamplingQuality.x4:
+ m_VolumeMaterial.EnableKeyword("SAMPLES_4");
+ break;
+ case DS_SamplingQuality.x8:
+ m_VolumeMaterial.EnableKeyword("SAMPLES_8");
+ break;
+ case DS_SamplingQuality.x16:
+ m_VolumeMaterial.EnableKeyword("SAMPLES_16");
+ break;
+ case DS_SamplingQuality.x32:
+ m_VolumeMaterial.EnableKeyword("SAMPLES_32");
+ break;
+ default:
+ m_VolumeMaterial.EnableKeyword("SAMPLES_16");
+ break;
+ }
+ float num = 1f - Mathf.Clamp01((Vector3.Distance(cameraTransform.position, base.transform.position) - m_StartFade) / (m_EndFade - m_StartFade));
+ m_VolumeMaterial.SetVector("_DS_HazeSamplingParams", new Vector4(offsetIndex, 0f, m_DensityTextureContrast, 0f));
+ m_VolumeMaterial.SetVector("_DS_HazeCameraDirection", new Vector4(cameraTransform.forward.x, cameraTransform.forward.y, cameraTransform.forward.z, 1f));
+ m_VolumeMaterial.SetColor("_DS_HazeLightVolumeColour", m_Light.color.linear * m_Light.intensity * num);
+ m_VolumeMaterial.SetVector("_DS_HazeLightVolumeScattering", new Vector4(m_Scattering, m_SecondaryScattering, m_ScatteringDirection, Mathf.Clamp01(1f - m_SecondaryScattering)));
+ m_VolumeMaterial.SetVector("_DS_HazeLightVolumeParams0", new Vector4(base.transform.position.x, base.transform.position.y, base.transform.position.z, m_Light.range));
+ Matrix4x4 matrix4x = Matrix4x4.TRS(base.transform.position, base.transform.rotation, new Vector3(m_Light.range, m_Light.range, m_Light.range));
+ m_VolumeMaterial.SetMatrix("_WorldViewProj", viewProjMtx * matrix4x);
+ m_VolumeMaterial.SetMatrix("_WorldView", viewMtx * matrix4x);
+ if ((bool)m_DensityTexture)
+ {
+ m_VolumeMaterial.EnableKeyword("DENSITY_TEXTURE");
+ m_VolumeMaterial.SetTexture("_DensityTexture", m_DensityTexture);
+ m_VolumeMaterial.SetVector("_DS_HazeDensityParams", new Vector4(m_DensityOffset.x, m_DensityOffset.y, m_DensityOffset.z, m_DensityTextureScale * 0.01f));
+ }
+ else
+ {
+ m_VolumeMaterial.DisableKeyword("DENSITY_TEXTURE");
+ }
+ bool flag = m_Light.shadows != LightShadows.None;
+ if (m_Light.type == LightType.Point)
+ {
+ m_VolumeMaterial.DisableKeyword("SPOT_COOKIE");
+ m_VolumeMaterial.DisableKeyword("SHADOWS_DEPTH");
+ if (flag)
+ {
+ m_VolumeMaterial.EnableKeyword("SHADOWS_CUBE");
+ }
+ else
+ {
+ m_VolumeMaterial.DisableKeyword("SHADOWS_CUBE");
+ }
+ if ((bool)m_Light.cookie)
+ {
+ m_VolumeMaterial.EnableKeyword("POINT_COOKIE");
+ m_VolumeMaterial.SetMatrix("_DS_Haze_WorldToCookie", base.transform.worldToLocalMatrix);
+ m_VolumeMaterial.SetTexture("_LightTexture0", m_Light.cookie);
+ }
+ else
+ {
+ m_VolumeMaterial.DisableKeyword("POINT_COOKIE");
+ }
+ }
+ else if (m_Light.type == LightType.Spot)
+ {
+ m_VolumeMaterial.DisableKeyword("POINT_COOKIE");
+ m_VolumeMaterial.DisableKeyword("SHADOWS_CUBE");
+ if (flag)
+ {
+ m_VolumeMaterial.EnableKeyword("SHADOWS_DEPTH");
+ Matrix4x4 inverse = Matrix4x4.TRS(base.transform.position, base.transform.rotation, Vector3.one).inverse;
+ Matrix4x4 matrix4x2 = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0.5f), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f));
+ Matrix4x4 matrix4x3 = Matrix4x4.Perspective(m_Light.spotAngle, 1f, m_Light.range, m_Light.shadowNearPlane);
+ Matrix4x4 value = matrix4x2 * matrix4x3;
+ value[0, 2] *= -1f;
+ value[1, 2] *= -1f;
+ value[2, 2] *= -1f;
+ value[3, 2] *= -1f;
+ value *= inverse;
+ m_VolumeMaterial.SetMatrix("_DS_Haze_WorldToShadow", value);
+ }
+ else
+ {
+ m_VolumeMaterial.DisableKeyword("SHADOWS_DEPTH");
+ }
+ float num2 = Mathf.Cos(m_Light.spotAngle / 2f * ((float)Math.PI / 180f));
+ Vector3 lhs = base.transform.position + base.transform.forward * m_Light.range;
+ float z = 0f - Vector3.Dot(lhs, base.transform.forward);
+ m_VolumeMaterial.SetVector("_DS_HazeLightVolumeParams1", new Vector4(base.transform.forward.x, base.transform.forward.y, base.transform.forward.z, 1f));
+ m_VolumeMaterial.SetVector("_DS_HazeLightVolumeParams2", new Vector4(num2, 1f / num2, z, 0f));
+ if ((bool)m_Light.cookie)
+ {
+ m_VolumeMaterial.EnableKeyword("SPOT_COOKIE");
+ Matrix4x4 inverse2 = Matrix4x4.TRS(base.transform.position, base.transform.rotation, Vector3.one).inverse;
+ Matrix4x4 matrix4x4 = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0f), Quaternion.identity, new Vector3(-0.5f, -0.5f, 1f));
+ Matrix4x4 matrix4x5 = Matrix4x4.Perspective(m_Light.spotAngle, 1f, 0f, 1f);
+ m_VolumeMaterial.SetMatrix("_DS_Haze_WorldToCookie", matrix4x4 * matrix4x5 * inverse2);
+ m_VolumeMaterial.SetTexture("_LightTexture0", m_Light.cookie);
+ }
+ else
+ {
+ m_VolumeMaterial.DisableKeyword("SPOT_COOKIE");
+ }
+ }
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeView.cs b/DeepSky.Haze/DS_HazeView.cs
new file mode 100644
index 0000000..925f1a3
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeView.cs
@@ -0,0 +1,1120 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+namespace DeepSky.Haze;
+
+[ExecuteInEditMode]
+[AddComponentMenu("DeepSky Haze/View", 1)]
+public class DS_HazeView : MonoBehaviour
+{
+ private enum SizeFactor
+ {
+ Half = 2,
+ Quarter = 4
+ }
+
+ private enum VolumeSamples
+ {
+ x16,
+ x24,
+ x32
+ }
+
+ private static string kClearRadianceCmdBufferName = "DS_Haze_ClearRadiance";
+
+ private static string kShadowCascadesCmdBufferName = "DS_Haze_ShadowCascadesCopy";
+
+ private static string kDirectionalLightCmdBufferName = "DS_Haze_DirectLight";
+
+ private static string kRenderLightVolumeCmdBufferName = "DS_Haze_RenderLightVolume";
+
+ private static string kPreviousDepthTargetName = "DS_Haze_PreviousDepthTarget";
+
+ private static string kRadianceTarget01Name = "DS_Haze_RadianceTarget_01";
+
+ private static string kRadianceTarget02Name = "DS_Haze_RadianceTarget_02";
+
+ private static Shader kShader;
+
+ [SerializeField]
+ private bool m_OverrideTime;
+
+ [SerializeField]
+ [Range(0f, 1f)]
+ private float m_Time = 0.5f;
+
+ [SerializeField]
+ private bool m_OverrideContextAsset;
+
+ [SerializeField]
+ private DS_HazeContextAsset m_Context;
+
+ [SerializeField]
+ private bool m_OverrideContextVariant;
+
+ [SerializeField]
+ private int m_ContextItemIndex;
+
+ [SerializeField]
+ private Light m_DirectLight;
+
+ [SerializeField]
+ private bool m_RenderAtmosphereVolumetrics = true;
+
+ [SerializeField]
+ private bool m_RenderLocalVolumetrics = true;
+
+ [SerializeField]
+ private bool m_TemporalReprojection = true;
+
+ [SerializeField]
+ private SizeFactor m_DownsampleFactor = SizeFactor.Half;
+
+ [SerializeField]
+ private VolumeSamples m_VolumeSamples;
+
+ [SerializeField]
+ [Range(100f, 5000f)]
+ private int m_GaussianDepthFalloff = 500;
+
+ [SerializeField]
+ [Range(0f, 0.5f)]
+ private float m_UpsampleDepthThreshold = 0.06f;
+
+ [SerializeField]
+ [Range(0.001f, 1f)]
+ private float m_TemporalRejectionScale = 0.1f;
+
+ [SerializeField]
+ [Range(0.1f, 0.9f)]
+ private float m_TemporalBlendFactor = 0.25f;
+
+ private ShadowProjection m_ShadowProjectionType = ShadowProjection.StableFit;
+
+ [SerializeField]
+ private bool m_ApplyAirToSkybox;
+
+ [SerializeField]
+ private bool m_ApplyHazeToSkybox = true;
+
+ [SerializeField]
+ private bool m_ApplyFogExtinctionToSkybox = true;
+
+ [SerializeField]
+ private bool m_ApplyFogLightingToSkybox = true;
+
+ [SerializeField]
+ private bool m_ShowTemporalRejection;
+
+ [SerializeField]
+ private bool m_ShowUpsampleThreshold;
+
+ private Camera m_Camera;
+
+ private RenderTexture m_PerFrameRadianceTarget;
+
+ private RenderTexture m_RadianceTarget_01;
+
+ private RenderTexture m_RadianceTarget_02;
+
+ private RenderTexture m_CurrentRadianceTarget;
+
+ private RenderTexture m_PreviousRadianceTarget;
+
+ private RenderTexture m_PreviousDepthTarget;
+
+ private CommandBuffer m_ShadowCascadesCmdBuffer;
+
+ private CommandBuffer m_DirectionalLightCmdBuffer;
+
+ private CommandBuffer m_ClearRadianceCmdBuffer;
+
+ private CommandBuffer m_RenderNonShadowVolumes;
+
+ private Material m_Material;
+
+ private Matrix4x4 m_PreviousViewProjMatrix = Matrix4x4.identity;
+
+ private Matrix4x4 m_PreviousInvViewProjMatrix = Matrix4x4.identity;
+
+ private float m_InterleavedOffsetIndex;
+
+ private int m_X;
+
+ private int m_Y;
+
+ private RenderingPath m_PreviousRenderPath;
+
+ private ColorSpace m_ColourSpace;
+
+ private List m_PerFrameLightVolumes = new List();
+
+ private List m_PerFrameShadowLightVolumes = new List();
+
+ private Dictionary m_LightVolumeCmdBuffers = new Dictionary();
+
+ public bool OverrideTime
+ {
+ get
+ {
+ return m_OverrideTime;
+ }
+ set
+ {
+ m_OverrideTime = value;
+ if (value && m_OverrideContextVariant)
+ {
+ m_OverrideContextVariant = false;
+ }
+ }
+ }
+
+ public float Time
+ {
+ get
+ {
+ return m_Time;
+ }
+ set
+ {
+ m_Time = value;
+ }
+ }
+
+ public bool OverrideContextAsset
+ {
+ get
+ {
+ return m_OverrideContextAsset;
+ }
+ set
+ {
+ m_OverrideContextAsset = value;
+ }
+ }
+
+ public DS_HazeContextAsset ContextAsset
+ {
+ get
+ {
+ return m_Context;
+ }
+ set
+ {
+ m_Context = value;
+ }
+ }
+
+ public bool OverrideContextVariant
+ {
+ get
+ {
+ return m_OverrideContextVariant;
+ }
+ set
+ {
+ m_OverrideContextVariant = value;
+ if (value && m_OverrideTime)
+ {
+ m_OverrideTime = false;
+ }
+ }
+ }
+
+ public int ContextItemIndex
+ {
+ get
+ {
+ return m_ContextItemIndex;
+ }
+ set
+ {
+ m_ContextItemIndex = ((value > 0) ? value : 0);
+ }
+ }
+
+ public Light DirectLight
+ {
+ get
+ {
+ return m_DirectLight;
+ }
+ set
+ {
+ m_DirectLight = value;
+ }
+ }
+
+ public Vector2 RadianceTargetSize => new Vector2(m_X, m_Y);
+
+ public int SampleCount => m_VolumeSamples switch
+ {
+ VolumeSamples.x16 => 16,
+ VolumeSamples.x24 => 24,
+ VolumeSamples.x32 => 32,
+ _ => 16,
+ };
+
+ public int DownSampleFactor => (m_DownsampleFactor != SizeFactor.Half) ? 4 : 2;
+
+ public bool RenderAtmosphereVolumetrics
+ {
+ get
+ {
+ return m_RenderAtmosphereVolumetrics;
+ }
+ set
+ {
+ m_RenderAtmosphereVolumetrics = value;
+ SetTemporalKeywords();
+ }
+ }
+
+ public bool RenderLocalVolumetrics
+ {
+ get
+ {
+ return m_RenderLocalVolumetrics;
+ }
+ set
+ {
+ m_RenderLocalVolumetrics = value;
+ SetTemporalKeywords();
+ }
+ }
+
+ public bool TemporalReprojection
+ {
+ get
+ {
+ return m_TemporalReprojection;
+ }
+ set
+ {
+ m_TemporalReprojection = value;
+ SetTemporalKeywords();
+ }
+ }
+
+ public bool WillRenderWithTemporalReprojection => m_TemporalReprojection & (m_RenderAtmosphereVolumetrics | m_RenderLocalVolumetrics);
+
+ public int AntiAliasingLevel()
+ {
+ int result = 1;
+ if (m_Camera.actualRenderingPath == RenderingPath.Forward && m_Camera.allowMSAA && QualitySettings.antiAliasing > 0)
+ {
+ result = QualitySettings.antiAliasing;
+ }
+ return result;
+ }
+
+ private bool CheckHasSystemSupport()
+ {
+ if (!SystemInfo.supportsImageEffects)
+ {
+ Debug.LogError("DeepSky::DS_HazeView: Image effects are not supported on this platform.");
+ base.enabled = false;
+ return false;
+ }
+ if (SystemInfo.graphicsShaderLevel < 30)
+ {
+ Debug.LogError("DeepSky::DS_HazeView: Minimum required shader model (3.0) is not supported on this platform.");
+ base.enabled = false;
+ return false;
+ }
+ if (m_Camera.allowHDR && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
+ {
+ Debug.LogError("DeepSky::DS_HazeView: ARGBHalf render texture format is not supported on this platform.");
+ base.enabled = false;
+ return false;
+ }
+ if (!SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat))
+ {
+ Debug.LogError("DeepSky::DS_HazeView: RFloat render texture format is not supported on this platform.");
+ base.enabled = false;
+ return false;
+ }
+ return true;
+ }
+
+ private void SetMaterialFromContext(DS_HazeContextItem ctx)
+ {
+ if (WillRenderWithTemporalReprojection)
+ {
+ m_InterleavedOffsetIndex += 0.0625f;
+ if (Mathf.Approximately(m_InterleavedOffsetIndex, 1f))
+ {
+ m_InterleavedOffsetIndex = 0f;
+ }
+ }
+ float x = 1f;
+ float y = 1f;
+ float z = 1f;
+ switch (DS_HazeCore.Instance.HeightFalloff)
+ {
+ case DS_HazeCore.HeightFalloffType.None:
+ x = 1f;
+ y = 1f;
+ z = 1f;
+ break;
+ case DS_HazeCore.HeightFalloffType.Exponential:
+ {
+ float num = Mathf.Abs(base.transform.position.y);
+ x = Mathf.Exp((0f - ctx.m_AirDensityHeightFalloff) * num);
+ y = Mathf.Exp((0f - ctx.m_HazeDensityHeightFalloff) * num);
+ z = Mathf.Exp((0f - ctx.m_FogDensityHeightFalloff) * (num - ctx.m_FogStartHeight));
+ break;
+ }
+ }
+ Vector3 vector = ctx.m_AirScatteringScale * new Vector3(0.00116f, 0.0027f, 0.00662f);
+ float x2 = ctx.m_HazeScatteringScale * 0.0021f;
+ float fogScatteringScale = ctx.m_FogScatteringScale;
+ float w = ctx.m_FogExtinctionScale * 0.01f;
+ Vector4 value = new Vector4(ctx.m_AirDensityHeightFalloff, ctx.m_HazeDensityHeightFalloff, 0f, ctx.m_HazeScatteringDirection);
+ Vector4 value2 = new Vector4(x2, (!m_RenderAtmosphereVolumetrics) ? 0f : ctx.m_HazeSecondaryScatteringRatio, fogScatteringScale, w);
+ Vector4 value3 = new Vector4(x, y, z, 0f);
+ Vector4 value4 = new Vector4(ctx.m_FogStartDistance, ctx.m_FogDensityHeightFalloff, ctx.m_FogOpacity, ctx.m_FogScatteringDirection);
+ Vector4 value5 = new Vector4(m_GaussianDepthFalloff, m_UpsampleDepthThreshold * 0.01f, m_TemporalRejectionScale, m_TemporalBlendFactor);
+ m_Material.SetVector("_SamplingParams", value5);
+ m_Material.SetVector("_InterleavedOffset", new Vector4(m_InterleavedOffsetIndex, 0f, 0f, 0f));
+ m_Material.SetMatrix("_PreviousViewProjMatrix", m_PreviousViewProjMatrix);
+ m_Material.SetMatrix("_PreviousInvViewProjMatrix", m_PreviousInvViewProjMatrix);
+ Shader.SetGlobalVector("_DS_BetaParams", value2);
+ Shader.SetGlobalVector("_DS_RBetaS", vector);
+ Shader.SetGlobalVector("_DS_AirHazeParams", value);
+ Shader.SetGlobalVector("_DS_FogParams", value4);
+ Shader.SetGlobalVector("_DS_InitialDensityParams", value3);
+ Vector3 vector2;
+ Color color;
+ if ((bool)m_DirectLight)
+ {
+ vector2 = -m_DirectLight.transform.forward;
+ color = m_DirectLight.color.linear * m_DirectLight.intensity;
+ Shader.SetGlobalColor("_DS_FogAmbientLight", ctx.m_FogAmbientColour.linear * m_DirectLight.intensity);
+ Shader.SetGlobalColor("_DS_FogDirectLight", ctx.m_FogLightColour.linear * m_DirectLight.intensity);
+ }
+ else
+ {
+ vector2 = Vector3.up;
+ color = Color.white;
+ Shader.SetGlobalColor("_DS_FogAmbientLight", ctx.m_FogAmbientColour.linear);
+ Shader.SetGlobalColor("_DS_FogDirectLight", ctx.m_FogLightColour.linear);
+ }
+ Shader.SetGlobalVector("_DS_LightDirection", vector2);
+ Shader.SetGlobalVector("_DS_LightColour", color);
+ }
+
+ private void SetGlobalParamsToNull()
+ {
+ Shader.SetGlobalVector("_DS_BetaParams", Vector4.zero);
+ Shader.SetGlobalVector("_DS_RBetaS", Vector4.zero);
+ }
+
+ public void SetDebugKeywords()
+ {
+ if (m_ShowTemporalRejection)
+ {
+ m_Material.EnableKeyword("SHOW_TEMPORAL_REJECTION");
+ }
+ else
+ {
+ m_Material.DisableKeyword("SHOW_TEMPORAL_REJECTION");
+ }
+ if (m_ShowUpsampleThreshold)
+ {
+ m_Material.EnableKeyword("SHOW_UPSAMPLE_THRESHOLD");
+ }
+ else
+ {
+ m_Material.DisableKeyword("SHOW_UPSAMPLE_THRESHOLD");
+ }
+ }
+
+ public void SetSkyboxKeywords()
+ {
+ if (m_ApplyAirToSkybox)
+ {
+ m_Material.EnableKeyword("DS_HAZE_APPLY_RAYLEIGH");
+ }
+ else
+ {
+ m_Material.DisableKeyword("DS_HAZE_APPLY_RAYLEIGH");
+ }
+ if (m_ApplyHazeToSkybox)
+ {
+ m_Material.EnableKeyword("DS_HAZE_APPLY_MIE");
+ }
+ else
+ {
+ m_Material.DisableKeyword("DS_HAZE_APPLY_MIE");
+ }
+ if (m_ApplyFogExtinctionToSkybox)
+ {
+ m_Material.EnableKeyword("DS_HAZE_APPLY_FOG_EXTINCTION");
+ }
+ else
+ {
+ m_Material.DisableKeyword("DS_HAZE_APPLY_FOG_EXTINCTION");
+ }
+ if (m_ApplyFogLightingToSkybox)
+ {
+ m_Material.EnableKeyword("DS_HAZE_APPLY_FOG_RADIANCE");
+ }
+ else
+ {
+ m_Material.DisableKeyword("DS_HAZE_APPLY_FOG_RADIANCE");
+ }
+ }
+
+ public void SetTemporalKeywords()
+ {
+ if (WillRenderWithTemporalReprojection)
+ {
+ m_Material.EnableKeyword("DS_HAZE_TEMPORAL");
+ return;
+ }
+ m_Material.DisableKeyword("DS_HAZE_TEMPORAL");
+ if (m_ShowTemporalRejection)
+ {
+ m_ShowTemporalRejection = false;
+ m_Material.DisableKeyword("SHOW_TEMPORAL_REJECTION");
+ }
+ if ((bool)m_RadianceTarget_01)
+ {
+ m_RadianceTarget_01.Release();
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_01);
+ m_RadianceTarget_01 = null;
+ }
+ if ((bool)m_RadianceTarget_02)
+ {
+ m_RadianceTarget_02.Release();
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_02);
+ m_RadianceTarget_02 = null;
+ }
+ if ((bool)m_PreviousDepthTarget)
+ {
+ m_PreviousDepthTarget.Release();
+ UnityEngine.Object.DestroyImmediate(m_PreviousDepthTarget);
+ m_PreviousDepthTarget = null;
+ }
+ }
+
+ private void SetShaderKeyWords()
+ {
+ if (m_ShadowProjectionType == ShadowProjection.CloseFit)
+ {
+ m_Material.EnableKeyword("SHADOW_PROJ_CLOSE");
+ }
+ else if (m_ShadowProjectionType == ShadowProjection.StableFit)
+ {
+ m_Material.DisableKeyword("SHADOW_PROJ_CLOSE");
+ }
+ if (DS_HazeCore.Instance != null)
+ {
+ switch (DS_HazeCore.Instance.HeightFalloff)
+ {
+ case DS_HazeCore.HeightFalloffType.None:
+ m_Material.EnableKeyword("DS_HAZE_HEIGHT_FALLOFF_NONE");
+ break;
+ case DS_HazeCore.HeightFalloffType.Exponential:
+ m_Material.DisableKeyword("DS_HAZE_HEIGHT_FALLOFF_NONE");
+ break;
+ default:
+ m_Material.EnableKeyword("DS_HAZE_HEIGHT_FALLOFF_NONE");
+ break;
+ }
+ }
+ }
+
+ private void OnEnable()
+ {
+ SetGlobalParamsToNull();
+ m_Camera = GetComponent();
+ if (!m_Camera)
+ {
+ Debug.LogError("DeepSky::DS_HazeView: GameObject '" + base.gameObject.name + "' does not have a camera component!");
+ base.enabled = false;
+ return;
+ }
+ if (!CheckHasSystemSupport())
+ {
+ base.enabled = false;
+ return;
+ }
+ if (kShader == null)
+ {
+ kShader = Resources.Load("DS_Haze");
+ }
+ if (m_Material == null)
+ {
+ m_Material = new Material(kShader);
+ m_Material.hideFlags = HideFlags.HideAndDontSave;
+ }
+ if (m_Camera.actualRenderingPath == RenderingPath.Forward && (m_Camera.depthTextureMode & DepthTextureMode.Depth) != DepthTextureMode.Depth)
+ {
+ m_Camera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+ if (m_RenderNonShadowVolumes == null)
+ {
+ CommandBuffer[] commandBuffers = m_Camera.GetCommandBuffers(CameraEvent.BeforeImageEffectsOpaque);
+ bool flag = false;
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kRenderLightVolumeCmdBufferName)
+ {
+ m_RenderNonShadowVolumes = commandBuffer;
+ flag = true;
+ break;
+ }
+ }
+ if (!flag)
+ {
+ m_RenderNonShadowVolumes = new CommandBuffer();
+ m_RenderNonShadowVolumes.name = kRenderLightVolumeCmdBufferName;
+ m_Camera.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, m_RenderNonShadowVolumes);
+ }
+ }
+ m_CurrentRadianceTarget = m_RadianceTarget_01;
+ m_PreviousRadianceTarget = m_RadianceTarget_02;
+ SetSkyboxKeywords();
+ SetDebugKeywords();
+ m_ColourSpace = QualitySettings.activeColorSpace;
+ m_PreviousRenderPath = m_Camera.actualRenderingPath;
+ }
+
+ private void CreateRadianceTarget(string name, out RenderTexture radianceTarget)
+ {
+ if (m_Camera.allowHDR)
+ {
+ radianceTarget = new RenderTexture(m_Camera.pixelWidth, m_Camera.pixelHeight, 0, RenderTextureFormat.ARGBHalf);
+ }
+ else
+ {
+ radianceTarget = new RenderTexture(m_Camera.pixelWidth, m_Camera.pixelHeight, 0, RenderTextureFormat.ARGB32);
+ }
+ radianceTarget.name = name;
+ radianceTarget.antiAliasing = AntiAliasingLevel();
+ radianceTarget.useMipMap = false;
+ radianceTarget.hideFlags = HideFlags.HideAndDontSave;
+ radianceTarget.filterMode = FilterMode.Point;
+ }
+
+ private void CreateDepthTarget(string name, out RenderTexture depthTarget, bool downsample = false)
+ {
+ depthTarget = new RenderTexture((!downsample) ? m_Camera.pixelWidth : m_X, (!downsample) ? m_Camera.pixelHeight : m_Y, 0, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear);
+ depthTarget.name = name;
+ depthTarget.antiAliasing = 1;
+ depthTarget.useMipMap = false;
+ depthTarget.hideFlags = HideFlags.HideAndDontSave;
+ depthTarget.filterMode = FilterMode.Point;
+ }
+
+ private bool CameraHasClearRadianceCmdBuffer(out CommandBuffer foundCmd)
+ {
+ CommandBuffer[] commandBuffers;
+ if (m_Camera.actualRenderingPath == RenderingPath.DeferredShading)
+ {
+ commandBuffers = m_Camera.GetCommandBuffers(CameraEvent.BeforeGBuffer);
+ }
+ else
+ {
+ CameraEvent evt = (((m_Camera.depthTextureMode & DepthTextureMode.DepthNormals) == DepthTextureMode.DepthNormals) ? CameraEvent.BeforeDepthNormalsTexture : CameraEvent.BeforeDepthTexture);
+ commandBuffers = m_Camera.GetCommandBuffers(evt);
+ }
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kClearRadianceCmdBufferName)
+ {
+ foundCmd = commandBuffer;
+ return true;
+ }
+ }
+ foundCmd = null;
+ return false;
+ }
+
+ private CommandBuffer LightHasCascadesCopyCmdBuffer()
+ {
+ CommandBuffer[] commandBuffers = m_DirectLight.GetCommandBuffers(LightEvent.AfterShadowMap);
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kShadowCascadesCmdBufferName)
+ {
+ return commandBuffer;
+ }
+ }
+ return null;
+ }
+
+ private CommandBuffer LightHasRenderCmdBuffer()
+ {
+ CommandBuffer[] commandBuffers = m_DirectLight.GetCommandBuffers(LightEvent.AfterScreenspaceMask);
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kDirectionalLightCmdBufferName)
+ {
+ return commandBuffer;
+ }
+ }
+ return null;
+ }
+
+ public void RemoveCommandBufferFromLight(Light light)
+ {
+ CommandBuffer[] commandBuffers = light.GetCommandBuffers(LightEvent.AfterShadowMap);
+ for (int i = 0; i < commandBuffers.Length; i++)
+ {
+ if (commandBuffers[i].name == kShadowCascadesCmdBufferName)
+ {
+ light.RemoveCommandBuffer(LightEvent.AfterShadowMap, commandBuffers[i]);
+ break;
+ }
+ }
+ commandBuffers = light.GetCommandBuffers(LightEvent.AfterScreenspaceMask);
+ for (int j = 0; j < commandBuffers.Length; j++)
+ {
+ if (commandBuffers[j].name == kDirectionalLightCmdBufferName)
+ {
+ light.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, commandBuffers[j]);
+ break;
+ }
+ }
+ }
+
+ private void RenderPathChanged()
+ {
+ if (m_Camera.actualRenderingPath == RenderingPath.Forward && (m_Camera.depthTextureMode & DepthTextureMode.Depth) != DepthTextureMode.Depth)
+ {
+ m_Camera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+ if (m_ClearRadianceCmdBuffer != null)
+ {
+ CameraEvent evt = ((m_PreviousRenderPath != RenderingPath.DeferredShading) ? (((m_Camera.depthTextureMode & DepthTextureMode.DepthNormals) == DepthTextureMode.DepthNormals) ? CameraEvent.BeforeDepthNormalsTexture : CameraEvent.BeforeDepthTexture) : CameraEvent.BeforeGBuffer);
+ CommandBuffer[] commandBuffers = m_Camera.GetCommandBuffers(evt);
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kClearRadianceCmdBufferName)
+ {
+ m_Camera.RemoveCommandBuffer(evt, commandBuffer);
+ break;
+ }
+ }
+ }
+ m_PreviousRenderPath = m_Camera.actualRenderingPath;
+ }
+
+ private void UpdateResources()
+ {
+ m_X = m_Camera.pixelWidth / (int)m_DownsampleFactor;
+ m_Y = m_Camera.pixelHeight / (int)m_DownsampleFactor;
+ if (m_Camera.actualRenderingPath != m_PreviousRenderPath)
+ {
+ RenderPathChanged();
+ }
+ RenderTextureFormat renderTextureFormat = (m_Camera.allowHDR ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
+ bool flag = m_ColourSpace != QualitySettings.activeColorSpace;
+ m_ColourSpace = QualitySettings.activeColorSpace;
+ if (WillRenderWithTemporalReprojection)
+ {
+ if (m_RadianceTarget_01 == null)
+ {
+ CreateRadianceTarget(kRadianceTarget01Name, out m_RadianceTarget_01);
+ m_CurrentRadianceTarget = m_RadianceTarget_01;
+ }
+ else if (flag || m_RadianceTarget_01.width != m_Camera.pixelWidth || m_RadianceTarget_01.height != m_Camera.pixelHeight || m_RadianceTarget_01.format != renderTextureFormat)
+ {
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_01);
+ CreateRadianceTarget(kRadianceTarget01Name, out m_RadianceTarget_01);
+ m_CurrentRadianceTarget = m_RadianceTarget_01;
+ }
+ if (m_RadianceTarget_02 == null)
+ {
+ CreateRadianceTarget(kRadianceTarget02Name, out m_RadianceTarget_02);
+ m_PreviousRadianceTarget = m_RadianceTarget_02;
+ }
+ else if (flag || m_RadianceTarget_02.width != m_Camera.pixelWidth || m_RadianceTarget_02.height != m_Camera.pixelHeight || m_RadianceTarget_02.format != renderTextureFormat)
+ {
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_02);
+ CreateRadianceTarget(kRadianceTarget02Name, out m_RadianceTarget_02);
+ m_PreviousRadianceTarget = m_RadianceTarget_02;
+ }
+ if (m_PreviousDepthTarget == null)
+ {
+ CreateDepthTarget(kPreviousDepthTargetName, out m_PreviousDepthTarget);
+ }
+ else if (m_PreviousDepthTarget.width != m_Camera.pixelWidth || m_PreviousDepthTarget.height != m_Camera.pixelHeight)
+ {
+ UnityEngine.Object.DestroyImmediate(m_PreviousDepthTarget);
+ CreateDepthTarget(kPreviousDepthTargetName, out m_PreviousDepthTarget);
+ }
+ }
+ if (m_ClearRadianceCmdBuffer == null)
+ {
+ m_ClearRadianceCmdBuffer = new CommandBuffer();
+ m_ClearRadianceCmdBuffer.name = kClearRadianceCmdBufferName;
+ }
+ CameraEvent evt = ((m_Camera.actualRenderingPath != RenderingPath.DeferredShading) ? (((m_Camera.depthTextureMode & DepthTextureMode.DepthNormals) == DepthTextureMode.DepthNormals) ? CameraEvent.BeforeDepthNormalsTexture : CameraEvent.BeforeDepthTexture) : CameraEvent.BeforeGBuffer);
+ if (!CameraHasClearRadianceCmdBuffer(out var foundCmd))
+ {
+ m_Camera.AddCommandBuffer(evt, m_ClearRadianceCmdBuffer);
+ }
+ else if (foundCmd != m_ClearRadianceCmdBuffer)
+ {
+ m_Camera.RemoveCommandBuffer(evt, foundCmd);
+ foundCmd.Dispose();
+ m_Camera.AddCommandBuffer(evt, m_ClearRadianceCmdBuffer);
+ }
+ if ((bool)m_DirectLight)
+ {
+ m_ShadowCascadesCmdBuffer = LightHasCascadesCopyCmdBuffer();
+ if (m_ShadowCascadesCmdBuffer == null)
+ {
+ m_ShadowCascadesCmdBuffer = new CommandBuffer();
+ m_ShadowCascadesCmdBuffer.name = kShadowCascadesCmdBufferName;
+ m_ShadowCascadesCmdBuffer.SetGlobalTexture("_ShadowCascades", new RenderTargetIdentifier(BuiltinRenderTextureType.CurrentActive));
+ m_DirectLight.AddCommandBuffer(LightEvent.AfterShadowMap, m_ShadowCascadesCmdBuffer);
+ }
+ m_DirectionalLightCmdBuffer = LightHasRenderCmdBuffer();
+ if (m_DirectionalLightCmdBuffer == null)
+ {
+ m_DirectionalLightCmdBuffer = new CommandBuffer();
+ m_DirectionalLightCmdBuffer.name = kDirectionalLightCmdBufferName;
+ m_DirectLight.AddCommandBuffer(LightEvent.AfterScreenspaceMask, m_DirectionalLightCmdBuffer);
+ }
+ if (m_ShadowProjectionType != QualitySettings.shadowProjection)
+ {
+ m_ShadowProjectionType = QualitySettings.shadowProjection;
+ }
+ }
+ }
+
+ private void OnDisable()
+ {
+ SetGlobalParamsToNull();
+ CommandBuffer[] commandBuffers = m_Camera.GetCommandBuffers(CameraEvent.AfterSkybox);
+ CameraEvent evt = ((m_Camera.actualRenderingPath != RenderingPath.DeferredShading) ? (((m_Camera.depthTextureMode & DepthTextureMode.DepthNormals) == DepthTextureMode.DepthNormals) ? CameraEvent.BeforeDepthNormalsTexture : CameraEvent.BeforeDepthTexture) : CameraEvent.BeforeGBuffer);
+ commandBuffers = m_Camera.GetCommandBuffers(evt);
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == kClearRadianceCmdBufferName)
+ {
+ m_Camera.RemoveCommandBuffer(evt, commandBuffer);
+ break;
+ }
+ }
+ if ((bool)m_DirectLight)
+ {
+ commandBuffers = m_DirectLight.GetCommandBuffers(LightEvent.AfterShadowMap);
+ CommandBuffer[] array2 = commandBuffers;
+ foreach (CommandBuffer commandBuffer2 in array2)
+ {
+ if (commandBuffer2.name == kShadowCascadesCmdBufferName)
+ {
+ m_DirectLight.RemoveCommandBuffer(LightEvent.AfterShadowMap, commandBuffer2);
+ break;
+ }
+ }
+ commandBuffers = m_DirectLight.GetCommandBuffers(LightEvent.AfterScreenspaceMask);
+ CommandBuffer[] array3 = commandBuffers;
+ foreach (CommandBuffer commandBuffer3 in array3)
+ {
+ if (commandBuffer3.name == kDirectionalLightCmdBufferName)
+ {
+ m_DirectLight.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, commandBuffer3);
+ break;
+ }
+ }
+ }
+ if (m_LightVolumeCmdBuffers.Count > 0)
+ {
+ foreach (KeyValuePair lightVolumeCmdBuffer in m_LightVolumeCmdBuffers)
+ {
+ lightVolumeCmdBuffer.Key.RemoveCommandBuffer(LightEvent.AfterShadowMap, lightVolumeCmdBuffer.Value);
+ lightVolumeCmdBuffer.Value.Dispose();
+ }
+ m_LightVolumeCmdBuffers.Clear();
+ }
+ if (m_RenderNonShadowVolumes != null)
+ {
+ m_RenderNonShadowVolumes.Clear();
+ }
+ }
+
+ private void OnDestroy()
+ {
+ if ((bool)m_RadianceTarget_01)
+ {
+ m_RadianceTarget_01.Release();
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_01);
+ m_RadianceTarget_01 = null;
+ }
+ if ((bool)m_RadianceTarget_02)
+ {
+ m_RadianceTarget_02.Release();
+ UnityEngine.Object.DestroyImmediate(m_RadianceTarget_02);
+ m_RadianceTarget_02 = null;
+ }
+ if ((bool)m_PreviousDepthTarget)
+ {
+ m_PreviousDepthTarget.Release();
+ UnityEngine.Object.DestroyImmediate(m_PreviousDepthTarget);
+ m_PreviousDepthTarget = null;
+ }
+ if (m_ClearRadianceCmdBuffer != null)
+ {
+ if (m_Camera.actualRenderingPath == RenderingPath.DeferredShading)
+ {
+ m_Camera.RemoveCommandBuffer(CameraEvent.BeforeGBuffer, m_ClearRadianceCmdBuffer);
+ }
+ else
+ {
+ CameraEvent evt = (((m_Camera.depthTextureMode & DepthTextureMode.DepthNormals) == DepthTextureMode.DepthNormals) ? CameraEvent.BeforeDepthNormalsTexture : CameraEvent.BeforeDepthTexture);
+ m_Camera.RemoveCommandBuffer(evt, m_ClearRadianceCmdBuffer);
+ }
+ m_ClearRadianceCmdBuffer.Dispose();
+ m_ClearRadianceCmdBuffer = null;
+ }
+ if (m_ShadowCascadesCmdBuffer != null)
+ {
+ if (m_DirectLight != null)
+ {
+ m_DirectLight.RemoveCommandBuffer(LightEvent.AfterShadowMap, m_ShadowCascadesCmdBuffer);
+ }
+ m_ShadowCascadesCmdBuffer.Dispose();
+ m_ShadowCascadesCmdBuffer = null;
+ }
+ if (m_DirectionalLightCmdBuffer != null)
+ {
+ if (m_DirectLight != null)
+ {
+ m_DirectLight.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, m_DirectionalLightCmdBuffer);
+ }
+ m_DirectionalLightCmdBuffer.Dispose();
+ m_DirectionalLightCmdBuffer = null;
+ }
+ if (m_LightVolumeCmdBuffers.Count > 0)
+ {
+ foreach (KeyValuePair lightVolumeCmdBuffer in m_LightVolumeCmdBuffers)
+ {
+ lightVolumeCmdBuffer.Key.RemoveCommandBuffer(LightEvent.AfterShadowMap, lightVolumeCmdBuffer.Value);
+ lightVolumeCmdBuffer.Value.Dispose();
+ }
+ m_LightVolumeCmdBuffers.Clear();
+ }
+ if (m_RenderNonShadowVolumes != null)
+ {
+ m_Camera.RemoveCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, m_RenderNonShadowVolumes);
+ m_RenderNonShadowVolumes.Dispose();
+ m_RenderNonShadowVolumes = null;
+ }
+ }
+
+ private void OnPreRender()
+ {
+ if (!CheckHasSystemSupport())
+ {
+ base.enabled = false;
+ }
+ UpdateResources();
+ SetShaderKeyWords();
+ RenderTextureFormat format = (m_Camera.allowHDR ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
+ m_PerFrameRadianceTarget = RenderTexture.GetTemporary(m_X, m_Y, 0, format, RenderTextureReadWrite.Linear, AntiAliasingLevel());
+ m_PerFrameRadianceTarget.name = "_DS_Haze_PerFrameRadiance";
+ m_PerFrameRadianceTarget.filterMode = FilterMode.Point;
+ m_ClearRadianceCmdBuffer.Clear();
+ m_ClearRadianceCmdBuffer.SetRenderTarget(m_PerFrameRadianceTarget);
+ m_ClearRadianceCmdBuffer.ClearRenderTarget(clearDepth: false, clearColor: true, Color.clear);
+ DS_HazeCore instance = DS_HazeCore.Instance;
+ DS_HazeContextItem dS_HazeContextItem = null;
+ if (m_OverrideContextAsset && m_Context != null)
+ {
+ dS_HazeContextItem = ((!m_OverrideContextVariant) ? m_Context.Context.GetContextItemBlended(m_Time) : m_Context.Context.GetItemAtIndex(m_ContextItemIndex));
+ }
+ else
+ {
+ if (instance == null)
+ {
+ SetGlobalParamsToNull();
+ return;
+ }
+ dS_HazeContextItem = instance.GetRenderContextAtPosition(base.transform.position);
+ }
+ if (dS_HazeContextItem == null)
+ {
+ SetGlobalParamsToNull();
+ }
+ else
+ {
+ SetMaterialFromContext(dS_HazeContextItem);
+ float farClipPlane = m_Camera.farClipPlane;
+ float num = m_Camera.fieldOfView * 0.5f;
+ float num2 = Mathf.Tan(num * ((float)Math.PI / 180f));
+ float num3 = num2 * m_Camera.aspect;
+ Vector3 vector = base.transform.forward * farClipPlane;
+ Vector3 vector2 = base.transform.right * num3 * farClipPlane;
+ Vector3 vector3 = base.transform.up * num2 * farClipPlane;
+ m_Material.SetVector("_ViewportCorner", vector - vector2 - vector3);
+ m_Material.SetVector("_ViewportRight", vector2 * 2f);
+ m_Material.SetVector("_ViewportUp", vector3 * 2f);
+ if ((bool)m_DirectLight && m_RenderAtmosphereVolumetrics)
+ {
+ m_DirectionalLightCmdBuffer.Blit(BuiltinRenderTextureType.None, m_PerFrameRadianceTarget, m_Material, (int)(m_VolumeSamples + ((m_DownsampleFactor != SizeFactor.Half) ? 3 : 0)));
+ }
+ }
+ if (!m_RenderLocalVolumetrics)
+ {
+ return;
+ }
+ Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(m_Camera.projectionMatrix, renderIntoTexture: true);
+ Matrix4x4 viewProjMtx = gPUProjectionMatrix * m_Camera.worldToCameraMatrix;
+ instance.GetRenderLightVolumes(base.transform.position, m_PerFrameLightVolumes, m_PerFrameShadowLightVolumes);
+ if (m_PerFrameLightVolumes.Count > 0)
+ {
+ m_RenderNonShadowVolumes.SetRenderTarget(m_PerFrameRadianceTarget);
+ }
+ foreach (DS_HazeLightVolume perFrameLightVolume in m_PerFrameLightVolumes)
+ {
+ perFrameLightVolume.SetupMaterialPerFrame(viewProjMtx, m_Camera.worldToCameraMatrix, base.transform, (!WillRenderWithTemporalReprojection) ? 0f : m_InterleavedOffsetIndex);
+ perFrameLightVolume.AddLightRenderCommand(base.transform, m_RenderNonShadowVolumes, (int)m_DownsampleFactor);
+ }
+ foreach (DS_HazeLightVolume perFrameShadowLightVolume in m_PerFrameShadowLightVolumes)
+ {
+ perFrameShadowLightVolume.SetupMaterialPerFrame(viewProjMtx, m_Camera.worldToCameraMatrix, base.transform, (!WillRenderWithTemporalReprojection) ? 0f : m_InterleavedOffsetIndex);
+ perFrameShadowLightVolume.FillLightCommandBuffer(m_PerFrameRadianceTarget, base.transform, (int)m_DownsampleFactor);
+ m_LightVolumeCmdBuffers.Add(perFrameShadowLightVolume.LightSource, perFrameShadowLightVolume.RenderCommandBuffer);
+ }
+ }
+
+ private void BlitToMRT(RenderTexture source, RenderTexture[] destination, Material mat, int pass)
+ {
+ RenderBuffer[] array = new RenderBuffer[destination.Length];
+ for (int i = 0; i < destination.Length; i++)
+ {
+ ref RenderBuffer reference = ref array[i];
+ reference = destination[i].colorBuffer;
+ }
+ Graphics.SetRenderTarget(array, destination[0].depthBuffer);
+ mat.SetTexture("_MainTex", source);
+ mat.SetPass(pass);
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ GL.Begin(7);
+ GL.MultiTexCoord2(0, 0f, 0f);
+ GL.Vertex3(0f, 0f, 0.1f);
+ GL.MultiTexCoord2(0, 1f, 0f);
+ GL.Vertex3(1f, 0f, 0.1f);
+ GL.MultiTexCoord2(0, 1f, 1f);
+ GL.Vertex3(1f, 1f, 0.1f);
+ GL.MultiTexCoord2(0, 0f, 1f);
+ GL.Vertex3(0f, 1f, 0.1f);
+ GL.End();
+ GL.PopMatrix();
+ }
+
+ [ImageEffectOpaque]
+ private void OnRenderImage(RenderTexture src, RenderTexture dest)
+ {
+ RenderTexture renderTexture = null;
+ RenderTexture renderTexture2 = null;
+ if (m_RenderAtmosphereVolumetrics || m_RenderLocalVolumetrics)
+ {
+ renderTexture = RenderTexture.GetTemporary(m_X, m_Y, 0, m_Camera.allowHDR ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
+ renderTexture2 = RenderTexture.GetTemporary(m_X, m_Y, 0, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear, 1);
+ Graphics.Blit(null, renderTexture2, m_Material, (m_DownsampleFactor != SizeFactor.Half) ? 11 : 10);
+ m_Material.SetTexture("_HalfResDepth", renderTexture2);
+ Graphics.Blit(m_PerFrameRadianceTarget, renderTexture, m_Material, 6);
+ Graphics.Blit(renderTexture, m_PerFrameRadianceTarget, m_Material, 7);
+ if (m_TemporalReprojection)
+ {
+ m_Material.SetTexture("_PrevAccumBuffer", m_PreviousRadianceTarget);
+ m_Material.SetTexture("_PrevDepthBuffer", m_PreviousDepthTarget);
+ }
+ }
+ m_PerFrameRadianceTarget.filterMode = FilterMode.Bilinear;
+ m_Material.SetTexture("_RadianceBuffer", m_PerFrameRadianceTarget);
+ if (dest == null)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(src.width, src.height, src.depth, src.format);
+ if (WillRenderWithTemporalReprojection)
+ {
+ RenderTexture[] destination = new RenderTexture[2] { temporary, m_CurrentRadianceTarget };
+ BlitToMRT(src, destination, m_Material, 8);
+ }
+ else
+ {
+ Graphics.Blit(src, temporary, m_Material, 8);
+ }
+ Graphics.Blit((Texture)temporary, (RenderTexture)null);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ else if (WillRenderWithTemporalReprojection)
+ {
+ RenderTexture[] destination2 = new RenderTexture[2] { dest, m_CurrentRadianceTarget };
+ BlitToMRT(src, destination2, m_Material, 8);
+ }
+ else
+ {
+ Graphics.Blit(src, dest, m_Material, 8);
+ }
+ if (WillRenderWithTemporalReprojection)
+ {
+ Graphics.Blit(src, m_PreviousDepthTarget, m_Material, 9);
+ Graphics.SetRenderTarget(dest);
+ Shader.SetGlobalTexture("_DS_RadianceBuffer", m_CurrentRadianceTarget);
+ RenderTexture.ReleaseTemporary(m_PerFrameRadianceTarget);
+ }
+ else
+ {
+ Shader.SetGlobalTexture("_DS_RadianceBuffer", m_PerFrameRadianceTarget);
+ }
+ if (renderTexture != null)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+ if (renderTexture2 != null)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture2);
+ }
+ }
+
+ private void OnPostRender()
+ {
+ if (WillRenderWithTemporalReprojection)
+ {
+ RenderTexture currentRadianceTarget = m_CurrentRadianceTarget;
+ m_CurrentRadianceTarget = m_PreviousRadianceTarget;
+ m_PreviousRadianceTarget = currentRadianceTarget;
+ Matrix4x4 worldToCameraMatrix = m_Camera.worldToCameraMatrix;
+ Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(m_Camera.projectionMatrix, renderIntoTexture: true);
+ m_PreviousViewProjMatrix = gPUProjectionMatrix * worldToCameraMatrix;
+ m_PreviousInvViewProjMatrix = m_PreviousViewProjMatrix.inverse;
+ }
+ else
+ {
+ RenderTexture.ReleaseTemporary(m_PerFrameRadianceTarget);
+ }
+ if (m_LightVolumeCmdBuffers.Count > 0)
+ {
+ foreach (KeyValuePair lightVolumeCmdBuffer in m_LightVolumeCmdBuffers)
+ {
+ lightVolumeCmdBuffer.Value.Clear();
+ }
+ m_LightVolumeCmdBuffers.Clear();
+ }
+ if ((bool)m_DirectLight)
+ {
+ m_DirectionalLightCmdBuffer.Clear();
+ }
+ m_RenderNonShadowVolumes.Clear();
+ m_PerFrameLightVolumes.Clear();
+ m_PerFrameShadowLightVolumes.Clear();
+ }
+}
diff --git a/DeepSky.Haze/DS_HazeZone.cs b/DeepSky.Haze/DS_HazeZone.cs
new file mode 100644
index 0000000..b4ffabb
--- /dev/null
+++ b/DeepSky.Haze/DS_HazeZone.cs
@@ -0,0 +1,105 @@
+using UnityEngine;
+
+namespace DeepSky.Haze;
+
+[ExecuteInEditMode]
+[AddComponentMenu("DeepSky Haze/Zone", 52)]
+public class DS_HazeZone : MonoBehaviour
+{
+ [SerializeField]
+ private DS_HazeContext m_Context = new DS_HazeContext();
+
+ [SerializeField]
+ [Range(0f, 250f)]
+ private int m_Priority;
+
+ [SerializeField]
+ [Range(0.001f, 1f)]
+ private float m_BlendRange = 0.1f;
+
+ private Bounds m_AABB;
+
+ private float m_BlendRangeInverse;
+
+ public DS_HazeContext Context => m_Context;
+
+ public int Priority
+ {
+ get
+ {
+ return m_Priority;
+ }
+ set
+ {
+ m_Priority = ((value > 0) ? value : 0);
+ }
+ }
+
+ public float BlendRange
+ {
+ get
+ {
+ return m_BlendRange;
+ }
+ set
+ {
+ m_BlendRange = Mathf.Clamp01(value);
+ }
+ }
+
+ private void Setup()
+ {
+ m_AABB = new Bounds(Vector3.zero, base.transform.localScale);
+ m_BlendRangeInverse = 1f / Mathf.Max(Mathf.Min(m_AABB.extents.x, m_AABB.extents.y, m_AABB.extents.z) * m_BlendRange, Mathf.Epsilon);
+ }
+
+ private void Start()
+ {
+ Setup();
+ }
+
+ private void OnValidate()
+ {
+ Setup();
+ }
+
+ public bool Contains(Vector3 position)
+ {
+ if (base.transform.hasChanged)
+ {
+ Setup();
+ }
+ Vector3 point = base.transform.InverseTransformPoint(position);
+ point.Scale(base.transform.localScale);
+ return m_AABB.Contains(point);
+ }
+
+ public float GetBlendWeight(Vector3 position)
+ {
+ Vector3 vector = base.transform.InverseTransformPoint(position);
+ vector.Scale(base.transform.localScale);
+ float num = Mathf.Abs(m_AABB.extents.x - Mathf.Abs(vector.x));
+ float num2 = Mathf.Abs(m_AABB.extents.y - Mathf.Abs(vector.y));
+ float num3 = Mathf.Abs(m_AABB.extents.z - Mathf.Abs(vector.z));
+ float num4 = Mathf.Min(num, num2, num3);
+ return Mathf.Clamp01(num4 * m_BlendRangeInverse);
+ }
+
+ public static bool operator >(DS_HazeZone c1, DS_HazeZone c2)
+ {
+ if (c1.m_Priority == c2.m_Priority)
+ {
+ return (Vector3.Dot(c1.m_AABB.extents, c1.m_AABB.extents) > Vector3.Dot(c2.m_AABB.extents, c2.m_AABB.extents)) ? true : false;
+ }
+ return (c1.m_Priority > c2.m_Priority) ? true : false;
+ }
+
+ public static bool operator <(DS_HazeZone c1, DS_HazeZone c2)
+ {
+ if (c1.m_Priority == c2.m_Priority)
+ {
+ return (Vector3.Dot(c1.m_AABB.extents, c1.m_AABB.extents) < Vector3.Dot(c2.m_AABB.extents, c2.m_AABB.extents)) ? true : false;
+ }
+ return (c1.m_Priority < c2.m_Priority) ? true : false;
+ }
+}
diff --git a/DeepSky.Haze/DS_LightFalloff.cs b/DeepSky.Haze/DS_LightFalloff.cs
new file mode 100644
index 0000000..7aeca76
--- /dev/null
+++ b/DeepSky.Haze/DS_LightFalloff.cs
@@ -0,0 +1,7 @@
+namespace DeepSky.Haze;
+
+public enum DS_LightFalloff
+{
+ Unity,
+ Quadratic
+}
diff --git a/DeepSky.Haze/DS_SamplingQuality.cs b/DeepSky.Haze/DS_SamplingQuality.cs
new file mode 100644
index 0000000..5ac91e5
--- /dev/null
+++ b/DeepSky.Haze/DS_SamplingQuality.cs
@@ -0,0 +1,9 @@
+namespace DeepSky.Haze;
+
+public enum DS_SamplingQuality
+{
+ x4,
+ x8,
+ x16,
+ x32
+}
diff --git a/DoggoMovement.cs b/DoggoMovement.cs
new file mode 100644
index 0000000..ea7519b
--- /dev/null
+++ b/DoggoMovement.cs
@@ -0,0 +1,43 @@
+using UnityEngine;
+
+public class DoggoMovement : MonoBehaviour
+{
+ public float drag = 0.1f;
+
+ private CollisionChecker[] checkers;
+
+ private Rigidbody rig;
+
+ private Rigidbody[] rigs;
+
+ private MovementHandler move;
+
+ private void Start()
+ {
+ move = base.transform.root.GetComponent();
+ rigs = base.transform.root.GetComponentsInChildren();
+ checkers = base.transform.root.GetComponentsInChildren();
+ rig = GetComponent();
+ }
+
+ private void FixedUpdate()
+ {
+ float num = 1f;
+ num = 0f;
+ for (int i = 0; i < checkers.Length; i++)
+ {
+ if (checkers[i].sinceGrounded < 0.3f)
+ {
+ num += 1f / (float)checkers.Length;
+ }
+ }
+ move.multiplier = num;
+ Rigidbody[] array = rigs;
+ foreach (Rigidbody rigidbody in array)
+ {
+ rigidbody.velocity *= 1f - drag * num;
+ rigidbody.angularVelocity *= 1f - drag * num;
+ }
+ rig.AddTorque(Vector3.Angle(base.transform.up, Vector3.up) * Vector3.Cross(base.transform.up, Vector3.up) * 50f * num, ForceMode.Acceleration);
+ }
+}
diff --git a/DragHandler.cs b/DragHandler.cs
new file mode 100644
index 0000000..adb8df4
--- /dev/null
+++ b/DragHandler.cs
@@ -0,0 +1,25 @@
+using UnityEngine;
+
+public class DragHandler : MonoBehaviour
+{
+ private float drag;
+
+ private float angularDrag;
+
+ private Rigidbody rig;
+
+ public float dragAmount = 1f;
+
+ private void Start()
+ {
+ rig = GetComponent();
+ drag = rig.drag;
+ angularDrag = rig.angularDrag;
+ }
+
+ private void Update()
+ {
+ rig.drag = drag * dragAmount;
+ rig.angularDrag = angularDrag * dragAmount;
+ }
+}
diff --git a/EnemyAI.cs b/EnemyAI.cs
new file mode 100644
index 0000000..7337bbe
--- /dev/null
+++ b/EnemyAI.cs
@@ -0,0 +1,103 @@
+using UnityEngine;
+
+public class EnemyAI : MonoBehaviour
+{
+ private InputHandler input;
+
+ public Transform target;
+
+ public Transform rotationTarget;
+
+ private Transform hip;
+
+ public Vector3 randomOffset;
+
+ private PlayerDeath death;
+
+ private PlayerDeath ownDeath;
+
+ private float counter;
+
+ private float counter2 = 1f;
+
+ private float deadCounter;
+
+ private bool hasDespawned;
+
+ private void Start()
+ {
+ input = GetComponent();
+ hip = GetComponentInChildren().transform;
+ death = target.root.GetComponent();
+ ownDeath = GetComponent();
+ }
+
+ private void Update()
+ {
+ if (ownDeath.dead)
+ {
+ deadCounter += Time.deltaTime;
+ if (deadCounter > 5f && !hasDespawned)
+ {
+ Despawn();
+ }
+ if (deadCounter > 8f)
+ {
+ Object.Destroy(base.gameObject);
+ }
+ }
+ else
+ {
+ Logic();
+ }
+ }
+
+ public bool IsDead()
+ {
+ return ownDeath.dead;
+ }
+
+ private void Despawn()
+ {
+ hasDespawned = true;
+ Rigidbody[] componentsInChildren = GetComponentsInChildren();
+ Collider[] componentsInChildren2 = GetComponentsInChildren();
+ MonoBehaviour[] componentsInChildren3 = GetComponentsInChildren();
+ for (int i = 0; i < componentsInChildren.Length; i++)
+ {
+ componentsInChildren[i].drag = 5f;
+ componentsInChildren[i].angularDrag = 5f;
+ }
+ for (int j = 0; j < componentsInChildren2.Length; j++)
+ {
+ componentsInChildren2[j].enabled = false;
+ }
+ for (int k = 0; k < componentsInChildren3.Length; k++)
+ {
+ if (componentsInChildren3[k].GetType() != GetType())
+ {
+ componentsInChildren3[k].enabled = false;
+ }
+ }
+ }
+
+ private void Logic()
+ {
+ counter2 -= Time.deltaTime;
+ if (counter2 < 0f)
+ {
+ counter2 = Random.Range(1f, 4f);
+ randomOffset = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f));
+ }
+ float num = Vector3.Distance(target.position, hip.position);
+ input.inputMovementDirection = (target.position + randomOffset * num * 0.7f - hip.position).normalized;
+ rotationTarget.rotation = Quaternion.LookRotation(input.inputMovementDirection);
+ input.isSpringting = true;
+ counter += Time.deltaTime;
+ if (num < 0.7f && counter > 0.3f)
+ {
+ death.TakeDamage(15f * (target.position - hip.position).normalized, Vector3.zero);
+ counter = 0f;
+ }
+ }
+}
diff --git a/EnemyGroup.cs b/EnemyGroup.cs
new file mode 100644
index 0000000..7afbffe
--- /dev/null
+++ b/EnemyGroup.cs
@@ -0,0 +1,15 @@
+using System;
+
+[Serializable]
+public class EnemyGroup
+{
+ public enum EnemyType
+ {
+ DefaultEnemy,
+ Fast
+ }
+
+ public EnemyType enemyType;
+
+ public float number = 5f;
+}
diff --git a/EnemyWave.cs b/EnemyWave.cs
new file mode 100644
index 0000000..fff6d4a
--- /dev/null
+++ b/EnemyWave.cs
@@ -0,0 +1,8 @@
+using System;
+using System.Collections.Generic;
+
+[Serializable]
+public class EnemyWave
+{
+ public List groups = new List();
+}
diff --git a/EnvMapAnimator.cs b/EnvMapAnimator.cs
new file mode 100644
index 0000000..3d19693
--- /dev/null
+++ b/EnvMapAnimator.cs
@@ -0,0 +1,29 @@
+using System.Collections;
+using TMPro;
+using UnityEngine;
+
+public class EnvMapAnimator : MonoBehaviour
+{
+ public Vector3 RotationSpeeds;
+
+ private TMP_Text m_textMeshPro;
+
+ private Material m_material;
+
+ private void Awake()
+ {
+ m_textMeshPro = GetComponent();
+ m_material = m_textMeshPro.fontSharedMaterial;
+ }
+
+ private IEnumerator Start()
+ {
+ Matrix4x4 matrix = default(Matrix4x4);
+ while (true)
+ {
+ matrix.SetTRS(Vector3.zero, Quaternion.Euler(Time.time * RotationSpeeds.x, Time.time * RotationSpeeds.y, Time.time * RotationSpeeds.z), Vector3.one);
+ m_material.SetMatrix("_EnvMatrix", matrix);
+ yield return null;
+ }
+ }
+}
diff --git a/ExampleWheelController.cs b/ExampleWheelController.cs
new file mode 100644
index 0000000..a2f05e0
--- /dev/null
+++ b/ExampleWheelController.cs
@@ -0,0 +1,38 @@
+using UnityEngine;
+
+public class ExampleWheelController : MonoBehaviour
+{
+ private static class Uniforms
+ {
+ internal static readonly int _MotionAmount = Shader.PropertyToID("_MotionAmount");
+ }
+
+ public float acceleration;
+
+ public Renderer motionVectorRenderer;
+
+ private Rigidbody m_Rigidbody;
+
+ private void Start()
+ {
+ m_Rigidbody = GetComponent();
+ m_Rigidbody.maxAngularVelocity = 100f;
+ }
+
+ private void Update()
+ {
+ if (Input.GetKey(KeyCode.UpArrow))
+ {
+ m_Rigidbody.AddRelativeTorque(new Vector3(-1f * acceleration, 0f, 0f), ForceMode.Acceleration);
+ }
+ else if (Input.GetKey(KeyCode.DownArrow))
+ {
+ m_Rigidbody.AddRelativeTorque(new Vector3(1f * acceleration, 0f, 0f), ForceMode.Acceleration);
+ }
+ float value = (0f - m_Rigidbody.angularVelocity.x) / 100f;
+ if ((bool)motionVectorRenderer)
+ {
+ motionVectorRenderer.material.SetFloat(Uniforms._MotionAmount, Mathf.Clamp(value, -0.25f, 0.25f));
+ }
+ }
+}
diff --git a/FPSCarCam.cs b/FPSCarCam.cs
new file mode 100644
index 0000000..3905c84
--- /dev/null
+++ b/FPSCarCam.cs
@@ -0,0 +1,42 @@
+using UnityEngine;
+
+public class FPSCarCam : MonoBehaviour
+{
+ public Rigidbody rig;
+
+ public float movementAmount = 1f;
+
+ public float returnAmount = 1f;
+
+ public float friction = 0.9f;
+
+ private Vector3 cameraVelocity;
+
+ private Vector3 lastRigVelocity;
+
+ private Vector3 startPos;
+
+ private WobbleShake shake;
+
+ private void Start()
+ {
+ startPos = base.transform.localPosition;
+ shake = base.transform.root.GetComponentInChildren();
+ }
+
+ private void Update()
+ {
+ Vector3 vector = rig.velocity - lastRigVelocity;
+ cameraVelocity -= vector;
+ cameraVelocity -= cameraVelocity * Time.deltaTime * friction;
+ Vector3 vector2 = base.transform.parent.TransformPoint(startPos) - base.transform.position;
+ cameraVelocity += vector2.normalized * Mathf.Pow(vector2.magnitude, 2f) * Time.deltaTime * returnAmount;
+ base.transform.position += cameraVelocity * Time.deltaTime * movementAmount;
+ base.transform.rotation = Quaternion.Lerp(base.transform.rotation, rig.rotation, 10f * Time.deltaTime);
+ lastRigVelocity = rig.velocity;
+ }
+
+ private void FixedUpdate()
+ {
+ }
+}
diff --git a/FPSmeter.cs b/FPSmeter.cs
new file mode 100644
index 0000000..f762fe7
--- /dev/null
+++ b/FPSmeter.cs
@@ -0,0 +1,40 @@
+using UnityEngine;
+
+public class FPSmeter : MonoBehaviour
+{
+ public float updateInterval = 0.5f;
+
+ private float lastInterval;
+
+ private int frames;
+
+ public static float fps;
+
+ public bool showFPS;
+
+ private void Start()
+ {
+ lastInterval = Time.realtimeSinceStartup;
+ frames = 0;
+ }
+
+ private void OnGUI()
+ {
+ if (showFPS)
+ {
+ GUI.Label(new Rect(10f, 10f, 100f, 20f), string.Empty + Mathf.Round(fps * 100f) / 100f);
+ }
+ }
+
+ private void Update()
+ {
+ frames++;
+ float realtimeSinceStartup = Time.realtimeSinceStartup;
+ if (realtimeSinceStartup > lastInterval + updateInterval)
+ {
+ fps = (float)frames / (realtimeSinceStartup - lastInterval);
+ frames = 0;
+ lastInterval = realtimeSinceStartup;
+ }
+ }
+}
diff --git a/FollowRotation.cs b/FollowRotation.cs
new file mode 100644
index 0000000..514281a
--- /dev/null
+++ b/FollowRotation.cs
@@ -0,0 +1,15 @@
+using UnityEngine;
+
+public class FollowRotation : MonoBehaviour
+{
+ public Transform target;
+
+ private void Start()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ base.transform.rotation = target.rotation;
+ }
+}
diff --git a/FollowTransform.cs b/FollowTransform.cs
new file mode 100644
index 0000000..83a7f2d
--- /dev/null
+++ b/FollowTransform.cs
@@ -0,0 +1,17 @@
+using UnityEngine;
+
+public class FollowTransform : MonoBehaviour
+{
+ public Transform target;
+
+ public Vector3 offset;
+
+ private void Start()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ base.transform.position = target.position + offset;
+ }
+}
diff --git a/FollowTransformVelocity.cs b/FollowTransformVelocity.cs
new file mode 100644
index 0000000..584846c
--- /dev/null
+++ b/FollowTransformVelocity.cs
@@ -0,0 +1,16 @@
+using UnityEngine;
+
+public class FollowTransformVelocity : MonoBehaviour
+{
+ public TransformVelocity transformVelocty;
+
+ private void Start()
+ {
+ }
+
+ private void FixedUpdate()
+ {
+ base.transform.position = transformVelocty.transform.position + transformVelocty.velocity * 5f;
+ base.transform.rotation = transformVelocty.transform.rotation;
+ }
+}
diff --git a/FootHandler.cs b/FootHandler.cs
new file mode 100644
index 0000000..7343e21
--- /dev/null
+++ b/FootHandler.cs
@@ -0,0 +1,75 @@
+using UnityEngine;
+
+public class FootHandler : MonoBehaviour
+{
+ private AnimationHandler animHandler;
+
+ private Collider collider;
+
+ public PhysicMaterial slippery;
+
+ private PhysicMaterial footMaterial;
+
+ private Transform torso;
+
+ private MovementDataHandler moveData;
+
+ private Rigidbody rig;
+
+ private RotationHandler rot;
+
+ private Vector3 rotationDif;
+
+ private AnimationObject anim;
+
+ private StepHandler handler;
+
+ private void Start()
+ {
+ animHandler = base.transform.root.GetComponent();
+ moveData = base.transform.root.GetComponent();
+ collider = GetComponentInChildren();
+ rig = GetComponent();
+ footMaterial = collider.material;
+ torso = base.transform.root.GetComponentInChildren().transform;
+ rot = base.transform.root.GetComponent();
+ handler = base.transform.root.GetComponent();
+ anim = GetComponentInChildren();
+ }
+
+ private void Update()
+ {
+ float num = Mathf.Abs(torso.position.x - base.transform.position.x) + Mathf.Abs(torso.position.z - base.transform.position.z);
+ if (rot.hipCorrectionAmount > 30f || ((bool)anim && anim.isLeft != handler.isLeft))
+ {
+ SetFoot(active: false);
+ }
+ else if (animHandler.animationState == 0)
+ {
+ if (num > 0.1f || rotationDif.magnitude > 15f)
+ {
+ SetFoot(active: false);
+ }
+ else
+ {
+ SetFoot(active: true);
+ }
+ }
+ else
+ {
+ SetFoot(active: true);
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ }
+
+ private void SetFoot(bool active)
+ {
+ if (active)
+ {
+ collider.material = footMaterial;
+ }
+ }
+}
diff --git a/FootLeft.cs b/FootLeft.cs
new file mode 100644
index 0000000..da0d11f
--- /dev/null
+++ b/FootLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class FootLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/FootRenderer.cs b/FootRenderer.cs
new file mode 100644
index 0000000..a5dc15e
--- /dev/null
+++ b/FootRenderer.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+
+public class FootRenderer : MonoBehaviour
+{
+ private CollisionChecker collisionChecker;
+
+ private MovementDataHandler movementData;
+
+ private void Start()
+ {
+ collisionChecker = GetComponentInParent();
+ movementData = base.transform.root.GetComponent();
+ }
+
+ private void Update()
+ {
+ if (collisionChecker.sinceGrounded < 0.1f)
+ {
+ base.transform.rotation = Quaternion.LookRotation(movementData.groundedForward);
+ }
+ else
+ {
+ base.transform.rotation = Quaternion.identity;
+ }
+ }
+}
diff --git a/FootRight.cs b/FootRight.cs
new file mode 100644
index 0000000..c5014db
--- /dev/null
+++ b/FootRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class FootRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/ForceLerp.cs b/ForceLerp.cs
new file mode 100644
index 0000000..1d5a5b4
--- /dev/null
+++ b/ForceLerp.cs
@@ -0,0 +1,59 @@
+using UnityEngine;
+
+public class ForceLerp : MonoBehaviour
+{
+ public Rigidbody rig;
+
+ public float predictionAmount;
+
+ public Transform target;
+
+ public float movementMultiplier = 1f;
+
+ public float friction = 0.97f;
+
+ private Vector3 velocity;
+
+ public float inputVelocityAmount;
+
+ public float inputFriction;
+
+ private GenericInputHandler input;
+
+ private float inputVelocity;
+
+ private CollisionChecker[] checkers;
+
+ private void Start()
+ {
+ input = GetComponentInParent();
+ checkers = base.transform.root.GetComponentsInChildren();
+ }
+
+ private void FixedUpdate()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ float num = Mathf.Clamp(Time.smoothDeltaTime, 0f, 0.1f);
+ float num2 = 1f;
+ if (checkers.Length > 0)
+ {
+ num2 = 0f;
+ for (int i = 0; i < checkers.Length; i++)
+ {
+ if (checkers[i].sinceGrounded < 0.2f)
+ {
+ num2 += 1f / (float)checkers.Length;
+ }
+ }
+ }
+ inputVelocity += rig.angularVelocity.y * 0.5f * num2 * num - num * inputVelocity * inputFriction;
+ Vector3 vector = target.position - base.transform.position + rig.transform.right * inputVelocity * inputVelocityAmount + rig.velocity * predictionAmount;
+ Vector3 vector2 = velocity * friction;
+ velocity += (vector - vector2) * num;
+ base.transform.position += velocity * movementMultiplier * num;
+ base.transform.rotation = Quaternion.Lerp(base.transform.rotation, Quaternion.LookRotation(target.forward), num * 4f);
+ }
+}
diff --git a/ForcePosition.cs b/ForcePosition.cs
new file mode 100644
index 0000000..ed6dcc3
--- /dev/null
+++ b/ForcePosition.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class ForcePosition : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/GameMode.cs b/GameMode.cs
new file mode 100644
index 0000000..2d717aa
--- /dev/null
+++ b/GameMode.cs
@@ -0,0 +1,124 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class GameMode : MonoBehaviour
+{
+ public List wavesToSpawn = new List();
+
+ public static GameMode instance;
+
+ private int currentWave;
+
+ public List enemies = new List();
+
+ public Transform spawnPointParent;
+
+ private List spawnPoints = new List();
+
+ public LayerMask mask;
+
+ public GameObject enemy_Default;
+
+ public GameObject enemy_Fast;
+
+ private IEnumerator Start()
+ {
+ Screen.fullScreen = false;
+ Screen.SetResolution(1800, 1000, false);
+
+ Cursor.visible = false;
+ Cursor.lockState = CursorLockMode.Locked;
+
+ Init();
+ while (true)
+ {
+ yield return new WaitForSeconds(3f);
+ //SpawnWave();
+ yield return WaitForWaveToEnd();
+ }
+ }
+
+ private IEnumerator WaitForWaveToEnd()
+ {
+ while (enemies.Count > 0)
+ {
+ yield return null;
+ }
+ }
+
+ private void Update()
+ {
+ for (int num = enemies.Count - 1; num >= 0; num--)
+ {
+ if (enemies[num] == null)
+ {
+ enemies.RemoveAt(num);
+ }
+ else if (enemies[num].IsDead())
+ {
+ enemies.RemoveAt(num);
+ }
+ }
+ }
+
+ private void Init()
+ {
+ mask = LayerMask.GetMask("Map");
+ for (int i = 0; i < spawnPointParent.childCount; i++)
+ {
+ spawnPoints.Add(spawnPointParent.GetChild(i));
+ }
+ }
+
+ private void SpawnWave()
+ {
+ for (int i = 0; i < wavesToSpawn[currentWave].groups.Count; i++)
+ {
+ for (int j = 0; (float)j < wavesToSpawn[currentWave].groups[i].number; j++)
+ {
+ SpawnEnemy(wavesToSpawn[currentWave].groups[i].enemyType);
+ }
+ }
+ currentWave++;
+ if (currentWave >= wavesToSpawn.Count)
+ {
+ currentWave = wavesToSpawn.Count - 1;
+ }
+ }
+
+ private void SpawnEnemy(EnemyGroup.EnemyType enemyType)
+ {
+ GameObject gameObject = Object.Instantiate(GetEnemyFromType(enemyType), GetSpawnPos(), Quaternion.identity);
+ gameObject.GetComponent().target = Player.localPlayer.torso;
+ enemies.Add(gameObject.GetComponent());
+ }
+
+ private Vector3 GetSpawnPos()
+ {
+ bool flag = false;
+ int num = 100000;
+ while (true && num > 0)
+ {
+ num--;
+ Vector3 vector = spawnPoints[Random.Range(0, spawnPoints.Count)].position + Vector3.up * 0.3f;
+ RaycastHit hitInfo = default(RaycastHit);
+ Ray ray = new Ray(vector, vector - Player.localPlayer.transform.position);
+ Physics.Raycast(ray, out hitInfo, Vector3.Distance(vector, Player.localPlayer.transform.position), mask);
+ if (hitInfo.collider == null)
+ {
+ return vector;
+ }
+ }
+ return spawnPoints[Random.Range(0, spawnPoints.Count)].position + Vector3.up * 0.3f;
+ }
+
+ private GameObject GetEnemyFromType(EnemyGroup.EnemyType enemyType)
+ {
+ if (enemyType == EnemyGroup.EnemyType.Fast)
+ {
+ return enemy_Fast;
+ }
+ return enemy_Default;
+ }
+}
diff --git a/GenericForceMovement.cs b/GenericForceMovement.cs
new file mode 100644
index 0000000..4c8160f
--- /dev/null
+++ b/GenericForceMovement.cs
@@ -0,0 +1,40 @@
+using UnityEngine;
+
+public class GenericForceMovement : MonoBehaviour
+{
+ public Vector3 movementDirection;
+
+ public float forceMultiplier = 1f;
+
+ public MovementRig[] rigs;
+
+ public bool useGroundedMultiplier;
+
+ private CollisionChecker[] checkers;
+
+ private void Start()
+ {
+ checkers = GetComponentsInChildren();
+ }
+
+ private void FixedUpdate()
+ {
+ float num = 1f;
+ if (useGroundedMultiplier)
+ {
+ num = 0f;
+ for (int i = 0; i < checkers.Length; i++)
+ {
+ if (checkers[i].sinceGrounded < 0.1f)
+ {
+ num += 1f / (float)checkers.Length;
+ }
+ }
+ }
+ MovementRig[] array = rigs;
+ foreach (MovementRig movementRig in array)
+ {
+ movementRig.rig.AddForce(movementDirection * num * forceMultiplier * movementRig.multiplier, ForceMode.Acceleration);
+ }
+ }
+}
diff --git a/GenericInputHandler.cs b/GenericInputHandler.cs
new file mode 100644
index 0000000..deeed7e
--- /dev/null
+++ b/GenericInputHandler.cs
@@ -0,0 +1,40 @@
+using UnityEngine;
+
+public class GenericInputHandler : MonoBehaviour
+{
+ public Vector3 inputDirection;
+
+ public bool normalized;
+
+ public bool space;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ space = Input.GetKey(KeyCode.Space);
+ inputDirection = Vector3.zero;
+ if (Input.GetKey(KeyCode.W))
+ {
+ inputDirection += Vector3.forward;
+ }
+ if (Input.GetKey(KeyCode.S))
+ {
+ inputDirection += Vector3.back;
+ }
+ if (Input.GetKey(KeyCode.D))
+ {
+ inputDirection += Vector3.right;
+ }
+ if (Input.GetKey(KeyCode.A))
+ {
+ inputDirection += Vector3.left;
+ }
+ if (normalized)
+ {
+ inputDirection = inputDirection.normalized;
+ }
+ }
+}
diff --git a/GeometryVsTerrainBlend.cs b/GeometryVsTerrainBlend.cs
new file mode 100644
index 0000000..20ab882
--- /dev/null
+++ b/GeometryVsTerrainBlend.cs
@@ -0,0 +1,215 @@
+using UnityEngine;
+
+[AddComponentMenu("Relief Terrain/Geometry Blend")]
+[SelectionBase]
+[RequireComponent(typeof(MeshFilter))]
+public class GeometryVsTerrainBlend : MonoBehaviour
+{
+ public double UpdTim;
+
+ private int progress_count_max;
+
+ private int progress_count_current;
+
+ private const int progress_granulation = 1000;
+
+ private string progress_description = string.Empty;
+
+ public float blend_distance = 0.1f;
+
+ public GameObject blendedObject;
+
+ public bool VoxelBlendedObject;
+
+ public float _DeferredBlendGloss = 0.8f;
+
+ [HideInInspector]
+ public bool undo_flag;
+
+ [HideInInspector]
+ public bool paint_flag;
+
+ [HideInInspector]
+ public int paint_mode;
+
+ [HideInInspector]
+ public float paint_size = 0.5f;
+
+ [HideInInspector]
+ public float paint_smoothness;
+
+ [HideInInspector]
+ public float paint_opacity = 1f;
+
+ [HideInInspector]
+ public RTPColorChannels vertex_paint_channel = RTPColorChannels.A;
+
+ [HideInInspector]
+ public int addTrisSubdivision;
+
+ [HideInInspector]
+ public float addTrisMinAngle;
+
+ [HideInInspector]
+ public float addTrisMaxAngle = 90f;
+
+ private Vector3[] paint_vertices;
+
+ private Vector3[] paint_normals;
+
+ private int[] paint_tris;
+
+ private Transform underlying_transform;
+
+ private MeshRenderer underlying_renderer;
+
+ [HideInInspector]
+ public RaycastHit paintHitInfo;
+
+ [HideInInspector]
+ public bool paintHitInfo_flag;
+
+ [HideInInspector]
+ private Texture2D tmp_globalColorMap;
+
+ [HideInInspector]
+ public Vector3[] normals_orig;
+
+ [HideInInspector]
+ public Vector4[] tangents_orig;
+
+ [HideInInspector]
+ public bool baked_normals;
+
+ [HideInInspector]
+ public Mesh orig_mesh;
+
+ [HideInInspector]
+ public Mesh pmesh;
+
+ [HideInInspector]
+ public bool shader_global_blend_capabilities;
+
+ [HideInInspector]
+ public float StickOffset = 0.03f;
+
+ [HideInInspector]
+ public bool Sticked;
+
+ [HideInInspector]
+ public bool StickedOptimized = true;
+
+ [HideInInspector]
+ public bool ModifyTris;
+
+ [HideInInspector]
+ public bool BuildMeshFlag;
+
+ [HideInInspector]
+ public bool RealizePaint_Flag;
+
+ [HideInInspector]
+ public string save_path = string.Empty;
+
+ [HideInInspector]
+ public bool isBatched;
+
+ private Renderer _renderer;
+
+ private void Start()
+ {
+ SetupValues();
+ }
+
+ private void GetRenderer()
+ {
+ if (!_renderer)
+ {
+ _renderer = GetComponent();
+ }
+ }
+
+ public void SetupValues()
+ {
+ if (!blendedObject || (!(blendedObject.GetComponent(typeof(MeshRenderer)) != null) && !(blendedObject.GetComponent(typeof(Terrain)) != null)))
+ {
+ return;
+ }
+ if (underlying_transform == null)
+ {
+ underlying_transform = base.transform.Find("RTP_blend_underlying");
+ }
+ if (underlying_transform != null)
+ {
+ GameObject gameObject = underlying_transform.gameObject;
+ underlying_renderer = (MeshRenderer)gameObject.GetComponent(typeof(MeshRenderer));
+ }
+ if (!(underlying_renderer != null) || !(underlying_renderer.sharedMaterial != null))
+ {
+ return;
+ }
+ ReliefTerrain reliefTerrain = (ReliefTerrain)blendedObject.GetComponent(typeof(ReliefTerrain));
+ if ((bool)reliefTerrain)
+ {
+ Material sharedMaterial = underlying_renderer.sharedMaterial;
+ reliefTerrain.RefreshTextures(sharedMaterial);
+ reliefTerrain.globalSettingsHolder.Refresh(sharedMaterial);
+ if (sharedMaterial.HasProperty("RTP_DeferredAddPassSpec"))
+ {
+ sharedMaterial.SetFloat("RTP_DeferredAddPassSpec", _DeferredBlendGloss);
+ }
+ if ((bool)reliefTerrain.controlA)
+ {
+ sharedMaterial.SetTexture("_Control", reliefTerrain.controlA);
+ }
+ if ((bool)reliefTerrain.ColorGlobal)
+ {
+ sharedMaterial.SetTexture("_Splat0", reliefTerrain.ColorGlobal);
+ }
+ if ((bool)reliefTerrain.NormalGlobal)
+ {
+ sharedMaterial.SetTexture("_Splat1", reliefTerrain.NormalGlobal);
+ }
+ if ((bool)reliefTerrain.TreesGlobal)
+ {
+ sharedMaterial.SetTexture("_Splat2", reliefTerrain.TreesGlobal);
+ }
+ if ((bool)reliefTerrain.BumpGlobalCombined)
+ {
+ sharedMaterial.SetTexture("_Splat3", reliefTerrain.BumpGlobalCombined);
+ }
+ }
+ Terrain terrain = (Terrain)blendedObject.GetComponent(typeof(Terrain));
+ if ((bool)terrain)
+ {
+ underlying_renderer.lightmapIndex = terrain.lightmapIndex;
+ underlying_renderer.lightmapScaleOffset = terrain.lightmapScaleOffset;
+ underlying_renderer.realtimeLightmapIndex = terrain.realtimeLightmapIndex;
+ underlying_renderer.realtimeLightmapScaleOffset = terrain.realtimeLightmapScaleOffset;
+ }
+ else
+ {
+ underlying_renderer.lightmapIndex = blendedObject.GetComponent().lightmapIndex;
+ underlying_renderer.lightmapScaleOffset = blendedObject.GetComponent().lightmapScaleOffset;
+ underlying_renderer.realtimeLightmapIndex = blendedObject.GetComponent().realtimeLightmapIndex;
+ underlying_renderer.realtimeLightmapScaleOffset = blendedObject.GetComponent().realtimeLightmapScaleOffset;
+ }
+ if (Sticked)
+ {
+ if ((bool)terrain)
+ {
+ GetComponent().lightmapIndex = terrain.lightmapIndex;
+ GetComponent().lightmapScaleOffset = terrain.lightmapScaleOffset;
+ GetComponent().realtimeLightmapIndex = terrain.realtimeLightmapIndex;
+ GetComponent().realtimeLightmapScaleOffset = terrain.realtimeLightmapScaleOffset;
+ }
+ else
+ {
+ GetComponent().lightmapIndex = blendedObject.GetComponent().lightmapIndex;
+ GetComponent().lightmapScaleOffset = blendedObject.GetComponent().lightmapScaleOffset;
+ GetComponent().realtimeLightmapIndex = blendedObject.GetComponent().realtimeLightmapIndex;
+ GetComponent().realtimeLightmapScaleOffset = blendedObject.GetComponent().realtimeLightmapScaleOffset;
+ }
+ }
+ }
+}
diff --git a/Gravity.cs b/Gravity.cs
new file mode 100644
index 0000000..f646f0c
--- /dev/null
+++ b/Gravity.cs
@@ -0,0 +1,47 @@
+using UnityEngine;
+
+public class Gravity : MonoBehaviour
+{
+ public float baseGravity;
+
+ public float scalingGravity;
+
+ private RigidbodyHolder allRigs;
+
+ private StandingDataHandler standingData;
+
+ private Holding holding;
+
+ private PlayerDeath death;
+
+ private void Start()
+ {
+ death = GetComponent();
+ allRigs = GetComponent();
+ standingData = GetComponent();
+ holding = GetComponent();
+ }
+
+ private void FixedUpdate()
+ {
+ if (death.dead)
+ {
+ return;
+ }
+ for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ {
+ allRigs.GetAllRigs()[i].AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration);
+ }
+ if ((bool)holding)
+ {
+ if ((bool)holding.heldObject)
+ {
+ holding.heldObject.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration);
+ }
+ if ((bool)holding.heldObjectOffHand)
+ {
+ holding.heldObjectOffHand.rig.AddForce(Vector3.down * baseGravity + Vector3.down * scalingGravity * standingData.sinceGrounded, ForceMode.Acceleration);
+ }
+ }
+ }
+}
diff --git a/Gun.cs b/Gun.cs
new file mode 100644
index 0000000..d9a3532
--- /dev/null
+++ b/Gun.cs
@@ -0,0 +1,94 @@
+using UnityEngine;
+
+public class Gun : MonoBehaviour
+{
+ public GameObject projectile;
+
+ public float rateOfFire = 0.1f;
+
+ public bool auto = true;
+
+ public int bulletsInMag = 30;
+
+ public float reloadTime = 0.5f;
+
+ public float ADSFOV = 60f;
+
+ [HideInInspector]
+ public Rigidbody rig;
+
+ private Transform shootPosition;
+
+ private Recoil recoil;
+
+ private AddScreenShake shake;
+
+ private float counter;
+
+ public float extraSpread;
+
+ public float addForceToAllSpawnedRigs;
+
+ private ParticleSystem part;
+
+ private GunSFX sfx;
+
+ private void Start()
+ {
+ rig = GetComponent();
+ sfx = GetComponent();
+ recoil = GetComponent();
+ shake = GetComponent();
+ shootPosition = GetComponentInChildren().transform;
+ part = GetComponentInChildren();
+ }
+
+ private void Update()
+ {
+ counter += Time.deltaTime;
+ }
+
+ public void Shoot(Transform shooter, bool ADS)
+ {
+ if (counter < rateOfFire)
+ {
+ return;
+ }
+ counter = 0f;
+ if ((bool)part)
+ {
+ part.Play();
+ }
+ GameObject gameObject = Object.Instantiate(projectile, shootPosition.position, shootPosition.rotation);
+ RandomizeRotation component = gameObject.GetComponent();
+ if ((bool)component)
+ {
+ component.spread += extraSpread;
+ }
+ SpawnerHolder component2 = gameObject.GetComponent();
+ if ((bool)component2)
+ {
+ component2.spawner = shooter;
+ }
+ if ((bool)recoil)
+ {
+ recoil.AddRecoil(ADS);
+ }
+ if ((bool)shake)
+ {
+ shake.DoShake();
+ }
+ if ((bool)sfx)
+ {
+ sfx.PlayShootSound();
+ }
+ if (addForceToAllSpawnedRigs != 0f)
+ {
+ Rigidbody[] componentsInChildren = gameObject.GetComponentsInChildren();
+ foreach (Rigidbody rigidbody in componentsInChildren)
+ {
+ rigidbody.AddForce(shootPosition.forward * addForceToAllSpawnedRigs, ForceMode.VelocityChange);
+ }
+ }
+ }
+}
diff --git a/GunSFX.cs b/GunSFX.cs
new file mode 100644
index 0000000..a00422c
--- /dev/null
+++ b/GunSFX.cs
@@ -0,0 +1,23 @@
+using UnityEngine;
+
+public class GunSFX : MonoBehaviour
+{
+ public AudioClip[] shootClips;
+
+ private AudioSource au;
+
+ private void Start()
+ {
+ au = GetComponent();
+ au.mute = true;
+ }
+
+ private void Update()
+ {
+ }
+
+ public void PlayShootSound()
+ {
+ //au.PlayOneShot(shootClips[Random.Range(0, shootClips.Length)]);
+ }
+}
diff --git a/HandLeft.cs b/HandLeft.cs
new file mode 100644
index 0000000..5f92108
--- /dev/null
+++ b/HandLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HandLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/HandRight.cs b/HandRight.cs
new file mode 100644
index 0000000..cb78d06
--- /dev/null
+++ b/HandRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HandRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/HardAnimation.cs b/HardAnimation.cs
new file mode 100644
index 0000000..3821be6
--- /dev/null
+++ b/HardAnimation.cs
@@ -0,0 +1,61 @@
+using UnityEngine;
+
+public class HardAnimation : MonoBehaviour
+{
+ public bool isLeft;
+
+ public Vector3 targetRotationForward;
+
+ public Vector3 targetRotationBack;
+
+ private Vector3 currentTarget;
+
+ private Vector3 currentTargetGoal;
+
+ public float friction;
+
+ public float movementAmount;
+
+ public float delay;
+
+ private float counter;
+
+ private Vector3 velocity;
+
+ private StepHandler step;
+
+ private ConfigurableJoint joint;
+
+ private Quaternion startRot;
+
+ private Quaternion startRotLocal;
+
+ private void Start()
+ {
+ joint = GetComponent();
+ step = base.transform.root.GetComponent();
+ startRot = base.transform.rotation;
+ startRotLocal = base.transform.localRotation;
+ }
+
+ private void Update()
+ {
+ Vector3 vector = ((step.isLeft != isLeft) ? targetRotationBack : targetRotationForward);
+ if (currentTargetGoal != vector)
+ {
+ if (counter >= delay)
+ {
+ counter = 0f;
+ currentTargetGoal = vector;
+ }
+ else
+ {
+ counter += Time.deltaTime;
+ }
+ }
+ velocity += (currentTargetGoal - currentTarget) * Time.deltaTime;
+ velocity -= velocity * friction * Time.deltaTime;
+ currentTarget += velocity * movementAmount * Time.deltaTime;
+ joint.SetTargetRotationLocal(Quaternion.Euler(currentTarget), startRotLocal);
+ }
+}
diff --git a/HardAnimations.cs b/HardAnimations.cs
new file mode 100644
index 0000000..b14ab1c
--- /dev/null
+++ b/HardAnimations.cs
@@ -0,0 +1,64 @@
+using UnityEngine;
+
+public class HardAnimations : MonoBehaviour
+{
+ public bool isLeft;
+
+ public HardPhysicsAnimation[] animations;
+
+ private AnimationHandler animHandler;
+
+ private Vector3 currentTarget;
+
+ private Vector3 currentTargetGoal;
+
+ private float counter;
+
+ private Vector3 velocity;
+
+ private StepHandler step;
+
+ private ConfigurableJoint joint;
+
+ private Quaternion startRot;
+
+ private Quaternion startRotLocal;
+
+ private CollisionChecker checker;
+
+ private void Start()
+ {
+ animHandler = base.transform.root.GetComponent();
+ joint = GetComponent();
+ checker = GetComponent();
+ step = base.transform.root.GetComponent();
+ startRot = base.transform.rotation;
+ startRotLocal = base.transform.localRotation;
+ }
+
+ private void Update()
+ {
+ Vector3 vector = ((step.isLeft != isLeft) ? animations[animHandler.animationState].targetRotationBack : animations[animHandler.animationState].targetRotationForward);
+ if (currentTargetGoal != vector)
+ {
+ if (counter >= animations[animHandler.animationState].delay)
+ {
+ counter = 0f;
+ currentTargetGoal = vector;
+ }
+ else
+ {
+ counter += Time.deltaTime;
+ }
+ }
+ checker.active = isLeft != step.isLeft;
+ velocity += (currentTargetGoal - currentTarget) * Time.deltaTime;
+ velocity *= animations[animHandler.animationState].friction;
+ currentTarget += velocity * animations[animHandler.animationState].movementAmount * Time.deltaTime;
+ joint.SetTargetRotationLocal(Quaternion.Euler(currentTarget), startRotLocal);
+ }
+
+ private void FixedUpdate()
+ {
+ }
+}
diff --git a/HardPhysicsAnimation.cs b/HardPhysicsAnimation.cs
new file mode 100644
index 0000000..57796ee
--- /dev/null
+++ b/HardPhysicsAnimation.cs
@@ -0,0 +1,16 @@
+using System;
+using UnityEngine;
+
+[Serializable]
+public class HardPhysicsAnimation
+{
+ public Vector3 targetRotationForward;
+
+ public Vector3 targetRotationBack;
+
+ public float friction;
+
+ public float movementAmount;
+
+ public float delay;
+}
diff --git a/HasControl.cs b/HasControl.cs
new file mode 100644
index 0000000..dde8ad6
--- /dev/null
+++ b/HasControl.cs
@@ -0,0 +1,28 @@
+using UnityEngine;
+
+public class HasControl : MonoBehaviour
+{
+ public bool hasControl = true;
+
+ public GameObject[] objectsToRemove;
+
+ private void Awake()
+ {
+ UpdateControl();
+ }
+
+ private void UpdateControl()
+ {
+ GameObject[] array = objectsToRemove;
+ foreach (GameObject gameObject in array)
+ {
+ gameObject.SetActive(hasControl);
+ }
+ }
+
+ public void ChangeControl(bool control)
+ {
+ hasControl = control;
+ UpdateControl();
+ }
+}
diff --git a/Head.cs b/Head.cs
new file mode 100644
index 0000000..ce81442
--- /dev/null
+++ b/Head.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Head : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/HeadCollisionHandler.cs b/HeadCollisionHandler.cs
new file mode 100644
index 0000000..c929f0e
--- /dev/null
+++ b/HeadCollisionHandler.cs
@@ -0,0 +1,31 @@
+using UnityEngine;
+
+public class HeadCollisionHandler : MonoBehaviour
+{
+ public float collisionValue;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ collisionValue = Mathf.Lerp(collisionValue, 0f, Time.deltaTime * 6f);
+ }
+
+ private void OnCollisionEnter(Collision collision)
+ {
+ if (!(collision.transform.root == base.transform.root))
+ {
+ collisionValue += collision.relativeVelocity.magnitude * 0.5f;
+ }
+ }
+
+ private void OnCollisionStay(Collision collision)
+ {
+ if (!(collision.transform.root == base.transform.root))
+ {
+ collisionValue += collision.relativeVelocity.magnitude * 0.1f;
+ }
+ }
+}
diff --git a/Hip.cs b/Hip.cs
new file mode 100644
index 0000000..379fb1d
--- /dev/null
+++ b/Hip.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Hip : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/HoldableObject.cs b/HoldableObject.cs
new file mode 100644
index 0000000..3bfbfc5
--- /dev/null
+++ b/HoldableObject.cs
@@ -0,0 +1,88 @@
+using UnityEngine;
+
+public class HoldableObject : MonoBehaviour
+{
+ public Transform holder;
+
+ public Vector3 holdingPosition;
+
+ public Vector3 holdingRotation;
+
+ public Vector3 holdingUpRotation;
+
+ [HideInInspector]
+ public Rigidbody rig;
+
+ [HideInInspector]
+ public Transform leftHandPos;
+
+ [HideInInspector]
+ public Transform rightHandPos;
+
+ [HideInInspector]
+ public PID pid;
+
+ [HideInInspector]
+ public Vector2 swingAngles;
+
+ public float swingSpring;
+
+ public Vector2 twistAngles;
+
+ public float twistSpring;
+
+ public bool isHeld;
+
+ private DragHandler dragHandler;
+
+ public LayerMask mask;
+
+ private void Awake()
+ {
+ pid = GetComponent();
+ rig = GetComponent();
+ RightHandPos componentInChildren = GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ rightHandPos = componentInChildren.transform;
+ }
+ LeftHandPos componentInChildren2 = GetComponentInChildren();
+ if ((bool)componentInChildren2)
+ {
+ leftHandPos = componentInChildren2.transform;
+ }
+ dragHandler = GetComponent();
+ mask = LayerMask.GetMask("Map");
+ }
+
+ private void Update()
+ {
+ if (isHeld)
+ {
+ dragHandler.dragAmount = 1f;
+ }
+ else
+ {
+ dragHandler.dragAmount = 0f;
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ if (!isHeld)
+ {
+ Hover();
+ }
+ }
+
+ private void Hover()
+ {
+ RaycastHit hitInfo = default(RaycastHit);
+ Ray ray = new Ray(base.transform.position, Vector3.down);
+ Physics.Raycast(ray, out hitInfo, 1.5f, mask);
+ Vector3 vector = new Vector3(0f, 0f, 0f);
+ vector.y = 1f - hitInfo.distance;
+ rig.velocity = Vector3.Lerp(rig.velocity, vector * 2f, Time.fixedDeltaTime * 100f);
+ rig.angularVelocity = Vector3.Lerp(rig.angularVelocity, Vector3.up * 5f, Time.deltaTime * 100f);
+ }
+}
diff --git a/Holding.cs b/Holding.cs
new file mode 100644
index 0000000..dafc08b
--- /dev/null
+++ b/Holding.cs
@@ -0,0 +1,288 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Holding : MonoBehaviour
+{
+ [HideInInspector]
+ public HoldableObject heldObject;
+
+ [HideInInspector]
+ public HoldableObject heldObjectOffHand;
+
+ [HideInInspector]
+ public Transform baseTransform;
+
+ private Rigidbody rightHand;
+
+ private Rigidbody leftHand;
+
+ [HideInInspector]
+ public ConfigurableJoint leftHandJoint;
+
+ [HideInInspector]
+ public ConfigurableJoint rightHandJoint;
+
+ public float grabForce;
+
+ [HideInInspector]
+ public bool isGrabbing;
+
+ private Transform rotaionTarget;
+
+ private bool hasMainHandWeapon;
+
+ private PlayerDeath death;
+
+ public LayerMask mask = default(LayerMask);
+
+ private Strength str;
+
+ private float strength = 1f;
+
+ private PID leftHandPID;
+
+ private PID rightHandPID;
+
+ private StandingDataHandler standingData;
+
+ private void Awake()
+ {
+ death = GetComponent();
+ standingData = GetComponent();
+ str = GetComponent();
+ if (!baseTransform)
+ {
+ baseTransform = GetComponentInChildren().transform;
+ }
+ rightHand = GetComponentInChildren().GetComponent();
+ leftHand = GetComponentInChildren().GetComponent();
+ rotaionTarget = base.transform.GetComponentInChildren().transform;
+ mask = LayerMask.GetMask("Map");
+ leftHandPID = leftHand.GetComponent();
+ rightHandPID = rightHand.GetComponent();
+ }
+
+ private void Update()
+ {
+ if (!death.dead && (bool)heldObject)
+ {
+ strength = str.strength;
+ if (((bool)rightHandJoint || !heldObject.rightHandPos) && ((bool)leftHandJoint || !heldObject.leftHandPos) && (!heldObjectOffHand || (((bool)rightHandJoint || !heldObjectOffHand.rightHandPos) && ((bool)leftHandJoint || !heldObjectOffHand.leftHandPos))))
+ {
+ isGrabbing = false;
+ }
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ if (death.dead || isGrabbing)
+ {
+ return;
+ }
+ if ((bool)heldObject)
+ {
+ HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, rightHand);
+ if (!heldObjectOffHand && (bool)leftHandJoint)
+ {
+ HoldObjectInPlace(heldObject.rig, heldObject, offHand: false, leftHand, justHand: true);
+ }
+ }
+ if ((bool)heldObjectOffHand)
+ {
+ HoldObjectInPlace(heldObjectOffHand.rig, heldObjectOffHand, offHand: true, leftHand);
+ }
+ }
+
+ private void HoldObjectInPlace(Rigidbody rigi, HoldableObject held, bool offHand, Rigidbody hand, bool justHand = false)
+ {
+ Vector3 holdingPosition = held.holdingPosition;
+ if (offHand)
+ {
+ holdingPosition.x *= -1f;
+ }
+ holdingPosition = baseTransform.TransformPoint(holdingPosition);
+ Vector3 holdingRotation = held.holdingRotation;
+ Vector3 targetRotation = baseTransform.TransformDirection(holdingRotation);
+ Vector3 targetRotationUp = baseTransform.TransformDirection(held.holdingUpRotation);
+ if (!justHand)
+ {
+ held.pid.DoPID(holdingPosition, targetRotation, targetRotationUp, strength);
+ }
+ PID pID = rightHandPID;
+ Vector3 localPosition = held.rightHandPos.localPosition;
+ if (hand == leftHand)
+ {
+ localPosition = held.leftHandPos.localPosition;
+ pID = leftHandPID;
+ }
+ Vector3 position = held.holdingPosition + localPosition;
+ if (offHand)
+ {
+ position.x *= -1f;
+ }
+ position = baseTransform.TransformPoint(position);
+ Debug.DrawLine(position, position + Vector3.up);
+ Debug.DrawLine(holdingPosition, holdingPosition + Vector3.up);
+ pID.DoPID(position, Vector3.zero, Vector3.zero, strength);
+ }
+
+ public void StartHolding(HoldableObject holdableObject, bool hasOffHand)
+ {
+ holdableObject.isHeld = true;
+ isGrabbing = true;
+ bool offHand = false;
+ if (!hasMainHandWeapon)
+ {
+ hasMainHandWeapon = true;
+ heldObject = holdableObject;
+ if ((bool)heldObject.rightHandPos)
+ {
+ StartCoroutine(Grab(mainHand: true, rightHand, heldObject, offHand: false));
+ }
+ if ((bool)heldObject.leftHandPos && !hasOffHand)
+ {
+ StartCoroutine(Grab(mainHand: false, leftHand, heldObject, offHand: false));
+ }
+ }
+ else
+ {
+ offHand = true;
+ heldObjectOffHand = holdableObject;
+ heldObjectOffHand.leftHandPos = heldObjectOffHand.rightHandPos;
+ if ((bool)heldObjectOffHand.rightHandPos)
+ {
+ StartCoroutine(Grab(mainHand: false, leftHand, heldObjectOffHand, offHand: true));
+ }
+ }
+ StartCoroutine(HoldweaponStill(holdableObject.rig, offHand, holdableObject));
+ }
+
+ private IEnumerator Grab(bool mainHand, Rigidbody hand, HoldableObject held, bool offHand)
+ {
+ while (isGrabbing)
+ {
+ if (mainHand)
+ {
+ if (!rightHandJoint)
+ {
+ ReachForPoint(rightHand, rightHand.transform.GetChild(0).position, held.rightHandPos, isLeft: false, held.rig, held, offHand);
+ rightHand.GetComponentInChildren().enabled = false;
+ }
+ }
+ else if (!leftHandJoint)
+ {
+ ReachForPoint(leftHand, leftHand.transform.GetChild(0).position, held.leftHandPos, isLeft: true, held.rig, held, offHand);
+ leftHand.GetComponentInChildren().enabled = false;
+ }
+ yield return null;
+ }
+ leftHand.GetComponentInChildren().enabled = true;
+ rightHand.GetComponentInChildren().enabled = true;
+ }
+
+ private IEnumerator HoldweaponStill(Rigidbody rigToGrab, bool offHand, HoldableObject held)
+ {
+ while (isGrabbing)
+ {
+ Vector3 pos = held.holdingPosition;
+ if (offHand)
+ {
+ pos.x *= -1f;
+ }
+ rigToGrab.transform.position = baseTransform.TransformPoint(pos);
+ rigToGrab.transform.rotation = Quaternion.LookRotation(baseTransform.TransformDirection(heldObject.holdingRotation));
+ yield return null;
+ }
+ }
+
+ public void Drop()
+ {
+ List list = new List();
+ if ((bool)heldObject)
+ {
+ list.Add(heldObject);
+ }
+ if ((bool)heldObjectOffHand)
+ {
+ list.Add(heldObjectOffHand);
+ }
+ for (int i = 0; i < list.Count; i++)
+ {
+ list[i].holder = null;
+ list[i].isHeld = false;
+ list[i].rig.useGravity = true;
+ list[i].rig.drag = 0f;
+ list[i].rig.angularDrag = 0f;
+ Collider[] componentsInChildren = list[i].GetComponentsInChildren();
+ foreach (Collider collider in componentsInChildren)
+ {
+ collider.material = null;
+ }
+ }
+ heldObject = null;
+ heldObjectOffHand = null;
+ if ((bool)rightHandJoint)
+ {
+ Object.Destroy(rightHandJoint);
+ }
+ if ((bool)leftHandJoint)
+ {
+ Object.Destroy(leftHandJoint);
+ }
+ hasMainHandWeapon = false;
+ }
+
+ private void ReachForPoint(Rigidbody rigToReach, Vector3 forcePosition, Transform targetPositionTransform, bool isLeft, Rigidbody rigToGrab, HoldableObject held, bool offHand)
+ {
+ Vector3 normalized = (targetPositionTransform.position - forcePosition).normalized;
+ rigToReach.AddForceAtPosition(normalized * grabForce * Mathf.Clamp(Time.deltaTime, 0f, 0.1f), forcePosition, ForceMode.Acceleration);
+ if (Vector3.Distance(targetPositionTransform.position, forcePosition) < 0.5f)
+ {
+ ConnectRig(rigToReach, rigToGrab, targetPositionTransform, isLeft, held, offHand);
+ }
+ }
+
+ private void ConnectRig(Rigidbody startRig, Rigidbody targetRig, Transform targetPositionTransform, bool isLeft, HoldableObject held, bool offHand)
+ {
+ ConfigurableJoint configurableJoint = startRig.gameObject.AddComponent();
+ if (offHand)
+ {
+ targetPositionTransform.localRotation = Quaternion.Euler(targetPositionTransform.localEulerAngles.x, 0f - targetPositionTransform.localEulerAngles.y, targetPositionTransform.localEulerAngles.z);
+ }
+ startRig.transform.rotation = targetPositionTransform.rotation;
+ startRig.transform.position += targetPositionTransform.position - startRig.transform.GetChild(0).position;
+ configurableJoint.connectedBody = targetRig;
+ configurableJoint.projectionMode = JointProjectionMode.PositionAndRotation;
+ configurableJoint.xMotion = ConfigurableJointMotion.Locked;
+ configurableJoint.yMotion = ConfigurableJointMotion.Locked;
+ configurableJoint.zMotion = ConfigurableJointMotion.Locked;
+ configurableJoint.angularXMotion = ConfigurableJointMotion.Limited;
+ configurableJoint.angularYMotion = ConfigurableJointMotion.Limited;
+ configurableJoint.angularZMotion = ConfigurableJointMotion.Limited;
+ SoftJointLimit highAngularXLimit = configurableJoint.highAngularXLimit;
+ highAngularXLimit.limit = held.swingAngles.y;
+ configurableJoint.highAngularXLimit = highAngularXLimit;
+ highAngularXLimit.limit = held.swingAngles.x;
+ configurableJoint.lowAngularXLimit = highAngularXLimit;
+ highAngularXLimit.limit = held.twistAngles.x;
+ configurableJoint.angularYLimit = highAngularXLimit;
+ highAngularXLimit.limit = held.twistAngles.y;
+ configurableJoint.angularZLimit = highAngularXLimit;
+ SoftJointLimitSpring angularXLimitSpring = configurableJoint.angularXLimitSpring;
+ angularXLimitSpring.spring = held.swingSpring;
+ configurableJoint.angularXLimitSpring = angularXLimitSpring;
+ angularXLimitSpring.spring = held.twistSpring;
+ configurableJoint.angularYZLimitSpring = angularXLimitSpring;
+ configurableJoint.anchor = startRig.transform.InverseTransformPoint(startRig.transform.GetChild(0).position);
+ if (isLeft)
+ {
+ leftHandJoint = configurableJoint;
+ }
+ else
+ {
+ rightHandJoint = configurableJoint;
+ }
+ }
+}
diff --git a/HoldingBaseTransform.cs b/HoldingBaseTransform.cs
new file mode 100644
index 0000000..f28221b
--- /dev/null
+++ b/HoldingBaseTransform.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HoldingBaseTransform : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/InfoBubble.cs b/InfoBubble.cs
new file mode 100644
index 0000000..3c410c3
--- /dev/null
+++ b/InfoBubble.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+
+public class InfoBubble : MonoBehaviour
+{
+ public Vector3 WobbleAxis = Vector3.one;
+
+ public float WobbleFrequency = 1f;
+
+ public float WobbleAmplitude = 0.25f;
+
+ public Transform TrackTarget;
+
+ private Vector3 startOffsetTarget;
+
+ private void Start()
+ {
+ startOffsetTarget = base.transform.position - TrackTarget.position;
+ }
+
+ private void Update()
+ {
+ Vector3 eulerAngles = Mathf.Sin(WobbleFrequency * Time.timeSinceLevelLoad) * WobbleAxis * WobbleAmplitude;
+ base.transform.Rotate(eulerAngles);
+ base.transform.position = TrackTarget.position + startOffsetTarget;
+ }
+}
diff --git a/InputHandler.cs b/InputHandler.cs
new file mode 100644
index 0000000..27adc82
--- /dev/null
+++ b/InputHandler.cs
@@ -0,0 +1,120 @@
+using UnityEngine;
+
+public class InputHandler : MonoBehaviour
+{
+ public Vector3 inputMovementDirection;
+
+ public Vector3 lastInputDirection;
+
+ public bool isSpringting;
+
+ private WeaponHandler wepaonHandler;
+
+ private MovementDataHandler movementData;
+
+ private WeaponHandler weaponHandler;
+
+ private CameraMovement cameraMovement;
+
+ private PlayerDeath death;
+
+ private HasControl hasControl;
+
+ private MovementHandler movement;
+
+ public bool allowStrafe = true;
+
+ private void Start()
+ {
+ death = GetComponent();
+ movement = GetComponent();
+ wepaonHandler = GetComponent();
+ hasControl = GetComponent();
+ movementData = GetComponent();
+ weaponHandler = GetComponent();
+ cameraMovement = GetComponentInChildren();
+ }
+
+ private void Update()
+ {
+ if ((bool)death && death.dead)
+ {
+ return;
+ }
+ if (!hasControl || hasControl.hasControl)
+ {
+ isSpringting = false;
+ inputMovementDirection = Vector3.zero;
+ if (Input.GetKey(KeyCode.W))
+ {
+ inputMovementDirection += movementData.groundedForward;
+ }
+ if (Input.GetKey(KeyCode.S))
+ {
+ inputMovementDirection += movementData.groundedBack;
+ }
+ if (Input.GetKey(KeyCode.D) && allowStrafe)
+ {
+ inputMovementDirection += movementData.right;
+ }
+ if (Input.GetKey(KeyCode.A) && allowStrafe)
+ {
+ inputMovementDirection += movementData.left;
+ }
+ if (Input.GetKey(KeyCode.LeftShift) && (!cameraMovement || !cameraMovement.ADS))
+ {
+ isSpringting = true;
+ }
+ inputMovementDirection = inputMovementDirection.normalized;
+ if ((bool)movement && Input.GetKeyDown(KeyCode.Space))
+ {
+ movement.Jump();
+ }
+ if ((bool)weaponHandler)
+ {
+ if (weaponHandler.isDualWeilding)
+ {
+ if (Input.GetKey(KeyCode.Mouse1))
+ {
+ weaponHandler.HoldAttack(shootWithRightGun: true, ADS: false);
+ }
+ if (Input.GetKeyDown(KeyCode.Mouse1))
+ {
+ weaponHandler.PressAttack(shootWithRightGun: true, ADS: false);
+ }
+ if (Input.GetKey(KeyCode.Mouse0))
+ {
+ weaponHandler.HoldAttack(shootWithRightGun: false, ADS: false);
+ }
+ if (Input.GetKeyDown(KeyCode.Mouse0))
+ {
+ weaponHandler.PressAttack(shootWithRightGun: false, ADS: false);
+ }
+ }
+ else
+ {
+ if (Input.GetKey(KeyCode.Mouse1))
+ {
+ cameraMovement.ADS = true;
+ }
+ else
+ {
+ cameraMovement.ADS = false;
+ }
+ if (Input.GetKey(KeyCode.Mouse0))
+ {
+ weaponHandler.HoldAttack(shootWithRightGun: true, cameraMovement.ADS);
+ }
+ if (Input.GetKeyDown(KeyCode.Mouse0))
+ {
+ weaponHandler.PressAttack(shootWithRightGun: true, cameraMovement.ADS);
+ }
+ }
+ }
+ }
+ if (inputMovementDirection != Vector3.zero)
+ {
+ lastInputDirection = inputMovementDirection;
+ }
+ }
+}
diff --git a/KneeLeft.cs b/KneeLeft.cs
new file mode 100644
index 0000000..da00140
--- /dev/null
+++ b/KneeLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class KneeLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/KneeRight.cs b/KneeRight.cs
new file mode 100644
index 0000000..302a4ed
--- /dev/null
+++ b/KneeRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class KneeRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/Landfall.Network/LoginInformation.cs b/Landfall.Network/LoginInformation.cs
new file mode 100644
index 0000000..989d15e
--- /dev/null
+++ b/Landfall.Network/LoginInformation.cs
@@ -0,0 +1,6 @@
+namespace Landfall.Network;
+
+public class LoginInformation
+{
+ public string PlayerName { get; set; }
+}
diff --git a/Landfall.Network/NetworkController.cs b/Landfall.Network/NetworkController.cs
new file mode 100644
index 0000000..22791ab
--- /dev/null
+++ b/Landfall.Network/NetworkController.cs
@@ -0,0 +1,65 @@
+using UnityEngine;
+
+namespace Landfall.Network;
+
+public class NetworkController : MonoBehaviour
+{
+ [SerializeField]
+ private MonoBehaviour[] m_ScriptsToDisable;
+
+ [SerializeField]
+ private Camera[] m_CamerasToDisable;
+
+ [SerializeField]
+ private Transform m_Hip;
+
+ private bool m_HasControl;
+
+ private NetworkManager m_NetworkManager;
+
+ private string m_Name;
+
+ public void Init(NetworkManager manager, bool hasControl, string playerName)
+ {
+ m_NetworkManager = manager;
+ m_HasControl = hasControl;
+ GetComponent().ChangeControl(m_HasControl);
+ m_Name = playerName;
+ }
+
+ private void StripPlayer()
+ {
+ if (!m_HasControl)
+ {
+ MonoBehaviour[] scriptsToDisable = m_ScriptsToDisable;
+ foreach (MonoBehaviour monoBehaviour in scriptsToDisable)
+ {
+ monoBehaviour.enabled = false;
+ }
+ Camera[] camerasToDisable = m_CamerasToDisable;
+ foreach (Camera camera in camerasToDisable)
+ {
+ camera.enabled = false;
+ }
+ }
+ }
+
+ private void Update()
+ {
+ if (m_HasControl)
+ {
+ SendUpdatesToServer();
+ }
+ }
+
+ private void SendUpdatesToServer()
+ {
+ Vector3 position = m_Hip.position;
+ m_NetworkManager.UpdateFromLocalClient(position);
+ }
+
+ public void UpdatePosition(Vector3 newPos)
+ {
+ base.transform.position = newPos;
+ }
+}
diff --git a/Landfall.Network/NetworkManager.cs b/Landfall.Network/NetworkManager.cs
new file mode 100644
index 0000000..89d790a
--- /dev/null
+++ b/Landfall.Network/NetworkManager.cs
@@ -0,0 +1,213 @@
+using System;
+using System.Collections.Generic;
+using Lidgren.Network;
+using UnityEngine;
+
+namespace Landfall.Network;
+
+public class NetworkManager : MonoBehaviour
+{
+ [SerializeField]
+ private GameObject m_PlayerPrefab;
+
+ private GameObject m_SpawnedPlayer;
+
+ private NetClient m_Client;
+
+ private List m_Players = new List();
+
+ private NetPlayer m_LocalPlayer;
+
+ private string m_LocalName;
+
+ public bool Active { get; private set; }
+
+ private void Awake()
+ {
+ }
+
+ private void Start()
+ {
+ InitNetwork();
+ }
+
+ private void InitNetwork()
+ {
+ if (!StartClient())
+ {
+ Debug.LogError("Could Not Connect to server!");
+ return;
+ }
+ Debug.Log("Connected To Server!");
+ SpawnPlayer();
+ }
+
+ public bool StartClient()
+ {
+ m_LocalName = "Philip " + UnityEngine.Random.Range(0, int.MaxValue);
+ LoginInformation loginInformation = new LoginInformation();
+ loginInformation.PlayerName = m_LocalName;
+ LoginInformation ob = loginInformation;
+ NetPeerConfiguration netPeerConfiguration = new NetPeerConfiguration("RobotsNetwork");
+ netPeerConfiguration.EnableMessageType(NetIncomingMessageType.Data);
+ m_Client = new NetClient(netPeerConfiguration);
+ m_Client.Start();
+ NetOutgoingMessage netOutgoingMessage = m_Client.CreateMessage();
+ netOutgoingMessage.Write((byte)1);
+ netOutgoingMessage.WriteAllProperties(ob);
+ m_Client.Connect("127.0.0.1", 1337, netOutgoingMessage);
+ return EstablishConnection();
+ }
+
+ private bool EstablishConnection()
+ {
+ DateTime now = DateTime.Now;
+ do
+ {
+ NetIncomingMessage netIncomingMessage;
+ if ((netIncomingMessage = m_Client.ReadMessage()) != null)
+ {
+ NetIncomingMessageType messageType = netIncomingMessage.MessageType;
+ if (messageType == NetIncomingMessageType.StatusChanged && netIncomingMessage.SenderConnection.Status == NetConnectionStatus.Connected)
+ {
+ Active = true;
+ NetOutgoingMessage netOutgoingMessage = m_Client.CreateMessage();
+ netOutgoingMessage.Write((byte)4);
+ m_Client.SendMessage(netOutgoingMessage, NetDeliveryMethod.ReliableOrdered);
+ return true;
+ }
+ }
+ }
+ while (DateTime.Now.Subtract(now).Seconds <= 5);
+ return false;
+ }
+
+ private void SpawnPlayer()
+ {
+ m_SpawnedPlayer = UnityEngine.Object.Instantiate(m_PlayerPrefab);
+ m_LocalPlayer = new NetPlayer
+ {
+ PlayerName = m_LocalName,
+ PlayerObject = m_SpawnedPlayer
+ };
+ m_SpawnedPlayer.GetComponent().Init(this, hasControl: true, m_LocalName);
+ m_SpawnedPlayer.SetActive(value: true);
+ }
+
+ private void Update()
+ {
+ if (Active)
+ {
+ ReadMessages();
+ }
+ }
+
+ private void ReadMessages()
+ {
+ NetIncomingMessage netIncomingMessage;
+ while ((netIncomingMessage = m_Client.ReadMessage()) != null)
+ {
+ if (netIncomingMessage.MessageType == NetIncomingMessageType.Data)
+ {
+ PacketType packetType = (PacketType)netIncomingMessage.ReadByte();
+ Debug.Log("Recieved Message: " + packetType);
+ switch (packetType)
+ {
+ case PacketType.Login:
+ {
+ bool flag = netIncomingMessage.ReadBoolean();
+ RecieveAllPlayers(netIncomingMessage);
+ break;
+ }
+ case PacketType.NewPlayer:
+ RecieveNewPlayer(netIncomingMessage);
+ break;
+ case PacketType.AllPlayers:
+ RecieveAllPlayers(netIncomingMessage);
+ break;
+ case PacketType.Ping:
+ Debug.Log("Recieved Ping!");
+ break;
+ case PacketType.PlayerUpdate:
+ RecievedPlayerUpdate(netIncomingMessage);
+ break;
+ }
+ }
+ }
+ }
+
+ private void RecievedPlayerUpdate(NetIncomingMessage msg)
+ {
+ Vector3 newPos = msg.ReadVector3();
+ string playerName = msg.ReadString();
+ NetPlayer netPlayer = FindPlayerByName(playerName);
+ netPlayer.PlayerObject.GetComponent().UpdatePosition(newPos);
+ }
+
+ private NetPlayer FindPlayerByName(string playerName)
+ {
+ foreach (NetPlayer player in m_Players)
+ {
+ if (player.PlayerName == playerName)
+ {
+ return player;
+ }
+ }
+ throw new Exception("Could not find player woth name: " + playerName);
+ }
+
+ private void RecieveNewPlayer(NetIncomingMessage msg)
+ {
+ Player player = new Player();
+ msg.ReadAllProperties(player);
+ SpawnRemotePlayer(player);
+ }
+
+ private void RecieveAllPlayers(NetIncomingMessage message)
+ {
+ byte b = message.ReadByte();
+ for (byte b2 = 0; b2 < b; b2 = (byte)(b2 + 1))
+ {
+ Player player = new Player();
+ message.ReadAllProperties(player);
+ if (IsNewPlayer(player))
+ {
+ SpawnRemotePlayer(player);
+ }
+ }
+ }
+
+ private bool IsNewPlayer(Player player)
+ {
+ foreach (NetPlayer player2 in m_Players)
+ {
+ if (player2.PlayerName == player.Name)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void SpawnRemotePlayer(Player newPlayer)
+ {
+ GameObject gameObject = UnityEngine.Object.Instantiate(m_PlayerPrefab);
+ gameObject.name = newPlayer.Name;
+ gameObject.GetComponent().Init(this, hasControl: false, newPlayer.Name);
+ gameObject.SetActive(value: true);
+ m_Players.Add(new NetPlayer
+ {
+ PlayerObject = gameObject,
+ PlayerName = newPlayer.Name
+ });
+ }
+
+ public void UpdateFromLocalClient(Vector3 position)
+ {
+ NetOutgoingMessage netOutgoingMessage = m_Client.CreateMessage();
+ netOutgoingMessage.Write((byte)5);
+ netOutgoingMessage.Write(position);
+ netOutgoingMessage.Write(m_LocalName);
+ m_Client.SendMessage(netOutgoingMessage, NetDeliveryMethod.Unreliable);
+ }
+}
diff --git a/Landfall.Network/PacketType.cs b/Landfall.Network/PacketType.cs
new file mode 100644
index 0000000..e137b60
--- /dev/null
+++ b/Landfall.Network/PacketType.cs
@@ -0,0 +1,10 @@
+namespace Landfall.Network;
+
+public enum PacketType : byte
+{
+ Login = 1,
+ NewPlayer,
+ AllPlayers,
+ Ping,
+ PlayerUpdate
+}
diff --git a/Landfall.Network/Player.cs b/Landfall.Network/Player.cs
new file mode 100644
index 0000000..3f5a66f
--- /dev/null
+++ b/Landfall.Network/Player.cs
@@ -0,0 +1,13 @@
+using Lidgren.Network;
+using UnityEngine;
+
+namespace Landfall.Network;
+
+public class Player
+{
+ public string Name { get; set; }
+
+ public NetConnection Connection { get; set; }
+
+ public Vector3 Position { get; set; }
+}
diff --git a/LeftHandPos.cs b/LeftHandPos.cs
new file mode 100644
index 0000000..955cf44
--- /dev/null
+++ b/LeftHandPos.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class LeftHandPos : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/LegLeft.cs b/LegLeft.cs
new file mode 100644
index 0000000..23446b9
--- /dev/null
+++ b/LegLeft.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class LegLeft : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/LegRight.cs b/LegRight.cs
new file mode 100644
index 0000000..a050339
--- /dev/null
+++ b/LegRight.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class LegRight : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/LookAtVelocity.cs b/LookAtVelocity.cs
new file mode 100644
index 0000000..6504d6f
--- /dev/null
+++ b/LookAtVelocity.cs
@@ -0,0 +1,19 @@
+using UnityEngine;
+
+public class LookAtVelocity : MonoBehaviour
+{
+ private Rigidbody rig;
+
+ private void Start()
+ {
+ rig = GetComponentInParent();
+ }
+
+ private void Update()
+ {
+ if (rig.velocity.magnitude > 2f)
+ {
+ base.transform.rotation = Quaternion.LookRotation(rig.velocity);
+ }
+ }
+}
diff --git a/MipTexMap.cs b/MipTexMap.cs
new file mode 100644
index 0000000..57b6abc
--- /dev/null
+++ b/MipTexMap.cs
@@ -0,0 +1,119 @@
+using UnityEngine;
+
+public class MipTexMap : MonoBehaviour
+{
+ private static Texture2D mipFilterTex64;
+
+ private static Texture2D mipFilterTex128;
+
+ private static Texture2D mipFilterTex256;
+
+ private static Texture2D mipFilterTex512;
+
+ private static Texture2D mipFilterTex1024;
+
+ private static Texture2D mipFilterTex2048;
+
+ private static void BuildMipFilterTex(int size)
+ {
+ size = Mathf.ClosestPowerOfTwo(size);
+ Texture2D texture2D = new Texture2D(size, size, TextureFormat.Alpha8, mipmap: true);
+ texture2D.anisoLevel = 3;
+ texture2D.filterMode = FilterMode.Trilinear;
+ texture2D.mipMapBias = 0f;
+ for (int i = 0; i < texture2D.mipmapCount; i++)
+ {
+ int num = size * size;
+ Color[] array = new Color[num];
+ float num2 = 1f * (float)i / (float)(texture2D.mipmapCount - 1);
+ Color color = new Color(num2, num2, num2, num2);
+ for (int j = 0; j < num; j++)
+ {
+ array[j] = color;
+ }
+ texture2D.SetPixels(array, i);
+ }
+ texture2D.Apply(updateMipmaps: false, makeNoLongerReadable: true);
+ switch (size)
+ {
+ case 64:
+ mipFilterTex64 = texture2D;
+ break;
+ case 128:
+ mipFilterTex128 = texture2D;
+ break;
+ case 256:
+ mipFilterTex256 = texture2D;
+ break;
+ case 512:
+ mipFilterTex512 = texture2D;
+ break;
+ case 1024:
+ mipFilterTex1024 = texture2D;
+ break;
+ case 2048:
+ mipFilterTex2048 = texture2D;
+ break;
+ default:
+ mipFilterTex512 = texture2D;
+ break;
+ }
+ }
+
+ public static Texture2D GetTex(int size)
+ {
+ size = Mathf.ClosestPowerOfTwo(size);
+ switch (size)
+ {
+ case 64:
+ if ((bool)mipFilterTex64)
+ {
+ return mipFilterTex64;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex64;
+ case 128:
+ if ((bool)mipFilterTex128)
+ {
+ return mipFilterTex128;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex128;
+ case 256:
+ if ((bool)mipFilterTex256)
+ {
+ return mipFilterTex256;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex256;
+ case 512:
+ if ((bool)mipFilterTex512)
+ {
+ return mipFilterTex512;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex512;
+ case 1024:
+ if ((bool)mipFilterTex1024)
+ {
+ return mipFilterTex1024;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex1024;
+ case 2048:
+ if ((bool)mipFilterTex2048)
+ {
+ return mipFilterTex2048;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex2048;
+ default:
+ if ((bool)mipFilterTex512)
+ {
+ return mipFilterTex512;
+ }
+ BuildMipFilterTex(size);
+ return mipFilterTex512;
+ }
+ }
+}
diff --git a/MouseLook.cs b/MouseLook.cs
new file mode 100644
index 0000000..45c7cca
--- /dev/null
+++ b/MouseLook.cs
@@ -0,0 +1,117 @@
+using UnityEngine;
+
+public class MouseLook : MonoBehaviour
+{
+ public enum RotationAxes
+ {
+ MouseXAndY,
+ MouseX,
+ MouseY
+ }
+
+ public RotationAxes axes;
+
+ public float sensitivityX = 3f;
+
+ public float sensitivityY = 3f;
+
+ public float minimumX = -360f;
+
+ public float maximumX = 360f;
+
+ public float minimumY = -80f;
+
+ public float maximumY = 80f;
+
+ public float forwardSpeedScale = 0.03f;
+
+ public float strafeSpeedScale = 0.03f;
+
+ private float rotationX;
+
+ private float rotationY;
+
+ private bool look;
+
+ private Quaternion originalRotation;
+
+ private void Update()
+ {
+ if (GUIUtility.hotControl != 0)
+ {
+ return;
+ }
+ if (Input.GetMouseButtonDown(0))
+ {
+ look = true;
+ }
+ if (Input.GetMouseButtonUp(0))
+ {
+ look = false;
+ }
+ if (look)
+ {
+ if (axes == RotationAxes.MouseXAndY)
+ {
+ rotationX += Input.GetAxis("Mouse X") * sensitivityX;
+ rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
+ rotationX = ClampAngle(rotationX, minimumX, maximumX);
+ rotationY = ClampAngle(rotationY, minimumY, maximumY);
+ Quaternion quaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
+ Quaternion quaternion2 = Quaternion.AngleAxis(rotationY, Vector3.left);
+ base.transform.localRotation = originalRotation * quaternion * quaternion2;
+ }
+ else if (axes == RotationAxes.MouseX)
+ {
+ rotationX += Input.GetAxis("Mouse X") * sensitivityX;
+ rotationX = ClampAngle(rotationX, minimumX, maximumX);
+ Quaternion quaternion3 = Quaternion.AngleAxis(rotationX, Vector3.up);
+ base.transform.localRotation = originalRotation * quaternion3;
+ }
+ else
+ {
+ rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
+ rotationY = ClampAngle(rotationY, minimumY, maximumY);
+ Quaternion quaternion4 = Quaternion.AngleAxis(rotationY, Vector3.left);
+ base.transform.localRotation = originalRotation * quaternion4;
+ }
+ }
+ Vector3 direction = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
+ direction = base.transform.TransformDirection(direction);
+ direction *= 10f;
+ float num = ((!Input.GetKey(KeyCode.LeftShift)) ? 50f : 150f);
+ float num2 = Input.GetAxis("Vertical") * forwardSpeedScale * num;
+ float num3 = Input.GetAxis("Horizontal") * strafeSpeedScale * num;
+ if (num2 != 0f)
+ {
+ base.transform.position += base.transform.forward * num2;
+ }
+ if (num3 != 0f)
+ {
+ base.transform.position += base.transform.right * num3;
+ }
+ }
+
+ private void Start()
+ {
+ if ((bool)GetComponent())
+ {
+ GetComponent().freezeRotation = true;
+ }
+ originalRotation = base.transform.localRotation;
+ look = false;
+ }
+
+ public static float ClampAngle(float angle, float min, float max)
+ {
+ if (angle < -360f)
+ {
+ angle += 360f;
+ }
+ if (angle > 360f)
+ {
+ angle -= 360f;
+ }
+ return Mathf.Clamp(angle, min, max);
+ }
+}
diff --git a/MouseOrbitCS.cs b/MouseOrbitCS.cs
new file mode 100644
index 0000000..40c2fb2
--- /dev/null
+++ b/MouseOrbitCS.cs
@@ -0,0 +1,64 @@
+using UnityEngine;
+
+public class MouseOrbitCS : MonoBehaviour
+{
+ public Transform target;
+
+ public float distance = 10f;
+
+ public float xSpeed = 250f;
+
+ public float ySpeed = 120f;
+
+ public float yMinLimit = -20f;
+
+ public float yMaxLimit = 80f;
+
+ private float x;
+
+ private float y;
+
+ private float normal_angle;
+
+ private void Start()
+ {
+ Vector3 eulerAngles = base.transform.eulerAngles;
+ x = eulerAngles.y;
+ y = eulerAngles.x;
+ }
+
+ private void LateUpdate()
+ {
+ if ((bool)target && !Input.GetKey(KeyCode.F))
+ {
+ if (!Input.GetMouseButton(0))
+ {
+ x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
+ y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
+ }
+ y = ClampAngle(y, yMinLimit + normal_angle, yMaxLimit + normal_angle);
+ Quaternion quaternion = Quaternion.Euler(y, x, 0f);
+ Vector3 position = quaternion * new Vector3(0f, 0f, 0f - distance) + target.position;
+ base.transform.rotation = quaternion;
+ base.transform.position = position;
+ }
+ }
+
+ private static float ClampAngle(float angle, float min, float max)
+ {
+ if (angle < -360f)
+ {
+ angle += 360f;
+ }
+ if (angle > 360f)
+ {
+ angle -= 360f;
+ }
+ return Mathf.Clamp(angle, min, max);
+ }
+
+ public void set_normal_angle(float a)
+ {
+ normal_angle = a;
+ }
+}
diff --git a/MoveRig.cs b/MoveRig.cs
new file mode 100644
index 0000000..e4843f0
--- /dev/null
+++ b/MoveRig.cs
@@ -0,0 +1,20 @@
+using UnityEngine;
+
+public class MoveRig : MonoBehaviour
+{
+ private Rigidbody rig;
+
+ public float force;
+
+ public Transform target;
+
+ private void Start()
+ {
+ rig = GetComponentInParent();
+ }
+
+ private void FixedUpdate()
+ {
+ rig.AddForceAtPosition(force * (target.position - base.transform.position), base.transform.position, ForceMode.Acceleration);
+ }
+}
diff --git a/MoveTransform.cs b/MoveTransform.cs
new file mode 100644
index 0000000..1b135c3
--- /dev/null
+++ b/MoveTransform.cs
@@ -0,0 +1,21 @@
+using UnityEngine;
+
+public class MoveTransform : MonoBehaviour
+{
+ public Vector3 startForce;
+
+ private Vector3 velocity = Vector3.zero;
+
+ public float gravity;
+
+ private void Start()
+ {
+ velocity = base.transform.TransformDirection(startForce);
+ }
+
+ private void Update()
+ {
+ velocity += Time.deltaTime * Vector3.down * gravity;
+ base.transform.position += velocity * Time.deltaTime;
+ }
+}
diff --git a/MovementDataHandler.cs b/MovementDataHandler.cs
new file mode 100644
index 0000000..18d43f5
--- /dev/null
+++ b/MovementDataHandler.cs
@@ -0,0 +1,92 @@
+using UnityEngine;
+
+public class MovementDataHandler : MonoBehaviour
+{
+ [HideInInspector]
+ public Vector3 groundedForward;
+
+ [HideInInspector]
+ public Vector3 right;
+
+ [HideInInspector]
+ public Vector3 left;
+
+ [HideInInspector]
+ public Vector3 groundedBack;
+
+ private Transform hip;
+
+ private Transform torso;
+
+ public Transform rotationTarget;
+
+ [HideInInspector]
+ public float slopeStrenght;
+
+ public float slopeVelocityStrenght;
+
+ [HideInInspector]
+ public float sinceJump = 1f;
+
+ [HideInInspector]
+ public Vector3 groundNormal;
+
+ private InputHandler inputHandler;
+
+ private Transform leftKnee;
+
+ private Transform rightKnee;
+
+ private void Start()
+ {
+ inputHandler = GetComponent();
+ hip = GetComponentInChildren().transform;
+ torso = GetComponentInChildren().transform;
+ if (!rotationTarget)
+ {
+ rotationTarget = GetComponentInChildren().transform;
+ }
+ KneeLeft componentInChildren = GetComponentInChildren();
+ if ((bool)componentInChildren)
+ {
+ leftKnee = componentInChildren.transform;
+ }
+ KneeRight componentInChildren2 = GetComponentInChildren();
+ if ((bool)componentInChildren2)
+ {
+ rightKnee = componentInChildren2.transform;
+ }
+ }
+
+ private void Update()
+ {
+ sinceJump += Time.deltaTime;
+ groundedForward = rotationTarget.forward;
+ groundedForward.y = slopeStrenght * 1f;
+ groundedForward = groundedForward.normalized;
+ groundedBack = -groundedForward;
+ right = rotationTarget.right;
+ left = -rotationTarget.right;
+ slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f);
+ Debug.DrawLine(hip.position, hip.position + groundedForward * 10f);
+ }
+
+ public void SetSlope(Vector3 normal)
+ {
+ groundNormal = normal;
+ slopeStrenght = Vector3.Cross(rotationTarget.right, normal).y;
+ Vector3 lhs = Vector3.Cross(Vector3.up, inputHandler.inputMovementDirection);
+ slopeVelocityStrenght = Vector3.Cross(lhs, normal).y;
+ }
+
+ public float GetSmallestLegAngle()
+ {
+ float num = Vector3.Angle(leftKnee.forward, Vector3.down);
+ float num2 = Vector3.Angle(rightKnee.forward, Vector3.down);
+ if (num < num2)
+ {
+ return num;
+ }
+ return num2;
+ }
+}
diff --git a/MovementHandler.cs b/MovementHandler.cs
new file mode 100644
index 0000000..22795f7
--- /dev/null
+++ b/MovementHandler.cs
@@ -0,0 +1,85 @@
+using System.Collections;
+using UnityEngine;
+
+public class MovementHandler : MonoBehaviour
+{
+ private InputHandler inputHandler;
+
+ public float friction = 0.9f;
+
+ public Vector3 movementVector;
+
+ public float[] animationForceAmounts;
+
+ private AnimationHandler animationHandler;
+
+ private RigidbodyHolder allRigs;
+
+ public AnimationCurve jumpCurve;
+
+ public float jumpForce;
+
+ private StandingDataHandler standingData;
+
+ private MovementDataHandler data;
+
+ private PlayerDeath death;
+
+ [HideInInspector]
+ public float multiplier = 1f;
+
+ private WobbleShake wobbleShake;
+
+ private void Start()
+ {
+ wobbleShake = GetComponentInChildren();
+ death = GetComponent();
+ standingData = GetComponent();
+ inputHandler = GetComponent();
+ animationHandler = GetComponent();
+ allRigs = GetComponent();
+ data = GetComponent();
+ }
+
+ private void FixedUpdate()
+ {
+ if (!death.dead)
+ {
+ data.sinceJump += Time.fixedDeltaTime;
+ movementVector += inputHandler.inputMovementDirection * animationForceAmounts[animationHandler.animationState];
+ movementVector *= friction;
+ for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ {
+ allRigs.GetAllRigs()[i].AddForce(movementVector * multiplier, ForceMode.Acceleration);
+ }
+ }
+ }
+
+ public void Jump()
+ {
+ if (!(data.sinceJump < 0.5f) && !(standingData.sinceGrounded > 0.3f))
+ {
+ data.sinceJump = 0f;
+ StartCoroutine(AddJumpForce());
+ wobbleShake.AddShake(Vector3.up * 2f, 0.8f);
+ }
+ }
+
+ private IEnumerator AddJumpForce()
+ {
+ float counter = 0f;
+ for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ {
+ allRigs.GetAllRigs()[i].velocity = new Vector3(allRigs.GetAllRigs()[i].velocity.x, 0f, allRigs.GetAllRigs()[i].velocity.z);
+ }
+ while (counter < jumpCurve.keys[jumpCurve.length - 1].time && !death.dead)
+ {
+ counter += Time.deltaTime;
+ for (int j = 0; j < allRigs.GetAllRigs().Length; j++)
+ {
+ allRigs.GetAllRigs()[j].AddForce(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration);
+ }
+ yield return null;
+ }
+ }
+}
diff --git a/MovementRig.cs b/MovementRig.cs
new file mode 100644
index 0000000..e09ce49
--- /dev/null
+++ b/MovementRig.cs
@@ -0,0 +1,10 @@
+using System;
+using UnityEngine;
+
+[Serializable]
+public class MovementRig
+{
+ public Rigidbody rig;
+
+ public float multiplier = 1f;
+}
diff --git a/Neck.cs b/Neck.cs
new file mode 100644
index 0000000..31cd544
--- /dev/null
+++ b/Neck.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Neck : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/NetPlayer.cs b/NetPlayer.cs
new file mode 100644
index 0000000..213568d
--- /dev/null
+++ b/NetPlayer.cs
@@ -0,0 +1,8 @@
+using UnityEngine;
+
+public class NetPlayer
+{
+ public GameObject PlayerObject;
+
+ public string PlayerName;
+}
diff --git a/PID.cs b/PID.cs
new file mode 100644
index 0000000..9403232
--- /dev/null
+++ b/PID.cs
@@ -0,0 +1,104 @@
+using UnityEngine;
+
+public class PID : MonoBehaviour
+{
+ public float maxForce;
+
+ public float proportionalGain;
+
+ public float differentialGain;
+
+ private Vector3 lastError = Vector3.zero;
+
+ private Vector3 currentForce = Vector3.zero;
+
+ public float maxTorque;
+
+ public float proportionalGainTorque;
+
+ public float differentialGainTorque;
+
+ private Vector3 lastErrorTorque = Vector3.zero;
+
+ private Vector3 currentTorque = Vector3.zero;
+
+ private Vector3 lastErrorTorqueUp = Vector3.zero;
+
+ private Vector3 currentTorqueUp = Vector3.zero;
+
+ public float currentMultiplier = 1f;
+
+ private Rigidbody rig;
+
+ private SetInertiaTension inertia;
+
+ public Transform addForcePoint;
+
+ private Transform forcePoint;
+
+ private void Start()
+ {
+ rig = GetComponent();
+ inertia = GetComponent();
+ }
+
+ private void Update()
+ {
+ if ((bool)inertia)
+ {
+ currentMultiplier = 1f - Mathf.Clamp(inertia.collisionValue, 0f, 0.7f);
+ }
+ }
+
+ private void FixedUpdate()
+ {
+ }
+
+ public void DoPID(Vector3 targetPosition, Vector3 targetRotation, Vector3 targetRotationUp, float multiplier = 1f)
+ {
+ AddForce(targetPosition, currentMultiplier * multiplier);
+ if (proportionalGainTorque != 0f)
+ {
+ AddTorque(targetRotation, currentMultiplier * multiplier);
+ AddTorqueUp(targetRotationUp, currentMultiplier * multiplier);
+ }
+ }
+
+ public void AddForce(Vector3 targetPosition, float multiplier = 1f)
+ {
+ forcePoint = ((!(addForcePoint == null)) ? addForcePoint : base.transform);
+ Vector3 vector = targetPosition - forcePoint.position;
+ Vector3 vector2 = (vector - lastError) / Time.fixedDeltaTime;
+ lastError = vector;
+ currentForce = vector * proportionalGain + vector2 * differentialGain;
+ currentForce = Vector3.ClampMagnitude(currentForce, maxForce);
+ if ((bool)addForcePoint)
+ {
+ rig.AddForceAtPosition(currentForce * Time.fixedDeltaTime * 60f * multiplier, addForcePoint.position, ForceMode.Acceleration);
+ }
+ else
+ {
+ rig.AddForce(currentForce * Time.fixedDeltaTime * 60f * multiplier, ForceMode.Acceleration);
+ }
+ }
+
+ public void AddTorque(Vector3 targetRotation, float multiplier = 1f)
+ {
+ Vector3 vector = Mathf.Clamp(Vector3.Angle(targetRotation, base.transform.forward), 0f, 3f) * Vector3.Cross(targetRotation, base.transform.forward);
+ Vector3 vector2 = (vector - lastErrorTorque) / Time.fixedDeltaTime;
+ lastErrorTorque = vector;
+ currentTorque = vector * proportionalGainTorque + vector2 * differentialGainTorque;
+ currentTorque = Vector3.ClampMagnitude(currentTorque, maxTorque);
+ rig.AddTorque(-currentTorque * Time.fixedDeltaTime * 60f * multiplier, ForceMode.Acceleration);
+ }
+
+ public void AddTorqueUp(Vector3 targetRotation, float multiplier = 1f)
+ {
+ Vector3 vector = Mathf.Clamp(Vector3.Angle(targetRotation, base.transform.up), 0f, 3f) * Vector3.Cross(targetRotation, base.transform.up);
+ Vector3 vector2 = (vector - lastErrorTorqueUp) / Time.fixedDeltaTime;
+ lastErrorTorqueUp = vector;
+ currentTorqueUp = vector * proportionalGainTorque + vector2 * differentialGainTorque;
+ currentTorqueUp = Vector3.ClampMagnitude(currentTorqueUp, maxTorque);
+ rig.AddTorque(-currentTorqueUp * Time.fixedDeltaTime * 60f * multiplier, ForceMode.Acceleration);
+ }
+}
diff --git a/ParticleParent.cs b/ParticleParent.cs
new file mode 100644
index 0000000..dc8de91
--- /dev/null
+++ b/ParticleParent.cs
@@ -0,0 +1,39 @@
+using UnityEngine;
+
+public class ParticleParent : MonoBehaviour
+{
+ public GameObject particleObject;
+
+ private ParticleSystem[] parts;
+
+ private Vector2[] particleSizes;
+
+ private void Start()
+ {
+ particleObject = Object.Instantiate(particleObject, base.transform.position, base.transform.rotation);
+ particleObject.transform.parent = base.transform;
+ parts = particleObject.GetComponentsInChildren();
+ particleSizes = new Vector2[parts.Length];
+ for (int i = 0; i < parts.Length; i++)
+ {
+ particleSizes[i].x = parts[i].main.startSize.constantMin;
+ particleSizes[i].y = parts[i].main.startSize.constantMax;
+ }
+ }
+
+ private void Update()
+ {
+ }
+
+ public void Play(float damage, float multi)
+ {
+ for (int i = 0; i < parts.Length; i++)
+ {
+ ParticleSystem.MainModule mainModule = default(ParticleSystem.MainModule);
+ mainModule = parts[i].main;
+ float num = (1.5f + damage * 0.01f) * multi;
+ mainModule.startSize = new ParticleSystem.MinMaxCurve(particleSizes[i].x * num, particleSizes[i].y * num);
+ parts[i].Play();
+ }
+ }
+}
diff --git a/PhysicsAnimation.cs b/PhysicsAnimation.cs
new file mode 100644
index 0000000..120a343
--- /dev/null
+++ b/PhysicsAnimation.cs
@@ -0,0 +1,36 @@
+using System;
+using UnityEngine;
+
+[Serializable]
+public class PhysicsAnimation
+{
+ public enum TorqueSpace
+ {
+ World,
+ Local,
+ Parent,
+ Hip
+ }
+
+ public enum ForceSpace
+ {
+ World,
+ Local,
+ Parent,
+ Hip
+ }
+
+ [Header("TORQUES")]
+ public Vector3 forwardTorque;
+
+ public Vector3 backwardsTorque;
+
+ public TorqueSpace torqueSpace;
+
+ [Header("FORCES")]
+ public Vector3 forwardForce;
+
+ public Vector3 backwardsForce;
+
+ public ForceSpace forceSpace;
+}
diff --git a/PhysicsLerpBackToStart.cs b/PhysicsLerpBackToStart.cs
new file mode 100644
index 0000000..5139a00
--- /dev/null
+++ b/PhysicsLerpBackToStart.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class PhysicsLerpBackToStart : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/Pickup.cs b/Pickup.cs
new file mode 100644
index 0000000..1c44994
--- /dev/null
+++ b/Pickup.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class Pickup : MonoBehaviour
+{
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+}
diff --git a/PickupHandler.cs b/PickupHandler.cs
new file mode 100644
index 0000000..8bf1615
--- /dev/null
+++ b/PickupHandler.cs
@@ -0,0 +1,63 @@
+using UnityEngine;
+
+public class PickupHandler : MonoBehaviour
+{
+ public Pickup setWeapon;
+
+ public Pickup setWeapon2;
+
+ private WeaponHandler weaponHandler;
+
+ private Holding holding;
+
+ private float counter;
+
+ private void Start()
+ {
+ weaponHandler = GetComponent();
+ holding = GetComponent();
+ if ((bool)setWeapon)
+ {
+ PickUp(setWeapon);
+ }
+ if ((bool)setWeapon2)
+ {
+ PickUp2(setWeapon2);
+ }
+ }
+
+ private void Update()
+ {
+ counter += Time.deltaTime;
+ }
+
+ public void PickUp(Pickup objectToPickUp)
+ {
+ if (!(counter < 1f))
+ {
+ counter = 0f;
+ holding.Drop();
+ Weapon component = objectToPickUp.GetComponent();
+ Gun component2 = component.GetComponent();
+ weaponHandler.SetGun(component2, mainHand: true);
+ bool hasOffHand = false;
+ if ((bool)setWeapon2)
+ {
+ hasOffHand = true;
+ }
+ HoldableObject component3 = component.GetComponent();
+ component3.holder = base.transform;
+ holding.StartHolding(component3, hasOffHand);
+ }
+ }
+
+ public void PickUp2(Pickup objectToPickUp)
+ {
+ Weapon component = objectToPickUp.GetComponent();
+ Gun component2 = component.GetComponent();
+ weaponHandler.SetGun(component2, mainHand: false);
+ HoldableObject component3 = component.GetComponent();
+ component3.holder = base.transform;
+ holding.StartHolding(component3, hasOffHand: true);
+ }
+}
diff --git a/Player.cs b/Player.cs
new file mode 100644
index 0000000..55ff387
--- /dev/null
+++ b/Player.cs
@@ -0,0 +1,18 @@
+using UnityEngine;
+
+public class Player : MonoBehaviour
+{
+ public static Player localPlayer;
+
+ public bool isLocalPlayer;
+
+ public Transform torso;
+
+ private void Start()
+ {
+ if (isLocalPlayer)
+ {
+ localPlayer = this;
+ }
+ }
+}
diff --git a/PlayerDeath.cs b/PlayerDeath.cs
new file mode 100644
index 0000000..ec0813a
--- /dev/null
+++ b/PlayerDeath.cs
@@ -0,0 +1,125 @@
+using UnityEngine;
+
+public class PlayerDeath : MonoBehaviour
+{
+ public bool dead;
+
+ private bool isFrozen;
+
+ public float muscleFunction = 1f;
+
+ public bool terminalState;
+
+ private DamageEffects damageEffects;
+
+ private RagdollHandler ragdoll;
+
+ private Transform hip;
+
+ public float health = 100f;
+
+ public ParticleSystem[] damageParticles;
+
+ private HasControl hasControll;
+
+ private Holding holding;
+
+ private void Start()
+ {
+ damageEffects = GetComponent();
+ ragdoll = GetComponent();
+ hip = GetComponentInChildren().transform;
+ hasControll = GetComponent();
+ holding = GetComponent();
+ }
+
+ private void Update()
+ {
+ if (health < 100f)
+ {
+ health += Time.deltaTime * 10f;
+ health = Mathf.Clamp(health, -10f, 100f);
+ }
+ if (hip.transform.position.y < -10f)
+ {
+ Die();
+ }
+ if (terminalState && muscleFunction > 0f)
+ {
+ muscleFunction -= Time.deltaTime * 1f;
+ }
+ if (muscleFunction < 0f && !isFrozen)
+ {
+ FreezeBody();
+ }
+ }
+
+ public void TakeDamage(Vector3 damage, Vector3 hitPoint, Rigidbody hitRig = null)
+ {
+ if (hasControll.hasControl)
+ {
+ damageEffects.TakeDamage(damage, hitPoint);
+ }
+ if (hitPoint != Vector3.zero)
+ {
+ for (int i = 0; i < damageParticles.Length; i++)
+ {
+ damageParticles[i].transform.rotation = Quaternion.LookRotation(damage);
+ damageParticles[i].transform.position = hitPoint;
+ damageParticles[i].Play();
+ }
+ }
+ health -= damage.magnitude;
+ if (!(health <= 0f))
+ {
+ return;
+ }
+ if ((bool)hitRig)
+ {
+ ConfigurableJoint component = hitRig.GetComponent();
+ if ((bool)component)
+ {
+ Object.Destroy(component);
+ }
+ }
+ Kill();
+ }
+
+ public void FreezeBody()
+ {
+ isFrozen = true;
+ Joint[] componentsInChildren = GetComponentsInChildren();
+ for (int i = 0; i < componentsInChildren.Length; i++)
+ {
+ ConfigurableJoint configurableJoint = (ConfigurableJoint)componentsInChildren[i];
+ Rigidbody component = configurableJoint.GetComponent();
+ JointDrive angularXDrive = configurableJoint.angularXDrive;
+ angularXDrive.positionSpring = 5f * component.mass;
+ angularXDrive.positionDamper = 1f * component.mass;
+ configurableJoint.angularXDrive = angularXDrive;
+ configurableJoint.angularYZDrive = angularXDrive;
+ configurableJoint.SetTargetRotationLocal(configurableJoint.transform.localRotation, configurableJoint.gameObject.GetComponent().startRotationLocal);
+ }
+ }
+
+ public void Die()
+ {
+ if (!dead)
+ {
+ holding.Drop();
+ dead = true;
+ ragdoll.ragdollValue = 0f;
+ Collider[] componentsInChildren = GetComponentsInChildren();
+ foreach (Collider collider in componentsInChildren)
+ {
+ collider.material = null;
+ }
+ }
+ }
+
+ public void Kill()
+ {
+ terminalState = true;
+ Die();
+ }
+}
diff --git a/PlayerKnockback.cs b/PlayerKnockback.cs
new file mode 100644
index 0000000..89fffb8
--- /dev/null
+++ b/PlayerKnockback.cs
@@ -0,0 +1,52 @@
+using UnityEngine;
+
+public class PlayerKnockback : MonoBehaviour
+{
+ private RigidbodyHolder allRigs;
+
+ private StandingDataHandler standing;
+
+ private WeaponHandler weapons;
+
+ private void Start()
+ {
+ allRigs = GetComponent();
+ standing = GetComponent();
+ weapons = GetComponent();
+ }
+
+ private void Update()
+ {
+ if (Input.GetKeyDown(KeyCode.K))
+ {
+ AddSeriousKnockback();
+ }
+ }
+
+ public void AddForce(Vector3 force, Rigidbody rig)
+ {
+ if (force.magnitude > 200f)
+ {
+ AddSeriousKnockback();
+ force *= 0.1f;
+ }
+ for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ {
+ float num = 1f;
+ if (rig == allRigs.GetAllRigs()[i])
+ {
+ num *= 1f;
+ }
+ allRigs.GetAllRigs()[i].AddForce(force * num * 20f, ForceMode.Acceleration);
+ }
+ }
+
+ private void AddSeriousKnockback()
+ {
+ GetComponent().Kill();
+ }
+
+ private void AddNormalKnockback()
+ {
+ }
+}
diff --git a/ProjectileHit.cs b/ProjectileHit.cs
new file mode 100644
index 0000000..305f9fc
--- /dev/null
+++ b/ProjectileHit.cs
@@ -0,0 +1,75 @@
+using UnityEngine;
+
+public class ProjectileHit : MonoBehaviour
+{
+ public GameObject soundPlayer;
+
+ public ProjectileHitSpawn[] objectsToSpawnOnHit;
+
+ private bool done;
+
+ public float damage = 25f;
+
+ public float force;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ }
+
+ public void Hit(RaycastHit hit)
+ {
+ if (done)
+ {
+ return;
+ }
+ done = true;
+ Player component = hit.transform.root.GetComponent();
+ ProjectileHitSpawn[] array = objectsToSpawnOnHit;
+ foreach (ProjectileHitSpawn projectileHitSpawn in array)
+ {
+ Vector3 point = hit.point;
+ Quaternion rotation = Quaternion.identity;
+ if ((bool)component)
+ {
+ if (projectileHitSpawn.playerSpawnRotation == ProjectileHitSpawn.SpawnRotation.forward)
+ {
+ rotation = Quaternion.LookRotation(base.transform.forward);
+ }
+ if (projectileHitSpawn.playerSpawnRotation == ProjectileHitSpawn.SpawnRotation.normal)
+ {
+ rotation = Quaternion.LookRotation(hit.normal);
+ }
+ }
+ else
+ {
+ if (projectileHitSpawn.groundSpawnRotation == ProjectileHitSpawn.SpawnRotation.forward)
+ {
+ rotation = Quaternion.LookRotation(base.transform.forward);
+ }
+ if (projectileHitSpawn.groundSpawnRotation == ProjectileHitSpawn.SpawnRotation.normal)
+ {
+ rotation = Quaternion.LookRotation(hit.normal);
+ }
+ }
+ GameObject gameObject = Object.Instantiate(projectileHitSpawn.spawnedObject, point, rotation);
+ }
+ Damagable component2 = hit.transform.GetComponent();
+ if ((bool)component2)
+ {
+ component2.TakeDamage(damage * base.transform.forward, hit.point);
+ }
+ Rigidbody rigidbody = hit.rigidbody;
+ if ((bool)rigidbody && force != 0f)
+ {
+ float num = 1f;
+ num = Mathf.Clamp(rigidbody.mass / 10f, 0f, 1f);
+ rigidbody.AddForceAtPosition(base.transform.forward * force * num, hit.point, ForceMode.Impulse);
+ }
+ Object.Instantiate(soundPlayer, hit.point, Quaternion.identity).GetComponent().Play(hit);
+ Object.Destroy(base.gameObject);
+ }
+}
diff --git a/ProjectileHitSpawn.cs b/ProjectileHitSpawn.cs
new file mode 100644
index 0000000..8a1df24
--- /dev/null
+++ b/ProjectileHitSpawn.cs
@@ -0,0 +1,18 @@
+using System;
+using UnityEngine;
+
+[Serializable]
+public class ProjectileHitSpawn
+{
+ public enum SpawnRotation
+ {
+ normal,
+ forward
+ }
+
+ public GameObject spawnedObject;
+
+ public SpawnRotation groundSpawnRotation;
+
+ public SpawnRotation playerSpawnRotation;
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..80d7579
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,7 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Security;
+using System.Security.Permissions;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/RTPColorChannels.cs b/RTPColorChannels.cs
new file mode 100644
index 0000000..e60fb18
--- /dev/null
+++ b/RTPColorChannels.cs
@@ -0,0 +1,7 @@
+public enum RTPColorChannels
+{
+ R,
+ G,
+ B,
+ A
+}
diff --git a/RTPFogType.cs b/RTPFogType.cs
new file mode 100644
index 0000000..e6381d0
--- /dev/null
+++ b/RTPFogType.cs
@@ -0,0 +1,7 @@
+public enum RTPFogType
+{
+ Exponential,
+ Exp2,
+ Linear,
+ None
+}
diff --git a/RTPLodLevel.cs b/RTPLodLevel.cs
new file mode 100644
index 0000000..712f97b
--- /dev/null
+++ b/RTPLodLevel.cs
@@ -0,0 +1,8 @@
+public enum RTPLodLevel
+{
+ POM_SoftShadows,
+ POM_HardShadows,
+ POM_NoShadows,
+ PM,
+ SIMPLE
+}
diff --git a/RTPObjExporter.cs b/RTPObjExporter.cs
new file mode 100644
index 0000000..791de73
--- /dev/null
+++ b/RTPObjExporter.cs
@@ -0,0 +1,52 @@
+using System.IO;
+using System.Text;
+using UnityEngine;
+
+public class RTPObjExporter
+{
+ public static string MeshToString(MeshFilter mf)
+ {
+ Mesh sharedMesh = mf.sharedMesh;
+ Material[] sharedMaterials = mf.GetComponent().sharedMaterials;
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.Append("g ").Append(mf.name).Append("\n");
+ Vector3[] vertices = sharedMesh.vertices;
+ for (int i = 0; i < vertices.Length; i++)
+ {
+ Vector3 vector = vertices[i];
+ stringBuilder.Append($"v {0f - vector.x} {vector.y} {vector.z}\n");
+ }
+ stringBuilder.Append("\n");
+ Vector3[] normals = sharedMesh.normals;
+ for (int j = 0; j < normals.Length; j++)
+ {
+ Vector3 vector2 = normals[j];
+ stringBuilder.Append($"vn {0f - vector2.x} {vector2.y} {vector2.z}\n");
+ }
+ stringBuilder.Append("\n");
+ Vector2[] uv = sharedMesh.uv;
+ for (int k = 0; k < uv.Length; k++)
+ {
+ Vector3 vector3 = uv[k];
+ stringBuilder.Append($"vt {vector3.x} {vector3.y}\n");
+ }
+ for (int l = 0; l < sharedMesh.subMeshCount; l++)
+ {
+ stringBuilder.Append("\n");
+ stringBuilder.Append("usemtl ").Append(sharedMaterials[l].name).Append("\n");
+ stringBuilder.Append("usemap ").Append(sharedMaterials[l].name).Append("\n");
+ int[] triangles = sharedMesh.GetTriangles(l);
+ for (int m = 0; m < triangles.Length; m += 3)
+ {
+ stringBuilder.Append(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", triangles[m + 2] + 1, triangles[m + 1] + 1, triangles[m] + 1));
+ }
+ }
+ return stringBuilder.ToString();
+ }
+
+ public static void MeshToFile(MeshFilter mf, string filename)
+ {
+ using StreamWriter streamWriter = new StreamWriter(filename);
+ streamWriter.Write(MeshToString(mf));
+ }
+}
diff --git a/RTPTangentSolver.cs b/RTPTangentSolver.cs
new file mode 100644
index 0000000..d06b9d2
--- /dev/null
+++ b/RTPTangentSolver.cs
@@ -0,0 +1,59 @@
+using UnityEngine;
+
+public class RTPTangentSolver
+{
+ public static void Solve(Mesh theMesh, bool planetFlag = false)
+ {
+ int vertexCount = theMesh.vertexCount;
+ Vector3[] vertices = theMesh.vertices;
+ Vector3[] normals = theMesh.normals;
+ Vector2[] uv = theMesh.uv;
+ int[] triangles = theMesh.triangles;
+ Vector4[] array = new Vector4[vertexCount];
+ Vector3[] array2 = new Vector3[vertexCount];
+ Vector3[] array3 = new Vector3[vertexCount];
+ for (int i = 0; i < triangles.Length; i += 3)
+ {
+ int num = triangles[i];
+ int num2 = triangles[i + 1];
+ int num3 = triangles[i + 2];
+ Vector3 vector = vertices[num];
+ Vector3 vector2 = vertices[num2];
+ Vector3 vector3 = vertices[num3];
+ Vector2 vector4 = uv[num];
+ Vector2 vector5 = uv[num2];
+ Vector2 vector6 = uv[num3];
+ float num4 = vector2.x - vector.x;
+ float num5 = vector3.x - vector.x;
+ float num6 = vector2.y - vector.y;
+ float num7 = vector3.y - vector.y;
+ float num8 = vector2.z - vector.z;
+ float num9 = vector3.z - vector.z;
+ float num10 = vector5.x - vector4.x;
+ float num11 = vector6.x - vector4.x;
+ float num12 = vector5.y - vector4.y;
+ float num13 = vector6.y - vector4.y;
+ float num14 = num10 * num13 - num11 * num12;
+ float num15 = ((num14 != 0f) ? (1f / num14) : 0f);
+ Vector3 vector7 = new Vector3((num13 * num4 - num12 * num5) * num15, (num13 * num6 - num12 * num7) * num15, (num13 * num8 - num12 * num9) * num15);
+ Vector3 vector8 = new Vector3((num10 * num5 - num11 * num4) * num15, (num10 * num7 - num11 * num6) * num15, (num10 * num9 - num11 * num8) * num15);
+ array2[num] += vector7;
+ array2[num2] += vector7;
+ array2[num3] += vector7;
+ array3[num] += vector8;
+ array3[num2] += vector8;
+ array3[num3] += vector8;
+ }
+ for (int j = 0; j < vertexCount; j++)
+ {
+ Vector3 normal = ((!planetFlag) ? normals[j] : Vector3.Normalize(vertices[j]));
+ Vector3 tangent = array2[j];
+ Vector3.OrthoNormalize(ref normal, ref tangent);
+ array[j].x = tangent.x;
+ array[j].y = tangent.y;
+ array[j].z = tangent.z;
+ array[j].w = ((!(Vector3.Dot(Vector3.Cross(normal, tangent), array3[j]) < 0f)) ? 1f : (-1f));
+ }
+ theMesh.tangents = array;
+ }
+}
diff --git a/RTP_DeferredParams.cs b/RTP_DeferredParams.cs
new file mode 100644
index 0000000..2730d4a
--- /dev/null
+++ b/RTP_DeferredParams.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+[AddComponentMenu("Relief Terrain/Helpers/Deferred Params")]
+[RequireComponent(typeof(Camera))]
+[DisallowMultipleComponent]
+[ExecuteInEditMode]
+public class RTP_DeferredParams : MonoBehaviour
+{
+ private Camera mycam;
+
+ private CommandBuffer combufPreLight;
+
+ private CommandBuffer combufPostLight;
+
+ public Material CopyPropsMat;
+
+ private HashSet sceneCamsWithBuffer = new HashSet();
+
+ public void OnEnable()
+ {
+ if (NotifyDecals())
+ {
+ return;
+ }
+ if (mycam == null)
+ {
+ mycam = GetComponent();
+ if (mycam == null)
+ {
+ return;
+ }
+ }
+ Initialize();
+ Camera.onPreRender = (Camera.CameraCallback)Delegate.Combine(Camera.onPreRender, new Camera.CameraCallback(SetupCam));
+ }
+
+ public void OnDisable()
+ {
+ NotifyDecals();
+ Cleanup();
+ }
+
+ public void OnDestroy()
+ {
+ NotifyDecals();
+ Cleanup();
+ }
+
+ private bool NotifyDecals()
+ {
+ Type type = Type.GetType("UBERDecalSystem.DecalManager");
+ if (type != null)
+ {
+ bool flag = false;
+ if (UnityEngine.Object.FindObjectOfType(type) != null && UnityEngine.Object.FindObjectOfType(type) is MonoBehaviour && (UnityEngine.Object.FindObjectOfType(type) as MonoBehaviour).enabled)
+ {
+ (UnityEngine.Object.FindObjectOfType(type) as MonoBehaviour).Invoke("OnDisable", 0f);
+ (UnityEngine.Object.FindObjectOfType(type) as MonoBehaviour).Invoke("OnEnable", 0f);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void Cleanup()
+ {
+ if (combufPreLight != null)
+ {
+ if ((bool)mycam)
+ {
+ mycam.RemoveCommandBuffer(CameraEvent.BeforeReflections, combufPreLight);
+ mycam.RemoveCommandBuffer(CameraEvent.AfterLighting, combufPostLight);
+ }
+ foreach (Camera item in sceneCamsWithBuffer)
+ {
+ if ((bool)item)
+ {
+ item.RemoveCommandBuffer(CameraEvent.BeforeReflections, combufPreLight);
+ item.RemoveCommandBuffer(CameraEvent.AfterLighting, combufPostLight);
+ }
+ }
+ }
+ sceneCamsWithBuffer.Clear();
+ Camera.onPreRender = (Camera.CameraCallback)Delegate.Remove(Camera.onPreRender, new Camera.CameraCallback(SetupCam));
+ }
+
+ private void SetupCam(Camera cam)
+ {
+ bool flag = false;
+ if (cam == mycam || flag)
+ {
+ RefreshComBufs(cam, flag);
+ }
+ }
+
+ public void RefreshComBufs(Camera cam, bool isSceneCam)
+ {
+ if (!cam || combufPreLight == null || combufPostLight == null)
+ {
+ return;
+ }
+ CommandBuffer[] commandBuffers = cam.GetCommandBuffers(CameraEvent.BeforeReflections);
+ bool flag = false;
+ CommandBuffer[] array = commandBuffers;
+ foreach (CommandBuffer commandBuffer in array)
+ {
+ if (commandBuffer.name == combufPreLight.name)
+ {
+ flag = true;
+ break;
+ }
+ }
+ if (!flag)
+ {
+ cam.AddCommandBuffer(CameraEvent.BeforeReflections, combufPreLight);
+ cam.AddCommandBuffer(CameraEvent.AfterLighting, combufPostLight);
+ if (isSceneCam)
+ {
+ sceneCamsWithBuffer.Add(cam);
+ }
+ }
+ }
+
+ public void Initialize()
+ {
+ if (combufPreLight != null)
+ {
+ return;
+ }
+ int num = Shader.PropertyToID("_UBERPropsBuffer");
+ if (CopyPropsMat == null)
+ {
+ if (CopyPropsMat != null)
+ {
+ UnityEngine.Object.DestroyImmediate(CopyPropsMat);
+ }
+ CopyPropsMat = new Material(Shader.Find("Hidden/UBER_CopyPropsTexture"));
+ CopyPropsMat.hideFlags = HideFlags.DontSave;
+ }
+ combufPreLight = new CommandBuffer();
+ combufPreLight.name = "UBERPropsPrelight";
+ combufPreLight.GetTemporaryRT(num, -1, -1, 0, FilterMode.Point, RenderTextureFormat.RHalf);
+ combufPreLight.Blit(BuiltinRenderTextureType.CameraTarget, num, CopyPropsMat);
+ combufPostLight = new CommandBuffer();
+ combufPostLight.name = "UBERPropsPostlight";
+ combufPostLight.ReleaseTemporaryRT(num);
+ }
+}
diff --git a/RTP_LODmanager.cs b/RTP_LODmanager.cs
new file mode 100644
index 0000000..e14bd77
--- /dev/null
+++ b/RTP_LODmanager.cs
@@ -0,0 +1,378 @@
+using UnityEngine;
+
+public class RTP_LODmanager : MonoBehaviour
+{
+ public TerrainShaderLod RTP_LODlevel;
+
+ public bool RTP_SHADOWS = true;
+
+ public bool RTP_SOFT_SHADOWS = true;
+
+ public bool show_first_features;
+
+ public bool show_add_features;
+
+ public bool RTP_NOFORWARDADD;
+
+ public bool RTP_NO_DEFERRED;
+
+ public bool RTP_FULLFORWARDSHADOWS;
+
+ public bool RTP_NOLIGHTMAP;
+
+ public bool RTP_NODIRLIGHTMAP;
+
+ public bool RTP_NODYNLIGHTMAP;
+
+ public bool NO_SPECULARITY;
+
+ public bool RTP_ADDSHADOW;
+
+ public bool RTP_CUT_HOLES;
+
+ public bool FIX_REFRESHING_ISSUE = true;
+
+ public bool RTP_USE_COLOR_ATLAS_FIRST;
+
+ public bool RTP_USE_COLOR_ATLAS_ADD;
+
+ public RTPFogType RTP_FOGTYPE;
+
+ public bool ADV_COLOR_MAP_BLENDING_FIRST;
+
+ public bool ADV_COLOR_MAP_BLENDING_ADD;
+
+ public bool RTP_UV_BLEND_FIRST = true;
+
+ public bool RTP_UV_BLEND_ADD = true;
+
+ public bool RTP_DISTANCE_ONLY_UV_BLEND_FIRST = true;
+
+ public bool RTP_DISTANCE_ONLY_UV_BLEND_ADD = true;
+
+ public bool RTP_NORMALS_FOR_REPLACE_UV_BLEND_FIRST = true;
+
+ public bool RTP_NORMALS_FOR_REPLACE_UV_BLEND_ADD = true;
+
+ public bool RTP_SUPER_DETAIL_FIRST = true;
+
+ public bool RTP_SUPER_DETAIL_ADD = true;
+
+ public bool RTP_SUPER_DETAIL_MULTS_FIRST;
+
+ public bool RTP_SUPER_DETAIL_MULTS_ADD;
+
+ public bool RTP_SNOW_FIRST;
+
+ public bool RTP_SNOW_ADD;
+
+ public bool RTP_SNW_CHOOSEN_LAYER_COLOR_FIRST;
+
+ public bool RTP_SNW_CHOOSEN_LAYER_COLOR_ADD;
+
+ public int RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_FIRST = 7;
+
+ public int RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_ADD = 7;
+
+ public bool RTP_SNW_CHOOSEN_LAYER_NORMAL_FIRST;
+
+ public bool RTP_SNW_CHOOSEN_LAYER_NORMAL_ADD;
+
+ public int RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_FIRST = 7;
+
+ public int RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_ADD = 7;
+
+ public RTPLodLevel MAX_LOD_FIRST = RTPLodLevel.PM;
+
+ public RTPLodLevel MAX_LOD_FIRST_PLUS4 = RTPLodLevel.SIMPLE;
+
+ public RTPLodLevel MAX_LOD_ADD = RTPLodLevel.PM;
+
+ public bool RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_FIRST = true;
+
+ public bool RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_FIRST;
+
+ public bool RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_ADD = true;
+
+ public bool RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_ADD;
+
+ public bool RTP_HEIGHTBLEND_AO_FIRST;
+
+ public bool RTP_HEIGHTBLEND_AO_ADD;
+
+ public bool RTP_EMISSION_FIRST;
+
+ public bool RTP_EMISSION_ADD;
+
+ public bool RTP_FUILD_EMISSION_WRAP_FIRST;
+
+ public bool RTP_FUILD_EMISSION_WRAP_ADD;
+
+ public bool RTP_HOTAIR_EMISSION_FIRST;
+
+ public bool RTP_HOTAIR_EMISSION_ADD;
+
+ public bool RTP_SHOW_OVERLAPPED;
+
+ public bool RTP_TRIPLANAR_FIRST;
+
+ public bool RTP_TRIPLANAR_ADD;
+
+ public bool RTP_NORMALGLOBAL;
+
+ public bool RTP_TESSELLATION;
+
+ public bool RTP_TESSELLATION_SAMPLE_TEXTURE;
+
+ public bool RTP_HEIGHTMAP_SAMPLE_BICUBIC = true;
+
+ public bool RTP_DETAIL_HEIGHTMAP_SAMPLE;
+
+ public bool RTP_TREESGLOBAL;
+
+ public bool RTP_USE_BUMPMAPS_FIRST = true;
+
+ public bool RTP_USE_BUMPMAPS_ADD = true;
+
+ public bool RTP_USE_PERLIN_FIRST;
+
+ public bool RTP_USE_PERLIN_ADD;
+
+ public bool RTP_COLOR_MAP_BLEND_MULTIPLY_FIRST = true;
+
+ public bool RTP_COLOR_MAP_BLEND_MULTIPLY_ADD = true;
+
+ public bool RTP_SIMPLE_FAR_FIRST = true;
+
+ public bool RTP_SIMPLE_FAR_ADD = true;
+
+ public bool RTP_CROSSPASS_HEIGHTBLEND;
+
+ public int[] UV_BLEND_ROUTE_NUM_FIRST = new int[8] { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+ public int[] UV_BLEND_ROUTE_NUM_ADD = new int[8] { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+ public bool RTP_HARD_CROSSPASS = true;
+
+ public bool RTP_MAPPED_SHADOWS_FIRST;
+
+ public bool RTP_MAPPED_SHADOWS_ADD;
+
+ public bool RTP_VERTICAL_TEXTURE_FIRST;
+
+ public bool RTP_VERTICAL_TEXTURE_ADD;
+
+ public bool RTP_ADDITIONAL_FEATURES_IN_FALLBACKS = true;
+
+ public bool RTP_4LAYERS_MODE;
+
+ public int numLayers;
+
+ public int numLayersProcessedByFarShader = 8;
+
+ public bool ADDPASS_IN_BLENDBASE;
+
+ public bool RTP_GLITTER_FIRST;
+
+ public bool RTP_GLITTER_ADD;
+
+ public bool RTP_WETNESS_FIRST;
+
+ public bool RTP_WETNESS_ADD;
+
+ public bool RTP_WET_RIPPLE_TEXTURE_FIRST;
+
+ public bool RTP_WET_RIPPLE_TEXTURE_ADD;
+
+ public bool RTP_CAUSTICS_FIRST;
+
+ public bool RTP_CAUSTICS_ADD;
+
+ public bool RTP_VERTALPHA_CAUSTICS;
+
+ public bool SIMPLE_WATER_FIRST;
+
+ public bool SIMPLE_WATER_ADD;
+
+ public bool RTP_USE_EXTRUDE_REDUCTION_FIRST;
+
+ public bool RTP_USE_EXTRUDE_REDUCTION_ADD;
+
+ private Shader terrain_shader;
+
+ private Shader terrain_shader_far;
+
+ private Shader terrain_shader_add;
+
+ private Shader terrain2geom_shader;
+
+ private Shader terrain_geomBlend_shader;
+
+ private Shader terrain2geom_geomBlend_shader;
+
+ private Shader terrain_geomBlend_GeometryBlend_BumpedDetailSnow;
+
+ private Shader geomblend_GeometryBlend_WaterShader_2VertexPaint_HB;
+
+ private Shader geomBlend_GeometryBlend_WaterShader_FlowMap_HB;
+
+ private Shader terrain_geomBlendActual_shader;
+
+ public bool dont_sync;
+
+ private void Awake()
+ {
+ RefreshLODlevel();
+ }
+
+ public void RefreshLODlevel()
+ {
+ ReliefTerrain[] array = (ReliefTerrain[])Object.FindObjectsOfType(typeof(ReliefTerrain));
+ ReliefTerrain reliefTerrain = null;
+ for (int i = 0; i < array.Length; i++)
+ {
+ if ((bool)array[i].GetComponent(typeof(Terrain)))
+ {
+ reliefTerrain = array[i];
+ break;
+ }
+ }
+ if (reliefTerrain != null && reliefTerrain.globalSettingsHolder != null)
+ {
+ if (terrain_shader == null)
+ {
+ terrain_shader = Shader.Find("Relief Pack/ReliefTerrain-FirstPass");
+ }
+ if (terrain_shader_add == null)
+ {
+ terrain_shader_add = Shader.Find("Hidden/Relief Pack/ReliefTerrain-AddPass");
+ }
+ }
+ else
+ {
+ if (terrain_shader == null)
+ {
+ terrain_shader = Shader.Find("Hidden/TerrainEngine/Splatmap/Lightmap-FirstPass");
+ }
+ if (terrain_shader_add == null)
+ {
+ terrain_shader_add = Shader.Find("Hidden/TerrainEngine/Splatmap/Lightmap-AddPass");
+ }
+ if (terrain_shader == null)
+ {
+ terrain_shader = Shader.Find("Nature/Terrain/Diffuse");
+ }
+ if (terrain_shader_add == null)
+ {
+ terrain_shader_add = Shader.Find("Hidden/TerrainEngine/Splatmap/Diffuse-AddPass");
+ }
+ }
+ if (terrain_shader_far == null)
+ {
+ terrain_shader_far = Shader.Find("Hidden/Relief Pack/ReliefTerrain-FarOnly");
+ }
+ if (terrain2geom_shader == null)
+ {
+ terrain2geom_shader = Shader.Find("Relief Pack/Terrain2Geometry");
+ }
+ if (terrain_geomBlend_shader == null)
+ {
+ terrain_geomBlend_shader = Shader.Find("Hidden/Relief Pack/ReliefTerrainGeometryBlendBase");
+ }
+ if (terrain2geom_geomBlend_shader == null)
+ {
+ terrain2geom_geomBlend_shader = Shader.Find("Hidden/Relief Pack/ReliefTerrain2GeometryBlendBase");
+ }
+ if (terrain_geomBlend_GeometryBlend_BumpedDetailSnow == null)
+ {
+ terrain_geomBlend_GeometryBlend_BumpedDetailSnow = Shader.Find("Relief Pack - GeometryBlend/Bumped Detail Snow");
+ }
+ if (geomblend_GeometryBlend_WaterShader_2VertexPaint_HB == null)
+ {
+ geomblend_GeometryBlend_WaterShader_2VertexPaint_HB = Shader.Find("Relief Pack - GeometryBlend/Water/2 Layers/ HeightBlend");
+ }
+ if (geomBlend_GeometryBlend_WaterShader_FlowMap_HB == null)
+ {
+ geomBlend_GeometryBlend_WaterShader_FlowMap_HB = Shader.Find("Relief Pack - GeometryBlend/Water/ FlowMap - HeightBlend");
+ }
+ int maximumLOD = 700;
+ if (RTP_LODlevel == TerrainShaderLod.POM)
+ {
+ if (RTP_SHADOWS)
+ {
+ if (RTP_SOFT_SHADOWS)
+ {
+ Shader.EnableKeyword("RTP_POM_SHADING_HI");
+ Shader.DisableKeyword("RTP_POM_SHADING_MED");
+ Shader.DisableKeyword("RTP_POM_SHADING_LO");
+ }
+ else
+ {
+ Shader.EnableKeyword("RTP_POM_SHADING_MED");
+ Shader.DisableKeyword("RTP_POM_SHADING_HI");
+ Shader.DisableKeyword("RTP_POM_SHADING_LO");
+ }
+ }
+ else
+ {
+ Shader.EnableKeyword("RTP_POM_SHADING_LO");
+ Shader.DisableKeyword("RTP_POM_SHADING_MED");
+ Shader.DisableKeyword("RTP_POM_SHADING_HI");
+ }
+ Shader.DisableKeyword("RTP_PM_SHADING");
+ Shader.DisableKeyword("RTP_SIMPLE_SHADING");
+ }
+ else if (RTP_LODlevel == TerrainShaderLod.PM)
+ {
+ Shader.DisableKeyword("RTP_POM_SHADING_HI");
+ Shader.DisableKeyword("RTP_POM_SHADING_MED");
+ Shader.DisableKeyword("RTP_POM_SHADING_LO");
+ Shader.EnableKeyword("RTP_PM_SHADING");
+ Shader.DisableKeyword("RTP_SIMPLE_SHADING");
+ }
+ else
+ {
+ Shader.DisableKeyword("RTP_POM_SHADING_HI");
+ Shader.DisableKeyword("RTP_POM_SHADING_MED");
+ Shader.DisableKeyword("RTP_POM_SHADING_LO");
+ Shader.DisableKeyword("RTP_PM_SHADING");
+ Shader.EnableKeyword("RTP_SIMPLE_SHADING");
+ }
+ if (terrain_shader != null)
+ {
+ terrain_shader.maximumLOD = maximumLOD;
+ }
+ if (terrain_shader_far != null)
+ {
+ terrain_shader_far.maximumLOD = maximumLOD;
+ }
+ if (terrain_shader_add != null)
+ {
+ terrain_shader_add.maximumLOD = maximumLOD;
+ }
+ if (terrain2geom_shader != null)
+ {
+ terrain2geom_shader.maximumLOD = maximumLOD;
+ }
+ if (terrain_geomBlend_shader != null)
+ {
+ terrain_geomBlend_shader.maximumLOD = maximumLOD;
+ }
+ if (terrain2geom_geomBlend_shader != null)
+ {
+ terrain2geom_geomBlend_shader.maximumLOD = maximumLOD;
+ }
+ if (terrain_geomBlend_GeometryBlend_BumpedDetailSnow != null)
+ {
+ terrain_geomBlend_GeometryBlend_BumpedDetailSnow.maximumLOD = maximumLOD;
+ }
+ if (geomblend_GeometryBlend_WaterShader_2VertexPaint_HB != null)
+ {
+ geomblend_GeometryBlend_WaterShader_2VertexPaint_HB.maximumLOD = maximumLOD;
+ }
+ if (geomBlend_GeometryBlend_WaterShader_FlowMap_HB != null)
+ {
+ geomBlend_GeometryBlend_WaterShader_FlowMap_HB.maximumLOD = maximumLOD;
+ }
+ }
+}
diff --git a/RTP_MouseOrbit_DynamicDistance.cs b/RTP_MouseOrbit_DynamicDistance.cs
new file mode 100644
index 0000000..2965b07
--- /dev/null
+++ b/RTP_MouseOrbit_DynamicDistance.cs
@@ -0,0 +1,234 @@
+using UnityEngine;
+
+[AddComponentMenu("Relief Terrain/Helpers/Mouse Orbit - Dynamic Distance")]
+public class RTP_MouseOrbit_DynamicDistance : MonoBehaviour
+{
+ public GameObject target;
+
+ public Transform targetFocus;
+
+ public float distance = 1f;
+
+ [Range(0.1f, 8f)]
+ public float ZoomWheelSpeed = 4f;
+
+ public float minDistance = 0.5f;
+
+ public float maxDistance = 10f;
+
+ public float xSpeed = 250f;
+
+ public float ySpeed = 120f;
+
+ public float xObjSpeed = 250f;
+
+ public float yObjSpeed = 120f;
+
+ public float yMinLimit = -20f;
+
+ public float yMaxLimit = 80f;
+
+ private float x;
+
+ private float y;
+
+ private float normal_angle;
+
+ private float cur_distance;
+
+ private float cur_xSpeed;
+
+ private float cur_ySpeed;
+
+ private float req_xSpeed;
+
+ private float req_ySpeed;
+
+ private float cur_ObjxSpeed;
+
+ private float cur_ObjySpeed;
+
+ private float req_ObjxSpeed;
+
+ private float req_ObjySpeed;
+
+ private bool DraggingObject;
+
+ private bool lastLMBState;
+
+ private Collider[] surfaceColliders;
+
+ private float bounds_MaxSize = 20f;
+
+ [HideInInspector]
+ public bool disableSteering;
+
+ private void Start()
+ {
+ Vector3 eulerAngles = base.transform.eulerAngles;
+ x = eulerAngles.y;
+ y = eulerAngles.x;
+ Reset();
+ }
+
+ public void DisableSteering(bool state)
+ {
+ disableSteering = state;
+ }
+
+ public void Reset()
+ {
+ lastLMBState = Input.GetMouseButton(0);
+ disableSteering = false;
+ cur_distance = distance;
+ cur_xSpeed = 0f;
+ cur_ySpeed = 0f;
+ req_xSpeed = 0f;
+ req_ySpeed = 0f;
+ surfaceColliders = null;
+ cur_ObjxSpeed = 0f;
+ cur_ObjySpeed = 0f;
+ req_ObjxSpeed = 0f;
+ req_ObjySpeed = 0f;
+ if (!target)
+ {
+ return;
+ }
+ Renderer[] componentsInChildren = target.GetComponentsInChildren();
+ Bounds bounds = default(Bounds);
+ bool flag = false;
+ Renderer[] array = componentsInChildren;
+ foreach (Renderer renderer in array)
+ {
+ if (!flag)
+ {
+ flag = true;
+ bounds = renderer.bounds;
+ }
+ else
+ {
+ bounds.Encapsulate(renderer.bounds);
+ }
+ }
+ Vector3 size = bounds.size;
+ float num = ((!(size.x > size.y)) ? size.y : size.x);
+ num = ((!(size.z > num)) ? num : size.z);
+ bounds_MaxSize = num;
+ cur_distance += bounds_MaxSize * 1.2f;
+ surfaceColliders = target.GetComponentsInChildren();
+ }
+
+ private void LateUpdate()
+ {
+ if (!target || !targetFocus)
+ {
+ return;
+ }
+ if (!lastLMBState && Input.GetMouseButton(0))
+ {
+ DraggingObject = false;
+ if (surfaceColliders != null)
+ {
+ RaycastHit hitInfo = default(RaycastHit);
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
+ Collider[] array = surfaceColliders;
+ foreach (Collider collider in array)
+ {
+ if (collider.Raycast(ray, out hitInfo, float.PositiveInfinity))
+ {
+ DraggingObject = true;
+ break;
+ }
+ }
+ }
+ }
+ else if (lastLMBState && !Input.GetMouseButton(0))
+ {
+ DraggingObject = false;
+ }
+ lastLMBState = Input.GetMouseButton(0);
+ if (DraggingObject)
+ {
+ if (Input.GetMouseButton(0) && !disableSteering)
+ {
+ req_ObjxSpeed += (Input.GetAxis("Mouse X") * xObjSpeed * 0.02f - req_ObjxSpeed) * Time.deltaTime * 10f;
+ req_ObjySpeed += (Input.GetAxis("Mouse Y") * yObjSpeed * 0.02f - req_ObjySpeed) * Time.deltaTime * 10f;
+ }
+ else
+ {
+ req_ObjxSpeed += (0f - req_ObjxSpeed) * Time.deltaTime * 4f;
+ req_ObjySpeed += (0f - req_ObjySpeed) * Time.deltaTime * 4f;
+ }
+ req_xSpeed += (0f - req_xSpeed) * Time.deltaTime * 4f;
+ req_ySpeed += (0f - req_ySpeed) * Time.deltaTime * 4f;
+ }
+ else
+ {
+ if (Input.GetMouseButton(0) && !disableSteering)
+ {
+ req_xSpeed += (Input.GetAxis("Mouse X") * xSpeed * 0.02f - req_xSpeed) * Time.deltaTime * 10f;
+ req_ySpeed += (Input.GetAxis("Mouse Y") * ySpeed * 0.02f - req_ySpeed) * Time.deltaTime * 10f;
+ }
+ else
+ {
+ req_xSpeed += (0f - req_xSpeed) * Time.deltaTime * 4f;
+ req_ySpeed += (0f - req_ySpeed) * Time.deltaTime * 4f;
+ }
+ req_ObjxSpeed += (0f - req_ObjxSpeed) * Time.deltaTime * 4f;
+ req_ObjySpeed += (0f - req_ObjySpeed) * Time.deltaTime * 4f;
+ }
+ distance -= Input.GetAxis("Mouse ScrollWheel") * ZoomWheelSpeed;
+ distance = Mathf.Clamp(distance, minDistance, maxDistance);
+ cur_ObjxSpeed += (req_ObjxSpeed - cur_ObjxSpeed) * Time.deltaTime * 20f;
+ cur_ObjySpeed += (req_ObjySpeed - cur_ObjySpeed) * Time.deltaTime * 20f;
+ target.transform.RotateAround(targetFocus.position, Vector3.Cross(targetFocus.position - base.transform.position, base.transform.right), 0f - cur_ObjxSpeed);
+ target.transform.RotateAround(targetFocus.position, Vector3.Cross(targetFocus.position - base.transform.position, base.transform.up), 0f - cur_ObjySpeed);
+ cur_xSpeed += (req_xSpeed - cur_xSpeed) * Time.deltaTime * 20f;
+ cur_ySpeed += (req_ySpeed - cur_ySpeed) * Time.deltaTime * 20f;
+ x += cur_xSpeed;
+ y -= cur_ySpeed;
+ y = ClampAngle(y, yMinLimit + normal_angle, yMaxLimit + normal_angle);
+ if (surfaceColliders != null)
+ {
+ RaycastHit hitInfo2 = default(RaycastHit);
+ Vector3 vector = Vector3.Normalize(targetFocus.position - base.transform.position);
+ float num = 0.01f;
+ bool flag = false;
+ Collider[] array2 = surfaceColliders;
+ foreach (Collider collider2 in array2)
+ {
+ if (collider2.Raycast(new Ray(base.transform.position - vector * bounds_MaxSize, vector), out hitInfo2, float.PositiveInfinity))
+ {
+ num = Mathf.Max(Vector3.Distance(hitInfo2.point, targetFocus.position) + distance, num);
+ flag = true;
+ }
+ }
+ if (flag)
+ {
+ cur_distance += (num - cur_distance) * Time.deltaTime * 4f;
+ }
+ }
+ Quaternion quaternion = Quaternion.Euler(y, x, 0f);
+ Vector3 position = quaternion * new Vector3(0f, 0f, 0f - cur_distance) + targetFocus.position;
+ base.transform.rotation = quaternion;
+ base.transform.position = position;
+ }
+
+ private static float ClampAngle(float angle, float min, float max)
+ {
+ if (angle < -360f)
+ {
+ angle += 360f;
+ }
+ if (angle > 360f)
+ {
+ angle -= 360f;
+ }
+ return Mathf.Clamp(angle, min, max);
+ }
+
+ public void set_normal_angle(float a)
+ {
+ normal_angle = a;
+ }
+}
diff --git a/RTP_TintDielectricColor.cs b/RTP_TintDielectricColor.cs
new file mode 100644
index 0000000..9a6bdcd
--- /dev/null
+++ b/RTP_TintDielectricColor.cs
@@ -0,0 +1,24 @@
+using UnityEngine;
+
+[AddComponentMenu("Relief Terrain/Helpers/Tint dielectric color")]
+public class RTP_TintDielectricColor : MonoBehaviour
+{
+ [Tooltip("You can reduce/increase reflectivity by tinting default unity_ColorSpaceDielectricSpec.rgb color")]
+ [ColorUsage(false)]
+ public Color DielectricTint = new Color(0.2f, 0.2f, 0.2f, 1f);
+
+ private void Awake()
+ {
+ SetDielectricColorTint();
+ }
+
+ private void OnValidate()
+ {
+ SetDielectricColorTint();
+ }
+
+ public void SetDielectricColorTint()
+ {
+ Shader.SetGlobalColor("RTP_ColorSpaceDielectricSpecTint", DielectricTint);
+ }
+}
diff --git a/RagdollHandler.cs b/RagdollHandler.cs
new file mode 100644
index 0000000..ca52b8d
--- /dev/null
+++ b/RagdollHandler.cs
@@ -0,0 +1,21 @@
+using UnityEngine;
+
+public class RagdollHandler : MonoBehaviour
+{
+ public float ragdollValue = 1f;
+
+ private RigidbodyHolder rigs;
+
+ private void Start()
+ {
+ rigs = GetComponent