コード例 #1
0
 public override void OnReleased()
 {
     base.OnReleased();
     if (Container == null)
     {
         return;
     }
     Object.Destroy(Container.gameObject);
     Container = null;
     ModifyExistingNetInfos.Reset();
 }
コード例 #2
0
        private void InitializeByBuilder(object trackBuilder, List <KeyValuePair <NetInfo, NetInfoVersion> > tracks)
        {
            TrainTrackAI mainAi = null;

            new[] {
                NetInfoVersion.Ground, NetInfoVersion.Elevated, NetInfoVersion.Bridge, NetInfoVersion.Slope,
                NetInfoVersion.Tunnel
            }.ForEach(version =>
            {
                ModifyExistingNetInfos.ModifyExistingIcons();
                if (!(trackBuilder.GetPropery <NetInfoVersion>("SupportedVersions").IsFlagSet(version) || version == NetInfoVersion.Ground))
                {
                    return;
                }
                var newPrefabName      = SharedHelpers.NameBuilder(trackBuilder.GetPropery <string>("Name"), version);
                var originalPrefabName =
                    SharedHelpers.NameBuilder(trackBuilder.GetPropery <string>("BasedPrefabName"), version);
                Action <NetInfo> action;
                switch (version)
                {
                case NetInfoVersion.Ground:
                    action = arg => mainAi = arg.GetComponent <TrainTrackAI>();
                    break;

                case NetInfoVersion.Elevated:
                    action = arg => mainAi.m_elevatedInfo = arg;
                    break;

                case NetInfoVersion.Bridge:
                    action = arg => mainAi.m_bridgeInfo = arg;
                    break;

                case NetInfoVersion.Tunnel:
                    action = arg => mainAi.m_tunnelInfo = arg;
                    break;

                case NetInfoVersion.Slope:
                    action = arg => mainAi.m_slopeInfo = arg;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                CreatePrefab(newPrefabName, originalPrefabName,
                             SetupOneWayPrefabAction().Apply(trackBuilder).Apply(version)
                             .Chain(action)
                             .Chain(AddPairAction().Apply(version).Apply(tracks))
                             .Chain(SetupUIAction().Apply(trackBuilder))
                             );
            });
        }