Beispiel #1
0
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        Supply.ControllingNode.Node.FlushSupplyAndUp(Supply.gameObject);
        if (!Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            if (Supply.ControllingNode.Node.Data.SupplyingCurrent != 0)
            {
                Supply.ControllingNode.Node.ElectricityOutput(Supply.ControllingNode.Node.Data.SupplyingCurrent, Supply.ControllingNode.Node.GameObject());
            }
            else if (Supply.ControllingNode.Node.Data.SupplyingVoltage != 0)
            {
                int   SourceInstanceID = Supply.ControllingNode.Node.GameObject().GetInstanceID();
                float Current          = (Supply.SupplyingVoltage) / (Supply.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.Data.SupplyDependent[SourceInstanceID].ResistanceComingFrom));
                Supply.ControllingNode.Node.ElectricityOutput(Current, Supply.gameObject);
            }
        }
        else
        {
            foreach (ElectricalOIinheritance connectedDevice in Supply.ControllingNode.Node.connectedDevices)
            {
                if (ElectricalSynchronisation.ReactiveSuppliesSet.Contains(connectedDevice.InData.Categorytype))
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
        }
        ELCurrent.Currentloop(Supply.gameObject);

        if (Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            Supply.ControllingNode.Node.Data.ChangeToOff = false;
            Supply.ControllingNode.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.ControllingNode.Node.InData.ControllingDevice, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }
    public static void PowerUpdateCurrentChange(ElectricalOIinheritance Supply)
    {
        Supply.FlushSupplyAndUp(Supply.GameObject());
        if (Supply.connectedDevices.Count > 0)
        {
            if (!Supply.Data.ChangeToOff)
            {
                if (Supply.Data.SupplyingCurrent != 0)
                {
                    Supply.ElectricityOutput(Supply.Data.SupplyingCurrent, Supply.GameObject());
                }
                else if (Supply.Data.SupplyingVoltage != 0)
                {
                    int SourceInstanceID = Supply.GameObject().GetInstanceID();
                    Supply.ElectricityOutput((Supply.Data.SupplyingVoltage) / (Supply.Data.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.Data.ResistanceComingFrom[SourceInstanceID])), Supply.GameObject());
                }
            }
            else
            {
                foreach (ElectricalOIinheritance connectedDevice in Supply.connectedDevices)
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
            ELCurrent.Currentloop(Supply.GameObject());
        }

        if (Supply.Data.ChangeToOff)
        {
            Supply.Data.ChangeToOff = false;
            Supply.InData.ControllingDevice.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype);
        }
    }
Beispiel #3
0
 public void PotentialDestroyed()
 {
     if (SelfDestruct)
     {
         ElectricalSynchronisation.RemoveSupply(this, powerSupply.InData.Categorytype);
         PoolManager.PoolNetworkDestroy(gameObject);
     }
 }
Beispiel #4
0
 public void OnDestroy()
 {
     ElectricalSynchronisation.StructureChangeReact = true;
     ElectricalSynchronisation.ResistanceChange     = true;
     ElectricalSynchronisation.CurrentChange        = true;
     ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
     //Then you can destroy
 }
Beispiel #5
0
 public void PotentialDestroyed()
 {
     UpPotentialDestroyed();
     if (SelfDestruct)
     {
         ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
         PoolManager.PoolNetworkDestroy(gameObject);
     }
 }
 public override void ObjectStateChange(ObjectState tState)
 {
     if (tState == ObjectState.InConstruction)
     {
         //TurnOffSupply();
         ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType);
         ControllingNode.Node.FlushSupplyAndUp(this.gameObject);
     }
 }
Beispiel #7
0
    //FIXME: Objects at runtime do not get destroyed. Instead they are returned back to pool
    //FIXME: that also renderers IDevice useless. Please reassess
    public void OnDestroy()
    {
//		ElectricalSynchronisation.StructureChangeReact = true;
//		ElectricalSynchronisation.ResistanceChange = true;
//		ElectricalSynchronisation.CurrentChange = true;
        ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
        SelfDestruct = true;
        //Make Invisible
    }
Beispiel #8
0
 public void PotentialDestroyed()
 {
     UpPotentialDestroyed();
     if (SelfDestruct)
     {
         ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
         Despawn.ServerSingle(gameObject);
     }
 }
Beispiel #9
0
    public void PowerNetworkUpdate()
    {
        powerSupply.PowerNetworkUpdate();
        ActualVoltage = powerSupply.ActualVoltage;

        BatteryCalculation.PowerNetworkUpdate(this);



        if (ChangeToOff)
        {
            ChangeToOff = false;
            //PassChangeToOff = true;
            //ElectricalSynchronisation.ResistanceChange = true;
            //ElectricalSynchronisation.CurrentChange = true;
            //powerSupply.TurnOffSupply();
            powerSupply.TurnOffSupply();
            BatteryCalculation.TurnOffEverything(this);
            ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
        }

        if (current != Previouscurrent)
        {
            if (Previouscurrent == 0 && !(current <= 0))
            {
                //
            }
            else if (current == 0 && !(Previouscurrent <= 0))
            {
                Logger.Log("FlushSupplyAndUp");
                powerSupply.FlushSupplyAndUp(powerSupply.gameObject);
                //powerSupply.TurnOffSupply();
            }
            powerSupply.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.CurrentChange = true;
        }

        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                powerSupply.CanProvideResistance = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                powerSupply.CanProvideResistance = false;
                ElectricityFunctions.CleanConnectedDevices(powerSupply);
            }

            powerSupply.PassedDownResistance = Resistance;
            PreviousResistance = Resistance;
            ElectricalSynchronisation.ResistanceChange = true;
            ElectricalSynchronisation.CurrentChange    = true;
        }
        Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }
Beispiel #10
0
 public override void PotentialDestroyed()
 {
     ElectricalSynchronisation.NUStructureChangeReact.Add(ControllingNode);
     ElectricalSynchronisation.ResistanceChange.Add(ControllingNode);
     ElectricalSynchronisation.NUCurrentChange.Add(ControllingNode);
     if (ControllingNode.SelfDestruct)
     {
         ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType);
         PoolManager.PoolNetworkDestroy(gameObject);
     }
 }
Beispiel #11
0
 public static void PowerUpdateStructureChangeReact(IElectricityIO Supply)
 {
     ElectricityFunctions.CircuitSearchLoop(Supply, Supply.GameObject().GetComponent <IProvidePower>());
     if (Supply.Data.ChangeToOff)
     {
         Supply.Data.ChangeToOff = false;
         TurnOffSupply(Supply);
         Supply.InData.ControllingDevice.TurnOffCleanup();
         ElectricalSynchronisation.RemoveSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype);
     }
 }
Beispiel #12
0
 public override void PotentialDestroyed()
 {
     ElectricalSynchronisation.NUStructureChangeReact.Add(ControllingNode);        //this is needed
     ElectricalSynchronisation.ResistanceChange.Add(ControllingNode);
     ElectricalSynchronisation.NUCurrentChange.Add(ControllingNode);
     if (ControllingNode.SelfDestruct)
     {
         ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType);
         Despawn.ServerSingle(gameObject);
     }
 }
 public void PowerNetworkUpdate()
 {
     powerSupply.PowerNetworkUpdate();
     if (current != Previouscurrent)
     {
         powerSupply.SupplyingCurrent = current;
         Previouscurrent = current;
         ElectricalSynchronisation.CurrentChange = true;
     }
     if (ChangeToOff)
     {
         ChangeToOff = false;
         Logger.Log("Turning off");
         ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
         ElectricalSynchronisation.CurrentChange = true;
         powerSupply.TurnOffSupply();
     }
 }
Beispiel #14
0
    public void PowerNetworkUpdate()
    {
        RelatedDevice.PowerNetworkUpdate();
        ActualVoltage = RelatedDevice.Data.ActualVoltage;
        BatteryCalculation.PowerNetworkUpdate(this);
        if (ChangeToOff)
        {
            ChangeToOff = false;
            RelatedDevice.TurnOffSupply();
            BatteryCalculation.TurnOffEverything(this);
            ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
        }

        if (current != Previouscurrent)
        {
            if (Previouscurrent == 0 && !(current <= 0))
            {
            }
            else if (current == 0 && !(Previouscurrent <= 0))
            {
                RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject);
            }
            RelatedDevice.Data.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.CurrentChange = true;
        }
        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                CanProvideResistance.Bool = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                CanProvideResistance.Bool = false;
                ElectricalDataCleanup.CleanConnectedDevices(RelatedDevice);
            }
            PreviousResistance = Resistance;
            ElectricalSynchronisation.ResistanceChange = true;
            ElectricalSynchronisation.CurrentChange    = true;
        }
        Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }
 public override void GoingOffStageServer(OffStageInfo info)
 {
     ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType);
     ControllingNode.Node.FlushSupplyAndUp(this.gameObject);
 }
Beispiel #16
0
 public void TurnOffCleanup()
 {
     BatteryCalculation.TurnOffEverything(this);
     ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
 }