ET框架---RealmGateAddressComponent学习笔记

RealmGateAddressComponent

请大家关注我的微博:@NormanLin_BadPixel坏像素


这是一个管理AppType.Gate服务启动信息的组件。我们看到,它储存的是StartConfig类型的数据。

提供的获取信息的方法,很好理解。

public StartConfig GetAddress()
{
    int n = RandomHelper.RandomNumber(0, this.GateAddress.Count);
    return this.GateAddress[n];
}

把这些地址又是在哪里获取到的呢?有了之前的教训,这会我每看一个类,都会去看看它有没有其他的扩展方法。

public static class RealmGateAddressComponentEx
{
    public static void Start(this RealmGateAddressComponent component)
    {
        StartConfig[] startConfigs = component.Entity.GetComponent<StartConfigComponent>().GetAll();
        foreach (StartConfig config in startConfigs)
        {
            if (!config.AppType.Is(AppType.Gate))
            {
                continue;
            }

            component.GateAddress.Add(config);
        }
    }
}

由此可见,它保存了启动配置里面所有的AppType.Gate地址。

猜你喜欢

转载自blog.csdn.net/norman_lin/article/details/79941202