[General] Send and read ActorAnimPlay packets

0.6.1
David Cernat 8 years ago
parent 56aeb85965
commit 2872675f5e

@ -2155,7 +2155,6 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int
if (mwmp::Main::get().getCellController()->isLocalActor(mPtr))
{
mwmp::LocalActor *actor = mwmp::Main::get().getCellController()->getLocalActor(mPtr);
actor->hasAnimation = true;
actor->animation.groupname = groupname;
actor->animation.mode = mode;
actor->animation.count = count;

@ -29,6 +29,7 @@ void ActorList::reset()
baseActors.clear();
positionActors.clear();
animFlagsActors.clear();
animPlayActors.clear();
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
}
@ -52,6 +53,11 @@ void ActorList::addAnimFlagsActor(LocalActor localActor)
animFlagsActors.push_back(localActor);
}
void ActorList::addAnimPlayActor(LocalActor localActor)
{
animPlayActors.push_back(localActor);
}
void ActorList::sendPositionActors()
{
if (positionActors.size() > 0)
@ -72,6 +78,16 @@ void ActorList::sendAnimFlagsActors()
}
}
void ActorList::sendAnimPlayActors()
{
if (animPlayActors.size() > 0)
{
baseActors = animPlayActors;
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_PLAY)->setActorList(this);
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_PLAY)->Send();
}
}
// TODO: Finish this
void ActorList::editActorsInCell(MWWorld::CellStore* cellStore)
{

@ -23,9 +23,11 @@ namespace mwmp
void addPositionActor(LocalActor localActor);
void addAnimFlagsActor(LocalActor localActor);
void addAnimPlayActor(LocalActor localActor);
void sendPositionActors();
void sendAnimFlagsActors();
void sendAnimPlayActors();
void editActorsInCell(MWWorld::CellStore* cellStore);
@ -36,6 +38,7 @@ namespace mwmp
std::vector<BaseActor> positionActors;
std::vector<BaseActor> animFlagsActors;
std::vector<BaseActor> animPlayActors;
};
}

@ -54,6 +54,7 @@ void Cell::updateLocal(bool forceUpdate)
actorList->sendPositionActors();
actorList->sendAnimFlagsActors();
actorList->sendAnimPlayActors();
}
void Cell::updateDedicated(float dt)
@ -109,6 +110,28 @@ void Cell::readAnimFlags(ActorList& actorList)
}
}
void Cell::readAnimPlay(ActorList& actorList)
{
initializeDedicatedActors(actorList);
BaseActor baseActor;
for (unsigned int i = 0; i < actorList.count; i++)
{
baseActor = actorList.baseActors.at(i);
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
if (dedicatedActors.count(mapIndex) > 0)
{
DedicatedActor *actor = dedicatedActors[mapIndex];
actor->animation.groupname = baseActor.animation.groupname;
actor->animation.mode = baseActor.animation.mode;
actor->animation.count = baseActor.animation.count;
actor->animation.persist = baseActor.animation.persist;
}
}
}
void Cell::initializeLocalActors()
{
ESM::Cell esmCell = *store->getCell();

@ -20,6 +20,7 @@ namespace mwmp
void readPositions(ActorList& actorList);
void readAnimFlags(ActorList& actorList);
void readAnimPlay(ActorList& actorList);
void initializeLocalActors();
void initializeDedicatedActors(ActorList& actorList);

@ -115,6 +115,19 @@ void CellController::readAnimFlags(ActorList& actorList)
}
}
void CellController::readAnimPlay(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
initializeCell(actorList.cell);
// If this now exists, send it the data
if (cellsActive.count(mapIndex) > 0)
{
cellsActive[mapIndex]->readAnimPlay(actorList);
}
}
void CellController::setLocalActorRecord(std::string actorIndex, std::string cellIndex)
{
localActorsToCells[actorIndex] = cellIndex;

@ -24,6 +24,7 @@ namespace mwmp
void readPositions(mwmp::ActorList& actorList);
void readAnimFlags(mwmp::ActorList& actorList);
void readAnimPlay(mwmp::ActorList& actorList);
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
void removeLocalActorRecord(std::string actorIndex);

@ -17,6 +17,7 @@ DedicatedActor::DedicatedActor()
{
drawState = 0;
movementFlags = 0;
animation.groupname = "";
}
DedicatedActor::~DedicatedActor()
@ -28,7 +29,7 @@ void DedicatedActor::update(float dt)
{
move(dt);
setDrawState();
//setAnimation();
setAnimation();
}
void DedicatedActor::move(float dt)
@ -65,10 +66,12 @@ void DedicatedActor::setDrawState()
void DedicatedActor::setAnimation()
{
if (hasAnimation)
if (!animation.groupname.empty())
{
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(ptr,
animation.groupname, animation.mode, animation.count, animation.persist);
animation.groupname.clear();
}
}

@ -36,6 +36,7 @@ void LocalActor::update(bool forceUpdate)
{
updatePosition(forceUpdate);
updateAnimFlags(forceUpdate);
updateAnimPlay();
}
void LocalActor::updatePosition(bool forceUpdate)
@ -111,6 +112,15 @@ void LocalActor::updateAnimFlags(bool forceUpdate)
}
}
void LocalActor::updateAnimPlay()
{
if (!animation.groupname.empty())
{
mwmp::Main::get().getNetworking()->getActorList()->addAnimPlayActor(*this);
animation.groupname.clear();
}
}
MWWorld::Ptr LocalActor::getPtr()
{
return ptr;

@ -18,6 +18,7 @@ namespace mwmp
void updatePosition(bool forceUpdate);
void updateAnimFlags(bool forceUpdate);
void updateAnimPlay();
MWWorld::Ptr getPtr();
void setPtr(const MWWorld::Ptr& newPtr);

@ -879,6 +879,8 @@ void Networking::processActorPacket(RakNet::Packet *packet)
}
case ID_ACTOR_ANIM_PLAY:
{
//Main::get().getCellController()->readAnimPlay(actorList);
break;
}
case ID_ACTOR_ATTACK:

@ -33,7 +33,6 @@ namespace mwmp
float headYaw;
Animation animation;
bool hasAnimation;
};
class BaseActorList

@ -38,7 +38,10 @@ void PacketActorAnimPlay::Packet(RakNet::BitStream *bs, bool send)
RW(actor.refNumIndex, send);
RW(actor.mpNum, send);
// TODO: Fill this in
RW(actor.animation.groupname, send);
RW(actor.animation.mode, send);
RW(actor.animation.count, send);
RW(actor.animation.persist, send);
if (!send)
{

@ -37,21 +37,6 @@ void PacketActorTest::Packet(RakNet::BitStream *bs, bool send)
RW(actor.refId, send);
RW(actor.refNumIndex, send);
RW(actor.mpNum, send);
RW(actor.position, send);
RW(actor.drawState, send);
RW(actor.headPitch, send);
RW(actor.headYaw, send);
RW(actor.hasAnimation, send);
if (actor.hasAnimation)
{
RW(actor.animation.groupname, send);
RW(actor.animation.mode, send);
RW(actor.animation.count, send);
RW(actor.animation.persist, send);
}
if (!send)
{

Loading…
Cancel
Save