public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
        {
            if (!ComponentEngine.IsPowered(Utils.Terrain, cellFace.X, cellFace.Y, cellFace.Z) || worldItem.Velocity.Length() < 20f)
            {
                return;
            }
            int     l;
            Vector3 v        = CellFace.FaceToVector3(cellFace.Face);
            var     position = new Vector3(cellFace.Point) + new Vector3(0.5f) - 0.75f * v;

            if (Terrain.ExtractContents(worldItem.Value) == 6)
            {
                for (l = 0; l < 5; l++)
                {
                    Utils.SubsystemProjectiles.FireProjectile(79, position, -20f * v, Vector3.Zero, null);
                }
                worldItem.ToRemove = true;
            }
            else
            {
                var list = new List <BlockDropValue>(8);
                BlocksManager.Blocks[Terrain.ExtractContents(worldItem.Value)].GetDropValues(SubsystemTerrain, worldItem.Value, 0, 3, list, out bool s);
                for (l = 0; l < list.Count; l++)
                {
                    var blockDropValue = list[l];
                    for (int i = 0; i <= blockDropValue.Count; i++)
                    {
                        Utils.SubsystemProjectiles.FireProjectile(blockDropValue.Value, position, -20f * v, Vector3.Zero, null);
                    }
                }
                worldItem.ToRemove = true;
            }
        }
Пример #2
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            base.Load(valuesDictionary, idToEntityMap);
            m_componentBody  = Entity.FindComponent <ComponentBody>(true);
            componentDamage  = Entity.FindComponent <ComponentDamage>();
            m_componentMount = Entity.FindComponent <ComponentMount>(true);
            if ((ComponentEngine = Entity.FindComponent <ComponentEngine>()) != null)
            {
                m_componentBody.CollidedWithBody += CollidedWithBody;
            }
            else
            {
                ParentBody = valuesDictionary.GetValue("ParentBody", default(EntityReference)).GetComponent <ComponentTrain>(Entity, idToEntityMap, false);
            }

            Direction = valuesDictionary.GetValue("Direction", 0);
        }
Пример #3
0
        protected void Driller(Point3 point, int face)
        {
            Vector3 vector    = CellFace.FaceToVector3(face);
            int     x         = point.X;
            int     y         = point.Y;
            int     z         = point.Z;
            int     slotValue = GetSlotValue(8);

            if (!(ComponentEngine.IsPowered(Utils.Terrain, x, y, z) || Utils.SubsystemGameInfo.WorldSettings.GameMode == 0) || BlocksManager.Blocks[Terrain.ExtractContents(slotValue)].Durability <= 0)
            {
                return;
            }
            int[] array = new[]
            {
                0,
                0,
                1,
                1,
                1,
                0,
                -1,
                -1,
                -1
            }, array2 = new[]
            {
                0,
                -1,
                -1,
                0,
                1,
                1,
                1,
                0,
                -1
            };
            int     num2 = 0;
            Vector3 v    = Vector3.Zero;

            for (int l = 1; l < 19; l++)
            {
                for (int m = 0; m < 9; m++)
                {
                    x = point.X - (int)vector.X * l;
                    y = point.Y - (int)vector.Y * l;
                    z = point.Z - (int)vector.Z * l;
                    if (vector.X != 0f)
                    {
                        y = point.Y + array[m];
                        z = point.Z + array2[m];
                        v = new Vector3(0f, array[m] / (float)l, array2[m] / (float)l);
                    }
                    if (vector.Y != 0f)
                    {
                        x = point.X + array[m];
                        z = point.Z + array2[m];
                        v = new Vector3(array[m] / (float)l, 0f, array2[m] / (float)l);
                    }
                    if (vector.Z != 0f)
                    {
                        x = point.X + array[m];
                        y = point.Y + array2[m];
                        v = new Vector3(array[m] / (float)l, array2[m] / (float)l, 0f);
                    }
                    int   cellValue = Terrain.ReplaceLight(Utils.Terrain.GetCellValue(x, y, z), 0);
                    Block block     = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)];
                    if (num2 == 0 && block.BlockIndex == 92)
                    {
                        num2 = 9;
                    }
                    if (block.IsPlaceable && !block.IsDiggingTransparent && !block.DefaultIsInteractive)
                    {
                        Utils.SubsystemTerrain.ChangeCell(x, y, z, 0, true);
                        Utils.SubsystemProjectiles.FireProjectile(cellValue, new Vector3(x + 0.5f, y + 0.5f, z + 0.5f) - 0.25f * vector, 60f * (vector - v), Vector3.Zero, null);
                        RemoveSlotItems(8, 1);
                        AddSlotItems(8, BlocksManager.DamageItem(slotValue, 1 + num2), 1);
                        return;
                    }
                }
            }
        }
Пример #4
0
        protected new void Driller(Point3 point, int face)
        {
            Vector3 vector = Vector3.UnitY;
            int     x      = point.X;
            int     y      = point.Y;
            int     z      = point.Z;
            int     num    = ComponentEngine.IsPowered(Utils.Terrain, x, y, z) ? 1 : 0;

            if (num != 0)
            {
                int num2 = 0;
                int l;
                for (l = 4; 3 < l && l < 8; l++)
                {
                    num2 += GetSlotCount(l);
                }
                int num3 = 0;
                int num4 = 0;
                for (int m = 0; m < 4; m++)
                {
                    if (GetSlotCount(l) == 0)
                    {
                        num3 = 0;
                        num4 = 1;
                        break;
                    }
                    num4 += BlocksManager.Blocks[Terrain.ExtractContents(GetSlotValue(m))].MaxStacking;
                    num3 += GetSlotCount(m);
                }
                int slotValue = base.GetSlotValue(8);
                if (num2 != 0 && num4 > num3 && slotValue != 0 && BlocksManager.Blocks[Terrain.ExtractContents(slotValue)].Durability > 0)
                {
                    int[] array = new int[25]
                    {
                        0,
                        0,
                        1,
                        1,
                        1,
                        0,
                        -1,
                        -1,
                        -1,
                        -1,
                        0,
                        1,
                        2,
                        2,
                        2,
                        2,
                        2,
                        1,
                        0,
                        -1,
                        -2,
                        -2,
                        -2,
                        -2,
                        -2
                    };
                    int[] array2 = new int[25]
                    {
                        0,
                        -1,
                        -1,
                        0,
                        1,
                        1,
                        1,
                        0,
                        -1,
                        -2,
                        -2,
                        -2,
                        -2,
                        -1,
                        0,
                        1,
                        2,
                        2,
                        2,
                        2,
                        2,
                        1,
                        0,
                        -1,
                        -2
                    };
                    for (int n = 1; n < 8; n++)
                    {
                        for (int num5 = 0; num5 < 25; num5++)
                        {
                            x = point.X - (int)vector.X * n;
                            y = point.Y - (int)vector.Y * n;
                            z = point.Z - (int)vector.Z * n;
                            x = point.X + array[num5];
                            z = point.Z + array2[num5];
                            //new Vector3((float)array[num5] / (float)n, 0f, (float)array2[num5] / (float)n);
                            int cellValue = Utils.Terrain.GetCellValue(x, y, z);
                            var block     = Terrain.ExtractContents(cellValue);
                            if (block == 92 || block == 18 || block == RottenMeatBlock.Index)
                            {
                                int num6;
                                for (num6 = 4; 3 < num6 && num6 < 8 && GetSlotCount(num6) == 0; num6++)
                                {
                                }
                                int num7 = 0;
                                while (true)
                                {
                                    if (num7 >= 4)
                                    {
                                        return;
                                    }
                                    if (GetSlotCount(num7) < BlocksManager.Blocks[Terrain.ExtractContents(GetSlotValue(num7))].MaxStacking || GetSlotCount(num7) == 0)
                                    {
                                        if (block == 92 && (Terrain.ExtractContents(GetSlotValue(num7)) == 93 || GetSlotCount(num7) == 0))
                                        {
                                            if (FluidBlock.GetLevel(Terrain.ExtractData(cellValue)) == 0)
                                            {
                                                RemoveSlotItems(num6, 1);
                                                AddSlotItems(num7, 93, 1);
                                                RemoveSlotItems(8, 1);
                                                AddSlotItems(8, BlocksManager.DamageItem(slotValue, 1), 1);
                                            }
                                            Utils.SubsystemTerrain.ChangeCell(x, y, z, 0);
                                            return;
                                        }
                                        if (block == 18 && (Terrain.ExtractContents(GetSlotValue(num7)) == 91 || GetSlotCount(num7) == 0))
                                        {
                                            if (FluidBlock.GetLevel(Terrain.ExtractData(cellValue)) == 0)
                                            {
                                                RemoveSlotItems(num6, 1);
                                                AddSlotItems(num7, 91, 1);
                                            }
                                            Utils.SubsystemTerrain.ChangeCell(x, y, z, 0);
                                            return;
                                        }
                                        if (Terrain.ReplaceLight(cellValue, 0) == (RottenMeatBlock.Index | 1 << 4 << 14) && (Terrain.ReplaceLight(GetSlotValue(num7), 0) == (RottenMeatBlock.Index | 2 << 4 << 14) || GetSlotCount(num7) == 0))
                                        {
                                            RemoveSlotItems(num6, 1);
                                            AddSlotItems(num7, RottenMeatBlock.Index | 2 << 4 << 14, 1);
                                            Utils.SubsystemTerrain.ChangeCell(x, y, z, 0);
                                            return;
                                        }
                                    }
                                    num7++;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     base.Load(valuesDictionary, idToEntityMap);
     componentEngine = Entity.FindComponent <ComponentEngine>();
 }