///<summary> ///Called when the owner is unregistered ///</summary> protected override void _OnUnregister() { //todo: perform de-initialization for the component if (_shadow != null) { TorqueObjectDatabase.Instance.Unregister(_shadow); _shadow = null; } base._OnUnregister(); }
protected void SetMarker(string markerNamePrefix, Vector2 pos) { if (null != _marker && _marker.IsRegistered) _marker.MarkForDelete = true; if (null != _markerTemplate) { _marker = _markerTemplate.Clone() as T2DStaticSprite; if (null != _marker) { _marker.Position = pos; _marker.Size = new Vector2(_satisfactionRadius, _satisfactionRadius); _marker.Name = markerNamePrefix + SceneObject.ObjectId; TorqueObjectDatabase.Instance.Register(_marker); } } }
///<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 animation callback for this component. ProcessList.Instance.AddAnimationCallback(Owner, this); if (ShadowTemplate != null) { ShadowSprite = (T2DStaticSprite)ShadowTemplate.Clone(); TorqueObjectDatabase.Instance.Register(ShadowSprite); ShadowSprite.Size = SceneObject.Size * 1.2f; ShadowSprite.Layer = SceneObject.Layer + 2; } return true; }