//////////////// public void CheckAndApplyNegotiatorTimeUp_FromServer() { int negotType = NPCType <PirateNegotiatorTownNPC>(); NPC negotiator = Main.npc.FirstOrDefault(n => n?.active == true && n.type == negotType); if (negotiator == null) { return; } PirateNegotiatorTownNPC.AllDealingsFinished_FromServer(null, 0, 0); }
private void MakeOffer() { var npc = PirateNegotiatorTownNPC.GetNearbyNegotiator(Main.LocalPlayer); var mynpc = npc?.modNPC as PirateNegotiatorTownNPC; if (mynpc == null) { this.Close(); } mynpc.GiveOffer(this.OfferTotal); this.Close(); }
//////////////// /// @private public override void Action(CommandCaller caller, string input, string[] args) { var config = PDYBConfig.Instance; if (!config.DebugModeCheats) { caller.Reply("Cheats disabled.", Color.Yellow); } NPC npc = PirateNegotiatorTownNPC.GetNearbyNegotiator(caller.Player); if (npc != null) { caller.Reply("Negotiator is spawned nearby.", Color.Yellow); } int negotType = NPCType <PirateNegotiatorTownNPC>(); npc = Main.npc.FirstOrDefault(n => n?.active == true && n.type == negotType); if (npc != null) { caller.Reply("Negotiator is spawned.", Color.Yellow); } PirateNegotiatorTownNPC.Exit(npc, Main.netMode == NetmodeID.Server); int who, x, y; if (caller.Player?.active == true) { x = (int)caller.Player.position.X; y = (int)caller.Player.position.Y; } else { x = Main.spawnTileX << 4; y = Main.spawnTileY << 4; } who = NPC.NewNPC(x, y, negotType); if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, who); } caller.Reply("Pirate negotiator spawned at " + x + ", " + y, Color.Lime); }
//////////////// /// @private public override void Action( CommandCaller caller, string input, string[] args ) { var config = PDYBConfig.Instance; if( !config.DebugModeCheats ) { caller.Reply( "Cheats disabled.", Color.Yellow ); } int negotType = NPCType<PirateNegotiatorTownNPC>(); IList<NPC> npcs = Main.npc.Where( n => n?.active == true && n.type == negotType ).ToList(); if( npcs.Count == 0 ) { caller.Reply( "No negotiators spawned.", Color.Yellow ); } foreach( NPC npc in npcs ) { PirateNegotiatorTownNPC.Exit( npc, Main.netMode == NetmodeID.Server ); } caller.Reply( "Pirate negotiators despawned.", Color.Lime ); }
//// private void UpdateHagglingUIState() { if (!this.HagglePanel?.IsOpen ?? true) { return; } Player plr = Main.LocalPlayer; bool isHaggling = !plr.dead && !Main.playerInventory && !plr.CCed && PirateNegotiatorTownNPC.GetNearbyNegotiator(plr) != null; if (!isHaggling) { this.CloseHaggleUI(); } else { //plr.noItems = true; } }
protected override void ReceiveOnServer(int fromWho) { PirateNegotiatorTownNPC.AllDealingsFinished_FromServer(Main.player[this.WhoAmI], this.OfferTested, this.OfferAmount); }
//////////////// protected override void ReceiveOnClient() { PirateNegotiatorTownNPC.AllDealingsFinished_ToClient(Main.player[this.WhoAmI], this.OfferTested, this.OfferAmount); }