////// TILER2 Module Setup ////// public override void SetupAttributes() { base.SetupAttributes(); bulwarkDroneBodyPrefab = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneBody.prefab"); ModifyBodyPrefabWithVanillaAssets(); bulwarkDroneMasterPrefab = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneMaster.prefab"); bulwarkDroneInteractablePrefab = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneBroken.prefab"); ModifyInteractablePrefabWithVanillaAssets(); ContentAddition.AddBody(bulwarkDroneBodyPrefab); ContentAddition.AddMaster(bulwarkDroneMasterPrefab); ContentAddition.AddNetworkedObject(bulwarkDroneInteractablePrefab); SetupSpawnCard(); }
public override void SetupAttributes() { base.SetupAttributes(); //load custom assets skillDef = TinkersSatchelPlugin.resources.LoadAsset <SkillDef>("Assets/TinkersSatchel/SkillDefs/EngiUtilitySpeedispenser.asset"); var tmpDeployableBody = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/EngiSpeedispenser/EngiSpeedispenserBody.prefab") .InstantiateClone("TkSatTempSetupPrefab", false); deployableMaster = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/EngiSpeedispenser/EngiSpeedispenserMaster.prefab"); deployableBlueprint = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Characters/EngiSpeedispenser/EngiSpeedispenserBlueprints.prefab"); //load vanilla assets targetSkillFamily = Addressables.LoadAssetAsync <SkillFamily>("RoR2/Base/Engi/EngiBodyUtilityFamily.asset") .WaitForCompletion(); var captainSupply = Addressables.LoadAssetAsync <GameObject>("RoR2/Base/Captain/CaptainSupplyDrop, EquipmentRestock.prefab") .WaitForCompletion() .InstantiateClone("TkSatTempSetupPrefab2", false); var buffIcon = Addressables.LoadAssetAsync <Sprite>("RoR2/DLC1/AttackSpeedAndMoveSpeed/texCoffeeIcon.png") .WaitForCompletion(); var mainMtl = Addressables.LoadAssetAsync <Material>("RoR2/Base/Engi/matEngiTurret.mat") .WaitForCompletion(); var bpOkMtl = Addressables.LoadAssetAsync <Material>("RoR2/Base/Engi/matBlueprintsOk.mat") .WaitForCompletion(); var bpNokMtl = Addressables.LoadAssetAsync <Material>("RoR2/Base/Engi/matBlueprintsInvalid.mat") .WaitForCompletion(); var ctp = Addressables.LoadAssetAsync <CharacterCameraParams>("RoR2/Base/Common/ccpStandard.asset") .WaitForCompletion(); var turretBp = Addressables.LoadAssetAsync <GameObject>("RoR2/Base/Engi/EngiTurretBlueprints.prefab") .WaitForCompletion(); var turretObj = Addressables.LoadAssetAsync <GameObject>("RoR2/Base/Engi/EngiTurretBody.prefab") .WaitForCompletion(); var bpProjMtl = turretBp.transform.Find("BlobLightProjector").GetComponent <Projector>().material; //modify speedBuff = ScriptableObject.CreateInstance <BuffDef>(); speedBuff.buffColor = Color.white; speedBuff.canStack = false; speedBuff.isDebuff = false; speedBuff.name = "TKSATEngiSpeedispenserBuff"; speedBuff.iconSprite = buffIcon; tmpDeployableBody.GetComponent <CameraTargetParams>().cameraParams = ctp; tmpDeployableBody.GetComponent <ModelLocator>().modelTransform.GetComponent <MeshRenderer>().material = mainMtl; var eic = captainSupply.transform.Find("ModelBase/captain supply drop/EnergyIndicatorContainer"); eic.SetParent(tmpDeployableBody.transform); eic.localScale *= 0.5f; eic.position -= new Vector3(0f, 1.5f, 0f); var cl = tmpDeployableBody.GetComponent <ModelLocator>().modelTransform.GetComponent <ChildLocator>(); cl.transformPairs[0].transform = eic; cl.transformPairs[1].transform = eic.Find("Canvas/EnergyIndicatorBackgroundPanel/EnergyIndicator"); GameObject.Destroy(captainSupply); deployableBody = tmpDeployableBody.InstantiateClone("EngiSpeedispenserBody", true); GameObject.Destroy(tmpDeployableBody); deployableMaster.GetComponent <CharacterMaster>().bodyPrefab = deployableBody; deployableBlueprint.transform.Find("BlobLight").GetComponent <Projector>().material = bpProjMtl; deployableBlueprint.transform.Find("Model Base/SpeedispenserModel").GetComponent <MeshRenderer>().material = bpOkMtl; var bp = deployableBlueprint.GetComponent <BlueprintController>(); bp.okMaterial = bpOkMtl; bp.invalidMaterial = bpNokMtl; foreach (var akEvent in turretBp.GetComponents <AkEvent>()) { var newEvent = deployableBlueprint.AddComponent <AkEvent>(); newEvent.triggerList = akEvent.triggerList.ToArray().ToList(); newEvent.useOtherObject = akEvent.useOtherObject; newEvent.actionOnEventType = akEvent.actionOnEventType; newEvent.curveInterpolation = akEvent.curveInterpolation; newEvent.enableActionOnEvent = akEvent.enableActionOnEvent; newEvent.data = akEvent.data; newEvent.useCallbacks = akEvent.useCallbacks; newEvent.Callbacks = akEvent.Callbacks.ToArray().ToList(); newEvent.playingId = akEvent.playingId; newEvent.soundEmitterObject = deployableBlueprint; newEvent.transitionDuration = akEvent.transitionDuration; } foreach (var akEvent in turretObj.GetComponents <AkEvent>()) { var newEvent = deployableBody.AddComponent <AkEvent>(); newEvent.triggerList = akEvent.triggerList.ToArray().ToList(); newEvent.useOtherObject = akEvent.useOtherObject; newEvent.actionOnEventType = akEvent.actionOnEventType; newEvent.curveInterpolation = akEvent.curveInterpolation; newEvent.enableActionOnEvent = akEvent.enableActionOnEvent; newEvent.data = akEvent.data; newEvent.useCallbacks = akEvent.useCallbacks; newEvent.Callbacks = akEvent.Callbacks.ToArray().ToList(); newEvent.playingId = akEvent.playingId; newEvent.soundEmitterObject = deployableBody; newEvent.transitionDuration = akEvent.transitionDuration; } //R2API catalog reg var dmsSerializable = ContentAddition.AddEntityState <DispenserMainState>(out bool entStateDidSucceed); if (!entStateDidSucceed) { TinkersSatchelPlugin._logger.LogError("EntityState setup failed on EngiUtilitySpeedispenser (DispenserMainState)! Deployable will be unusable."); } else { var esm = deployableBody.GetComponent <EntityStateMachine>(); esm.initialStateType = dmsSerializable; esm.mainStateType = dmsSerializable; } R2API.Networking.NetworkingAPI.RegisterMessageType <PlaceDispenser.MsgConstructDispenser>(); ContentAddition.AddBuffDef(speedBuff); ContentAddition.AddBody(deployableBody); ContentAddition.AddMaster(deployableMaster); deployableSlot = DeployableAPI.RegisterDeployableSlot((master, countMult) => { return(1); }); skillDef.activationState = ContentAddition.AddEntityState <PlaceDispenser>(out entStateDidSucceed); if (!entStateDidSucceed) { TinkersSatchelPlugin._logger.LogError("EntityState setup failed on EngiUtilitySpeedispenser! Skill will not appear nor function."); } else if (!ContentAddition.AddSkillDef(skillDef)) { TinkersSatchelPlugin._logger.LogError("SkillDef setup failed on EngiUtilitySpeedispenser! Skill will not appear nor function."); } else { setupSucceeded = true; } }