public static int Redeploy(int fromPlayerWho) { var kitSingleton = ModContent.GetInstance <TrackDeploymentKitItem>(); (int x, int y, int dir)resume = kitSingleton.ResumeDeploymentAt; kitSingleton.ResumeDeploymentAt = (0, 0, 0); if (Main.tile[resume.x, resume.y]?.active() == true) { Main.NewText("Track kit auto-deploy obstructed.", Color.Yellow); return(0); } /*int blah=120; * Timers.SetTimer( "blah_"+resume.x+"_"+resume.y, 3, false, () => { * Dust.QuickDust( new Point(resume.x,resume.y), Color.Red ); * return blah-- > 0; * } );*/ if (Main.netMode == 0) { return(TrackDeploymentKitItem.Deploy(fromPlayerWho, resume.x, resume.y, resume.dir > 0)); } else { TrackKitDeployProtocol.SendToServer(resume.dir > 0, resume.x, resume.y, true); return(0); } }
public override void PlaceInWorld(int i, int j, Item item) { bool isFacingRight = Main.LocalPlayer.direction == 1; if (Main.netMode == 1) { TrackKitDeployProtocol.SendToServer(isFacingRight, i, j, false); } else if (Main.netMode == 0) { TrackDeploymentTile.DeployAt(i, j, isFacingRight, Main.myPlayer); } }
private void CheckTrackKitResume(int heldTrackKitItemType) { if (!this.player.mount.Active || !this.player.mount.Cart) { return; } var trackKitSingleton = ModContent.GetInstance <TrackDeploymentKitItem>(); (int x, int y, int dir)resume = trackKitSingleton.ResumeDeploymentAt; var resumeWldPos = new Vector2((resume.x << 4) + 8, (resume.y << 4) + 8); if (Vector2.DistanceSquared(this.player.Center, resumeWldPos) >= 4096) // 4 tiles { return; } PlayerItemLibraries.RemoveInventoryItemQuantity(this.player, heldTrackKitItemType, 1); int leftovers = TrackDeploymentKitItem.Redeploy(this.player.whoAmI); if (leftovers == 0) { return; } int itemWho = Item.NewItem(resumeWldPos, ItemID.MinecartTrack, leftovers); if (Main.netMode != NetmodeID.MultiplayerClient) { NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemWho, 1f); } else { TrackKitDeployProtocol.SendToServer(resume.dir > 0, resume.x, resume.y, true); } }