protected override void OnReInit() { base.OnReInit(); if (_component != null) { _gameCompoentInfo.Free(_component.GetComponentId(), _component); } }
public static ModifyComponentPatch Allocate(IGameComponent leftComponent, IGameComponent comp, BitArray32 mask) { var rc = ObjectAllocatorHolder <ModifyComponentPatch> .Allocate(); rc.CreateGameComponent(comp.GetComponentId()); (rc.Component as INetworkObject).CopyFrom(comp); rc.CreateLastGameComponent(comp.GetComponentId()); (rc.LastComponent as INetworkObject).CopyFrom(leftComponent); rc._bitMask = mask; return(rc); }
public override void OnDiffComponent(IGameEntity leftEntity, IGameComponent leftComponent, IGameEntity rightEntity, IGameComponent rightComponent) { IGameEntity localEntity; _localEntityMap.TryGetValue(leftEntity.EntityKey, out localEntity); if (localEntity != null) // entity存在,但是不是playback { var localComponent = localEntity.GetComponent(leftComponent.GetComponentId()); if (localComponent != null) { var local = localComponent as IInterpolatableComponent; if (local.IsInterpolateEveryFrame()) { _playBackInfos.Add(new PlayBackInfo(localComponent, leftComponent, rightComponent)); } try { _info.BeginProfile(); local.Interpolate(leftComponent, rightComponent, _interpolationInfo); } finally { _info.EndProfile(); } } else { //_logger.WarnFormat("component is null while playback {0}:{1}", localEntity.EntityKey, leftComponent.GetComponentId()); } } }
public override void OnDiffComponent(IGameEntity leftEntity, IGameComponent leftComponent, IGameEntity rightEntity, IGameComponent rightComponent) { IGameEntity localEntity; localEntityMap.TryGetValue(leftEntity.EntityKey, out localEntity); if (localEntity == null) { return; } // entity存在,但是不是playback var localComponent = localEntity.GetComponent(leftComponent.GetComponentId()); if (localComponent != null) { var local = localComponent as IInterpolatableComponent; if (local.IsInterpolateEveryFrame()) { playBackInfos.Add(new PlayBackInfo(localComponent, leftComponent, rightComponent)); } try { info.BeginProfileOnlyEnableProfile(); local.Interpolate(leftComponent, rightComponent, interpolationInfo); } finally { info.EndProfileOnlyEnableProfile(); } } }
/// <summary> /// 生成新加Component的Patch /// </summary> /// <param name="rightEntity"></param> /// <param name="leftEntity"></param> /// <param name="rightComponent"></param> public override void OnLeftComponentMissing(IGameEntity leftEntity, IGameEntity rightEntity, IGameComponent rightComponent) { logger.DebugFormat("AddComponentPatch :{0}, {1}", leftEntity.EntityKey, rightComponent.GetComponentId()); var componentPatch = AddComponentPatch.Allocate(rightComponent); currentEntityPatch.AddComponentPatch(componentPatch); componentPatch.ReleaseReference(); }
public static DeleteComponentPatch Allocate(IGameComponent comp) { var rc = ObjectAllocatorHolder <DeleteComponentPatch> .Allocate(); rc.CreateGameComponent(comp.GetComponentId()); // ReSharper disable once PossibleNullReferenceException (rc.Component as INetworkObject).CopyFrom(comp); return(rc); }
protected void SetComponent(int id, IGameComponent component) { if (component != null) { AssertUtility.Assert(!_components.ContainsKey(id)); AssertUtility.Assert(component.GetComponentId() == id); } SetDirty(); _components[id] = component; }
/// <summary> /// 生成单个Component的Patch /// </summary> /// <param name="leftEntity"></param> /// <param name="leftComponent"></param> /// <param name="rightEntity"></param> /// <param name="rightComponent"></param> public override void OnDiffComponent(IGameEntity leftEntity, IGameComponent leftComponent, IGameEntity rightEntity, IGameComponent rightComponent) { var serializer = serializerManager.GetSerializer(leftComponent.GetComponentId()); var bitMask = serializer.DiffNetworkObject(leftComponent as INetworkObject, rightComponent as INetworkObject); if (bitMask.HasValue()) { var componentPatch = ModifyComponentPatch.Allocate(leftComponent, rightComponent, bitMask); currentEntityPatch.AddComponentPatch(componentPatch); componentPatch.ReleaseReference(); } }
public override void OnDiffComponent(IGameEntity leftEntity, IGameComponent leftComponent, IGameEntity rightEntity, IGameComponent rightComponent) { var localEntity = snapshot.GetEntity(leftEntity.EntityKey); var localComponent = localEntity.AddComponent(rightComponent.GetComponentId()); var comp = localComponent as IInterpolatableComponent; // ReSharper disable once PossibleNullReferenceException comp.Interpolate(leftComponent, rightComponent, interpolationInfo); }
public void Free(IGameComponent component) { _allocators[component.GetComponentId()].Free(component); }
public void OnRightComponentMissing(IGameEntity leftEntity, IGameEntity rightEntity, IGameComponent leftComponent) { _logger.DebugFormat("remove component {0}:{1}", leftEntity.EntityKey, leftComponent.GetType()); leftEntity.RemoveComponent(leftComponent.GetComponentId()); }
public void OnLeftComponentMissing(IGameEntity leftEntity, IGameEntity rightEntity, IGameComponent rightComponent) { _logger.DebugFormat("add component {0}:{1}", leftEntity.EntityKey, rightComponent.GetType()); var leftComponent = (ILatestComponent)leftEntity.AddComponent(rightComponent.GetComponentId(), rightComponent); }
/// <summary> /// 在Patch中生成删除Entity的Patch /// </summary> /// <param name="leftEntity"></param> /// <param name="rightEntity"></param> /// <param name="leftComponent"></param> public void OnRightComponentMissing(IGameEntity leftEntity, IGameEntity rightEntity, IGameComponent leftComponent) { _logger.DebugFormat("DeleteComponentPatch ::{0}, {1}", leftEntity.EntityKey, leftComponent.GetComponentId()); var componentPatch = DeleteComponentPatch.Allocate(leftComponent); _currentEntityPatch.AddComponentPatch(componentPatch); componentPatch.ReleaseReference(); }
public override void OnLeftComponentMissing(IGameEntity leftEntity, IGameEntity rightEntity, IGameComponent rightComponent) { _logger.DebugFormat("add component {0}:{1}", leftEntity.EntityKey, rightComponent.GetType()); leftEntity.AddComponent(rightComponent.GetComponentId()); }