Ejemplo n.º 1
0
        //Used for other power devices to offer this device some energy
        public virtual int ReceivePacketOffer(BEElectric from, int inVolt, int inAmp) //eg 2
        {
            if (usedconnections == null)
            {
                usedconnections = new List <BEElectric>();
            }
            if (!isOn)
            {
                return(0);
            }                       //Not even on
            if (inVolt > maxVolts)
            {
                DoOverload(); return(0);
            }                                                 //!TOO MANY VOLTS!
            if (inVolt < maxVolts)
            {
                return(0);
            }                                   // not enough volts
            if (capacitor >= capacitance)
            {
                return(0);
            }                                                       //already full
            inAmp = Math.Min(inAmp, MaxAmps);                       //can only move a certain amount of amps - eg 2
            int useamps = Math.Min(inAmp, capacitance - capacitor); //2

            capacitor += useamps;                                   //capacitor=2
            usedconnections.Add(from);
            if (useamps != 0)
            {
                MarkDirty();
            }                //not zero should be dirty
            return(useamps); //return 2
        }
Ejemplo n.º 2
0
        public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos)
        {
            BEElectric bee = world.BlockAccessor.GetBlockEntity(pos) as BEElectric;

            if (bee != null)
            {
                bee.FindConnections();
            }
            base.OnNeighbourBlockChange(world, pos, neibpos);
        }
Ejemplo n.º 3
0
        public virtual bool TryOutputConnection(BEElectric connectto)
        {
            if (outputConnections == null)
            {
                outputConnections = new List <BEElectric>();
            }
            Vec3d       vector = connectto.Pos.ToVec3d() - Pos.ToVec3d();
            BlockFacing bf     = BlockFacing.FromVector(vector.X, vector.Y, vector.Z);

            if (distributionFaces == null)
            {
                return(false);
            }
            if (!distributionFaces.Contains(bf))
            {
                return(false);
            }
            if (!outputConnections.Contains(connectto))
            {
                outputConnections.Add(connectto); MarkDirty();
            }
            return(true);
        }
Ejemplo n.º 4
0
 //Tell a connection to remove itself
 public virtual void RemoveConnection(BEElectric disconnect)
 {
     inputConnections.Remove(disconnect);
     outputConnections.Remove(disconnect);
 }
Ejemplo n.º 5
0
 //generators don't receive power
 public override int ReceivePacketOffer(BEElectric from, int volt, int amp)
 {
     return(0);
 }