public TxAutotrophChrome1AB Copy() { var result = new TxAutotrophChrome1AB(); for (int i = 0; i < TxAutotrophChrome1.LENGTH; i++) { result.ValueA[i] = ValueA[i]; result.ValueB[i] = ValueB[i]; } return(result); }
public TxAutotrophChrome1AB RandomRange(ref Random random) { var result = new TxAutotrophChrome1AB(); for (int i = 0; i < TxAutotrophChrome1.LENGTH; i++) { result.ValueA[i] = random.NextFloat(ValueA[i], ValueB[i]); result.ValueB[i] = random.NextFloat(ValueA[i], ValueB[i]); } return(result); }
public void TxAutotrophGrow_Test() { //set Environment & genome var chrome1 = new TxAutotrophChrome1() { nrg2Height = 1, nrg2Leaf = 1, nrg2Seed = 1, nrg2Storage = 1, seedSize = 4, // not tested yet maxHeight = 10, //doubled because pollen values are all 0 maxLeaf = 11f //doubled because pollen values are all 0 }; var chrome1W = new TxAutotrophChrome1W { Value = chrome1.Copy() }; m_Manager.SetComponentData(sprout, chrome1W); var chrome1AB = new TxAutotrophChrome1AB { ValueA = chrome1.Copy(), ValueB = chrome1.Copy(), }; m_Manager.SetComponentData(sprout, chrome1AB); var es = Environment.environmentSettings[0]; es.txAutotrophConsts.seedDivisor = 2; es.txAutotrophConsts.stemScale = 1; es.txAutotrophConsts.minShadeRadius = 1; es.txAutotrophConsts.leafShadeRadiusMultiplier = 10; Environment.environmentSettings[0] = es; World.CreateSystem <TxAutotrophSproutSystem>().Update(); World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>().Update(); var stems = m_Manager.CreateEntityQuery(ComponentType.ReadOnly <TxAutotroph>(), ComponentType.ReadOnly <TxAutotrophMeshes>(), ComponentType.ReadOnly <EnergyStore>(), ComponentType.ReadOnly <TxAutotrophPhenotype>(), ComponentType.ReadOnly <Scale>(), ComponentType.ReadOnly <Translation>(), ComponentType.ReadOnly <PhysicsCollider>() ).ToEntityArray(Allocator.TempJob); var plant = stems[0]; stems.Dispose(); Assert.AreEqual(1f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).height, "Height start"); Assert.AreEqual(1f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).leaf, "Leaf start"); Assert.AreEqual(5, m_Manager.GetComponentData <TxAutotrophChrome1W>(plant).Value.maxHeight, "maxHeight start"); Assert.AreEqual(m_Manager.GetComponentData <TxAutotrophChrome1W>(plant).Value.nrg2Height, m_Manager.GetComponentData <TxAutotrophChrome1W>(plant).Value.nrg2Leaf, "nrg2Height == nrg2Leaf pre"); m_Manager.SetComponentData(plant, new EnergyStore() { Value = 10 }); World.CreateSystem <TxAutotrophGrow>().Update(); Assert.AreEqual(m_Manager.GetComponentData <TxAutotrophChrome1W>(plant).Value.nrg2Height, m_Manager.GetComponentData <TxAutotrophChrome1W>(plant).Value.nrg2Leaf, "nrg2Height == nrg2Leaf post"); Assert.AreEqual(m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).height, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).leaf, "Height == Leaf"); Assert.AreEqual(3.5f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).leaf, "Leaf"); Assert.AreEqual(1.25f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).seed, "Seed"); Assert.AreEqual(2.5f, m_Manager.GetComponentData <EnergyStore>(plant).Value, "EnergyStore"); Assert.AreEqual(3.5f, m_Manager.GetComponentData <Scale>(plant).Value, "stem Scale"); Assert.AreEqual(3.5f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).height, "Height"); World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>().Update(); //second pass catches missing m_EndSimulationEcbSystem.AddJobHandleForProducer(jobHandle)in TxAutotrophGrow m_Manager.SetComponentData(plant, new EnergyStore() { Value = 10f }); World.CreateSystem <TxAutotrophGrow>().Update(); World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>().Update(); Assert.AreEqual(4f, m_Manager.GetComponentData <EnergyStore>(plant).Value, "EnergyStore"); Assert.AreEqual(5f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).height, "Height Max"); Assert.AreEqual(5f, m_Manager.GetComponentData <Scale>(plant).Value, "stem Scale Max"); Assert.AreEqual(5.5f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).leaf, "leaf Max"); Assert.AreEqual(2.5f, m_Manager.GetComponentData <TxAutotrophPhenotype>(plant).seed, "seed size "); }