/// <summary> /// For internal use only, i.e. this method should not be called by user code. /// </summary> internal void OnAuthorityChanged(IComponentMetaclass componentMetaclass, Authority authority, object component) { for (var i = 0; i < ExtractedVisualizers.Count; i++) { var visualizer = ExtractedVisualizers[i]; var field = VisualizerMetadataLookup.Instance.GetFieldInfo(component.GetType(), visualizer.GetType()); if (field != null && VisualizerMetadataLookup.Instance.IsWriter(field)) { if (authority == Authority.Authoritative || authority == Authority.AuthorityLossImminent) { InjectField(visualizer, field, component); authoritativeComponents.Add(componentMetaclass.ComponentId); UpdateActivation(visualizer); } else { Deactivate(visualizer); field.SetValue(visualizer, null); authoritativeComponents.Remove(componentMetaclass.ComponentId); } } } TriggerRequiredComponentsPotentiallyChanged(); }
public void TriggerComponentAuthorityChanged(EntityId entityId, IComponentMetaclass componentId, Authority authority, object component) { if (ComponentAuthorityChanged != null) { ComponentAuthorityChanged(entityId, componentId, authority, component); } }
/// <summary> /// For internal use only, i.e. this method should not be called by user code. /// </summary> internal void OnComponentRemoved(IComponentMetaclass componentMetaclass, object component) { for (var i = 0; i < ExtractedVisualizers.Count; i++) { InjectNullAndDisable(ExtractedVisualizers[i], componentMetaclass, component.GetType()); } TriggerRequiredComponentsPotentiallyChanged(); }
/// <summary> /// For internal use only, i.e. this method should not be called by user code. /// </summary> internal void OnComponentAdded(IComponentMetaclass componentMetaclass, object component) { for (var i = 0; i < ExtractedVisualizers.Count; i++) { InjectReaders(ExtractedVisualizers[i], component); } TriggerRequiredComponentsPotentiallyChanged(); }
static void ProcessAdds <TComponent, TData, TUpdate>(IComponentMetaclass <TComponent, TData, TUpdate> metaclass, ConcurrentQueue <AddComponentOp <TData> > addOps) where TComponent : IComponentMetaclass { while (addOps.Count > 0) { if (addOps.TryDequeue(out var op)) { connection.SendAddComponent(metaclass, op.EntityId, op.Data, updateParameterNoLoopback); } } }
static void ProcessUpdates <TComponent, TData, TUpdate>(IComponentMetaclass <TComponent, TData, TUpdate> metaclass, ConcurrentQueue <ComponentUpdateOp <TUpdate> > updateOps) where TComponent : IComponentMetaclass { while (updateOps.Count > 0) { if (updateOps.TryDequeue(out var op)) { connection.SendComponentUpdate(metaclass, op.EntityId, op.Update, updateParameterNoLoopback); } } }
private void InjectNullAndDisable(MonoBehaviour visualizer, IComponentMetaclass componentMetaclass, Type componentType) { var field = VisualizerMetadataLookup.Instance.GetFieldInfo(componentType, visualizer.GetType()); if (field == null) { return; } Deactivate(visualizer); field.SetValue(visualizer, null); }
/// <inheritdoc /> public void AuthorityChanged(EntityId entityId, IComponentMetaclass componentId, Authority authority, object component) { spatialCommunicator.TriggerComponentAuthorityChanged(entityId, componentId, authority, component); for (int i = 0; i < authorityChangedCallbacks.Count; ++i) { try { authorityChangedCallbacks[i](entityId, componentId, authority, component); } catch (Exception e) { Debug.LogException(e); } } }
private void OnComponentAuthorityChanged(EntityId entityId, IComponentMetaclass componentId, Authority authority, object componentObj) { if (authority == Authority.Authoritative) { return; } var component = new EntityComponentId(entityId, componentId.ComponentId); HashSet <uint> requestIds; if (!componentToRequestIds.TryGetValue(component, out requestIds)) { return; } foreach (var requestId in requestIds) { componentCommander.ForgetRequestId(requestId); } componentToRequestIds.Remove(component); }
internal void UpdateComponent(EntityId entityId, IComponentMetaclass componentMetaclass, object update) { block.UpdateComponent(new UpdateComponentPipelineOp { EntityId = entityId, ComponentMetaClass = componentMetaclass, UpdateObject = update }); }
internal void ChangeAuthority(EntityId entityId, IComponentMetaclass componentMetaclass, Authority authority, object component) { block.ChangeAuthority(new ChangeAuthorityPipelineOp { EntityId = entityId, ComponentMetaClass = componentMetaclass, ComponentObject = component, Authority = authority }); }
internal void RemoveComponent(EntityId entityId, IComponentMetaclass componentMetaclass, object component) { block.RemoveComponent(new RemoveComponentPipelineOp { EntityId = entityId, ComponentMetaClass = componentMetaclass, ComponentObject = component }); }