protected override bool _OnRegister(TorqueObject owner) { if (!base._OnRegister(owner) || !(owner is T2DSceneObject)) return false; mountEvent = new TorqueEvent<bool>("mountAction"); TorqueEventManager.Instance.MgrListenEvents<bool>(mountEvent, ProcessMount, null); // Set the type of the melee object to a damage trigger type so it collides with enemies SceneObject.SetObjectType(PlatformerData.DamageTriggerObjecType, true); // Make sure we tell the melee object what to collide with, in this case // it will only collide with enemies (non-player actors) SceneObject.Collision.CollidesWith += PlatformerData.EnemyObjectType; return true; }
///<summary> ///Called when the owner is registered ///</summary> protected override bool _OnRegister(TorqueObject owner) { if (!base._OnRegister(owner) || !(owner is T2DSceneObject)) return false; //todo: perform initialization for the component //todo: look up interfaces exposed by other components //E.g., //_theirInterface = // Owner.Components.GetInterface<ValueInterface<float>>( // "float", "their interface name"); //activate tick callback for this component. ProcessList.Instance.AddTickCallback(Owner, this); _thrustEvent = new TorqueEvent<ThrustData>("thrustEvent"); TorqueEventManager.Instance.MgrListenEvents( _thrustEvent, OnThrustEvent, this); return true; }
protected override bool _OnRegister(TorqueObject owner) { if (!base._OnRegister(owner) || !(owner is T2DSceneObject)) return false; mountEvent = new TorqueEvent<bool>("mountAction"); TorqueEventManager.Instance.MgrListenEvents<bool>(mountEvent, ProcessMount, null); SetupCollision(); mounted = false; return true; }
protected override bool _OnRegister(TorqueObject owner) { if (!base._OnRegister(owner) || !(owner is T2DSceneObject)) return false; // tell the process list to notifiy us with ProcessTick and InterpolateTick events ProcessList.Instance.AddTickCallback(Owner, this); readyToRotate = false; if (facingLeft) signCoefficient = -1.0f; else { signCoefficient = 1.0f; endRotation += 180.0f; } if (onRotationFinished != null) { rotationFinishedEvent = new TorqueEvent<T2DSceneObject>("RotationFinished"); TorqueEventManager.ListenEvents<T2DSceneObject>(rotationFinishedEvent, OnRotationFinished); } BeginRotation(); return true; }
/// <summary> /// Called when the owner is registered /// </summary> protected override bool _OnRegister(TorqueObject owner) { if (!base._OnRegister(owner) || !(owner is T2DSceneObject)) return false; // todo: perform initialization for the component // todo: look up interfaces exposed by other components // E.g., // _theirInterface = // Owner.Components.GetInterface<ValueInterface<float>>( // "float", "their interface name"); // activate tick callback for this component. ProcessList.Instance.AddTickCallback(Owner, this); _thrustEvent = new TorqueEvent<ThrustData>("thrustEvent"); _steeringRegulator = new Regulator(UpdatesPerSec); _maxForwardSpeed = Owner.Components.GetInterface<ValueInterface<float>>( "float", "maxForwardSpeed"); _maxReverseSpeed = Owner.Components.GetInterface<ValueInterface<float>>( "float", "maxReverseSpeed"); _maxBrakingDeceleration = Owner.Components.GetInterface<ValueInterface<float>>( "float", "maxBrakingDeceleration"); return true; }