public void DrawDecals(UpdateEvent evt, StreaminWeaponNode weaponNode, [JoinAll] SingleNode <DecalManagerComponent> decalManagerNode)
 {
     if (decalManagerNode.component.EnableDecals)
     {
         StreamingDecalProjectorComponent streamingDecalProjector = weaponNode.streamingDecalProjector;
         DecalManagerComponent            component = decalManagerNode.component;
         if ((weaponNode.streamHit.StaticHit != null) && ((streamingDecalProjector.LastDecalCreationTime + streamingDecalProjector.DecalCreationPeriod) <= Time.time))
         {
             streamingDecalProjector.LastDecalCreationTime = Time.time;
             Vector3         barrelOriginWorld = new MuzzleVisualAccessor(weaponNode.muzzlePoint).GetBarrelOriginWorld();
             Vector3         normalized        = (weaponNode.streamHit.StaticHit.Position - barrelOriginWorld).normalized;
             DecalProjection decalProjection   = new DecalProjection {
                 AtlasHTilesCount      = streamingDecalProjector.AtlasHTilesCount,
                 AtlasVTilesCount      = streamingDecalProjector.AtlasVTilesCount,
                 SurfaceAtlasPositions = streamingDecalProjector.SurfaceAtlasPositions,
                 HalfSize   = streamingDecalProjector.HalfSize,
                 Up         = streamingDecalProjector.Up,
                 Distantion = streamingDecalProjector.Distance,
                 Ray        = new Ray(barrelOriginWorld - normalized, normalized)
             };
             Mesh mesh = null;
             if (component.DecalMeshBuilder.Build(decalProjection, ref mesh))
             {
                 component.BulletHoleDecalManager.AddDecal(mesh, streamingDecalProjector.Material, streamingDecalProjector.Color, streamingDecalProjector.LifeTime);
             }
         }
     }
 }
Exemple #2
0
 protected void DrawHitDecal(HitEvent evt, DecalManagerComponent decalManager, DynamicDecalProjectorComponent decalProjector, MuzzlePointComponent muzzlePoint)
 {
     if (evt.StaticHit != null)
     {
         Vector3 barrelOriginWorld = new MuzzleVisualAccessor(muzzlePoint).GetBarrelOriginWorld();
         this.DrawHitDecal(decalManager, decalProjector, barrelOriginWorld, (evt.StaticHit.Position - barrelOriginWorld).normalized);
     }
 }
Exemple #3
0
        public void Init(NodeAddedEvent evt, SingleNode <MapInstanceComponent> mapInstance, SingleNode <DecalSettingsComponent> settingsNode)
        {
            DecalSettingsComponent component  = settingsNode.component;
            DecalManagerComponent  component2 = new DecalManagerComponent {
                DecalMeshBuilder = new DecalMeshBuilder()
            };

            component2.DecalMeshBuilder.WarmupMeshCaches(mapInstance.component.SceneRoot);
            component2.BulletHoleDecalManager = new BulletHoleDecalManager(mapInstance.component.SceneRoot, component.MaxCount, component.LifeTimeMultipler, component2.DecalsQueue);
            component2.EnableDecals           = component.EnableDecals;
            mapInstance.Entity.AddComponent(component2);
        }
Exemple #4
0
        protected GameObject DrawGraffiti(DecalManagerComponent managerComponent, DynamicDecalProjectorComponent decalProjector, Vector3 position, Vector3 direction, Vector3 up)
        {
            DecalProjection decalProjection = new DecalProjection {
                AtlasHTilesCount      = decalProjector.AtlasHTilesCount,
                AtlasVTilesCount      = decalProjector.AtlasVTilesCount,
                SurfaceAtlasPositions = decalProjector.SurfaceAtlasPositions,
                HalfSize   = decalProjector.HalfSize,
                Up         = up,
                Distantion = decalProjector.Distance,
                Ray        = new Ray(position, direction)
            };
            Mesh mesh = null;

            return(!managerComponent.DecalMeshBuilder.Build(decalProjection, ref mesh) ? null : managerComponent.GraffitiDynamicDecalManager.AddGraffiti(mesh, decalProjector.Material, decalProjector.Color, decalProjector.LifeTime));
        }
Exemple #5
0
        protected void DrawHitDecal(DecalManagerComponent managerComponent, DynamicDecalProjectorComponent decalProjector, Vector3 position, Vector3 direction)
        {
            DecalProjection decalProjection = new DecalProjection {
                AtlasHTilesCount      = decalProjector.AtlasHTilesCount,
                AtlasVTilesCount      = decalProjector.AtlasVTilesCount,
                SurfaceAtlasPositions = decalProjector.SurfaceAtlasPositions,
                HalfSize   = decalProjector.HalfSize,
                Up         = decalProjector.Up,
                Distantion = decalProjector.Distance,
                Ray        = new Ray(position, direction)
            };
            Mesh mesh = null;

            if (managerComponent.DecalMeshBuilder.Build(decalProjection, ref mesh))
            {
                managerComponent.BulletHoleDecalManager.AddDecal(mesh, decalProjector.Material, decalProjector.Color, decalProjector.LifeTime);
            }
        }