private bool ShouldSend(PlaceSendMessage b, Point3D p) { if (b.SendCount > 10) { return(false); } if (b.NoChecks) { return(true); } if (!Actions.Of(this.BotBits).CanEdit) { return(false); } var playerData = ConnectionManager.Of(this.BotBits).PlayerData; var blocks = Blocks.Of(this.BotBits); var isAdministrator = playerData.PlayerObject.IsAdministrator; if (!WorldUtils.IsPlaceable(b, blocks, !isAdministrator)) { return(false); } if (!playerData.HasBlock(b.Id)) { return(false); } CheckHandle handle; return(!(this._sentLocations.TryGetValue(p, out handle) ? WorldUtils.AreSame(b, handle.Message) : WorldUtils.IsAlreadyPlaced(b, blocks))); }
private static void CheckBind(BotBitsClient client, Type type, bool isExtension, string extraText) { var message = isExtension ? "This extention does not support being loaded after {1} has already been received because it relies on receiving {0}." + extraText : "Cannot listen to {0}, a {1} has already been received. To fix this issue, load your EventListeners before joining a room." + extraText; if (type == typeof(ConnectEvent)) { if (ConnectionManager.Of(client).Connection != null) { throw new DiagnosticException(String.Format(message, type.Name, nameof(ConnectEvent))); } } if (type == typeof(InitEvent)) { if (Room.Of(client).InitComplete) { throw new DiagnosticException(String.Format(message, type.Name, nameof(InitEvent))); } } if (type == typeof(JoinFailureEvent) || type == typeof(JoinCompleteEvent)) { if (Room.Of(client).JoinComplete || !(ConnectionManager.Of(client).Connection?.Connected ?? true)) { throw new DiagnosticException(String.Format(message, type.Name, nameof(JoinCompleteEvent) + " or " + nameof(JoinFailureEvent))); } } }
private void BlockChecker_InitializeFinish(object sender, EventArgs e) { this._connectionManager = ConnectionManager.Of(this.BotBits); this._room = Room.Of(this.BotBits); this._world = Blocks.Of(this.BotBits); this._messageQueue = PlaceSendMessage.Of(this.BotBits); this._messageQueue.Sending += this.OnSendingPlace; this._messageQueue.Send += this.OnSendPlace; }
internal Task InitConnection(string roomId, int?version, Connection conn, CancellationToken ct) { var joinTask = this.CompleteJoinAsync(ct); return(this._argsAsync .Then(task => this.Attach(ConnectionManager.Of(this._botBitsClient), conn, new ConnectionArgs(this.ConnectUserId, roomId, task.Result, this.Database), version)) .Then(task => joinTask) .Then(task => { if (task.IsCanceled) { ConnectionManager.Of(this._botBitsClient).Connection.Disconnect(); } }) .ToSafeTask()); }
private void On(InitEvent e) { this.OwnPlayer = e.Player; this.OwnPlayer.Connected = true; this.OwnPlayer.Username = e.Username; this.OwnPlayer.ConnectUserId = ConnectionManager.Of(this.BotBits).ConnectUserId; this.OwnPlayer.Smiley = e.Smiley; this.OwnPlayer.AuraShape = e.AuraShape; this.OwnPlayer.AuraColor = e.AuraColor; this.OwnPlayer.Badge = e.Badge; this.OwnPlayer.ChatColor = e.ChatColor; this.OwnPlayer.X = e.SpawnX; this.OwnPlayer.Y = e.SpawnY; this.OwnPlayer.CrewMember = e.CrewMember; this.OwnPlayer.GoldBorder = true; }
internal bool SendMessage(T msg, BotBitsClient client) { var e = new SendingEvent <T>(msg); e.RaiseIn(client); if (e.Cancelled) { return(false); } var con = ConnectionManager.Of(client).Connection; if (con == null) { return(false); } new SentEvent <T>(msg) .RaiseIn(client); e.Message.Send(con); return(true); }
private void MessageSender_InitializeFinish(object sender, EventArgs e) { this._connectionManager = ConnectionManager.Of(this.BotBits); }
private bool HasAura(AuraShape auraShape, AuraColor auraColor) { return(ConnectionManager.Of(this.BotBits).PlayerData.HasAuraShape(auraShape) && ConnectionManager.Of(this.BotBits).PlayerData.HasAuraColor(auraColor)); }
private bool HasSmiley(Smiley smiley) { return(ConnectionManager.Of(this.BotBits).PlayerData.HasSmiley(smiley)); }
public override void Load(object obj) { ConnectionManager.Of(this.BotBits).CurrentScheduler.InitScheduler(false); base.Load(obj); }
public LoginClient WithClient(Client client) { return(new LoginClient(ConnectionManager.Of(this.BotBits), client)); }