PDA

View Full Version : Logic Entity


Nial
07-09-2007, 08:11 AM
I'm trying to create a logic entity that will coordinate my MP mod game. I have a number of questions, so here goes:

My coordinator entity works like so:
DEFINE_INPUTFUNC( FIELD_INTEGER, "Set_Door_Status", SetDoorStatus ),
DEFINE_OUTPUT( m_bDoorState, "Door_State" ),

void CNbN_GameCoordinator::SetDoorStatus( inputdata_t &inputData )
{
switch( inputData.value.Int() )
{
case 0:
m_bDoorState.FireOutput( inputData.pActivator, this );
break;
}
}


The idea here is that a mapper could then create a trigger which would toggle the door state. The trigger would be linked to the GameCoordinator and fire an Output to it. The GameCoordinator receives it, checks its value and acts accordingly, sending out an Output to every other entity that's been linked to it.

Is my code and logic correct here? If so, I have the following question:

1) Is it possible to spawn such a logic entity in code (rather than forcing a mapper to place it) and still have other entities within the map communicate with it via inputs?

Angry Beaver
07-09-2007, 12:47 PM
How i heck is that code supposed to toggle. All it'll ever do is fire the output if its sent a 0.

Also a switch statement for just 1 option kind of defeats the purpose, just use an if.

as for spawning it in code, I'll be honest I've never tried. But so long as you give it a name it will be able to be interacted with by levels without a problem.

lodle
07-09-2007, 09:35 PM
Spawning in code is easy. Just make a new instance of the object and set it up right.

Nial
07-10-2007, 12:42 AM
How i heck is that code supposed to toggle. All it'll ever do is fire the output if its sent a 0.

Also a switch statement for just 1 option kind of defeats the purpose, just use an if.

Obviously, this was just a piece of example code.

Spawning in code is easy. Just make a new instance of the object and set it up right.

I know how, that's not what I was asking. If I spawn a Logic Entity in code, can other entities placed by the mapper fire outputs/receive inputs from it?

lodle
07-10-2007, 09:56 AM
yes. Just need to find out how to set the links up.