public void OnApplicationQuit() { orig_OnApplicationQuit(); ModHooks.OnApplicationQuit(); }
private void OnTriggerEnter2D(Collider2D otherCollider) { ModHooks.OnSlashHit(otherCollider, gameObject); orig_OnTriggerEnter2D(otherCollider); }
public float GetFloat(string floatName) { return(ModHooks.GetPlayerFloat(floatName)); }
private void Update() { ModHooks.OnHeroUpdate(); orig_Update(); }
public void DoAttack() { ModHooks.OnDoAttack(); orig_DoAttack(); }
private void LookForQueueInput() { if (this.acceptingInput && !this.gm.isPaused && this.isGameplayScene) { if (this.inputHandler.inputActions.jump.WasPressed) { if (this.CanWallJump()) { this.DoWallJump(); } else if (this.CanJump()) { this.HeroJump(); } else if (this.CanDoubleJump()) { this.DoDoubleJump(); } else if (this.CanInfiniteAirJump()) { this.CancelJump(); this.audioCtrl.PlaySound(HeroSounds.JUMP); this.ResetLook(); this.cState.jumping = true; } else { this.jumpQueueSteps = 0; this.jumpQueuing = true; this.doubleJumpQueueSteps = 0; this.doubleJumpQueuing = true; } } if (this.inputHandler.inputActions.dash.WasPressed && !ModHooks.OnDashPressed()) { if (this.CanDash()) { this.HeroDash(); } else { this.dashQueueSteps = 0; this.dashQueuing = true; } } if (this.inputHandler.inputActions.attack.WasPressed) { if (this.CanAttack()) { this.DoAttack(); } else { this.attackQueueSteps = 0; this.attackQueuing = true; } } if (this.inputHandler.inputActions.jump.IsPressed) { if (this.jumpQueueSteps <= this.JUMP_QUEUE_STEPS && this.CanJump() && this.jumpQueuing) { this.HeroJump(); } else if (this.doubleJumpQueueSteps <= this.DOUBLE_JUMP_QUEUE_STEPS && this.CanDoubleJump() && this.doubleJumpQueuing) { if (this.cState.onGround) { this.HeroJump(); } else { this.DoDoubleJump(); } } if (this.CanSwim()) { if (this.hero_state != ActorStates.airborne) { this.SetState(ActorStates.airborne); } this.cState.swimming = true; } } if (this.inputHandler.inputActions.dash.IsPressed && this.dashQueueSteps <= this.DASH_QUEUE_STEPS && this.CanDash() && this.dashQueuing && !ModHooks.OnDashPressed() && this.CanDash()) { this.HeroDash(); } if (this.inputHandler.inputActions.attack.IsPressed && this.attackQueueSteps <= this.ATTACK_QUEUE_STEPS && this.CanAttack() && this.attackQueuing) { this.DoAttack(); } } }
public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount, int hazardType) { damageAmount = ModHooks.OnTakeDamage(ref hazardType, damageAmount); bool spawnDamageEffect = true; if (damageAmount > 0) { if (BossSceneController.IsBossScene) { int bossLevel = BossSceneController.Instance.BossLevel; if (bossLevel != 1) { if (bossLevel == 2) { damageAmount = 9999; } } else { damageAmount *= 2; } } if (this.CanTakeDamage()) { if (this.damageMode == DamageMode.HAZARD_ONLY && hazardType == 1) { return; } if (this.cState.shadowDashing && hazardType == 1) { return; } if (this.parryInvulnTimer > 0f && hazardType == 1) { return; } VibrationMixer mixer = VibrationManager.GetMixer(); if (mixer != null) { mixer.StopAllEmissionsWithTag("heroAction"); } bool flag = false; if (this.carefreeShieldEquipped && hazardType == 1) { if (this.hitsSinceShielded > 7) { this.hitsSinceShielded = 7; } switch (this.hitsSinceShielded) { case 1: if ((float)UnityEngine.Random.Range(1, 100) <= 10f) { flag = true; } break; case 2: if ((float)UnityEngine.Random.Range(1, 100) <= 20f) { flag = true; } break; case 3: if ((float)UnityEngine.Random.Range(1, 100) <= 30f) { flag = true; } break; case 4: if ((float)UnityEngine.Random.Range(1, 100) <= 50f) { flag = true; } break; case 5: if ((float)UnityEngine.Random.Range(1, 100) <= 70f) { flag = true; } break; case 6: if ((float)UnityEngine.Random.Range(1, 100) <= 80f) { flag = true; } break; case 7: if ((float)UnityEngine.Random.Range(1, 100) <= 90f) { flag = true; } break; default: flag = false; break; } if (flag) { this.hitsSinceShielded = 0; this.carefreeShield.SetActive(true); damageAmount = 0; spawnDamageEffect = false; } else { this.hitsSinceShielded++; } } if (this.playerData.GetBool("equippedCharm_5") && this.playerData.GetInt("blockerHits") > 0 && hazardType == 1 && this.cState.focusing && !flag) { this.proxyFSM.SendEvent("HeroCtrl-TookBlockerHit"); this.audioSource.PlayOneShot(this.blockerImpact, 1f); spawnDamageEffect = false; damageAmount = 0; } else { this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged"); } this.CancelAttack(); if (this.cState.wallSliding) { this.cState.wallSliding = false; this.wallSlideVibrationPlayer.Stop(); } if (this.cState.touchingWall) { this.cState.touchingWall = false; } if (this.cState.recoilingLeft || this.cState.recoilingRight) { this.CancelRecoilHorizontal(); } if (this.cState.bouncing) { this.CancelBounce(); this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f); } if (this.cState.shroomBouncing) { this.CancelBounce(); this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f); } if (!flag) { this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT); } damageAmount = ModHooks.AfterTakeDamage(hazardType, damageAmount); if (!this.takeNoDamage && !this.playerData.GetBool("invinciTest")) { if (this.playerData.GetBool("overcharmed")) { this.playerData.TakeHealth(damageAmount * 2); } else { this.playerData.TakeHealth(damageAmount); } } if (this.playerData.GetBool("equippedCharm_3") && damageAmount > 0) { if (this.playerData.GetBool("equippedCharm_35")) { this.AddMPCharge(this.GRUB_SOUL_MP_COMBO); } else { this.AddMPCharge(this.GRUB_SOUL_MP); } } if (this.joniBeam && damageAmount > 0) { this.joniBeam = false; } if (this.cState.nailCharging || this.nailChargeTimer != 0f) { this.cState.nailCharging = false; this.nailChargeTimer = 0f; } if (damageAmount > 0 && this.OnTakenDamage != null) { this.OnTakenDamage(); } if (this.playerData.GetInt("health") == 0) { base.StartCoroutine(this.Die()); } else if (hazardType == 2) { base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z)); } else if (hazardType == 3) { base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f)); } else if (hazardType == 4) { Debug.Log("Lava death"); } else if (hazardType == 5) { base.StartCoroutine(this.DieFromHazard(HazardType.PIT, 0f)); } else { base.StartCoroutine(this.StartRecoil(damageSide, spawnDamageEffect, damageAmount)); } } else if (this.cState.invulnerable && !this.cState.hazardDeath && !this.playerData.GetBool("isInvincible")) { if (hazardType == 2) { if (!this.takeNoDamage) { damageAmount = ModHooks.AfterTakeDamage(hazardType, damageAmount); this.playerData.TakeHealth(damageAmount); } this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged"); if (this.playerData.GetInt("health") == 0) { base.StartCoroutine(this.Die()); } else { this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT); base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z)); } } else if (hazardType == 3) { damageAmount = ModHooks.AfterTakeDamage(hazardType, damageAmount); this.playerData.TakeHealth(damageAmount); this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged"); if (this.playerData.GetInt("health") == 0) { base.StartCoroutine(this.Die()); } else { base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f)); } } else if (hazardType == 4) { Debug.Log("Lava damage"); } } } }
public T GetVariable <T>(string varName) { return(ModHooks.GetPlayerVariable <T>(varName)); }
public void SetVariable <T>(string varName, T value) { ModHooks.SetPlayerVariable <T>(varName, value); }
public Vector3 GetVector3(string vector3Name) { return(ModHooks.GetPlayerVector3(vector3Name)); }
public void SetVector3(string vector3Name, Vector3 value) { ModHooks.SetPlayerVector3(vector3Name, value); }
public void SetString(string stringName, string value) { ModHooks.SetPlayerString(stringName, value); }
public string GetString(string stringName) { return(ModHooks.GetPlayerString(stringName)); }
public void SetFloat(string floatName, float value) { ModHooks.SetPlayerFloat(floatName, value); }
public void BeginSceneTransition(GameManager.SceneLoadInfo info) { info.SceneName = ModHooks.BeforeSceneLoad(info.SceneName); orig_BeginSceneTransition(info); }
public void TakeHealth(int amount) { amount = ModHooks.OnTakeHealth(amount); orig_TakeHealth(amount); }
public void ClearSaveFile(int saveSlot, Action <bool> callback) { ModHooks.OnSavegameClear(saveSlot); orig_ClearSaveFile(saveSlot, callback); ModHooks.OnAfterSaveGameClear(saveSlot); }
public void UpdateBlueHealth() { orig_UpdateBlueHealth(); healthBlue += ModHooks.OnBlueHealth(); }
public void Attack(AttackDirection attackDir) { ModHooks.OnAttack(attackDir); //MOD API ADDED if (Time.timeSinceLevelLoad - this.altAttackTime > this.ALT_ATTACK_RESET) { this.cState.altAttack = false; } this.cState.attacking = true; if (this.playerData.equippedCharm_32) { this.attackDuration = this.ATTACK_DURATION_CH; } else { this.attackDuration = this.ATTACK_DURATION; } if (this.cState.wallSliding) { this.wallSlashing = true; this.slashComponent = this.wallSlash; this.slashFsm = this.wallSlashFsm; } else { this.wallSlashing = false; if (attackDir == AttackDirection.normal) { if (!this.cState.altAttack) { this.slashComponent = this.normalSlash; this.slashFsm = this.normalSlashFsm; this.cState.altAttack = true; } else { this.slashComponent = this.alternateSlash; this.slashFsm = this.alternateSlashFsm; this.cState.altAttack = false; } if (this.playerData.equippedCharm_35) { if ((this.playerData.health == this.playerData.maxHealth && !this.playerData.equippedCharm_27) || (this.joniBeam && this.playerData.equippedCharm_27)) { if (this.transform.localScale.x < 0f) { this.grubberFlyBeam = this.grubberFlyBeamPrefabR.Spawn(this.transform.position); } else { this.grubberFlyBeam = this.grubberFlyBeamPrefabL.Spawn(this.transform.position); } if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.MANTIS_CHARM_SCALE); } else { this.grubberFlyBeam.transform.SetScaleY(1f); } } if (this.playerData.health == 1 && this.playerData.equippedCharm_6 && this.playerData.healthBlue < 1) { if (this.transform.localScale.x < 0f) { this.grubberFlyBeam = this.grubberFlyBeamPrefabR_fury.Spawn(this.transform.position); } else { this.grubberFlyBeam = this.grubberFlyBeamPrefabL_fury.Spawn(this.transform.position); } if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.MANTIS_CHARM_SCALE); } else { this.grubberFlyBeam.transform.SetScaleY(1f); } } } } else if (attackDir == AttackDirection.upward) { this.slashComponent = this.upSlash; this.slashFsm = this.upSlashFsm; this.cState.upAttacking = true; if (this.playerData.equippedCharm_35) { if ((this.playerData.health == this.playerData.maxHealth && !this.playerData.equippedCharm_27) || (this.joniBeam && this.playerData.equippedCharm_27)) { this.grubberFlyBeam = this.grubberFlyBeamPrefabU.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); this.grubberFlyBeam.transform.localEulerAngles = new Vector3(0f, 0f, 270f); if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.grubberFlyBeam.transform.localScale.y * this.MANTIS_CHARM_SCALE); } } if (this.playerData.health == 1 && this.playerData.equippedCharm_6 && this.playerData.healthBlue < 1) { this.grubberFlyBeam = this.grubberFlyBeamPrefabU_fury.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); this.grubberFlyBeam.transform.localEulerAngles = new Vector3(0f, 0f, 270f); if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.grubberFlyBeam.transform.localScale.y * this.MANTIS_CHARM_SCALE); } } } } else if (attackDir == AttackDirection.downward) { this.slashComponent = this.downSlash; this.slashFsm = this.downSlashFsm; this.cState.downAttacking = true; if (this.playerData.equippedCharm_35) { if ((this.playerData.health == this.playerData.maxHealth && !this.playerData.equippedCharm_27) || (this.joniBeam && this.playerData.equippedCharm_27)) { this.grubberFlyBeam = this.grubberFlyBeamPrefabD.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); this.grubberFlyBeam.transform.localEulerAngles = new Vector3(0f, 0f, 90f); if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.grubberFlyBeam.transform.localScale.y * this.MANTIS_CHARM_SCALE); } } if (this.playerData.health == 1 && this.playerData.equippedCharm_6 && this.playerData.healthBlue < 1) { this.grubberFlyBeam = this.grubberFlyBeamPrefabD_fury.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); this.grubberFlyBeam.transform.localEulerAngles = new Vector3(0f, 0f, 90f); if (this.playerData.equippedCharm_13) { this.grubberFlyBeam.transform.SetScaleY(this.grubberFlyBeam.transform.localScale.y * this.MANTIS_CHARM_SCALE); } } } } } if (this.cState.wallSliding) { if (this.cState.facingRight) { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 180f; } else { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 0f; } } else if (attackDir == AttackDirection.normal && this.cState.facingRight) { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 0f; } else if (attackDir == AttackDirection.normal && !this.cState.facingRight) { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 180f; } else if (attackDir == AttackDirection.upward) { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 90f; } else if (attackDir == AttackDirection.downward) { this.slashFsm.FsmVariables.GetFsmFloat("direction").Value = 270f; } this.altAttackTime = Time.timeSinceLevelLoad; ModHooks.AfterAttack(attackDir); //MOD API - Added if (!this.cState.attacking) { return; //MOD API - Added } this.slashComponent.StartSlash(); if (this.playerData.equippedCharm_38) { this.fsm_orbitShield.SendEvent("SLASH"); } }
public void AddHealth(int amount) { amount = ModHooks.BeforeAddHealth(amount); orig_AddHealth(amount); }
public void StartMPDrain(float time) { orig_StartMPDrain(time); focusMP_amount *= ModHooks.OnFocusCost(); }
public void SetBool(string boolName, bool value) { ModHooks.SetPlayerBool(boolName, value); }
public void CharmUpdate() { orig_CharmUpdate(); ModHooks.OnCharmUpdate(); playerData.UpdateBlueHealth(); }
public bool GetBool(string boolName) { return(ModHooks.GetPlayerBool(boolName)); }
public static bool performTenMinuteClockUpdate(ref ModHooks ___hooks) { ___hooks.OnGame1_PerformTenMinuteClockUpdate(() => { int trulyDarkTime = Game1.getTrulyDarkTime(); Game1.gameTimeInterval = 0; if (Game1.IsMasterGame) { Game1.timeOfDay++; } if (Game1.timeOfDay % 10 != 0) { return; } if (Game1.timeOfDay % 100 >= 60) { Game1.timeOfDay = Game1.timeOfDay - Game1.timeOfDay % 100 + 100; } Game1.timeOfDay = Math.Min(Game1.timeOfDay, 2600); if (Game1.isLightning && Game1.timeOfDay < 2400 && Game1.IsMasterGame) { Utility.performLightningUpdate(); } if (Game1.timeOfDay == trulyDarkTime) { Game1.currentLocation.switchOutNightTiles(); } else if (Game1.timeOfDay == Game1.getModeratelyDarkTime()) { if (Game1.currentLocation.IsOutdoors && !Game1.isRaining) { Game1.ambientLight = Color.White; } if (!Game1.isRaining && !(Game1.currentLocation is MineShaft) && Game1.currentSong != null && !Game1.currentSong.Name.Contains("ambient") && Game1.currentLocation is Town) { Game1.changeMusicTrack("none", false, Game1.MusicContext.Default); } } if (Game1.getMusicTrackName(Game1.MusicContext.Default).StartsWith(Game1.currentSeason) && !Game1.getMusicTrackName(Game1.MusicContext.Default).Contains("ambient") && !Game1.eventUp && Game1.isDarkOut()) { Game1.changeMusicTrack("none", true, Game1.MusicContext.Default); } if (Game1.currentLocation.isOutdoors && !Game1.isRaining && !Game1.eventUp && Game1.getMusicTrackName(Game1.MusicContext.Default).Contains("day") && Game1.isDarkOut()) { Game1.changeMusicTrack("none", true, Game1.MusicContext.Default); } if (Game1.weatherIcon == 1) { int num = Convert.ToInt32(Game1.temporaryContent.Load <Dictionary <string, string> >(string.Concat(string.Concat("Data\\Festivals\\", Game1.currentSeason), Game1.dayOfMonth))["conditions"].Split(new char[] { '/' })[1].Split(new char[] { ' ' })[0]); if (Game1.whereIsTodaysFest == null) { Game1.whereIsTodaysFest = Game1.temporaryContent.Load <Dictionary <string, string> >(string.Concat(string.Concat("Data\\Festivals\\", Game1.currentSeason), Game1.dayOfMonth))["conditions"].Split(new char[] { '/' })[0]; } if (Game1.timeOfDay == num) { string str = Game1.temporaryContent.Load <Dictionary <string, string> >(string.Concat(string.Concat("Data\\Festivals\\", Game1.currentSeason), Game1.dayOfMonth))["conditions"].Split(new char[] { '/' })[0]; if (str == "Forest") { str = (Game1.currentSeason.Equals("winter") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2634") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2635")); } else if (str == "Town") { str = Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2637"); } else if (str == "Beach") { str = Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2639"); } Game1.showGlobalMessage(string.Concat(Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2640", Game1.temporaryContent.Load <Dictionary <string, string> >(string.Concat(string.Concat("Data\\Festivals\\", Game1.currentSeason), Game1.dayOfMonth))["name"]), str)); } } Game1.player.performTenMinuteUpdate(); int num1 = Game1.timeOfDay; if (num1 <= 2400) { if (num1 == 1200) { if (Game1.currentLocation.isOutdoors && !Game1.isRaining && (Game1.currentSong == null || Game1.currentSong.IsStopped || Game1.currentSong.Name.ToLower().Contains("ambient"))) { Game1.playMorningSong(); } } else if (num1 != 2000) { if (num1 == 2400) { Game1.dayTimeMoneyBox.timeShakeTimer = 2000; Game1.player.doEmote(24); Game1.showGlobalMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2652")); } } else if (!Game1.isRaining && Game1.currentLocation is Town) { Game1.changeMusicTrack("none", false, Game1.MusicContext.Default); } } else if (num1 == 2500) { Game1.dayTimeMoneyBox.timeShakeTimer = 2000; Game1.player.doEmote(24); } else if (num1 == 2600) { Game1.dayTimeMoneyBox.timeShakeTimer = 2000; if (Game1.player.mount != null) { Game1.player.mount.dismount(false); } if (Game1.player.UsingTool) { if (Game1.player.CurrentTool != null) { FishingRod currentTool = Game1.player.CurrentTool as FishingRod; FishingRod fishingRod = currentTool; if (currentTool != null && (fishingRod.isReeling || fishingRod.pullingOutOfWater)) { foreach (GameLocation location in Game1.locations) { location.performTenMinuteUpdate(Game1.timeOfDay); if (!(location is Farm)) { continue; } ((Farm)location).timeUpdate(10); } MineShaft.UpdateMines10Minutes(Game1.timeOfDay); if (Game1.IsMasterGame && Game1.farmEvent == null) { Game1.netWorldState.Value.UpdateFromGame1(); } return; } } Game1.player.completelyStopAnimatingOrDoingAction(); } } else if (num1 == 2800) { if (Game1.activeClickableMenu != null) { Game1.activeClickableMenu.emergencyShutDown(); Game1.exitActiveMenu(); } Game1.player.startToPassOut(); if (Game1.player.mount != null) { Game1.player.mount.dismount(false); } } foreach (GameLocation gameLocation in Game1.locations) { gameLocation.performTenMinuteUpdate(Game1.timeOfDay); if (!(gameLocation is Farm)) { continue; } ((Farm)gameLocation).timeUpdate(10); } MineShaft.UpdateMines10Minutes(Game1.timeOfDay); if (Game1.IsMasterGame && Game1.farmEvent == null) { Game1.netWorldState.Value.UpdateFromGame1(); } }); return(false); }
public int GetInt(string intName) { return(ModHooks.GetPlayerInt(intName)); }
private StardewModHooksWrapper(ModHooks previous) { this.previousHooks = previous; }
public void SetInt(string intName, int value) { ModHooks.SetPlayerInt(intName, value); }