// Token: 0x0600002B RID: 43 RVA: 0x00003098 File Offset: 0x00001298 public static bool Prefix(StasisRifle __instance) { SkinnedMeshRenderer[] allComponentsInChildren = __instance.GetAllComponentsInChildren <SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer skinnedMeshRenderer in allComponentsInChildren) { bool flag = skinnedMeshRenderer.name.Contains("stasis_rifle_geo"); if (flag) { skinnedMeshRenderer.material.color = new Color32(Convert.ToByte(MainPatch.config.SRiflevalue), Convert.ToByte(MainPatch.config.SRiflegvalue), Convert.ToByte(MainPatch.config.SRiflebvalue), 1); } } return(true); }
public override GameObject GetGameObject() { Console.WriteLine("[AlienRifle] Loading Prefab"); GameObject gobj = AlienRifleMod.bund.LoadAsset <GameObject>("AlienRifle.prefab"); try { BoxCollider box = gobj.AddOrGetComponent <BoxCollider>(); box.size = new Vector3(0.1f, 0.3f, 1f); Console.WriteLine("[AlienRifle] Modifying MeshRenderers of Object"); foreach (Renderer render in gobj.GetComponentsInChildren <Renderer>()) { render.material.shader = Shader.Find("MarmosetUBER"); } MeshRenderer rend = gobj.transform.Find("Main/MainBody").GetComponent <MeshRenderer>(); rend.material = gobj.transform.Find("Main/EnergyGlow").GetComponent <MeshRenderer>().material; rend.material.SetColor("_Emission", new Color(0.2f, 0.2f, 0.2f)); Console.WriteLine("[AlienRifle] Modifying Transform offset and rotation"); Vector3 offset = new Vector3(0, 0.05f, 0.1f); gobj.transform.GetChild(0).localPosition += offset; //gobj.transform.GetChild(1).localPosition = offset; Console.WriteLine("[AlienRifle] Adding Essential components"); gobj.AddOrGetComponent <PrefabIdentifier>().ClassId = ClassID; gobj.AddOrGetComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; Console.WriteLine("[AlienRifle] Adding SkyApplier"); SkyApplier sky = gobj.AddOrGetComponent <SkyApplier>(); sky.renderers = gobj.GetComponentsInChildren <MeshRenderer>(); sky.anchorSky = Skies.Auto; Console.WriteLine("[AlienRifle] Adding WorldForces"); WorldForces forces = gobj.AddOrGetComponent <WorldForces>(); Console.WriteLine("[AlienRifle] Adding Rigidbody"); Rigidbody rb = gobj.AddOrGetComponent <Rigidbody>(); forces.underwaterGravity = 0; forces.useRigidbody = rb; Pickupable pick = gobj.AddOrGetComponent <Pickupable>(); pick.isPickupable = true; gobj.AddOrGetComponent <TechTag>().type = TechType; Fixer fixer = gobj.AddOrGetComponent <Fixer>(); fixer.ClassId = ClassID; fixer.techType = TechType; Console.WriteLine("[AlienRifle] Adding VFX Component"); VFXFabricating vfxfabricating = gobj.transform.Find("Main").gameObject.AddOrGetComponent <VFXFabricating>(); vfxfabricating.localMinY = -0.4f; vfxfabricating.localMaxY = 0.2f; vfxfabricating.posOffset = new Vector3(-0.054f, 0f, -0.06f); vfxfabricating.eulerOffset = new Vector3(0f, 0f, 90f); vfxfabricating.scaleFactor = 1f; Console.WriteLine("[AlienRifle] Adding EnergyMixin Component"); EnergyMixin AREnergy = gobj.AddOrGetComponent <EnergyMixin>(); AREnergy.storageRoot = gobj.transform.Find("Main").gameObject.AddOrGetComponent <ChildObjectIdentifier>(); AREnergy.compatibleBatteries = new List <TechType> { TechType.PrecursorIonBattery }; AREnergy.allowBatteryReplacement = true; AREnergy.batteryModels = new EnergyMixin.BatteryModels[] { new EnergyMixin.BatteryModels { techType = TechType.PrecursorIonBattery, model = gobj.transform.Find("Main/EnergyGlow").gameObject } }; Material mat = new Material(Shader.Find("MarmosetUBER")); Console.WriteLine("[AlienRifle] Adding AlienRifle Component"); AlienRifle rifle = gobj.AddOrGetComponent <AlienRifle>(); GameObject power = CraftData.InstantiateFromPrefab(TechType.PowerTransmitter); rifle.beamPrefab = power.GetComponent <PowerFX>().vfxPrefab; rifle.beamPrefab.GetComponent <LineRenderer>().material.color = Color.green; Object.Destroy(power); StasisRifle stasisrifle = CraftData.InstantiateFromPrefab(TechType.StasisRifle).GetComponent <StasisRifle>(); RepulsionCannon cannon = CraftData.InstantiateFromPrefab(TechType.RepulsionCannon).GetComponent <RepulsionCannon>(); rifle.shootSound = cannon.shootSound; rifle.drawSound = stasisrifle.drawSound; rifle.reloadSound = stasisrifle.reloadSound; rifle.muzzleFlash = gobj.transform.Find("Main/Particles/Fire").GetComponent <ParticleSystem>(); rifle.chargeSparks = gobj.transform.Find("Main/Particles/Charging").GetComponent <ParticleSystem>(); Object.Destroy(stasisrifle); Object.Destroy(cannon); rifle.mainCollider = gobj.GetComponent <BoxCollider>(); rifle.ikAimRightArm = true; rifle.ikAimLeftArm = true; rifle.useLeftAimTargetOnPlayer = true; Console.WriteLine("[AlienRifle] Prefab loaded successfully!"); return(gobj); } catch (Exception e) { Console.WriteLine("[AlienRifle] Rifle Object couldn't be loaded!\n" + e.Message + e.StackTrace); return(gobj); } }
public override GameObject GetGameObject() { try { GameObject gun = techpistol.darktest.LoadAsset <GameObject>("techpistol.prefab"); MeshRenderer[] allshader = gun.FindChild("HandGun").GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer setshader in allshader) { setshader.material.shader = Shader.Find("MarmosetUBER"); setshader.material.SetColor("_Emission", new Color(1f, 1f, 1f)); } gun.transform.Find("Cannonmode/shoot/shoo").gameObject.AgComponent <cool>(); gun.AgComponent <PrefabIdentifier>().ClassId = ClassID; gun.AgComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; gun.AgComponent <Pickupable>().isPickupable = true;; gun.AgComponent <TechTag>().type = TechType; gun.AgComponent <Fixer>().techType = TechType; gun.AgComponent <Fixer>().ClassId = ClassID; WorldForces World = gun.AgComponent <WorldForces>(); Rigidbody body = gun.AgComponent <Rigidbody>(); World.underwaterGravity = 0; World.useRigidbody = body; EnergyMixin battery = gun.AgComponent <EnergyMixin>(); battery.storageRoot = gun.FindChild("BatteryRoot").AgComponent <ChildObjectIdentifier>(); battery.allowBatteryReplacement = true; battery.compatibleBatteries = new List <TechType> { TechType.PrecursorIonBattery, TechType.Battery, TechType.PrecursorIonPowerCell, TechType.PowerCell }; battery.batteryModels = new EnergyMixin.BatteryModels[] { new EnergyMixin.BatteryModels { techType = TechType.PrecursorIonPowerCell, model = gun.transform.Find("BatteryRoot/PrecursorIonPowerCell").gameObject }, new EnergyMixin.BatteryModels { techType = TechType.Battery, model = gun.transform.Find("BatteryRoot/Battery").gameObject }, new EnergyMixin.BatteryModels { techType = TechType.PrecursorIonBattery, model = gun.transform.Find("BatteryRoot/PrecursorIonBattery").gameObject }, new EnergyMixin.BatteryModels { techType = TechType.PowerCell, model = gun.transform.Find("BatteryRoot/PowerCell").gameObject } }; Gun biggun = gun.AgComponent <Gun>(); RepulsionCannon Boo = CraftData.InstantiateFromPrefab(TechType.RepulsionCannon).GetComponent <RepulsionCannon>(); StasisRifle Boo2 = CraftData.InstantiateFromPrefab(TechType.StasisRifle).GetComponent <StasisRifle>(); PropulsionCannon build = CraftData.InstantiateFromPrefab(TechType.PropulsionCannon).GetComponent <PropulsionCannon>(); Welder laserloop = CraftData.InstantiateFromPrefab(TechType.Welder).GetComponent <Welder>(); VFXFabricating vfxfabricating = gun.FindChild("HandGun").AgComponent <VFXFabricating>(); vfxfabricating.localMinY = -3f; vfxfabricating.localMaxY = 3f; vfxfabricating.posOffset = new Vector3(0f, 0, 0f); vfxfabricating.eulerOffset = new Vector3(0f, 90f, -90f); vfxfabricating.scaleFactor = 1f; biggun.shoot1 = Boo.shootSound; biggun.shoot2 = Boo2.fireSound; biggun.xulikai = Boo2.chargeBegin; biggun.modechang = build.shootSound; biggun.laseroopS = laserloop.weldSound; biggun.mainCollider = gun.GetComponent <BoxCollider>(); biggun.ikAimRightArm = true; biggun.useLeftAimTargetOnPlayer = true; UnityEngine.Object.Destroy(Boo2); UnityEngine.Object.Destroy(build); UnityEngine.Object.Destroy(Boo); UnityEngine.Object.Destroy(laserloop); return(gun); } catch { Console.WriteLine("初始化错误"); return(new GameObject()); } }