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); } }
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!!!"); } } }