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); } }
//Update the current State of the SMES (sprites and statistics) void UpdateState(bool _isOn) { isOn = _isOn; isOnForInterface = _isOn; if (isOn) { ElectricalSynchronisation.AddSupply(this, ApplianceType); ElectricalSynchronisation.StructureChangeReact = true; ElectricalSynchronisation.ResistanceChange = true; //Potential optimisation ElectricalSynchronisation.CurrentChange = true; Logger.Log("on"); OnOffIndicator.sprite = onlineSprite; chargeIndicator.gameObject.SetActive(true); statusIndicator.gameObject.SetActive(true); int chargeIndex = (currentCharge / 100) * 4; chargeIndicator.sprite = chargeIndicatorSprites [chargeIndex]; if (chargeIndex == 0) { statusIndicator.sprite = statusCriticalSprite; } else { statusIndicator.sprite = statusSupplySprite; } } else { Logger.Log("off"); ChangeToOff = true; OnOffIndicator.sprite = offlineSprite; chargeIndicator.gameObject.SetActive(false); statusIndicator.gameObject.SetActive(false); } }
void Update() { if (roundStartedServer && CustomNetworkManager.Instance._isServer) { ElectricalSynchronisation.DoUpdate(); } }
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 TurnOnSupply(IElectricityIO Supply) { ElectricalSynchronisation.AddSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype); ElectricalSynchronisation.NUStructureChangeReact.Add(Supply.InData.ControllingUpdate); ElectricalSynchronisation.NUResistanceChange.Add(Supply.InData.ControllingUpdate); ElectricalSynchronisation.NUCurrentChange.Add(Supply.InData.ControllingUpdate); }
public void PotentialDestroyed() { if (SelfDestruct) { ElectricalSynchronisation.RemoveSupply(this, powerSupply.InData.Categorytype); PoolManager.PoolNetworkDestroy(gameObject); } }
public static void TurnOnSupply(ModuleSupplyingDevice Supply) { Supply.ControllingNode.Node.Data.ChangeToOff = false; ElectricalSynchronisation.AddSupply(Supply.ControllingNode, Supply.ControllingNode.ApplianceType); ElectricalSynchronisation.NUStructureChangeReact.Add(Supply.ControllingNode); ElectricalSynchronisation.NUResistanceChange.Add(Supply.ControllingNode); ElectricalSynchronisation.NUCurrentChange.Add(Supply.ControllingNode); }
public void OnDestroy() { ElectricalSynchronisation.StructureChangeReact = true; ElectricalSynchronisation.ResistanceChange = true; ElectricalSynchronisation.CurrentChange = true; ElectricalSynchronisation.RemoveSupply(this, ApplianceType); //Then you can destroy }
public static void DirectionInput(GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire) { int SourceInstanceID = SourceInstance.GetInstanceID(); if (Thiswire.Data.FirstPresent == 0) { Thiswire.Data.FirstPresent = SourceInstanceID; } if (!(Thiswire.Data.Upstream.ContainsKey(SourceInstanceID))) { Thiswire.Data.Upstream[SourceInstanceID] = new HashSet <ElectricalOIinheritance>(); } if (!(Thiswire.Data.Downstream.ContainsKey(SourceInstanceID))) { Thiswire.Data.Downstream[SourceInstanceID] = new HashSet <ElectricalOIinheritance>(); } if (ComingFrom != null) { Thiswire.Data.Upstream[SourceInstanceID].Add(ComingFrom); } bool CanPass = true; if (Thiswire.InData.ConnectionReaction.ContainsKey(ComingFrom.InData.Categorytype)) { if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReaction) { ElectricalOIinheritance SourceInstancPowerSupply = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (SourceInstancPowerSupply != null) { if (!Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(SourceInstancPowerSupply)) { Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply] = new HashSet <PowerTypeCategory>(); } Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply].Add(ComingFrom.InData.Categorytype); SourceInstancPowerSupply.connectedDevices.Add(Thiswire); //Logger.Log(" add " + SourceInstance + " " + Thiswire); ElectricalSynchronisation.InitialiseResistanceChange.Add(Thiswire.InData.ControllingUpdate); } if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReactionA.YouShallNotPass) { CanPass = false; } } } if (CanPass) { if (Thiswire.Data.connections.Count > 2) { ElectricalSynchronisation.DirectionWorkOnNextListWaitADD(Thiswire); } else { ElectricalSynchronisation.DirectionWorkOnNextListADD(Thiswire); } } }
//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 }
public override void ObjectStateChange(ObjectState tState) { if (tState == ObjectState.InConstruction) { //TurnOffSupply(); ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType); ControllingNode.Node.FlushSupplyAndUp(this.gameObject); } }
public void PotentialDestroyed() { UpPotentialDestroyed(); if (SelfDestruct) { ElectricalSynchronisation.RemoveSupply(this, ApplianceType); Despawn.ServerSingle(gameObject); } }
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); }
public void PotentialDestroyed() { UpPotentialDestroyed(); if (SelfDestruct) { ElectricalSynchronisation.RemoveSupply(this, ApplianceType); PoolManager.PoolNetworkDestroy(gameObject); } }
public static void TurnOnSupply(ElectricalOIinheritance Supply) { Supply.Data.ChangeToOff = false; Supply.InData.ControllingDevice.isOnForInterface = true; ElectricalSynchronisation.AddSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype); ElectricalSynchronisation.NUStructureChangeReact.Add(Supply.InData.ControllingUpdate); ElectricalSynchronisation.NUResistanceChange.Add(Supply.InData.ControllingUpdate); ElectricalSynchronisation.NUCurrentChange.Add(Supply.InData.ControllingUpdate); }
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 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); } }
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); } }
public static void ResistanceInput(float Resistance, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire) { ElectricalOIinheritance IElec = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (ComingFrom == null) { if (Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(IElec)) { if (Thiswire.Data.ResistanceToConnectedDevices [IElec].Count > 1) { Logger.LogError("oh no!, problem!!!!"); } foreach (PowerTypeCategory ConnectionFrom in Thiswire.Data.ResistanceToConnectedDevices[IElec]) { Resistance = Thiswire.InData.ConnectionReaction[ConnectionFrom].ResistanceReactionA.Resistance.Ohms; //Logger.Log (Resistance.ToString () + " < to man Resistance | " + ConnectionFrom.ToString() + " < to man ConnectionFrom | " + Thiswire.GameObject().name + " < to man IS "); ComingFrom = ElectricalSynchronisation.DeadEnd; } } } if (ComingFrom != null | ElectricalSynchronisation.DeadEnd == ComingFrom) { int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Thiswire.Data.ResistanceComingFrom.ContainsKey(SourceInstanceID))) { Thiswire.Data.ResistanceComingFrom [SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float> (); } if (!(Thiswire.Data.ResistanceGoingTo.ContainsKey(SourceInstanceID))) { Thiswire.Data.ResistanceGoingTo[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>(); } if (Resistance == 0) { Thiswire.Data.ResistanceComingFrom [SourceInstanceID].Remove(ComingFrom); } else { Thiswire.Data.ResistanceComingFrom[SourceInstanceID][ComingFrom] = Resistance; } if (Thiswire.Data.connections.Count > 2) { KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> (IElec, Thiswire); ElectricalSynchronisation.ResistanceWorkOnNextListWaitADD(edd); } else { KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> (IElec, Thiswire); ElectricalSynchronisation.ResistanceWorkOnNextListADD(edd); } } }
public static void DirectionInput(GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire) { if (Thiswire.Data.connections.Count == 0) { Thiswire.FindPossibleConnections(); //plz don't remove it is necessary for preventing incomplete cleanups when there has been multiple } int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Thiswire.Data.SupplyDependent.ContainsKey(SourceInstanceID))) { Thiswire.Data.SupplyDependent[SourceInstanceID] = new ElectronicSupplyData(); } if (ComingFrom != null) { Thiswire.Data.SupplyDependent[SourceInstanceID].Upstream.Add(ComingFrom); } bool CanPass = true; if (Thiswire.InData.ConnectionReaction.ContainsKey(ComingFrom.InData.Categorytype)) { if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReaction || Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].ResistanceReaction) { ElectricalOIinheritance SourceInstancPowerSupply = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (SourceInstancPowerSupply != null) { if (!Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(SourceInstancPowerSupply)) { Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply] = new HashSet <PowerTypeCategory>(); } Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply].Add(ComingFrom.InData.Categorytype); SourceInstancPowerSupply.connectedDevices.Add(Thiswire); ElectricalSynchronisation.InitialiseResistanceChange.Add(Thiswire.InData.ControllingDevice); } if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReactionA.YouShallNotPass) { CanPass = false; } } } if (CanPass) { if (Thiswire.Data.connections.Count > 2) { ElectricalSynchronisation.DirectionWorkOnNextListWaitADD(Thiswire); } else { ElectricalSynchronisation.DirectionWorkOnNextListADD(Thiswire); } } }
public static void ResistanceInput(float Resistance, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire, int ComingFromOverride = 0) { ElectricalOIinheritance IElec = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (ComingFrom == null) { if (IElec != Thiswire) { if (Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(IElec)) { if (Thiswire.Data.ResistanceToConnectedDevices[IElec].Count > 1) { Logger.LogErrorFormat("{0} has too many resistance reactions specified.", Category.Electrical, Thiswire.ToString()); } foreach (PowerTypeCategory ConnectionFrom in Thiswire.Data.ResistanceToConnectedDevices[IElec]) { Resistance = Thiswire.InData.ConnectionReaction[ConnectionFrom].ResistanceReactionA.Resistance.Ohms; ComingFrom = ElectricalSynchronisation.DeadEnd; } } } else { return; } } if (ComingFrom != null | ElectricalSynchronisation.DeadEnd == ComingFrom) { int SourceInstanceID = SourceInstance.GetInstanceID(); ElectricalSynchronisation.InputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstanceID]; if (Resistance == 0) { ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom.Remove(ComingFrom); } else { ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom[ComingFrom] = Resistance; } if (Thiswire.Data.connections.Count > 2) { KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance>(IElec, Thiswire); ElectricalSynchronisation.ResistanceWorkOnNextListWaitADD(edd); } else { KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance>(IElec, Thiswire); ElectricalSynchronisation.ResistanceWorkOnNextListADD(edd); } } }
void UpdateState(bool _isOn) { isOn = _isOn; if (isOn) { ElectricalSynchronisation.AddSupply(this, ApplianceType); ElectricalSynchronisation.StructureChangeReact = true; ElectricalSynchronisation.ResistanceChange = true; ElectricalSynchronisation.CurrentChange = true; powerSupply.TurnOnSupply(); Logger.Log("on"); } else { Logger.Log("off"); ChangeToOff = true; } }
void UpdateState(bool _isOn) { isOn = _isOn; isOnForInterface = _isOn; if (isOn) { ElectricalSynchronisation.AddSupply(this, ApplianceType); ElectricalSynchronisation.StructureChangeReact = true; ElectricalSynchronisation.ResistanceChange = true; //Potential optimisation ElectricalSynchronisation.CurrentChange = true; Logger.Log("on"); } else { Logger.Log("off"); ChangeToOff = true; } }
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(); } }
//Update the current State of the SMES (sprites and statistics) void UpdateState(bool _isOn) { isOn = _isOn; isOnForInterface = _isOn; if (isOn) { ElectricalSynchronisation.AddSupply(this, ApplianceType); ElectricalSynchronisation.StructureChangeReact = true; ElectricalSynchronisation.ResistanceChange = true; //Potential optimisation ElectricalSynchronisation.CurrentChange = true; // Resistance = (1000/((StandardChargeNumber * ChargingMultiplier)/1000)); // powerSupply.PassedDownResistance = Resistance; // powerSupply.CanProvideResistance = true; //powerSupply.TurnOnSupply (0); //Test supply of 3000volts and 20amps, lol yeah Logger.Log("on"); OnOffIndicator.sprite = onlineSprite; chargeIndicator.gameObject.SetActive(true); statusIndicator.gameObject.SetActive(true); int chargeIndex = (currentCharge / 100) * 4; chargeIndicator.sprite = chargeIndicatorSprites [chargeIndex]; if (chargeIndex == 0) { statusIndicator.sprite = statusCriticalSprite; } else { statusIndicator.sprite = statusSupplySprite; } } else { Logger.Log("off"); ChangeToOff = true; OnOffIndicator.sprite = offlineSprite; chargeIndicator.gameObject.SetActive(false); statusIndicator.gameObject.SetActive(false); } }
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); }
void OnRoundEnd() { roundStartedServer = false; ElectricalSynchronisation.Reset(); Logger.Log("Round Ended", Category.Electrical); }
public override void GoingOffStageServer(OffStageInfo info) { ElectricalSynchronisation.RemoveSupply(ControllingNode, ControllingNode.ApplianceType); ControllingNode.Node.FlushSupplyAndUp(this.gameObject); }
public void TurnOffCleanup() { BatteryCalculation.TurnOffEverything(this); ElectricalSynchronisation.RemoveSupply(this, ApplianceType); }
public static void PowerUpdateStructureChangeReact(ElectricalOIinheritance Supply) { ElectricalSynchronisation.CircuitSearchLoop(Supply); }