public override GameObject GetGameObject() { GameObject gameObject = Main.assetBundle.LoadAsset <GameObject>("AncientSword"); foreach (Renderer renderer in gameObject.GetComponentsInChildren <Renderer>()) { renderer.material.shader = Shader.Find("MarmosetUBER"); renderer.material.SetColor("_Emission", new Color(1f, 1f, 1f)); } gameObject.AddComponent <PrefabIdentifier>().ClassId = ClassID; gameObject.AddComponent <TechTag>().type = TechType; gameObject.AddComponent <BoxCollider>().size = new Vector3(0.1f, 0.1f, 0.1f); gameObject.AddComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; gameObject.AddComponent <Pickupable>().isPickupable = true; Fixer fixer = gameObject.AddComponent <Fixer>(); fixer.ClassId = ClassID; fixer.techType = TechType; SkyApplier skyApplier = gameObject.AddComponent <SkyApplier>(); skyApplier.renderers = gameObject.GetComponentsInChildren <MeshRenderer>(); skyApplier.anchorSky = Skies.Auto; WorldForces worldForces = gameObject.AddComponent <WorldForces>(); Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>(); worldForces.underwaterGravity = 0; worldForces.useRigidbody = rigidbody; VFXFabricating vfxFabricating = gameObject.AddComponent <VFXFabricating>(); vfxFabricating.localMinY = -3f; vfxFabricating.localMaxY = 3f; vfxFabricating.posOffset = new Vector3(0f, 0, 0f); vfxFabricating.eulerOffset = new Vector3(0f, 90f, -90f); vfxFabricating.scaleFactor = 1f; AncientSword component = gameObject.AddComponent <AncientSword>(); var knifePrefab = Resources.Load <GameObject>("WorldEntities/Tools/Knife").GetComponent <Knife>(); component.attackSound = Object.Instantiate(knifePrefab.attackSound, gameObject.transform); component.underwaterMissSound = Object.Instantiate(knifePrefab.underwaterMissSound, gameObject.transform); component.surfaceMissSound = Object.Instantiate(knifePrefab.surfaceMissSound, gameObject.transform); return(gameObject); }
public override GameObject GetGameObject() { if (prefabCache) { return(prefabCache); } GameObject obj = GameObject.Instantiate <GameObject>(MainPatch.bundle.LoadAsset <GameObject>("PrecursorIngot.prefab")); obj.AddComponent <WorldForces>().useRigidbody = obj.GetComponent <Rigidbody>(); obj.AddComponent <TechTag>().type = TechType; obj.AddComponent <PrefabIdentifier>().ClassId = ClassID; obj.AddComponent <Pickupable>().isPickupable = true; obj.AddComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; VFXFabricating vfxfabricating = obj.AddComponent <VFXFabricating>(); vfxfabricating.localMinY = -0.4f; vfxfabricating.localMaxY = 0.2f; vfxfabricating.posOffset = Vector3.zero; vfxfabricating.eulerOffset = new Vector3(0f, 0f, 0f); vfxfabricating.scaleFactor = 1f; SkyApplier sky = obj.AddComponent <SkyApplier>(); sky.renderers = obj.GetComponentsInChildren <Renderer>(); foreach (Renderer rend in sky.renderers) { Material[] newMaterials = new Material[rend.materials.Length]; for (int i = 0; i < newMaterials.Length; i++) { Material mat = new Material(rend.materials[i]); mat.shader = Shader.Find("MarmosetUBER"); newMaterials[i] = mat; } } prefabCache = obj; return(obj); }
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() { GameObject prefab = GameObject.Instantiate(this.GameObject); prefab.name = this.ClassID; // Update TechTag var techTag = prefab.GetComponent <TechTag>(); techTag.type = this.TechType; // Update prefab ID var prefabId = prefab.GetComponent <PrefabIdentifier>(); prefabId.ClassId = this.ClassID; // Remove rigid body Rigidbody rb = prefab.GetComponent <Rigidbody>(); GameObject.DestroyImmediate(rb); // Update large world entity LargeWorldEntity lwe = prefab.GetComponent <LargeWorldEntity>(); lwe.cellLevel = LargeWorldEntity.CellLevel.Near; // Adjust collider BoxCollider collider = prefab.GetComponentInChildren <BoxCollider>(); collider.size = new Vector3(collider.size.x, collider.size.y - 0.022f, collider.size.z); collider.center = new Vector3(collider.center.x, collider.center.y - 0.011f, collider.center.z); if (!ConfigSwitcher.EmptyDesk_asBuildable) { // We can pick this item Pickupable pickupable = prefab.AddComponent <Pickupable>(); pickupable.isPickupable = true; pickupable.randomizeRotationWhenDropped = true; // We can place this item prefab.AddComponent <CustomPlaceToolController>(); var placeTool = prefab.AddComponent <GenericPlaceTool>(); placeTool.allowedInBase = true; placeTool.allowedOnBase = false; placeTool.allowedOnCeiling = false; placeTool.allowedOnConstructable = false; placeTool.allowedOnGround = true; placeTool.allowedOnRigidBody = true; placeTool.allowedOnWalls = false; placeTool.allowedOutside = ConfigSwitcher.AllowPlaceOutside; placeTool.rotationEnabled = true; placeTool.enabled = true; placeTool.hasAnimations = false; placeTool.hasBashAnimation = false; placeTool.hasFirstUseAnimation = false; placeTool.mainCollider = collider; placeTool.pickupable = pickupable; // Add fabricating animation VFXFabricating fabricating = prefab.FindChild("Starship_work_desk_01_empty").AddComponent <VFXFabricating>(); fabricating.localMinY = -0.1f; fabricating.localMaxY = 0.9f; fabricating.posOffset = new Vector3(-0.06f, 0f, 0.04f); fabricating.eulerOffset = new Vector3(-90f, 0f, 0f); fabricating.scaleFactor = 0.35f; } else { // Set as constructible Constructable constructible = prefab.AddComponent <Constructable>(); constructible.techType = this.TechType; constructible.allowedOnWall = false; constructible.allowedInBase = true; constructible.allowedInSub = true; constructible.allowedOutside = ConfigSwitcher.AllowBuildOutside; constructible.allowedOnCeiling = false; constructible.allowedOnGround = true; constructible.allowedOnConstructables = false; constructible.deconstructionAllowed = true; constructible.controlModelState = true; constructible.model = prefab.FindChild("Starship_work_desk_01_empty"); } return(prefab); }
public override GameObject GetGameObject() { GameObject prefab = GameObject.Instantiate(this.GameObject); GameObject model = prefab.FindChild("discovery_lab_cart_01"); prefab.name = this.ClassID; // Set TechTag TechTag techTag = prefab.AddComponent <TechTag>(); techTag.type = this.TechType; // Update prefab identifier PrefabIdentifier prefabId = prefab.GetComponent <PrefabIdentifier>(); prefabId.ClassId = this.ClassID; GameObject cube = prefab.FindChild("Cube"); GameObject.DestroyImmediate(cube); // Remove rigid body Rigidbody rb = prefab.GetComponent <Rigidbody>(); GameObject.DestroyImmediate(rb); // Add box collider BoxCollider collider = model.AddComponent <BoxCollider>(); collider.size = new Vector3(1.026103f, 0.6288151f, 0.91f); // -90X: Y<=>Z collider.center = new Vector3(0.005f, 0.001f, 0.455f); // -90X: Y<=>Z // Update large world entity LargeWorldEntity lwe = prefab.GetComponent <LargeWorldEntity>(); lwe.cellLevel = LargeWorldEntity.CellLevel.Near; // Get renderers Renderer[] rend = prefab.GetComponentsInChildren <Renderer>(); if (!ConfigSwitcher.LabCart_asBuildable) { // Set proper shaders for crafting animation foreach (Renderer renderer in rend) { renderer.material.shader = Shader.Find("MarmosetUBER"); } // We can pick this item Pickupable pickupable = prefab.AddComponent <Pickupable>(); pickupable.isPickupable = true; pickupable.randomizeRotationWhenDropped = true; // We can place this item prefab.AddComponent <CustomPlaceToolController>(); var placeTool = prefab.AddComponent <GenericPlaceTool>(); placeTool.allowedInBase = true; placeTool.allowedOnBase = true; placeTool.allowedOnCeiling = false; placeTool.allowedOnConstructable = false; placeTool.allowedOnGround = true; placeTool.allowedOnRigidBody = true; placeTool.allowedOnWalls = false; placeTool.allowedOutside = ConfigSwitcher.AllowPlaceOutside; placeTool.rotationEnabled = true; placeTool.enabled = true; placeTool.hasAnimations = false; placeTool.hasBashAnimation = false; placeTool.hasFirstUseAnimation = false; placeTool.mainCollider = collider; placeTool.pickupable = pickupable; // Add fabricating animation VFXFabricating fabricating = model.AddComponent <VFXFabricating>(); fabricating.localMinY = -0.1f; fabricating.localMaxY = 0.9f; fabricating.posOffset = new Vector3(0f, 0f, 0.04f); fabricating.eulerOffset = new Vector3(-90f, 0f, 0f); fabricating.scaleFactor = 0.5f; } else { // Set as constructible Constructable constructible = prefab.AddComponent <Constructable>(); constructible.techType = this.TechType; constructible.allowedOnWall = false; constructible.allowedInBase = true; constructible.allowedInSub = true; constructible.allowedOutside = ConfigSwitcher.AllowBuildOutside; constructible.allowedOnCeiling = false; constructible.allowedOnGround = true; constructible.allowedOnConstructables = false; constructible.deconstructionAllowed = true; constructible.controlModelState = true; constructible.model = model; // Add constructible bounds ConstructableBounds bounds = prefab.AddComponent <ConstructableBounds>(); } // Update sky applier SkyApplier applier = prefab.GetComponent <SkyApplier>(); applier.anchorSky = Skies.Auto; applier.renderers = rend; return(prefab); }
public override GameObject GetGameObject() { GameObject obj = MainPatch.bundle.LoadAsset <GameObject>("Assets/AlienRifle/Alien Rifle.prefab"); obj.GetOrAddComponent <PrefabIdentifier>().ClassId = ClassID; obj.GetOrAddComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; obj.GetOrAddComponent <TechTag>().type = TechType; obj.GetOrAddComponent <Pickupable>().isPickupable = true; SkyApplier sky = obj.GetOrAddComponent <SkyApplier>(); sky.renderers = obj.GetComponentsInChildren <MeshRenderer>(); sky.anchorSky = Skies.Auto; GameObject originalRifle = Resources.Load <GameObject>("WorldEntities/Doodads/Precursor/Prison/Relics/Alien_relic_07"); Material newMat = originalRifle.GetComponentInChildren <MeshRenderer>().material; sky.renderers[0].materials = new Material[] { newMat, newMat }; sky.renderers[0].GetComponent <MeshFilter>().mesh = originalRifle.GetComponentInChildren <MeshFilter>().mesh; VFXFabricating vfx = obj.transform.Find("RifleMesh").gameObject.GetOrAddComponent <VFXFabricating>(); vfx.localMinY = -0.4f; vfx.localMaxY = 0.2f; vfx.posOffset = new Vector3(-0.054f, 0.1f, -0.06f); vfx.eulerOffset = new Vector3(0f, 0f, 90f); vfx.scaleFactor = 1f; WorldForces forces = obj.GetOrAddComponent <WorldForces>(); forces.underwaterGravity = 0f; forces.useRigidbody = obj.GetOrAddComponent <Rigidbody>(); forces.useRigidbody.useGravity = false; RifleTool rifle = obj.GetOrAddComponent <RifleTool>(); rifle.mainCollider = obj.GetComponentInChildren <Collider>(); rifle.ikAimRightArm = true; rifle.ikAimLeftArm = true; rifle.useLeftAimTargetOnPlayer = true; rifle.chargeEffect = rifle.transform.Find("chargeparticles").GetComponent <ParticleSystem>(); rifle.shootEffect = rifle.transform.Find("shooteffect").GetComponent <ParticleSystem>(); rifle.chargeMeter = obj.transform.Find("HUD/ChargeBar"); rifle.bulletPrefab = obj.transform.Find("BulletPrefab").gameObject; rifle.energyMixin = obj.GetOrAddComponent <EnergyMixin>(); rifle.energyMixin.allowBatteryReplacement = true; rifle.energyMixin.compatibleBatteries = new List <TechType>() { TechType.PrecursorIonBattery }; rifle.energyMixin.defaultBattery = TechType.None; rifle.energyMixin.batteryModels = new EnergyMixin.BatteryModels[] { new EnergyMixin.BatteryModels() { model = obj.transform.Find("Battery").gameObject, techType = TechType.PrecursorIonBattery } }; rifle.energyMixin.storageRoot = obj.transform.Find("Battery").gameObject.GetOrAddComponent <ChildObjectIdentifier>(); GameObject seamoth = CraftData.GetPrefabForTechType(TechType.Seamoth); rifle.sonarSound = obj.GetOrAddComponent <FMOD_CustomEmitter>(); rifle.sonarSound.asset = seamoth.GetComponent <SeaMoth>().sonarSound.asset; rifle.sonarSound.playOnAwake = false; rifle.sonarSound.followParent = true; rifle.sonarSound.restartOnPlay = true; rifle.shootSound = CraftData.GetPrefabForTechType(TechType.RepulsionCannon).GetComponent <RepulsionCannon>().shootSound; rifle.chargeSound = obj.GetOrAddComponent <FMOD_CustomLoopingEmitter>(); rifle.chargeSound.asset = seamoth.GetComponent <SeaMoth>().pulseChargeSound.asset; rifle.chargeSound.followParent = true; rifle.sonarSound.restartOnPlay = true; rifle.Awake(); return(obj); }
public override GameObject GetGameObject() { base.GetGameObject(); GameObject modelGO = _GameObject.transform.Find("alien_relic_08_world_rot/alien_relic_08_hlpr/alien_relic_08_ctrl/alien_relic_08").gameObject; modelGO.transform.SetParent(_GameObject.transform, false); modelGO.name = "sword_model"; modelGO.transform.localPosition = new Vector3(0.06f, 0.27f, 0.05f); modelGO.transform.localRotation = Quaternion.Euler(350f, 265f, 172f); modelGO.transform.localScale = new Vector3(0.63f, 0.63f, 0.63f); GameObject colliderGO = new GameObject("collider_container"); colliderGO.transform.SetParent(_GameObject.transform, false); colliderGO.transform.localPosition = new Vector3(0f, 0.13f, 0.02f); colliderGO.transform.localScale = new Vector3(1f, 1f, 1f); colliderGO.transform.localRotation = Quaternion.Euler(7f, 358f, 355f); BoxCollider boxCollider = colliderGO.EnsureComponent <BoxCollider>(); boxCollider.size = new Vector3(0.13f, 0.83f, 0.05f); boxCollider.center = new Vector3(0f, 0.12f, 0f); Object.DestroyImmediate(_GameObject.FindChild("Cube")); Object.DestroyImmediate(_GameObject.FindChild("alien_relic_08_world_rot")); Object.DestroyImmediate(_GameObject.GetComponent <ImmuneToPropulsioncannon>()); Object.DestroyImmediate(_GameObject.GetComponent <CapsuleCollider>()); Object.DestroyImmediate(_GameObject.GetComponent <EntityTag>()); _GameObject.EnsureComponent <PrefabIdentifier>().ClassId = ClassID; _GameObject.EnsureComponent <TechTag>().type = TechType; _GameObject.EnsureComponent <Pickupable>().isPickupable = true; _GameObject.EnsureComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Near; _GameObject.EnsureComponent <VFXSurface>(); _GameObject.EnsureComponent <EcoTarget>(); _GameObject.EnsureComponent <FMOD_CustomEmitter>(); _GameObject.EnsureComponent <StudioEventEmitter>(); SkyApplier skyApplier = _GameObject.EnsureComponent <SkyApplier>(); skyApplier.renderers = _GameObject.GetComponentsInChildren <MeshRenderer>(); skyApplier.anchorSky = Skies.Auto; Rigidbody rigidbody = _GameObject.EnsureComponent <Rigidbody>(); rigidbody.useGravity = false; WorldForces worldForces = _GameObject.EnsureComponent <WorldForces>(); worldForces.underwaterGravity = 1f; worldForces.handleGravity = true; worldForces.aboveWaterDrag = 1f; worldForces.underwaterDrag = 0.00001f; worldForces.handleDrag = true; worldForces.useRigidbody = rigidbody; VFXFabricating vfxFabricating = modelGO.EnsureComponent <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; AncientSword component = _GameObject.EnsureComponent <AncientSword>(); Knife knife = Resources.Load <GameObject>("WorldEntities/Tools/Knife").GetComponent <Knife>(); component.mainCollider = boxCollider; component.socket = PlayerTool.Socket.RightHand; component.ikAimRightArm = true; component.attackSound = Object.Instantiate(knife.attackSound, _GameObject.transform); component.underwaterMissSound = Object.Instantiate(knife.underwaterMissSound, _GameObject.transform); component.surfaceMissSound = Object.Instantiate(knife.surfaceMissSound, _GameObject.transform); return(_GameObject); }
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()); } }