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)) ); }); }
public void WriteToGame(NetInfo gameNetInfo) { gameNetInfo.name = this.name; Utils.CopyToGame(this.basic, gameNetInfo); TrainTrackAI gameRoadAI = (TrainTrackAI)gameNetInfo.m_netAI; if (gameRoadAI.m_elevatedInfo != null) { Utils.CopyToGame(this.elevated, gameRoadAI.m_elevatedInfo); gameRoadAI.m_elevatedInfo.name = this.name + "_Elevated0"; } if (gameRoadAI.m_bridgeInfo != null) { Utils.CopyToGame(this.bridge, gameRoadAI.m_bridgeInfo); gameRoadAI.m_bridgeInfo.name = this.name + "_Bridge0"; } if (gameRoadAI.m_slopeInfo != null) { Utils.CopyToGame(this.slope, gameRoadAI.m_slopeInfo); gameRoadAI.m_slopeInfo.name = this.name + "_Slope0"; } if (gameRoadAI.m_tunnelInfo != null) { Utils.CopyToGame(this.tunnel, gameRoadAI.m_tunnelInfo); gameRoadAI.m_tunnelInfo.name = this.name + "_Tunnel0"; } Utils.CopyToGame(this.basicAI, gameRoadAI); Utils.CopyToGame(this.elevatedAI, gameRoadAI.m_elevatedInfo?.GetAI()); Utils.CopyToGame(this.bridgeAI, gameRoadAI.m_bridgeInfo?.GetAI()); Utils.CopyToGame(this.slopeAI, gameRoadAI.m_slopeInfo?.GetAI()); Utils.CopyToGame(this.tunnelAI, gameRoadAI.m_tunnelInfo?.GetAI()); Utils.RefreshRoadEditor(); basicModel?.Apply(gameNetInfo, "Basic"); elevatedModel?.Apply(gameRoadAI.m_elevatedInfo, "Elevated"); bridgeModel?.Apply(gameRoadAI.m_bridgeInfo, "Bridge"); slopeModel?.Apply(gameRoadAI.m_slopeInfo, "Slope"); tunnelModel?.Apply(gameRoadAI.m_tunnelInfo, "Tunnel"); }
public void ReadFromGame(NetInfo gameNetInfo) { this.name = gameNetInfo.name; Utils.CopyFromGame(gameNetInfo, this.basic); TrainTrackAI gameRoadAI = (TrainTrackAI)gameNetInfo.m_netAI; Utils.CopyFromGame(gameRoadAI.m_elevatedInfo, this.elevated); Utils.CopyFromGame(gameRoadAI.m_bridgeInfo, this.bridge); Utils.CopyFromGame(gameRoadAI.m_slopeInfo, this.slope); Utils.CopyFromGame(gameRoadAI.m_tunnelInfo, this.tunnel); Utils.CopyFromGame(gameRoadAI, this.basicAI); Utils.CopyFromGame(gameRoadAI.m_elevatedInfo?.GetAI(), this.elevatedAI); Utils.CopyFromGame(gameRoadAI.m_bridgeInfo?.GetAI(), this.bridgeAI); Utils.CopyFromGame(gameRoadAI.m_slopeInfo?.GetAI(), this.slopeAI); Utils.CopyFromGame(gameRoadAI.m_tunnelInfo?.GetAI(), this.tunnelAI); basicModel.Read(gameNetInfo, "Basic"); elevatedModel.Read(gameRoadAI.m_elevatedInfo, "Elevated"); bridgeModel.Read(gameRoadAI.m_bridgeInfo, "Bridge"); slopeModel.Read(gameRoadAI.m_slopeInfo, "Slope"); tunnelModel.Read(gameRoadAI.m_tunnelInfo, "Tunnel"); }