private void TeslaCoilUpdate()
        {
            if (CustomNetworkManager.IsServer == false)
            {
                return;
            }

            if (CurrentState == TeslaCoilState.Grounding || IsWrenched == false)
            {
                return;
            }

            hitTimer--;

            if (hitTimer <= 0)
            {
                hitTimer    = 0;
                hitRecently = false;

                if (generatedWatts != 0)
                {
                    moduleSupplyingDevice.TurnOffSupply();
                }
            }
            else
            {
                if (generatedWatts == 0)
                {
                    moduleSupplyingDevice.TurnOnSupply();
                }

                hitRecently = true;
            }

            if (CurrentState == TeslaCoilState.Power)
            {
                generatedWatts = hitRecently ? lightningHitWatts : 0;

                moduleSupplyingDevice.ProducingWatts = generatedWatts;

                if (hitRecently == false)
                {
                    spriteHandler.ChangeSprite(1);
                }
            }
            else
            {
                //TODO generate research points
                generatedWatts = 0;

                if (hitRecently == false)
                {
                    spriteHandler.ChangeSprite(3);
                }
            }
        }
Exemple #2
0
        private void OnEnable()
        {
            if (CustomNetworkManager.Instance._isServer == false)
            {
                return;
            }

            UpdateManager.Add(CycleUpdate, 1);
            //moduleSupplyingDevice = this.GetComponent<ModuleSupplyingDevice>();
            moduleSupplyingDevice?.TurnOnSupply();
        }