private void CreateSource(Source.SourceType type) { try { BasicSource newSource = null; switch (type) { case Source.SourceType.Base: newSource = Instantiate(_baseSourcePrefab, transform.position, Quaternion.identity); break; case Source.SourceType.Body: newSource = Instantiate(_bodySourcePrefab, transform.position, Quaternion.identity); break; case Source.SourceType.Detail: newSource = Instantiate(_detailSourcePrefab, transform.position, Quaternion.identity); break; default: break; } newSource.SetCurrentParent(this, true, false); newSource.Initialize(this); _nSourcesCreated++; #if DEBUG_PRINT Debug.Log("[" + name + "] generated source " + newSource.name); #endif SendSourceOut(newSource, this, OutputModules[0]); DataChanged(GetStats()); } catch (Exception e) { Debug.LogError(e); } }
public void Initialize(Bloc parent, Source.SourceType type) { if(parent == null) { Debug.Log ("Stream initialized without valid parent bloc!"); return; } _bloc = parent; BlocIndex streamIndex = _bloc.indexInMap; streamIndex.z += 1; //transform.position = Map.IndexToPosition(streamIndex); transform.parent = parent.transform; transform.localPosition = Vector3.zero; _type = type; ResetValues(); }