SBSPSS/Utils/MkLevel/Layers/MkLevelLayerActor.cpp

100 lines
3.3 KiB
C++
Raw Normal View History

2001-04-17 18:42:07 +02:00
/*******************/
/*** Layer Actor ***/
/*******************/
#include <Davelib.h>
#include <List2d.h>
#include "..\MkLevel.h"
#include "MkLevelLayerActor.h"
/*****************************************************************************/
/*****************************************************************************/
/*** Pre-Process *************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CMkLevelLayerActor::PreProcess(CMkLevel *Core)
{
}
/*****************************************************************************/
/*****************************************************************************/
/*** Process *****************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CMkLevelLayerActor::Process(CMkLevel *Core)
{
int i,ListSize;
bool NotFound;
// Extract Player Start
GString Player=Core->GetConfigStr("MISC","PlayerActor");
NotFound=true;
ListSize=ThingList.size();
for (i=0; i<ListSize && NotFound; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
if (ThisThing.Name==Player)
{
Core->SetStart(ThisThing.XY[0].x,ThisThing.XY[0].y);
NotFound=false;
ThingList.erase(i);
}
}
if (NotFound)
{
2001-04-19 17:12:21 +02:00
GObject::Error(ERR_WARNING,"No Start Point defined\n");
2001-04-17 18:42:07 +02:00
}
2001-04-19 17:12:21 +02:00
ProcessList(Core);
2001-04-17 18:42:07 +02:00
printf("%i actors\n",ThingList.size());
}
/*****************************************************************************/
/*****************************************************************************/
/** Write ********************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-06-25 17:54:07 +02:00
int CMkLevelLayerActor::Write(CMkLevel *Core,FILE *File,const char *LayerName)
2001-04-17 18:42:07 +02:00
{
int ThisPos=ftell(File);
sThingHdr Hdr;
int i,ListSize=ThingList.size();
Hdr.Count=ListSize;
fwrite(&Hdr,sizeof(sThingHdr),1,File);
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
int p,PointCount=ThisThing.XY.size();
sThingActor OutThing;
OutThing.Type=ThisThing.Type;
2001-04-30 23:49:54 +02:00
OutThing.Health=ThisThing.Data.Actor.ActorHealth;
OutThing.AttackStrength=ThisThing.Data.Actor.ActorAttackStrength;
OutThing.Speed=ThisThing.Data.Actor.ActorSpeed;
OutThing.TurnRate=ThisThing.Data.Actor.ActorTurnRate;
2001-05-09 23:56:48 +02:00
OutThing.Flags=0;
if (ThisThing.Data.Actor.ActorCollisionFlag) OutThing.Flags|=THING_FLAG_COLLISION;
if (ThisThing.Data.Flip & PC_TILE_FLAG_MIRROR_X) OutThing.Flags|=THING_FLAG_MIRRORX;
if (ThisThing.Data.Flip & PC_TILE_FLAG_MIRROR_Y) OutThing.Flags|=THING_FLAG_MIRRORY;
2001-04-17 18:42:07 +02:00
OutThing.PointCount=PointCount;
fwrite(&OutThing,sizeof(sThingActor),1,File);
for (p=0;p<PointCount;p++)
{
sThingPoint Pnt;
Pnt.X=ThisThing.XY[p].x;
Pnt.Y=ThisThing.XY[p].y;
fwrite(&Pnt,sizeof(sThingPoint),1,File);
}
}
2001-06-25 17:54:07 +02:00
Size=ftell(File)-ThisPos;
2001-04-17 18:42:07 +02:00
return(ThisPos);
}
/*****************************************************************************/