public override void Load(ValuesDictionary valuesDictionary)
 {
     SubsystemTerrain       = base.Project.FindSubsystem <SubsystemTerrain>(true);
     subsystemBlockEntities = base.Project.FindSubsystem <SubsystemBlockEntities>(true);
     base.Load(valuesDictionary);
     foreach (Point3 item in valuesDictionary.GetValue <ValuesDictionary>("Devices").Values)
     {
         devices.Add(item);
     }
     foreach (ValuesDictionary pairs in valuesDictionary.GetValue <ValuesDictionary>("MutiDevices").Values)
     {
         List <Point3> points = new List <Point3>();
         foreach (Point3 po in pairs.GetValue <ValuesDictionary>("Data").Values)
         {
             points.Add(po);
         }
         MutiDevices.Add(pairs.GetValue <Point3>("Point"), points);
     }
     foreach (ValuesDictionary keyValuePairs in valuesDictionary.GetValue <ValuesDictionary>("tranmitPoints").Values)
     {
         NewMutiBlockCheck.TranmitResult tranmitResult = new NewMutiBlockCheck.TranmitResult();
         List <Point3> blocks = new List <Point3>();
         tranmitResult.savePoint    = keyValuePairs.GetValue <Point3>("savePoint");
         tranmitResult.connectPoint = keyValuePairs.GetValue <Point3>("connPoint");
         tranmitResult.pa           = keyValuePairs.GetValue <Point3>("pa");
         tranmitResult.directionIsX = keyValuePairs.GetValue <bool>("directionIsX");
         tranmitResult.pb           = keyValuePairs.GetValue <Point3>("pb");
         foreach (Point3 point in keyValuePairs.GetValue <ValuesDictionary>("blocks").Values)
         {
             blocks.Add(point);
         }
         tranmitResult.blocks   = blocks;
         tranmitResult.finished = true;
         tranmitPoints.Add(tranmitResult.savePoint, tranmitResult);
     }
 }
        public override void OnBlockAdded(int value, int oldValue, int x, int y, int z)
        {
            try
            {
                Point3 point = new Point3(x, y, z);

                int id  = ILibrary.getItemId(value);
                int bid = Terrain.ExtractContents(value);
                if (bid == 1003)
                {
                    switch (id)
                    {        //39,40,41为动态储罐
                    case 27: //燃煤发电机
                        ILibrary.addCoalGeneratorEntity(Project, point, 1024);
                        devices.Add(point);
                        break;

                    case 30:                                                                    //太阳能发电
                        ILibrary.addBaseEnergyEntity(Project, "SolarEnergyBlock", point, 1024); //1k eu电量
                        devices.Add(point);
                        break;

                    case 40:

                        NewMutiBlockCheck.Result result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                        if (result.finish)
                        {
                            int v = result.Size.X * result.Size.Y * result.Size.Z;
                            if (!MutiDevices.ContainsKey(result.savaPoint))
                            {
                                MutiDevices.Add(result.savaPoint, result.blocks); ILibrary.addMekDynamicEntity(Project, result.savaPoint, 1000 * v);
                            }
                            if (component != null)
                            {
                                component.ComponentGui.DisplaySmallMessage($"动态储罐成型,储量{1000 * result.Size.X * result.Size.Y * result.Size.Z}MB t:{result.Size}", false, false);
                            }
                        }

                        break;

                    case 41:

                        result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                        if (result.finish)
                        {
                            int v = result.Size.X * result.Size.Y * result.Size.Z;
                            if (!MutiDevices.ContainsKey(result.savaPoint))
                            {
                                MutiDevices.Add(result.savaPoint, result.blocks);
                                ILibrary.addMekDynamicEntity(Project, result.savaPoint, 1000 * v);
                            }
                            if (component != null)
                            {
                                component.ComponentGui.DisplaySmallMessage($"动态储罐成型,储量{1000 * result.Size.X * result.Size.Y * result.Size.Z}MB t:{result.Size}", false, false);
                            }
                        }
                        break;

                    case 63:                                                                          //基础能量立方
                        ILibrary.addBaseEnergyEntity(Project, "BaseEnergyBlock", point, 1024 * 1024); //1k eu电量
                        devices.Add(point);
                        break;

                    case 64:    //传送机
                        NewMutiBlockCheck.TranmitResult tranmitResult = mutiBlockCheck.checkTransmit(SubsystemTerrain, point, new List <int>()
                        {
                            Terrain.MakeBlockValue(1003, 0, 64), Terrain.MakeBlockValue(1003, 0, 65)
                        }, Terrain.MakeBlockValue(1007));
                        if (tranmitResult.finished)
                        {
                            component.ComponentGui.DisplaySmallMessage("传送门成型", false, false);
                            if (!tranmitPoints.ContainsKey(tranmitResult.savePoint))
                            {
                                tranmitPoints.Add(tranmitResult.savePoint, tranmitResult);
                            }
                        }
                        break;

                    case 65:    //传送框架
                        tranmitResult = mutiBlockCheck.checkTransmit(SubsystemTerrain, point, new List <int>()
                        {
                            Terrain.MakeBlockValue(1003, 0, 64), Terrain.MakeBlockValue(1003, 0, 65)
                        }, Terrain.MakeBlockValue(1007));
                        if (tranmitResult.finished)
                        {
                            component.ComponentGui.DisplaySmallMessage("传送门成型", false, false);
                            if (!tranmitPoints.ContainsKey(tranmitResult.savePoint))
                            {
                                tranmitPoints.Add(tranmitResult.savePoint, tranmitResult);
                            }
                        }
                        break;


                    case 47:                                             //粉碎机
                        ILibrary.addCrusherEntity(Project, point, 1024); //1k eu电量
                        devices.Add(point);
                        break;

                    case 72:                                              //充能冶炼炉
                        ILibrary.addMekSmeltEntity(Project, point, 1024); //1k eu电量
                        devices.Add(point);
                        break;

                    case 78:
                        ILibrary.addEnrichEntity(Project, point, 1024);    //1k eu电量
                        devices.Add(point);
                        break;

                    case 80:                                           //合金炉
                        ILibrary.addAlloyEntity(Project, point, 1024); //1k eu电量
                        devices.Add(point);
                        break;

                    case 82:                                                     //制造厂
                        ILibrary.addManufactorymeltEntity(Project, point, 1024); //1k eu电量
                        devices.Add(point);
                        break;
                    }
                }
                else if (bid == 1007)
                {
                    switch (id)
                    {
                    case 39:
                        NewMutiBlockCheck.Result result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                        if (result.finish)
                        {
                            int v = result.Size.X * result.Size.Y * result.Size.Z;
                            if (!MutiDevices.ContainsKey(result.savaPoint))
                            {
                                MutiDevices.Add(result.savaPoint, result.blocks);
                                ILibrary.addMekDynamicEntity(Project, result.savaPoint, 1000 * v);
                            }
                            if (component != null)
                            {
                                component.ComponentGui.DisplaySmallMessage($"动态储罐成型,储量{1000 * result.Size.X * result.Size.Y * result.Size.Z}MB t:{result.Size}", false, false);
                            }
                        }
                        break;
                    }
                }
                updateList();
            }
            catch (Exception e)
            {
                if (component != null)
                {
                    component.ComponentGui.DisplaySmallMessage(e.ToString(), false, false);
                }
            }
        }
示例#3
0
        public override bool OnUse(Vector3 start, Vector3 direction, ComponentMiner componentMiner)
        {
            int blockid = Terrain.ExtractContents(componentMiner.ActiveBlockValue);
            int id      = ILibrary.getItemId(componentMiner.ActiveBlockValue);

            switch (blockid)
            {
            case 1006:
                switch (id)
                {
                case 500:
                    TerrainRaycastResult?raycastResult = componentMiner.PickTerrainForDigging(start, direction);
                    if (TransmitSetflag && !raycastResult.HasValue)          //设定了传送地点且不对准传送机
                    {
                        subsystemItemElectricBehavior.tranFLag = true;
                        subsystemItemElectricBehavior.leftFLag = false;
                        componentMiner.ComponentPlayer.ComponentBody.Position = new Vector3(TransmitStartPoint.X, TransmitStartPoint.Y + 1, TransmitStartPoint.Z + 1);
                        SubsystemTerrain.TerrainUpdater.UpdateChunkSingleStep(SubsystemTerrain.Terrain.GetChunkAtCell(TransmitStartPoint.X, TransmitStartPoint.Z), 15);
                    }
                    if (Terrain.ExtractContents(raycastResult.Value.Value) == 1003 && Terrain.ExtractData(raycastResult.Value.Value) == 64)
                    {
                        if (!TransmitSetflag)           //没有设定地点
                        {
                            TransmitStartPoint = raycastResult.Value.CellFace.Point;
                            TransmitSetflag    = true;
                            componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage("传送门1设定成功", false, false);
                            return(false);
                        }
                        if (raycastResult.Value.CellFace.Point != TransmitStartPoint && TransmitSetflag)
                        {
                            if (subsystemItemElectricBehavior.tranmitPoints.TryGetValue(TransmitStartPoint, out NewMutiBlockCheck.TranmitResult tranmitResult))
                            {
                                NewMutiBlockCheck.TranmitResult tranmitResult1 = subsystemItemElectricBehavior.tranmitPoints[TransmitStartPoint];
                                if (subsystemItemElectricBehavior.tranmitPoints.TryGetValue(raycastResult.Value.CellFace.Point, out NewMutiBlockCheck.TranmitResult tranmitResultaa))
                                {
                                    NewMutiBlockCheck.TranmitResult tranmitResult2 = subsystemItemElectricBehavior.tranmitPoints[raycastResult.Value.CellFace.Point];
                                    TransmitSetflag             = false;
                                    tranmitResult2.connectPoint = TransmitStartPoint;
                                    tranmitResult1.connectPoint = raycastResult.Value.CellFace.Point;
                                    subsystemItemElectricBehavior.tranmitPoints[TransmitStartPoint] = tranmitResult1;
                                    subsystemItemElectricBehavior.tranmitPoints[raycastResult.Value.CellFace.Point] = tranmitResult2;
                                    componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage("传送门连接成功", false, false);
                                    return(false);
                                }
                                else
                                {
                                    componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage("传送门结构被破坏,无法连接", false, false);
                                    return(false);
                                }
                            }
                        }
                    }
                    break;
                }

                break;

            case 1007:

                switch (id)
                {
                case 39:
                    break;
                }
                break;
            }
            return(false);
        }