コード例 #1
0
        void AddSwitch(AutoTurret aturret)
        {
            ElectricBattery bat = null;

            if (IsBatEnabled())
            {
                bat = AddBattery(aturret.GetParentEntity() as MiniCopter);
            }

            ElectricSwitch aSwitch = aturret.GetComponentInChildren <ElectricSwitch>();

            aSwitch = GameManager.server.CreateEntity(switchPrefab, aturret.transform.position)?.GetComponent <ElectricSwitch>();
            if (aSwitch == null)
            {
                return;
            }
            aSwitch.pickup.enabled = false;
            aSwitch.SetParent(aturret);
            aSwitch.transform.localPosition = new Vector3(0f, -0.65f, 0.325f);
            aSwitch.transform.localRotation = Quaternion.Euler(0, 0, 0);
            DestroyMeshCollider(aSwitch);
            DestroyGroundComp(aSwitch);
            aSwitch.Spawn();
            aSwitch._limitedNetworking = false;
            if (!IsBatEnabled())
            {
                RunWire(aSwitch, 0, aturret, 0, 12);
            }
            else if (bat != null)
            {
                RunWire(bat, 0, aSwitch, 0);
                RunWire(aSwitch, 0, aturret, 0);
            }
        }
コード例 #2
0
        private void RefreshDroneTurret(Drone drone, AutoTurret turret)
        {
            var sphereEntity = turret.GetParentEntity() as SphereEntity;

            if (sphereEntity == null)
            {
                return;
            }

            SetupSphereEntity(sphereEntity);
            SetupDroneTurret(drone, turret, sphereEntity);

            var electricSwitch = turret.GetComponentInChildren <ElectricSwitch>();

            if (electricSwitch != null)
            {
                SetupTurretSwitch(electricSwitch);
            }
        }