Beispiel #1
0
        public void AddBuff <T>(Main.Ecs.YuoEntity entity) where T : BuffComponent, new()
        {
            var component = entity.GetComponent <T>();

            if (component == null)
            {
                component = entity.AddComponent <T>();
                World.Instance.RunSystemOfTag <IBuffCreateBefore>(component);
                if (component.BooleanOption.Get("CanAdd"))
                {
                    World.Instance.RunSystemOfTag <IBuffCreate>(component);
                }
                else
                {
                    World.Instance.RunSystemOfTag <IBuffCreateError>(component);
                    entity.RemoveComponent(component);
                }
            }
            else
            {
                if (component.BuffCount < component.BuffMaxCount)
                {
                    component.BuffCount++;
                    World.Instance.RunSystemOfTag <IBuffAdd>(component);
                }
            }
        }
Beispiel #2
0
 public static long GetID(Main.Ecs.YuoEntity entity)
 {
     return(entity.GetHashCode());
 }