protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); //item.OnHeldActionEvent += this.OnHeldAction; parentFirearm = this.GetComponent <Weapons.BaseFirearmGenerator>(); if (!String.IsNullOrEmpty(module.ammoCounterRef)) { ammoCounterMesh = item.GetCustomReference(module.ammoCounterRef).GetComponent <MeshRenderer>(); digitsGridTexture = (Texture2D)item.GetCustomReference(module.ammoCounterRef).GetComponent <MeshRenderer>().material.mainTexture; } //if (digitsGridTexture == null) Debug.LogError("[Fisher-ModularFirearms] COULD NOT GET GRID TEXTURE"); //if (ammoCounterMesh == null) Debug.LogError("[Fisher-ModularFirearms] COULD NOT GET MESH RENDERER"); if ((digitsGridTexture != null) && (ammoCounterMesh != null)) { ammoCounter = new TextureProcessor(); ammoCounter.SetGridTexture(digitsGridTexture); ammoCounter.SetTargetRenderer(ammoCounterMesh); } if (ammoCounter != null) { ammoCounter.DisplayUpdate(newAmmoCount); } }
protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); item.OnHeldActionEvent += this.OnHeldAction; if (module.flashlightRef != null) { attachedLight = item.GetCustomReference(module.flashlightRef).GetComponent <Light>(); if (!String.IsNullOrEmpty(module.flashlightMeshRef)) { flashlightMaterial = item.GetCustomReference(module.flashlightMeshRef).GetComponent <MeshRenderer>().material; flashlightEmissionColor = flashlightMaterial.GetColor("_EmissionColor"); if (!attachedLight.enabled) { flashlightMaterial.SetColor("_EmissionColor", Color.black); } } } if (!String.IsNullOrEmpty(module.flashlightActivationSoundRef)) { activationSound = item.GetCustomReference(module.flashlightActivationSoundRef).GetComponent <AudioSource>(); } if (module.flashlightHandleRef != null) { attachmentHandle = item.GetCustomReference(module.flashlightHandleRef).GetComponent <Handle>(); } //if (module.ignoredMeshRef != null) ignoredMesh = item.GetCustomReference(module.attachmentRef).GetComponent<MeshRenderer>(); lightCullingMask = 1 << 20; lightCullingMask = ~lightCullingMask; }
public void Awake() { item = this.GetComponent <Item>(); item.OnHeldActionEvent += OnHeldAction; module = item.data.GetModule <Shared.AttachmentModule>(); if (!string.IsNullOrEmpty(module.mainGripID)) { secondaryHandle = item.GetCustomReference(module.mainGripID).GetComponent <Handle>(); } if (!string.IsNullOrEmpty(module.fireSoundRef)) { fireSound = item.GetCustomReference(module.fireSoundRef).GetComponent <AudioSource>(); } if (!string.IsNullOrEmpty(module.muzzleFlashRef)) { MuzzleFlash = item.GetCustomReference(module.muzzleFlashRef).GetComponent <ParticleSystem>(); } if (!string.IsNullOrEmpty(module.muzzlePositionRef)) { muzzlePoint = item.GetCustomReference(module.muzzlePositionRef); } else { muzzlePoint = item.transform; } }
protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); item.OnHeldActionEvent += this.OnHeldAction; if (!String.IsNullOrEmpty(module.laserRef)) { attachedLaser = item.GetCustomReference(module.laserRef).GetComponent <LineRenderer>(); } if (attachedLaser != null) { if (!String.IsNullOrEmpty(module.laserStartRef)) { laserStart = item.GetCustomReference(module.laserStartRef); } if (!String.IsNullOrEmpty(module.laserEndRef)) { laserEnd = item.GetCustomReference(module.laserEndRef); } if (!String.IsNullOrEmpty(module.laserRayCastPointRef)) { rayCastPoint = item.GetCustomReference(module.laserRayCastPointRef); } LayerMask layermask1 = 1 << 29; LayerMask layermask2 = 1 << 28; LayerMask layermask3 = 1 << 25; LayerMask layermask4 = 1 << 23; LayerMask layermask5 = 1 << 9; LayerMask layermask6 = 1 << 5; LayerMask layermask7 = 1 << 1; laserIgnore = layermask1 | layermask2 | layermask3 | layermask4 | layermask5 | layermask6 | layermask7; laserIgnore = ~laserIgnore; maxLaserDistance = module.maxLaserDistance; laserEnd.localPosition = new Vector3(laserEnd.localPosition.x, laserEnd.localPosition.y, laserEnd.localPosition.z); } if (!String.IsNullOrEmpty(module.laserActivationSoundRef)) { activationSound = item.GetCustomReference(module.laserActivationSoundRef).GetComponent <AudioSource>(); } if (!String.IsNullOrEmpty(module.laserHandleRef)) { attachmentHandle = item.GetCustomReference(module.laserHandleRef).GetComponent <Handle>(); } }
void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); item.OnHeldActionEvent += this.OnHeldAction; switchPositions = new List <Transform>(); switchModes = new List <FireMode>(); // Get reference to attached weapon (current firemode selection) parentFirearm = this.GetComponent <Weapons.BaseFirearmGenerator>(); if (!String.IsNullOrEmpty(module.attachmentHandleRef)) { attachmentHandle = item.GetCustomReference(module.attachmentHandleRef).GetComponent <Handle>(); } if (!String.IsNullOrEmpty(module.activationSoundRef)) { activationSound = item.GetCustomReference(module.activationSoundRef).GetComponent <AudioSource>(); } // Gameobject that which will move to match the reference positions if (!String.IsNullOrEmpty(module.swtichRef)) { pivotTransform = item.GetCustomReference(module.swtichRef); } // Swtich Positions are passed as custom references. pivotTransform is then matched to these transforms foreach (string switchPositionRef in module.switchPositionRefs) { Transform switchPosition = item.GetCustomReference(switchPositionRef); switchPositions.Add(switchPosition); } // allowed fire modes are matched to swtich positions based on list index foreach (string allowedFireMode in module.allowedFireModes) { FrameworkCore.FireMode switchMode = (FrameworkCore.FireMode)Enum.Parse(typeof(FrameworkCore.FireMode), allowedFireMode); switchModes.Add(switchMode); } // If we are using a moving swtich, check that our lists have mappable indicies if (pivotTransform != null) { if (switchPositions.Count != switchModes.Count) { Debug.LogWarning("WARNING, FireModeSwtich switchPositions and switchModes have different lengths!!!"); } } }
protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); item.OnHeldActionEvent += this.OnHeldAction; if (!String.IsNullOrEmpty(module.compassRef)) { compass = item.GetCustomReference(module.compassRef).gameObject; } if (compass != null) { currentIndex = -1; compassIndex = 0; } }
protected void Awake() { item = this.GetComponent <Item>(); module = item.data.GetModule <Shared.AttachmentModule>(); item.OnHeldActionEvent += this.OnHeldAction; }