Fixed MP Issue on ClimateChange/Invasion Items (#51)
This commit is contained in:
1 parent
4a79687aa6
commit
194b086ccd
6 files changed
+69
-20
No files matched your search
@@ -38,8 +38,13 @@ namespace CalamityMod.Items.SummonItems.Invasion
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
AcidRainEvent.TryStartEvent(forceRain: true);
|
||||
//CalamityNetcode.SyncWorld(); //TryStartEvent(forceRain: true) already sync the world data
|
||||
// Only Single Player client and Server should call this!
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
AcidRainEvent.TryStartEvent(forceRain: true);
|
||||
// TryStartEvent already syncs the world data
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -35,20 +36,38 @@ namespace CalamityMod.Items.SummonItems.Invasion
|
||||
itemGroup = ContentSamples.CreativeHelper.ItemGroup.EventItem;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player) => Main.invasionType == InvasionID.None;
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
// Do not start new invasion when it's already on going
|
||||
if (Main.invasionType != InvasionID.None)
|
||||
return false;
|
||||
|
||||
// This is the requirement for StartInvasion for some reason
|
||||
// If this part is missing MartianRemote will show DD2 invasion GUI without any enemy spawn on MP
|
||||
if (!Main.player.Any(p => p.active && p.ConsumedLifeCrystals >= 5))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
// Single Player case
|
||||
if (Main.netMode == NetmodeID.SinglePlayer)
|
||||
{
|
||||
Main.invasionDelay = 0;
|
||||
Main.StartInvasion(InvasionID.MartianMadness);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
// MP case: only owner should send Spawn Message to Master
|
||||
if (player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
//-7.0 is hardcoded id for MartianMadness Event
|
||||
NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, number: player.whoAmI, number2: -7.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
using SandstormEvent = Terraria.GameContent.Events.Sandstorm;
|
||||
|
||||
namespace CalamityMod.Items.Tools.ClimateChange
|
||||
{
|
||||
|
||||
|
||||
public class AridArtifact : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Tools";
|
||||
@@ -27,13 +32,17 @@ namespace CalamityMod.Items.Tools.ClimateChange
|
||||
return DownedBossSystem.downedDesertScourge || Main.hardMode;
|
||||
}
|
||||
|
||||
// this is extremely ugly and has to be fully qualified because we add an item called Sandstorm
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
if (Terraria.GameContent.Events.Sandstorm.Happening)
|
||||
// Only SinglePlayer and Server need to sync those parameters
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return true;
|
||||
|
||||
if (SandstormEvent.Happening)
|
||||
CalamityUtils.StopSandstorm();
|
||||
else
|
||||
CalamityUtils.StartSandstorm();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,17 +32,14 @@ namespace CalamityMod.Items.Tools.ClimateChange
|
||||
itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
public override bool CanUseItem(Player player) => !CalamityPlayer.areThereAnyDamnBosses;
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
//Only SinglePlayer or DedServ should change time to prevent unwanted race condition
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return true;
|
||||
|
||||
if (CalamityPlayer.areThereAnyDamnBosses)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// Early Morning -> Noon
|
||||
if (Main.dayTime && Main.time < NoonCutoff)
|
||||
Main.SkipToTime(NoonCutoff, true);
|
||||
|
||||
@@ -31,16 +31,19 @@ namespace CalamityMod.Items.Tools.ClimateChange
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
// Only SinglePlayer and Server need to sync those parameters
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return true;
|
||||
|
||||
if (!Main.raining)
|
||||
{
|
||||
CalamityUtils.StartRain(true);
|
||||
CalamityUtils.StartRain(torrentialTear: true, worldSync: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.raining = false;
|
||||
CalamityUtils.StopRain(clearWeather: false, worldSync: true);
|
||||
}
|
||||
|
||||
CalamityNetcode.SyncWorld();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+19
-3
@@ -197,7 +197,7 @@ namespace CalamityMod
|
||||
sfx.Volume = MathHelper.Clamp(sfx.Volume * volumeMultiplier, 0f, 1f);
|
||||
}
|
||||
|
||||
public static void StartRain(bool torrentialTear = false, bool maxSeverity = false)
|
||||
public static void StartRain(bool torrentialTear = false, bool maxSeverity = false, bool worldSync = true)
|
||||
{
|
||||
int framesInDay = 86400;
|
||||
int framesInHour = framesInDay / 24;
|
||||
@@ -247,7 +247,20 @@ namespace CalamityMod
|
||||
Main.raining = true;
|
||||
if (torrentialTear)
|
||||
TorrentialTear.AdjustRainSeverity(maxSeverity);
|
||||
CalamityNetcode.SyncWorld();
|
||||
|
||||
if (worldSync)
|
||||
CalamityNetcode.SyncWorld();
|
||||
}
|
||||
|
||||
public static void StopRain(bool clearWeather = false, bool worldSync = true)
|
||||
{
|
||||
if (clearWeather)
|
||||
Main.StopRain();
|
||||
else
|
||||
Main.raining = false;
|
||||
|
||||
if (worldSync)
|
||||
CalamityNetcode.SyncWorld();
|
||||
}
|
||||
|
||||
public static void StartSandstorm()
|
||||
@@ -278,7 +291,10 @@ namespace CalamityMod
|
||||
|
||||
public static void StopSandstorm()
|
||||
{
|
||||
Terraria.GameContent.Events.Sandstorm.Happening = false;
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
Sandstorm.StopSandstorm();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddWithCondition<T>(this List<T> list, T type, bool condition)
|
||||
|
||||
Reference in new issue
Block a user