You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
		
		
			
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
| 
											2 years ago
										 | using Entitas; | ||
|  | using Game; | ||
|  | 
 | ||
|  | public enum EInteractType | ||
|  | { | ||
|  |     Monster, | ||
|  |     Door, | ||
|  |     Npc, | ||
|  |     Bless, | ||
|  | } | ||
|  | [Game] | ||
|  | public class InteractComponent : IComponent | ||
|  | { | ||
|  |     public MetaData<bool> IsActive = new MetaData<bool>(); //是否激活 | ||
|  |     public MetaData<bool> IsTarget = new MetaData<bool>(); //是否在交互范围内、并成为交互目标 | ||
|  |     public EInteractType InteractType;  //交互类型 | ||
|  |     public string TargetId;             //交互目标id 关卡/宝箱/npc | ||
|  | } | ||
|  | 
 | ||
|  | namespace Game | ||
|  | { | ||
|  |     public abstract partial class Util | ||
|  |     { | ||
|  |         public static void SetIsTarget(int entityID, bool isTarget) | ||
|  |         { | ||
|  |             var entity = GetEntity(entityID); | ||
|  |             if (entity == null) | ||
|  |             { | ||
|  |                 return; | ||
|  |             } | ||
|  |             var interact = entity.interact; | ||
|  |             interact.IsTarget.Value = isTarget; | ||
|  |         } | ||
|  |         public static void ClearInteract(GameEntity entity) | ||
|  |         { | ||
|  |             var interact = entity.interact; | ||
|  |             interact.IsActive.Value = false; | ||
|  |             interact.IsTarget.Value = false; | ||
|  |         } | ||
|  |     } | ||
|  | } |