/// <summary>
    /// Sends updates to things that might need it
    /// </summary>
    private static void PowerNetworkUpdate()
    {
//		Profiler.BeginSample("PowerNetworkUpdate");
        for (int i = 0; i < OrderList.Count; i++)
        {
            foreach (ElectricalNodeControl TheSupply in AliveSupplies[OrderList[i]])
            {
                TheSupply.PowerNetworkUpdate();
            }
        }

        foreach (ElectricalNodeControl ToWork in PoweredDevices)
        {
            ToWork.PowerNetworkUpdate();
        }

        WorkingCableUpdates = new HashSet <CableInheritance>(CableUpdates);
        CableUpdates.Clear();
        foreach (CableInheritance ToWork in WorkingCableUpdates)
        {
            ToWork.PowerNetworkUpdate();             //This is used to update the cables  if they have the current change to detect if there was an overcurrent
        }

        WorkingCableUpdates.Clear();
        if (CableToDestroy != null)
        {
            CableToDestroy.toDestroy();
            CableToDestroy = null;
        }

//		Profiler.EndSample();
    }
    public override void OnInspectorGUI()
    {
        CableInheritance sTarget = (CableInheritance)target;

        startCache = sTarget.WireEndB;
        endCache   = sTarget.WireEndA;

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.HelpBox(
            "yeah Enum are Great, The order is done by clockwise starting at north then going to middle then machine connect", MessageType.Info);
        sTarget.WireEndB = (Connection)EditorGUILayout.EnumPopup(sTarget.WireEndB);

        EditorGUILayout.HelpBox(
            "yeah Enum are Great, The order is done by clockwise starting at north then going to middle then machine connect", MessageType.Info);

        sTarget.WireEndA = (Connection)EditorGUILayout.EnumPopup(sTarget.WireEndA);

        sTarget.CableType = (WiringColor)EditorGUILayout.EnumPopup("Wiring Color: ", sTarget.CableType);

        if (EditorGUI.EndChangeCheck())
        {
            try
            {
                sTarget.SetDirection(sTarget.WireEndB, sTarget.WireEndA, sTarget.CableType);
                showError = false;
                PrefabUtility.RecordPrefabInstancePropertyModifications(sTarget);
            }
            catch
            {
                msgTime   = 0f;
                showError = true;
                //sTarget.WireEndB = startCache;
                //sTarget.WireEndA = endCache;
            }
        }

        if (showError)
        {
            msgTime += Time.deltaTime;
            if (msgTime > 3f)
            {
                showError = false;
                msgTime   = 0f;
            }
            EditorGUILayout.HelpBox("Incorrect start and end combination", MessageType.Error);
        }
        SerializedProperty TRay = serializedObject.FindProperty("TRay");

        EditorGUILayout.PropertyField(TRay, true);

        EditorGUILayout.HelpBox(
            "TODO: Create a specific component to handle wiring changes\r\n" + "via the map editor. Do this by inheriting the component from\r\n" +
            "SpriteRotate.cs", MessageType.Warning);
    }
    /// <summary>
    /// Sends updates to things that might need it
    /// </summary>
    public void PowerNetworkUpdate()
    {
        //Logger.Log("PowerNetworkUpdate");
        for (int i = 0; i < SupplyToadd.Count; i++)
        {
            InternalAddSupply(SupplyToadd[i]);
        }

        SupplyToadd.Clear();

        for (int i = 0; i < OrderList.Count; i++)
        {
            foreach (ElectricalNodeControl TheSupply in AliveSupplies[OrderList[i]])
            {
                TheSupply.PowerNetworkUpdate();
            }
        }

        foreach (ElectricalNodeControl ToWork in PoweredDevices)
        {
            ToWork.PowerNetworkUpdate();
        }

        foreach (CableInheritance ToWork in CableUpdates)
        {
            ToWork.PowerNetworkUpdate();
        }

        CableUpdates.Clear();


        if (CableToDestroy != null)
        {
            CableToDestroy.wireConnect.DestroyThisPlease();
            CableToDestroy = null;
        }

        //Structure change and stuff
        foreach (var Thing in NUElectricalObjectsToDestroy)
        {
            Thing.DestroyingThisNow();
        }

        NUElectricalObjectsToDestroy.Clear();
    }
Пример #4
0
 public void QueueForDemolition(CableInheritance CableToDestroy)
 {
     Sparks.Play();
     DestructionPriority = wireConnect.Data.CurrentInWire * MaximumBreakdownCurrent;
     if (ElectricalSynchronisation.CableToDestroy != null)
     {
         if (DestructionPriority > ElectricalSynchronisation.CableToDestroy.DestructionPriority)
         {
             ElectricalSynchronisation.CableUpdates.Add(ElectricalSynchronisation.CableToDestroy);
             ElectricalSynchronisation.CableToDestroy = this;
         }
         else
         {
             ElectricalSynchronisation.CableUpdates.Add(this);
         }
     }
     else
     {
         ElectricalSynchronisation.CableToDestroy = this;
     }
 }
Пример #5
0
        /// <summary>
        /// Sends updates to things that might need it
        /// </summary>
        public void PowerNetworkUpdate()
        {
            foreach (var categoryHashset in AliveSupplies)
            {
                foreach (var supply in categoryHashset.Value)
                {
                    supply.PowerNetworkUpdate();
                }
            }

            foreach (var device in PoweredDevices)
            {
                device.PowerNetworkUpdate();
            }

            foreach (var device in CableUpdates)
            {
                device.PowerNetworkUpdate();
            }

            CableUpdates.Clear();


            if (CableToDestroy != null)
            {
                CableToDestroy.wireConnect.DestroyThisPlease();
                CableToDestroy = null;
            }

            // Structure change and stuff
            foreach (var device in NUElectricalObjectsToDestroy)
            {
                device.DestroyingThisNow();
            }

            NUElectricalObjectsToDestroy.Clear();
        }
Пример #6
0
    public void QueueForDemolition(CableInheritance CableToDestroy)
    {
        var sync = ElectricalManager.Instance.electricalSync;

        DestructionPriority = wireConnect.InData.Data.CurrentInWire * MaximumBreakdownCurrent;
        if (sync.CableToDestroy != null)
        {
            if (DestructionPriority >= sync.CableToDestroy.DestructionPriority)
            {
                sync.CableToDestroy.Smoke.Stop();
                sync.CableToDestroy.Sparks.Stop();
                sync.CableUpdates.Add(sync.CableToDestroy);
                sync.CableToDestroy = this;
            }
            else
            {
                sync.CableUpdates.Add(this);
            }
        }
        else
        {
            sync.CableToDestroy = this;
        }
    }