/// <summary> /// 检测世界交换物体的缓存 /// </summary> private void CheckWorldItemCaches(ref IShipDockEntitas target) { if (WorldComp.IsDataValid(ref target)) { mWorldItem = WorldComp.GetEntitasData(ref target); if (ShouldAddToWorldItems()) { mWorldItemMapper.Put(mWorldItem.worldItemID, mWorldItem); AfterWorldItemCached(ref target); } } }
public static void Init <T>(int componentName, WorldInteracter item, EntitasComponentable entitas, GameObject gameObject, IWorldIntercatable target = default) where T : WorldComponent { T comp = entitas.GetComponentByName <T>(componentName); item = comp.GetEntitasData(ref entitas); item.worldItemID = gameObject.GetInstanceID(); if (target != default) { item.Add(target.WorldItemHandler); item.WorldItemDispose = target.WorldItemDispose; } }
public override int DropEntitas(IShipDockEntitas target, int entitasID) { mWorldItem = WorldComp.GetEntitasData(ref target); if ((mWorldItem != default) && (mWorldItem.worldItemID != int.MaxValue)) { if (mWorldItemMapper.ContainsKey(mWorldItem.worldItemID)) { DropWorldItem(ref target); } } return(base.DropEntitas(target, entitasID)); }
/// <summary> /// 检测世界交换物体的事件 /// </summary> private void CheckWorldEvents() { if (mWorldEventNotices.Count > 0) { mItemNotice = mWorldEventNotices.Dequeue(); if (mEventItems.Count > 0) { mEventItem = mEventItems.Dequeue(); if (IsEventItemValid()) { mEventItem.Dispatch(mItemNotice);//派发世界物体消息 mItemNotice.ToPool(); } } } }
private bool IsWorldItemValid(ref WorldInteracter item) { return((item != default) && !item.isDroped); }