Пример #1
0
        internal PhysicalBody GetPhysicsComponent()
        {
            IGameObjectComponent phys = null;

            mComponentSet.TryGetValue(ComponentType.PHYSICS, out phys);
            return((PhysicalBody)phys);
        }
Пример #2
0
        internal IAIController GetAIComponent()
        {
            IGameObjectComponent ai = null;

            mComponentSet.TryGetValue(ComponentType.AI, out ai);
            return((IAIController)ai);
        }
Пример #3
0
        internal IRenderableObject GetGraphicComponent()
        {
            IGameObjectComponent graphic = null;

            mComponentSet.TryGetValue(ComponentType.GRAPHICS, out graphic);
            return((IRenderableObject)graphic);
        }
Пример #4
0
 /// <summary>
 /// Inject component
 /// </summary>
 /// <param name="pType">Component Type</param>
 /// <param name="pComponentToAdd">Component to Inject</param>
 public void Inject(ComponentType pType, IGameObjectComponent pComponentToAdd)
 {
     if (pComponentToAdd != null)
     {
         pComponentToAdd.OnBind(this);
         mComponentSet.Add(pType, pComponentToAdd);
     }
 }
        /// <summary>
        /// Gets the first MonoBehavior on the component's game object that is of type T. This is different from GetComponent in that the type can be an interface or class that is not itself a component.
        /// It is however a relatively slow operation, and should not be used in actions that happen frequently, e.g. Update.
        /// </summary>
        /// <typeparam name="T">The type of behavior to look for</typeparam>
        /// <param name="c">The component whose siblings will be inspected if they are of type T</param>
        /// <param name="searchParent">if set to <c>true</c> the parent transform will also be inspected if no match is found on the current component's transform.</param>
        /// <param name="required">if set to <c>true</c> and the requested component is not found, an exception will be thrown.</param>
        /// <returns>
        /// The T behavior sibling of the component or null if not found.
        /// </returns>
        public static T As <T>(this IGameObjectComponent c, bool searchParent = false, bool required = false) where T : class
        {
            if (c.Equals(null))
            {
                return(null);
            }

            return(As <T>(c.gameObject, searchParent, required));
        }
 public IGameObject GetGameObject(IGameObjectComponent component)
 {
     return(objects.FirstOrDefault(o => o.HasComponent(component)));
 }
Пример #7
0
 /// <summary>
 /// Gets a specialized unit facade for the unit on which this component resides.
 /// </summary>
 /// <param name="goc">The game object related component.</param>
 /// <param name="createIfMissing">Controls whether the facade is created if missing.</param>
 /// <returns>The unit facade for the unit.</returns>
 public static T GetUnitFacade <T>(this IGameObjectComponent goc, bool createIfMissing = true) where T : class, IUnitFacade, new()
 {
     return(GameServices.gameStateManager.GetUnitFacade <T>(goc.gameObject, createIfMissing));
 }
Пример #8
0
 /// <summary>
 /// Gets the unit facade for the unit represented by this component.
 /// </summary>
 /// <param name="goc">The game object related component.</param>
 /// <param name="createIfMissing">Controls whether the facade is created if missing.</param>
 /// <returns>The unit facade for the unit.</returns>
 public static IUnitFacade GetUnitFacade(this IGameObjectComponent goc, bool createIfMissing = true)
 {
     return(GameServices.gameStateManager.GetUnitFacade(goc.gameObject, createIfMissing));
 }
 public static IGameObjectComponent AddComponent(this IGameObject gameObject, IGameObjectComponent component)
 {
     component.GameObject = gameObject;
     gameObject.Components.Add(component);
     return(component);
 }
Пример #10
0
 public bool HasComponent(IGameObjectComponent component)
 {
     return(components.ContainsValue(component));
 }
Пример #11
0
 public void SetGameObjectComponent(IGameObjectComponent newGameObjectComponent)
 {
     string id = newGameObjectComponent.ComponentId;
     if (!components.ContainsKey(id))
         components.Add(id, newGameObjectComponent);
     else
         components[id] = newGameObjectComponent;
     newGameObjectComponent.Owner = this;
 }