Class BaseToggle
Namespace: ValveResourceFormat.Renderer.Entities
Assembly: Renderer.dll
The base of the brush entities that travel between two places, Source's CBaseToggle: buttons, doors, and anything else that slides open and shut.
public abstract class BaseToggle : BaseModelEntityInheritance
object ← BaseEntity ← BaseModelEntity ← BaseToggle
Derived
Inherited Members
BaseModelEntity.ModelNode, BaseModelEntity.CreateRootNode(), BaseEntity.Scene, BaseEntity.RootNode, BaseEntity.Transform, BaseEntity.LayerName, BaseEntity.EntitySystem, BaseEntity.Data, BaseEntity.KeyValues, BaseEntity.Classname, BaseEntity.TargetName, BaseEntity.SpawnFlags, BaseEntity.ParentTransform, BaseEntity.Owner, BaseEntity.MoveParent, BaseEntity.EntityScale, BaseEntity.ModelName, BaseEntity.Origin, BaseEntity.Angles, BaseEntity.Velocity, BaseEntity.AngularVelocity, BaseEntity.NextThink, BaseEntity.MoveDoneTime, BaseEntity.IsRemoved, BaseEntity.Collider, BaseEntity.IsSolid, BaseEntity.IsTrigger, BaseEntity.IsDrawn, BaseEntity.InPlayableWorld, BaseEntity.IsCollidable, BaseEntity.TouchingEntities, BaseEntity.CreateRootNode(), BaseEntity.HasSpawnFlags<TSpawnFlags>(TSpawnFlags), BaseEntity.Spawn(), BaseEntity.Activate(), BaseEntity.Think(), BaseEntity.RoundStart(), BaseEntity.MoveDone(), BaseEntity.TryGetTouchBounds(out Vector3, out Vector3), BaseEntity.AcceptsTouchFrom(BaseEntity), BaseEntity.OnStartTouch(BaseEntity), BaseEntity.OnTouch(BaseEntity), BaseEntity.OnEndTouch(BaseEntity), BaseEntity.ObjectCaps, BaseEntity.Use(BaseEntity?), BaseEntity.Teleport(Vector3, Vector3?), BaseEntity.AcceptInput(string, EntityInputData), BaseEntity.InputKill(EntityInputData), BaseEntity.InputFireUser1(EntityInputData), BaseEntity.InputFireUser2(EntityInputData), BaseEntity.InputFireUser3(EntityInputData), BaseEntity.InputFireUser4(EntityInputData), BaseEntity.SetNextThink(float), BaseEntity.SetMoveDoneTime(float), BaseEntity.PhysicsSimulate(float), BaseEntity.IsPusher, BaseEntity.PusherForcesThrough, BaseEntity.GetSurfaceVelocity(Vector3), BaseEntity.TurnBody(Vector3, Vector3), BaseEntity.SetOriginAndAngles(Vector3, Vector3), BaseEntity.AddNode(SceneNode), BaseEntity.OnRemove(), BaseEntity.UpdateTransform(), BaseEntity.UpdateColliderTransform(), BaseEntity.UpdateRenderTransform(float), BaseEntity.SnapInterpolation(), BaseEntity.OnSpawnGroupTransformApplied(), BaseEntity.AngleMod(float)
Remarks
The travel is a LinearMove, not an interpolation: the entity is given a constant velocity and a deadline, the tick integrates it like anything else that moves, and the arrival lands on the exact destination rather than wherever the last tick happened to leave it.
Constructors
BaseToggle(EntitySystem, EntitySpawnInfo)
Initializes a moving brush from its keyvalues.
protected BaseToggle(EntitySystem system, EntitySpawnInfo spawnInfo)Parameters
system EntitySystem
spawnInfo EntitySpawnInfo
Properties
FinalDestination
Gets where the brush is currently heading.
protected Vector3 FinalDestination { get; }Property Value
IsLinearMoving
Gets whether a or is under way.
protected bool IsLinearMoving { get; }Property Value
IsPusher
A travelling brush shoves the player rather than swallowing them.
protected override bool IsPusher { get; }Property Value
Lip
Gets or sets how much of the brush stays proud of its opening, the lip keyvalue.
public float Lip { get; protected set; }Property Value
MoveDirection
Gets the direction the brush travels, resolved from its angles or movedir.
protected Vector3 MoveDirection { get; }Property Value
Speed
Gets or sets how fast the brush travels, in units per second.
public float Speed { get; protected set; }Property Value
Methods
AngularMove(Vector3, float)
Turns towards a destination angle at speed degrees per second, arriving when the move-done comes due. Source's CBaseToggle::AngularMove.
protected void AngularMove(Vector3 destinationAngle, float speed)Parameters
destinationAngle Vector3
speed float
FinishLinearMove()
Ends a travel exactly on its destination. Call from MoveDone before acting on the arrival.
protected bool FinishLinearMove()Returns
true when a travel was in progress and has now landed.
GetAxisDirection(bool, bool)
Reads the axis a rotating brush turns about from its spawnflags. Source's CBaseToggle::AxisDir, whose flag names are for the QAngle component they set, so its "roll" flag is what Hammer labels X Axis.
protected static Vector3 GetAxisDirection(bool rollAxis, bool pitchAxis)Parameters
rollAxis bool
pitchAxis bool
Returns
GetTravelDistance()
How far the brush slides: its own length along the travel axis, less the lip that keeps it proud.
protected float GetTravelDistance()Returns
Remarks
Source subtracts a further 2 units because the engine hands it a brush bound that is 1 unit larger in every direction. The bounds here come from the compiled collision hull and are not padded, so the same authored lip lands in the same place without that correction.
LinearMove(Vector3)
Sets off towards a destination at , arriving when the move-done comes due. Source's CBaseToggle::LinearMove: constant velocity and a deadline, not a lerp.
protected void LinearMove(Vector3 destination)Parameters
destination Vector3
ResolveMoveDirection(bool)
Reads the direction the brush travels. Source encodes it in angles, with two magic values for straight up and down, and zeroes the angles afterwards because they were never an orientation. Source 2 authors it as its own movedir keyvalue on some entities, and there the brush's own angles mean what they say, so they are left alone.
protected void ResolveMoveDirection(bool consumeAngles = true)Parameters
consumeAngles bool
Whether the angles are the travel direction and should be cleared once read, which is what CBaseButton::Spawn does through SetMovedir. A door does not: its angles are where a swinging travel starts from.

