RealmGateAddressComponent.cs 788 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. using Base;
  3. namespace Model
  4. {
  5. [ObjectEvent]
  6. public class RealmGateAddressComponentEvent : ObjectEvent<RealmGateAddressComponent>, IAwake
  7. {
  8. public void Awake()
  9. {
  10. this.GetValue().Awake();
  11. }
  12. }
  13. public class RealmGateAddressComponent : Component
  14. {
  15. private readonly List<StartConfig> GateAddress = new List<StartConfig>();
  16. public void Awake()
  17. {
  18. StartConfig[] startConfigs = this.GetComponent<StartConfigComponent>().GetAll();
  19. foreach (StartConfig config in startConfigs)
  20. {
  21. if (!config.AppType.Is(AppType.Gate))
  22. {
  23. continue;
  24. }
  25. this.GateAddress.Add(config);
  26. }
  27. }
  28. public Entity GetAddress()
  29. {
  30. int n = RandomHelper.RandomNumber(0, this.GateAddress.Count);
  31. return this.GateAddress[n];
  32. }
  33. }
  34. }