OpenFusion/src/Groups.hpp

38 lines
974 B
C++
Raw Normal View History

#pragma once
2022-04-23 01:13:00 +00:00
#include "Entities.hpp"
#include <vector>
#include <map>
#include <list>
/* forward declaration(s) */
2022-04-23 01:13:00 +00:00
struct Player;
struct Group {
std::vector<EntityRef> members;
std::vector<EntityRef> filter(EntityKind kind) {
2022-04-23 01:13:00 +00:00
std::vector<EntityRef> filtered;
std::copy_if(members.begin(), members.end(), std::back_inserter(filtered), [kind](EntityRef e) {
return e.kind == kind;
});
return filtered;
}
2022-07-31 00:43:17 +00:00
Group(EntityRef leader);
2022-04-23 01:13:00 +00:00
};
namespace Groups {
2021-12-16 02:34:15 +00:00
void init();
2022-04-23 01:13:00 +00:00
void sendToGroup(Group* group, void* buf, uint32_t type, size_t size);
2022-07-31 00:43:17 +00:00
void sendToGroup(Group* group, EntityRef excluded, void* buf, uint32_t type, size_t size);
void groupTickInfo(CNSocket* sock);
2022-04-23 01:13:00 +00:00
2022-07-31 00:43:17 +00:00
void groupKick(Group* group, EntityRef ref);
void addToGroup(Group* group, EntityRef member);
bool removeFromGroup(Group* group, EntityRef member); // true iff group deleted
2022-04-23 01:13:00 +00:00
void disbandGroup(Group* group);
}