示例#1
0
 public EnergyDuctCore CombineCores(EnergyDuctCore core)
 {
     storage.setEnergy(Math.Min(storage.getEnergyStored() + core.storage.getEnergyStored(), storage.getMaxEnergyStored()));
     foreach (IEnergyPoint item in core.ducts)
     {
         item.SetCore(this);
     }
     ducts.AddRange(core.ducts);
     return(this);
 }
示例#2
0
 public void InitializeEnergyPoint(ICoreAPI api)
 {
     if (api.World.Side == EnumAppSide.Server)
     {
         foreach (BlockFacing face in BlockFacing.ALLFACES)
         {
             BlockPos pos = Pos.AddCopy(face);
             BlockEntityEnergyDuct block = api.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityEnergyDuct;
             if (block != null)
             {
                 if (core == null)
                 {
                     if (block.core == null)
                     {
                         core = new EnergyDuctCore(MyMiniLib.GetAttributeInt(Block, "transfer", 500));
                         core.ducts.Add(this);
                     }
                     else
                     {
                         core = block.core;
                         core.ducts.Add(this);
                     }
                 }
                 else
                 {
                     if (core != block.core && block.core != null)
                     {
                         core = core.CombineCores(block.core);
                     }
                 }
             }
         }
         if (core == null)
         {
             core = new EnergyDuctCore(MyMiniLib.GetAttributeInt(Block, "transfer", 500));
             core.ducts.Add(this);
         }
     }
 }
示例#3
0
 public void InitializeEnergyPoint(ICoreAPI api)
 {
     if (api.World.Side == EnumAppSide.Server)
     {
         foreach (var kv in wiresList)
         {
             BlockEntityConnector block = api.World.BlockAccessor.GetBlockEntity(kv.Key) as BlockEntityConnector;
             if (block != null)
             {
                 if (core == null)
                 {
                     if (block.core == null)
                     {
                         core = new EnergyDuctCore(MyMiniLib.GetAttributeInt(Block, "transfer", 500));
                         core.ducts.Add(this);
                     }
                     else
                     {
                         core = block.core;
                         core.ducts.Add(this);
                     }
                 }
                 else
                 {
                     if (core != block.core && block.core != null)
                     {
                         core = core.CombineCores(block.core);
                     }
                 }
             }
         }
         if (core == null)
         {
             core = new EnergyDuctCore(MyMiniLib.GetAttributeInt(Block, "transfer", 500));
             core.ducts.Add(this);
         }
     }
 }
示例#4
0
 public void SetCore(EnergyDuctCore core)
 {
     this.core = core;
 }