Serious-Engine/Sources/EntitiesMP/GravityRouter.es
2016-03-11 15:57:17 +02:00

86 lines
1.9 KiB
JavaScript

/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */
227
%{
#include "StdH.h"
%}
uses "EntitiesMP/Marker";
event EChangeGravity {
CEntityPointer penNewGravity,
};
class CGravityRouter: CMarker {
name "Gravity Router";
thumbnail "Thumbnails\\GravityRouter.tbn";
features "IsImportant";
properties:
components:
1 model MODEL_MARKER "Models\\Editor\\GravityRouter.mdl",
2 texture TEXTURE_MARKER "Models\\Editor\\GravityRouter.tex"
functions:
/* Get force type name, return empty string if not used. */
const CTString &GetForceName(INDEX i)
{
return m_strName;
}
/* Get force in given point. */
void GetForce(INDEX i, const FLOAT3D &vPoint,
CForceStrength &fsGravity, CForceStrength &fsField)
{
if( (m_penTarget != NULL) && (IsOfClass( m_penTarget, "Gravity Marker")))
{
m_penTarget->GetForce(i, vPoint, fsGravity, fsField);
}
}
/* Get entity that controls the force, used for change notification checking. */
CEntity *GetForceController(INDEX iForce)
{
return this;
}
/* Handle an event, return false if the event is not handled. */
BOOL HandleEvent(const CEntityEvent &ee)
{
if( ((EChangeGravity &) ee).ee_slEvent==EVENTCODE_EChangeGravity)
{
m_penTarget = ((EChangeGravity &) ee).penNewGravity;
// notify engine that gravity defined by this entity has changed
NotifyGravityChanged();
return TRUE;
}
return FALSE;
}
procedures:
Main()
{
InitAsEditorModel();
SetPhysicsFlags(EPF_MODEL_IMMATERIAL);
SetCollisionFlags(ECF_IMMATERIAL);
// set appearance
SetModel(MODEL_MARKER);
SetModelMainTexture(TEXTURE_MARKER);
// set name
if (m_strName=="Marker") {
m_strName = "Gravity Router";
}
if( m_penTarget!=NULL && !IsOfClass( m_penTarget, "Gravity Marker")) {
WarningMessage( "Entity '%s' is not of Gravity Marker class!", m_penTarget);
m_penTarget = NULL;
}
return;
}
};