SHARE
TWEET

Untitled

a guest Feb 27th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. #ifndef TERRAFORMINGCOMPONENT_H
  4. #define TERRAFORMINGCOMPONENT_H
  5.  
  6. #include <AzCore/Component/Component.h>
  7. #include <AzCore/Component/EntityBus.h>
  8. #include <AzCore/Component/TickBus.h>
  9.  
  10. // EBUS
  11. #include <AzFramework/Entity/GameEntityContextBus.h>
  12. #include "TerraformingBus.h"
  13. #include <ITerrain.h>
  14.  
  15. namespace GameProject
  16. {
  17.     class TerraformingComponent:
  18.         public AZ::Component,
  19.         public AZ::EntityBus::MultiHandler,
  20.         public AZ::TickBus::Handler,
  21.         public AzFramework::GameEntityContextEventBus::Handler,
  22.         public TerraformingBus::Handler
  23.     {
  24.     public:
  25.         AZ_COMPONENT(TerraformingComponent, "{23DD0B83-BDEA-4354-B677-8F6AB26DDFC3}", AZ::Component);
  26.  
  27.         TerraformingComponent() {};
  28.         virtual ~TerraformingComponent() {};
  29.  
  30.         static void Reflect(AZ::ReflectContext* context);
  31.  
  32.         void Init() override;
  33.         void Activate() override;
  34.         void Deactivate() override;
  35.  
  36.         // AZ::TickBus
  37.         void OnTick(float deltaTime, AZ::ScriptTimePoint time);
  38.  
  39.         //GameEntityContextEventBus
  40.         void OnGameEntitiesStarted() override;
  41.         void OnGameEntitiesReset() override;
  42.    
  43.         // TerraformingBus
  44.         void UpdateTerrainCutout(AZ::Vector3 pos, float radius, bool cutout = true) override;
  45.  
  46.         void UpdateTerrain();
  47.         void UpdateTerrainUnderEntity(float radius, float inland);
  48.         void UpdateTerrainUnderEntityOptimized(float radius, float inland);
  49.  
  50.         void SaveOriginalTerrain();
  51.         void RestoreOriginalTerrain();
  52.  
  53.     private:
  54.         float* pOriginalTerrain = nullptr;
  55.         float* pCurTerrain = nullptr;
  56.         ITerrain::SurfaceWeight* pCurTerrainSW = nullptr;
  57.  
  58.         float m_Value = 0.0f;
  59.         AZ::SimpleLcgRandom m_RndGenerator;
  60.         float m_radius = 32.0f;
  61.         float m_inland = 16.0f;
  62.         bool m_wholeTerrainNoise = false;
  63.         bool m_saveAndRestoreOriginalTerrain = true;
  64.        
  65.  
  66.     };
  67. }
  68. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top