Example #1
0
        public override void OnStart(PartModule.StartState state)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                part.force_activate();

                aimerTexture = BDArmorySettings.Instance.greenPointCircleTexture;                // GameDatabase.Instance.GetTexture("BDArmory/Textures/grayCircle", false);

                sfAudioSource              = gameObject.AddComponent <AudioSource>();
                sfAudioSource.minDistance  = 1;
                sfAudioSource.maxDistance  = 2000;
                sfAudioSource.dopplerLevel = 0;
                sfAudioSource.priority     = 230;
                sfAudioSource.spatialBlend = 1;

                MakeRocketArray();
                UpdateRocketScales();

                if (shortName == string.Empty)
                {
                    shortName = part.partInfo.title;
                }

                UpdateAudio();
                BDArmorySettings.OnVolumeChange += UpdateAudio;
            }

            if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
            {
                foreach (var turr in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (turr.turretID == turretID)
                    {
                        turret             = turr;
                        targetInTurretView = false;
                        break;
                    }
                }

                if (turret)
                {
                    Events["GuiFire"].guiActive  = false;
                    Events["Jettison"].guiActive = false;
                    Actions["AGFire"].active     = false;

                    if (HighLogic.LoadedSceneIsFlight)
                    {
                        Events["ToggleTurret"].guiActive = true;
                    }
                }

                if (!string.IsNullOrEmpty(deployAnimationName))
                {
                    deployAnimState    = Misc.SetUpSingleAnimation(deployAnimationName, part);
                    hasDeployAnimation = true;

                    readyToFire = false;
                }
            }
        }
Example #2
0
        public override void OnStart(PartModule.StartState state)
        {
            // extension for feature_engagementenvelope
            InitializeEngagementRange(0, maxTargetingRange);

            if (HighLogic.LoadedSceneIsFlight)
            {
                part.force_activate();

                aimerTexture = BDArmorySettings.Instance.greenPointCircleTexture;
                // GameDatabase.Instance.GetTexture("BDArmory/Textures/grayCircle", false);


                MakeRocketArray();
                UpdateRocketScales();

                if (shortName == string.Empty)
                {
                    shortName = part.partInfo.title;
                }

                UpdateAudio();
                BDArmorySettings.OnVolumeChange += UpdateAudio;
            }

            if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
            {
                foreach (var turr in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (turr.turretID == turretID)
                    {
                        turret             = turr;
                        targetInTurretView = false;
                        break;
                    }
                }

                if (turret)
                {
                    Events["GuiFire"].guiActive  = false;
                    Events["Jettison"].guiActive = false;
                    Actions["AGFire"].active     = false;

                    if (HighLogic.LoadedSceneIsFlight)
                    {
                        Events["ToggleTurret"].guiActive = true;
                    }
                }

                if (!string.IsNullOrEmpty(deployAnimationName))
                {
                    deployAnimState    = Misc.SetUpSingleAnimation(deployAnimationName, part);
                    hasDeployAnimation = true;

                    readyToFire = false;
                }
            }
            SetupAudio();
        }
Example #3
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            part.force_activate();

            //setup anim
            if (!string.IsNullOrEmpty(deployAnimationName))
            {
                hasDeployAnimation = true;
                deployAnimState    = Misc.SetUpSingleAnimation(deployAnimationName, part);
                if (state == StartState.Editor)
                {
                    Events["EditorToggleAnimation"].guiActiveEditor = true;
                }
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                foreach (var tur in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (tur.turretID == turretID)
                    {
                        turret = tur;
                        break;
                    }
                }

                attachedRadar = part.FindModuleImplementing <ModuleRadar>();
                if (attachedRadar)
                {
                    hasAttachedRadar = true;
                }

                finalTransform = part.FindModelTransform(finalTransformName);

                UpdateMissileChildren();

                if (!autoReturn)
                {
                    Events["ReturnTurret"].guiActive = true;
                }
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            if(HighLogic.LoadedSceneIsFlight)
            {
                part.force_activate();

                aimerTexture = BDArmorySettings.Instance.greenPointCircleTexture;// GameDatabase.Instance.GetTexture("BDArmory/Textures/grayCircle", false);

                MakeRocketArray();
                UpdateRocketScales();

                if (shortName == string.Empty)
                {
                    shortName = part.partInfo.title;
                }

                UpdateAudio();
                BDArmorySettings.OnVolumeChange += UpdateAudio;

            }

            if(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
            {
                foreach(var turr in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(turr.turretID == turretID)
                    {
                        turret = turr;
                        targetInTurretView = false;
                        break;
                    }
                }

                if(turret)
                {
                    Events["GuiFire"].guiActive = false;
                    Events["Jettison"].guiActive = false;
                    Actions["AGFire"].active = false;

                    if(HighLogic.LoadedSceneIsFlight)
                    {
                        Events["ToggleTurret"].guiActive = true;
                    }
                }

                if(!string.IsNullOrEmpty(deployAnimationName))
                {
                    deployAnimState = Misc.SetUpSingleAnimation(deployAnimationName, part);
                    hasDeployAnimation = true;

                    readyToFire = false;
                }
            }
            SetupAudio();
        }
Example #5
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (HighLogic.LoadedSceneIsFlight)
            {
                myVesselID = vessel.id.ToString();
                RadarUtils.SetupRadarCamera();

                if (string.IsNullOrEmpty(radarName))
                {
                    radarName = part.partInfo.title;
                }

                linkedToVessels = new List <VesselRadarData>();


                //rIncrements = Misc.ParseToFloatArray(rangeIncrements);
                //rangeIndex = Mathf.Clamp(rangeIndex, 0, rIncrements.Length-1);
                //maxRange = rIncrements[rIncrements.Length-1];
                signalPersistTime = omnidirectional
                    ? 360 / (scanRotationSpeed + 5)
                    : directionalFieldOfView / (scanRotationSpeed + 5);

                if (rotationTransformName != string.Empty)
                {
                    rotationTransform = part.FindModelTransform(rotationTransformName);
                }


                //lockedTarget = TargetSignatureData.noTarget;


                attemptedLocks = new TargetSignatureData[3];
                TargetSignatureData.ResetTSDArray(ref attemptedLocks);

                lockedTargets = new List <TargetSignatureData>();

                referenceTransform               = (new GameObject()).transform;
                referenceTransform.parent        = transform;
                referenceTransform.localPosition = Vector3.zero;

                foreach (var tur in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (tur.turretID == turretID)
                    {
                        lockingTurret = tur;
                        break;
                    }
                }

                rwrType = (RadarWarningReceiver.RWRThreatTypes)rwrThreatType;


                foreach (var wm in vessel.FindPartModulesImplementing <MissileFire>())
                {
                    wm.radars.Add(this);
                }

                GameEvents.onVesselGoOnRails.Add(OnGoOnRails);


                EnsureVesselRadarData();

                StartCoroutine(StartUpRoutine());
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                foreach (var tur in part.FindModulesImplementing <ModuleTurret>())
                {
                    if (tur.turretID == turretID)
                    {
                        lockingTurret = tur;
                        break;
                    }
                }

                if (lockingTurret)
                {
                    lockingTurret.Fields["minPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["maxPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["yawRange"].guiActiveEditor = false;
                }
            }
        }
Example #6
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            ParseWeaponType();

            if(shortName == string.Empty)
            {
                shortName = part.partInfo.title;
            }

            if(!airDetonation)
            {
                Fields["defaultDetonationRange"].guiActive = false;
                Fields["defaultDetonationRange"].guiActiveEditor = false;
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                if(eWeaponType!=WeaponTypes.Laser)
                {
                    if(bulletPool == null)
                    {
                        SetupBulletPool();
                    }
                    if(shellPool == null)
                    {
                        SetupShellPool();
                    }
                }

                //setup transforms
                fireTransforms = part.FindModelTransforms(fireTransformName);
                shellEjectTransforms = part.FindModelTransforms(shellEjectTransformName);

                //setup emitters
                foreach(var pe in part.FindModelComponents<KSPParticleEmitter>())
                {
                    pe.maxSize *= part.rescaleFactor;
                    pe.minSize *= part.rescaleFactor;
                    pe.shape3D *= part.rescaleFactor;
                    pe.shape2D *= part.rescaleFactor;
                    pe.shape1D *= part.rescaleFactor;

                    if(pe.useWorldSpace && !oneShotWorldParticles)
                    {
                        BDAGaplessParticleEmitter gpe = pe.gameObject.AddComponent<BDAGaplessParticleEmitter>();
                        gpe.part = part;
                        gaplessEmitters.Add(gpe);
                    }
                }

                //setup projectile colors
                projectileColorC = Misc.ParseColor255(projectileColor);
                startColorC = Misc.ParseColor255(startColor);

                //init and zero points
                targetPosition = Vector3.zero;
                pointingAtPosition = Vector3.zero;
                bulletPrediction = Vector3.zero;

                //setup audio
                SetupAudio();

                //laser setup
                if(eWeaponType == WeaponTypes.Laser)
                {
                    SetupLaserSpecifics();
                }

            }

            //turret setup
            turret = part.FindModuleImplementing<ModuleTurret>();
            if(!turret)
            {
                Fields["onlyFireInRange"].guiActive = false;
                Fields["onlyFireInRange"].guiActiveEditor = false;
            }

            //setup animations
            if(hasDeployAnim)
            {
                deployState = Misc.SetUpSingleAnimation(deployAnimName, this.part);
                deployState.normalizedTime = 0;
                deployState.speed = 0;
                deployState.enabled = true;
            }
            if(hasFireAnimation)
            {
                fireState = Misc.SetUpSingleAnimation (fireAnimName, this.part);
                fireState.enabled = false;
            }

            BDArmorySettings.OnVolumeChange += UpdateVolume;
        }
Example #7
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            ParseWeaponType();
            ParseBulletDragType();

            bulletBallisticCoefficient = bulletMass / bulletDragArea * 1000;        //1000 to convert from tonnes to kilograms

            if(shortName == string.Empty)
            {
                shortName = part.partInfo.title;
            }

            foreach(var emitter in part.FindModelComponents<KSPParticleEmitter>())
            {
                emitter.emit = false;
            }

            if(roundsPerMinute >= 1500)
            {
                Events["ToggleRipple"].guiActiveEditor = false;
                Fields["useRippleFire"].guiActiveEditor = false;
            }

            if(airDetonation)
            {
                var detRange = (UI_FloatRange)Fields["defaultDetonationRange"].uiControlEditor;
                detRange.maxValue = maxAirDetonationRange;
            }
            else
            {
                Fields["defaultDetonationRange"].guiActive = false;
                Fields["defaultDetonationRange"].guiActiveEditor = false;
            }

            muzzleFlashEmitters = new List<KSPParticleEmitter>();
            foreach(Transform mtf in part.FindModelTransforms("muzzleTransform"))
            {
                KSPParticleEmitter kpe = mtf.GetComponent<KSPParticleEmitter>();
                muzzleFlashEmitters.Add(kpe);
                kpe.emit = false;
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                if(eWeaponType != WeaponTypes.Laser)
                {
                    if(bulletPool == null)
                    {
                        SetupBulletPool();
                    }
                    if(shellPool == null)
                    {
                        SetupShellPool();
                    }
                }

                //setup transforms
                fireTransforms = part.FindModelTransforms(fireTransformName);
                shellEjectTransforms = part.FindModelTransforms(shellEjectTransformName);

                //setup emitters
                foreach(var pe in part.FindModelComponents<KSPParticleEmitter>())
                {
                    pe.maxSize *= part.rescaleFactor;
                    pe.minSize *= part.rescaleFactor;
                    pe.shape3D *= part.rescaleFactor;
                    pe.shape2D *= part.rescaleFactor;
                    pe.shape1D *= part.rescaleFactor;

                    if(pe.useWorldSpace && !oneShotWorldParticles)
                    {
                        BDAGaplessParticleEmitter gpe = pe.gameObject.AddComponent<BDAGaplessParticleEmitter>();
                        gpe.part = part;
                        gaplessEmitters.Add(gpe);
                    }
                }

                //setup projectile colors
                projectileColorC = Misc.ParseColor255(projectileColor);
                startColorC = Misc.ParseColor255(startColor);

                //init and zero points
                targetPosition = Vector3.zero;
                pointingAtPosition = Vector3.zero;
                bulletPrediction = Vector3.zero;

                //setup audio
                SetupAudio();

                //laser setup
                if(eWeaponType == WeaponTypes.Laser)
                {
                    SetupLaserSpecifics();
                }
            }
            else if(HighLogic.LoadedSceneIsEditor)
            {
                fireTransforms = part.FindModelTransforms(fireTransformName);
            }

            //turret setup
            foreach(var turr in part.FindModulesImplementing<ModuleTurret>())
            {
                if(turr.turretID == turretID)
                {
                    turret = turr;
                    turret.SetReferenceTransform(fireTransforms[0]);
                    break;
                }
            }

            if(!turret)
            {
                Fields["onlyFireInRange"].guiActive = false;
                Fields["onlyFireInRange"].guiActiveEditor = false;
            }

            //setup animations
            if(hasDeployAnim)
            {
                deployState = Misc.SetUpSingleAnimation(deployAnimName, this.part);
                deployState.normalizedTime = 0;
                deployState.speed = 0;
                deployState.enabled = true;
            }
            if(hasFireAnimation)
            {
                fireState = Misc.SetUpSingleAnimation (fireAnimName, this.part);
                fireState.enabled = false;
            }
            bulletInfo = BulletInfo.bullets[bulletType];
            if (bulletInfo == null)
                Debug.Log("Failed To load bullet!");
            BDArmorySettings.OnVolumeChange += UpdateVolume;
        }
Example #8
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            if(HighLogic.LoadedSceneIsFlight)
            {
                myVesselID = vessel.id.ToString();
                RadarUtils.SetupRadarCamera();

                if(string.IsNullOrEmpty(radarName))
                {
                    radarName = part.partInfo.title;
                }

                linkedToVessels = new List<VesselRadarData>();

                //rIncrements = Misc.ParseToFloatArray(rangeIncrements);
                //rangeIndex = Mathf.Clamp(rangeIndex, 0, rIncrements.Length-1);
                //maxRange = rIncrements[rIncrements.Length-1];
                signalPersistTime = omnidirectional ? 360/(scanRotationSpeed+5) : directionalFieldOfView/(scanRotationSpeed+5);

                if(rotationTransformName!=string.Empty)
                {
                    rotationTransform = part.FindModelTransform(rotationTransformName);
                }

                //lockedTarget = TargetSignatureData.noTarget;

                attemptedLocks = new TargetSignatureData[3];
                TargetSignatureData.ResetTSDArray(ref attemptedLocks);

                lockedTargets = new List<TargetSignatureData>();

                referenceTransform = (new GameObject()).transform;
                referenceTransform.parent = transform;
                referenceTransform.localPosition = Vector3.zero;

                foreach(var tur in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(tur.turretID == turretID)
                    {
                        lockingTurret = tur;
                        break;
                    }
                }

                rwrType = (RadarWarningReceiver.RWRThreatTypes) rwrThreatType;

                foreach(var wm in vessel.FindPartModulesImplementing<MissileFire>())
                {
                    wm.radars.Add(this);
                }

                GameEvents.onVesselGoOnRails.Add(OnGoOnRails);

                EnsureVesselRadarData();

                StartCoroutine(StartUpRoutine());
            }

            if(HighLogic.LoadedSceneIsEditor)
            {
                foreach(var tur in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(tur.turretID == turretID)
                    {
                        lockingTurret = tur;
                        break;
                    }
                }

                if(lockingTurret)
                {
                    lockingTurret.Fields["minPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["maxPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["yawRange"].guiActiveEditor = false;
                }
            }
        }
Example #9
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            part.force_activate();

            //setup anim
            if(!string.IsNullOrEmpty(deployAnimationName))
            {
                hasDeployAnimation = true;
                deployAnimState = Misc.SetUpSingleAnimation(deployAnimationName, part);
                if(state == StartState.Editor)
                {
                    Events["EditorToggleAnimation"].guiActiveEditor = true;
                }
            }

            if(HighLogic.LoadedSceneIsFlight)
            {
                foreach(var tur in part.FindModulesImplementing<ModuleTurret>())
                {
                    if(tur.turretID == turretID)
                    {
                        turret = tur;
                        break;
                    }
                }

                attachedRadar = part.FindModuleImplementing<ModuleRadar>();
                if(attachedRadar) hasAttachedRadar = true;

                finalTransform = part.FindModelTransform(finalTransformName);

                UpdateMissileChildren();

                if(!autoReturn)
                {
                    Events["ReturnTurret"].guiActive = true;
                }
            }
        }
Example #10
0
        public override void OnStart(StartState state)
        {
            base.OnStart (state);

            if(HighLogic.LoadedSceneIsFlight)
            {
                RadarUtils.SetupRadarCamera();

                distanceStyle = new GUIStyle();
                distanceStyle.normal.textColor = new Color(0,1,0,0.75f);
                distanceStyle.alignment = TextAnchor.UpperLeft;

                lockStyle = new GUIStyle();
                lockStyle.normal.textColor = new Color(0,1,0,0.75f);
                lockStyle.alignment = TextAnchor.LowerCenter;
                lockStyle.fontSize = 16;

                radarTopStyle = new GUIStyle();
                radarTopStyle.normal.textColor = new Color(0, 1, 0, 0.65f);
                radarTopStyle.alignment = TextAnchor.UpperCenter;
                radarTopStyle.fontSize = 12;

                rIncrements = Misc.ParseToFloatArray(rangeIncrements);
                rangeIndex = Mathf.Clamp(rangeIndex, 0, rIncrements.Length-1);
                maxRange = rIncrements[rIncrements.Length-1];
                signalPersistTime = omnidirectional ? 360/(scanRotationSpeed+5) : directionalFieldOfView/(scanRotationSpeed+5);

                if(rotationTransformName!=string.Empty)
                {
                    rotationTransform = part.FindModelTransform(rotationTransformName);
                }

                if(!radarRectInitialized)
                {
                    float width = radarScreenSize + (2*windowBorder);
                    float height = radarScreenSize + (2*windowBorder) + headerHeight + controlsHeight;
                    radarWindowRect = new Rect(Screen.width - width, Screen.height - height, width, height);
                    radarRectInitialized = true;
                }

                lockedTarget = TargetSignatureData.noTarget;

                contacts = new TargetSignatureData[10];
                TargetSignatureData.ResetTSDArray(ref contacts);

                attemptedLocks = new TargetSignatureData[3];
                TargetSignatureData.ResetTSDArray(ref attemptedLocks);

                referenceTransform = (new GameObject()).transform;
                referenceTransform.parent = transform;
                referenceTransform.localPosition = Vector3.zero;

                lockingTurret = part.FindModuleImplementing<ModuleTurret> ();

                rwrType = (RadarWarningReceiver.RWRThreatTypes) rwrThreatType;

                unlinkNullRadar = false;

                foreach(var wm in vessel.FindPartModulesImplementing<MissileFire>())
                {
                    wm.radars.Add(this);
                }

                StartCoroutine(StartUpRoutine());

            }
        }
Example #11
0
		bool TargetInTurretRange(ModuleTurret turret, float tolerance)
		{
			if(!turret)
			{
				return false;
			}

			if(!guardTarget)
			{
				if(BDArmorySettings.DRAW_DEBUG_LABELS)
				{
					Debug.Log("Checking turret range but no guard target");
				}
				return false;
			}
			if(turret.yawRange == 360)
			{
				if(BDArmorySettings.DRAW_DEBUG_LABELS)
				{
					Debug.Log("Checking turret range - turret has full swivel");
				}
				return true;
			}

			Transform turretTransform = turret.yawTransform.parent;
			Vector3 direction = guardTarget.transform.position-turretTransform.position;
			Vector3 directionYaw = Vector3.ProjectOnPlane(direction, turretTransform.up);
			Vector3 directionPitch = Vector3.ProjectOnPlane(direction, turretTransform.right);

			float angleYaw = Vector3.Angle(turretTransform.forward, directionYaw);
			//float anglePitch = Vector3.Angle(-turret.transform.forward, directionPitch);
			float signedAnglePitch = Misc.SignedAngle(turretTransform.forward, directionPitch, turretTransform.up);
			if(Mathf.Abs(signedAnglePitch) > 90)
			{
				signedAnglePitch -= Mathf.Sign(signedAnglePitch)*180;
			}
			bool withinPitchRange = (signedAnglePitch > turret.minPitch && signedAnglePitch < turret.maxPitch);

			if(angleYaw < (turret.yawRange/2)+tolerance && withinPitchRange)
			{
				if(BDArmorySettings.DRAW_DEBUG_LABELS)
				{
					Debug.Log("Checking turret range - target is INSIDE gimbal limits! signedAnglePitch: " + signedAnglePitch + ", minPitch: " + turret.minPitch + ", maxPitch: " + turret.maxPitch);
				}
				return true;
			}
			else
			{
				if(BDArmorySettings.DRAW_DEBUG_LABELS)
				{
					Debug.Log("Checking turret range - target is OUTSIDE gimbal limits! signedAnglePitch: " + signedAnglePitch + ", minPitch: " + turret.minPitch + ", maxPitch: " + turret.maxPitch + ", angleYaw: " + angleYaw);
				}
				return false;
			}
		}
Example #12
0
		public override void OnStart (StartState state)
		{
			base.OnStart (state);

			ParseWeaponType();
            ParseBulletDragType();

            bulletBallisticCoefficient = bulletMass / bulletDragArea * 1000;        //1000 to convert from tonnes to kilograms

			if(shortName == string.Empty)
			{
				shortName = part.partInfo.title;
			}

			foreach(var emitter in part.FindModelComponents<KSPParticleEmitter>())
			{
				emitter.emit = false;
			}

			if(airDetonation)
			{
				var detRange = (UI_FloatRange)Fields["defaultDetonationRange"].uiControlEditor;
				detRange.maxValue = maxAirDetonationRange;
			}
			else
			{
				Fields["defaultDetonationRange"].guiActive = false;
				Fields["defaultDetonationRange"].guiActiveEditor = false;
			}

			if(HighLogic.LoadedSceneIsFlight)
			{
				if(eWeaponType != WeaponTypes.Laser)
				{
					if(bulletPool == null)
					{
						SetupBulletPool();
					}
					if(shellPool == null)
					{
						SetupShellPool();
					}
				}

				//setup transforms
				fireTransforms = part.FindModelTransforms(fireTransformName);
				shellEjectTransforms = part.FindModelTransforms(shellEjectTransformName);

				//setup emitters
				foreach(var pe in part.FindModelComponents<KSPParticleEmitter>())
				{
					pe.maxSize *= part.rescaleFactor;
					pe.minSize *= part.rescaleFactor;
					pe.shape3D *= part.rescaleFactor;
					pe.shape2D *= part.rescaleFactor;
					pe.shape1D *= part.rescaleFactor;

					if(pe.useWorldSpace && !oneShotWorldParticles)
					{
						BDAGaplessParticleEmitter gpe = pe.gameObject.AddComponent<BDAGaplessParticleEmitter>();	
						gpe.part = part;
						gaplessEmitters.Add(gpe);
					}
				}

				
				//setup projectile colors
				projectileColorC = Misc.ParseColor255(projectileColor);
				startColorC = Misc.ParseColor255(startColor);
				
				//init and zero points
				targetPosition = Vector3.zero;
				pointingAtPosition = Vector3.zero;
				bulletPrediction = Vector3.zero;

				//setup audio
				SetupAudio();

				//laser setup
				if(eWeaponType == WeaponTypes.Laser)
				{
					SetupLaserSpecifics();
				}
			}
			else if(HighLogic.LoadedSceneIsEditor)
			{
				fireTransforms = part.FindModelTransforms(fireTransformName);
			}

			//turret setup
			foreach(var turr in part.FindModulesImplementing<ModuleTurret>())
			{
				if(turr.turretID == turretID)
				{
					turret = turr;
					break;
				}
			}

			if(!turret)
			{
				Fields["onlyFireInRange"].guiActive = false;
				Fields["onlyFireInRange"].guiActiveEditor = false;
			}


			//setup animations
			if(hasDeployAnim)
			{
				deployState = Misc.SetUpSingleAnimation(deployAnimName, this.part);
				deployState.normalizedTime = 0;
				deployState.speed = 0;
				deployState.enabled = true;
			}
			if(hasFireAnimation)
			{
				fireState = Misc.SetUpSingleAnimation (fireAnimName, this.part);
				fireState.enabled = false;	
			}

			BDArmorySettings.OnVolumeChange += UpdateVolume;
		}