예제 #1
0
 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
 {
     if (m_score == 0 && !ElectricElement.IsSignalHigh(m_voltage))
     {
         if (cellFace.Face == 0 || cellFace.Face == 2)
         {
             float num  = worldItem.Position.X - (float)cellFace.X - 0.5f;
             float num2 = worldItem.Position.Y - (float)cellFace.Y - 0.5f;
             float num3 = MathUtils.Sqrt(num * num + num2 * num2);
             m_score = MathUtils.Clamp((int)MathUtils.Round(8f * (1f - num3 / 0.707f)), 1, 8);
         }
         else
         {
             float num4 = worldItem.Position.Z - (float)cellFace.Z - 0.5f;
             float num5 = worldItem.Position.Y - (float)cellFace.Y - 0.5f;
             float num6 = MathUtils.Sqrt(num4 * num4 + num5 * num5);
             m_score = MathUtils.Clamp((int)MathUtils.Round(8f * (1f - num6 / 0.5f)), 1, 8);
         }
         base.SubsystemElectricity.QueueElectricElementForSimulation(this, base.SubsystemElectricity.CircuitStep + 1);
     }
 }
예제 #2
0
        public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
        {
            int             x   = cellFace.X;
            int             y   = cellFace.Y;
            int             z   = cellFace.Z;
            int             num = 0;
            ElectricElement electricElement;

            while (true)
            {
                if (num < 6)
                {
                    electricElement = m_subsystemElectricity.GetElectricElement(x, y, z, num);
                    if (electricElement != null)
                    {
                        break;
                    }
                    num++;
                    continue;
                }
                return;
            }
            electricElement.OnHitByProjectile(cellFace, worldItem);
        }
예제 #3
0
        public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            int  data   = TerrainData.ExtractData(worldItem.Value);
            bool isLaid = EggBlock.GetIsLaid(data);

            if (!EggBlock.GetIsCooked(data) && ((this.m_subsystemGameInfo.WorldInfo.GameMode == GameMode.Creative) || (this.m_random.UniformFloat(0f, 1f) <= (isLaid ? 0.2f : 1f))))
            {
                EggBlock.EggType eggType = this.m_eggBlock.GetEggType(data);
                Entity           entity  = this.m_subsystemEntityFactory.CreateEntity(eggType.TemplateName, true);
                entity.FindComponent <ComponentBody>(true).Position       = worldItem.Position;
                entity.FindComponent <ComponentBody>(true).Rotation       = Quaternion.CreateFromAxisAngle(Vector3.UnitY, this.m_random.UniformFloat(0f, 6.283185f));
                entity.FindComponent <ComponentSpawn>(true).SpawnDuration = 0.25f;
                base.Project.AddEntity(entity);
            }
            return(true);
        }
예제 #4
0
 public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
 {
     return(true);
 }
 public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
 {
     return(m_subsystemExplosions.TryExplodeBlock(Terrain.ToCell(worldItem.Position.X), Terrain.ToCell(worldItem.Position.Y), Terrain.ToCell(worldItem.Position.Z), worldItem.Value));
 }
예제 #6
0
 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
 {
     Press();
 }
예제 #7
0
 public virtual void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
 {
 }
        public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            BulletBlock.BulletType bulletType = BulletBlock.GetBulletType(Terrain.ExtractData(worldItem.Value));
            bool result = true;

            if (cellFace.HasValue)
            {
                int   cellValue = m_subsystemTerrain.Terrain.GetCellValue(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z);
                int   num       = Terrain.ExtractContents(cellValue);
                Block obj       = BlocksManager.Blocks[num];
                if (worldItem.Velocity.Length() > 30f)
                {
                    m_subsystemExplosions.TryExplodeBlock(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z, cellValue);
                }
                if (obj.Density >= 1.5f && worldItem.Velocity.Length() > 30f)
                {
                    float num2        = 1f;
                    float minDistance = 8f;
                    if (bulletType == BulletBlock.BulletType.BuckshotBall)
                    {
                        num2        = 0.25f;
                        minDistance = 4f;
                    }
                    if (m_random.Float(0f, 1f) < num2)
                    {
                        m_subsystemAudio.PlayRandomSound("Audio/Ricochets", 1f, m_random.Float(-0.2f, 0.2f), new Vector3(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z), minDistance, autoDelay: true);
                        result = false;
                    }
                }
            }
            return(result);
        }
예제 #9
0
 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
 {
     Utils.OnHitByProjectile(cellFace, worldItem);
 }
예제 #10
0
 public virtual bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
 {
     return(false);
 }
예제 #11
0
파일: Elements.cs 프로젝트: Lixue9jiu/SCIE
 public void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) => Utils.OnHitByProjectile(cellFace, worldItem);
        public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            int  data     = Terrain.ExtractData(worldItem.Value);
            bool isCooked = EggBlock.GetIsCooked(data);
            bool isLaid   = EggBlock.GetIsLaid(data);

            if (!isCooked && (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative || m_random.Float(0f, 1f) <= (isLaid ? 0.15f : 1f)))
            {
                if (m_subsystemCreatureSpawn.Creatures.Count < 35)
                {
                    EggBlock.EggType eggType = m_eggBlock.GetEggType(data);
                    Entity           entity  = DatabaseManager.CreateEntity(base.Project, eggType.TemplateName, throwIfNotFound: true);
                    entity.FindComponent <ComponentBody>(throwOnError: true).Position       = worldItem.Position;
                    entity.FindComponent <ComponentBody>(throwOnError: true).Rotation       = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.Float(0f, (float)Math.PI * 2f));
                    entity.FindComponent <ComponentSpawn>(throwOnError: true).SpawnDuration = 0.25f;
                    base.Project.AddEntity(entity);
                }
                else
                {
                    ((worldItem as Projectile)?.Owner as ComponentPlayer)?.ComponentGui.DisplaySmallMessage("Too many creatures", Color.White, blinking: true, playNotificationSound: false);
                }
            }
            return(true);
        }
예제 #13
0
 public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
 {
     if (Terrain.ExtractContents(worldItem.Value) != Bullet2Block.Index)
     {
         return(false);
     }
     if (cellFace.HasValue)
     {
         var value     = cellFace.Value;
         int cellValue = SubsystemTerrain.Terrain.GetCellValue(value.X, value.Y, value.Z);
         if (worldItem.Velocity.Length() > 30f)
         {
             Utils.SubsystemExplosions.TryExplodeBlock(value.X, value.Y, value.Z, cellValue);
         }
         if (BlocksManager.Blocks[Terrain.ExtractContents(cellValue)].Density >= 1.5f && worldItem.Velocity.Length() > 30f)
         {
             const float num         = 1f;
             const float minDistance = 8f;
             if (Utils.Random.UniformFloat(0f, 1f) < num)
             {
                 Utils.SubsystemAudio.PlayRandomSound("Audio/Ricochets", 1f, Utils.Random.UniformFloat(-0.2f, 0.2f), new Vector3(value.X, value.Y, value.Z), minDistance, true);
                 return(false);
             }
         }
     }
     return(true);
 }
 public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
 {
     ArrowBlock.ArrowType arrowType = ArrowBlock.GetArrowType(Terrain.ExtractData(worldItem.Value));
     if (worldItem.Velocity.Length() > 10f)
     {
         float num = 0.1f;
         if (arrowType == ArrowBlock.ArrowType.FireArrow)
         {
             num = 0.5f;
         }
         if (arrowType == ArrowBlock.ArrowType.WoodenArrow)
         {
             num = 0.2f;
         }
         if (arrowType == ArrowBlock.ArrowType.DiamondArrow)
         {
             num = 0f;
         }
         if (arrowType == ArrowBlock.ArrowType.IronBolt)
         {
             num = 0.05f;
         }
         if (arrowType == ArrowBlock.ArrowType.DiamondBolt)
         {
             num = 0f;
         }
         if (m_random.Float(0f, 1f) < num)
         {
             return(true);
         }
     }
     return(false);
 }