// Start is called before the first frame update void Start() { //get the current things that this drone will drop //usually just an explosion. //ensures that the regular dropondeath is not overwritten DropOnDeath dropper = GetComponent <DropOnDeath>(); GameObject[] dropArray = dropper.drops; //final array starts with the contents of dropondeath List <GameObject> dropList = new List <GameObject>(); dropList.AddRange(dropArray); if (randomSelection) { for (int i = 0; i < randomItemCount; i++) { int itemNumber = Random.Range(0, itemsToDrop.Length); dropList.Add(itemsToDrop[itemNumber]); } GameObject[] finalDrops = dropList.ToArray(); dropper.drops = finalDrops; } else { //add the entire contents of the items to drop list dropList.AddRange(itemsToDrop); GameObject[] finalDrops = dropList.ToArray(); dropper.drops = finalDrops; } }
public void Execute(Entity entity, int index, [ReadOnly] ref Character character, [ReadOnly] ref Health health, [ReadOnly] ref Translation pos) { if (health.Value <= 0f) { if (dropOnDeath.Exists(entity)) { DropOnDeath dod = dropOnDeath[entity]; Entity inst = entityCommandBuffer.Instantiate(index, dod.toDrop); entityCommandBuffer.SetComponent(index, inst, new Translation { Value = pos.Value }); } entityCommandBuffer.DestroyEntity(index, entity); } }
// Start is called before the first frame update void Start() { drop = GetComponent <DropOnDeath>(); life_point = max_life_point; }