protected override void OnAddReference() { if (ComponentTracker.Enable && ComponentTracker.EnableEvents) { ComponentTracker.NotifyEvent(this, ComponentEventType.AddReference); } }
public int CreateComponentTracker(ComponentTrackerModel componentTrackerModel) { ComponentTracker componentTracker = _componentTrackerRepository.GetComponentTrackerByID(componentTrackerModel.ID); if (componentTracker == null) { componentTracker = this._componentTrackerRepository.CreateComponentTracker(new ComponentTracker() { AssetID = componentTrackerModel.AssetID, ComponentStatusID = componentTrackerModel.ComponentStatusID, ComponentID = componentTrackerModel.ComponentID, CreatedDate = componentTrackerModel.CreatedDate, CreatedBy = componentTrackerModel.CreatedBy, Remarks = componentTrackerModel.Remarks, }); } else if (componentTracker.AssetID != componentTrackerModel.AssetID || componentTracker.ComponentID != componentTrackerModel.ComponentID || componentTracker.ComponentStatusID != componentTrackerModel.ComponentStatusID) { componentTracker = this._componentTrackerRepository.CreateComponentTracker(new ComponentTracker() { AssetID = componentTrackerModel.AssetID, ComponentStatusID = componentTrackerModel.ComponentStatusID, ComponentID = componentTrackerModel.ComponentID, CreatedDate = componentTrackerModel.CreatedDate, CreatedBy = componentTrackerModel.CreatedBy, Remarks = componentTrackerModel.Remarks, }); } return(componentTracker.ID); }
private Action AddComponentToGameObject(Component component, ComponentTracker tracker) { component.gameObject = this; tracker.component = component; var methods = GetMethods( component, new List <string>() { StartMethodName, UpdateMethodName, LateUpdateMethodName, OnPlayerConnectedMethodName, OnPlayerDisconnectedMethodName, OnComponentAddedMethodName, AwakeMethodName, OnInstantiationFinishedMethodName, OnDestroyMethodName, OnPlayerLeftRoomMethodName, OnPlayerEnteredRoomMethodName }, new List <Type>() { typeof(Action), typeof(Action), typeof(Action), typeof(Action <Player>), typeof(Action <Player>), typeof(Action <Component>), typeof(Action), typeof(Action <Player>), typeof(Action), typeof(Action <Player>), typeof(Action <Player>) }); var startMethod = methods[0] as Action; tracker.update = methods[1] as Action; tracker.lateUpdate = methods[2] as Action; tracker.onPlayerConnected = methods[3] as Action <Player>; tracker.onPlayerDisconnected = methods[4] as Action <Player>; tracker.onComponentAdded = methods[5] as Action <Component>; var awakeMethod = methods[6] as Action; tracker.onFinishedInstantiate = methods[7] as Action <Player>; tracker.onDestroy = methods[8] as Action; tracker.onPlayerLeftRoom = methods[9] as Action <Player>; tracker.onPlayerEnteredRoom = methods[10] as Action <Player>; components.Add(tracker); if (startMethod != null) { GameState.AddStart(startMethod); } return(awakeMethod); }
/// <summary> /// Disposes of object resources. /// </summary> protected virtual void Destroy() { // Untrack this object if (ComponentTracker.Enable) { ComponentTracker.UnTrack(this); } collector.Dispose(); }
/// <summary> /// Disposes of object resources. /// </summary> protected override void Destroy() { // Untrack this object if (ComponentTracker.Enable) { ComponentTracker.UnTrack(this); } base.Destroy(); }
/// <summary> /// Initializes a new instance of the <see cref="ComponentBase"/> class. /// </summary> /// <param name="name">The name attached to this component</param> protected ComponentBase(string name) { Name = name ?? GetType().Name; Id = Interlocked.Increment(ref globalCounterId); // Track this component if (ComponentTracker.Enable) { ComponentTracker.Track(this); } }
/// <summary> /// Initializes a new instance of the <see cref="ComponentBase"/> class. /// </summary> /// <param name="name">The name attached to this component</param> protected ComponentBase(string name) { Name = name ?? GetType().Name; Id = Guid.NewGuid(); // Track this component if (ComponentTracker.Enable) { ComponentTracker.Track(this); } }
/// <summary> /// Initializes a new instance of the <see cref="ComponentBase"/> class. /// </summary> /// <param name="name">The name attached to this component</param> protected ComponentBase(string name) { Name = name ?? GetType().Name; Id = Interlocked.Increment(ref globalCounterId); collector = new ObjectCollector(); // Track this component if (ComponentTracker.Enable) { ComponentTracker.Track(this); } Tags = new PropertyContainer(this); }
/// <inheritdoc/> int IReferencable.AddReference() { if (ComponentTracker.Enable && ComponentTracker.EnableEvents) { ComponentTracker.NotifyEvent(this, ComponentEventType.AddReference); } int newCounter = Interlocked.Increment(ref counter); if (newCounter <= 1) { throw new InvalidOperationException(FrameworkResources.AddReferenceError); } return(newCounter); }
/// <inheritdoc/> int IReferencable.Release() { if (ComponentTracker.Enable && ComponentTracker.EnableEvents) { ComponentTracker.NotifyEvent(this, ComponentEventType.Release); } int newCounter = Interlocked.Decrement(ref counter); if (newCounter == 0) { Destroy(); } else if (newCounter < 0) { throw new InvalidOperationException(FrameworkResources.ReleaseReferenceError); } return(newCounter); }
internal Component DeserializeAddComponent(Type componentType, out Action awakeMethod, ComponentTracker tracker) { var component = Activator.CreateInstance(componentType) as Component; awakeMethod = null; if (component == null) { Debug.LogError("Attempted to add a type that was not of the type Component to the gameobject"); return(null); } awakeMethod = AddComponentToGameObject(component, tracker); return(component); }