| Line | |
|---|
| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 |
|
|---|
| 4 | namespace AllocsFixes.LiveData
|
|---|
| 5 | {
|
|---|
| 6 | public class Animals
|
|---|
| 7 | {
|
|---|
| 8 | public static void Get (List<EntityAnimal> _list) {
|
|---|
| 9 | _list.Clear ();
|
|---|
| 10 | try {
|
|---|
| 11 | List<Entity> entities = GameManager.Instance.World.Entities.list;
|
|---|
| 12 | for (int i = 0; i < entities.Count; i++) {
|
|---|
| 13 | Entity entity = entities [i];
|
|---|
| 14 |
|
|---|
| 15 | // Kind of hack-ish, but the game is legitimately setting the base type of animals ('entityType') to enum 0 ('EntityType.Unknown').
|
|---|
| 16 | if ((entity.entityType == EntityType.Animal) || (entity is EntityAnimal)) {
|
|---|
| 17 | EntityAnimal ea = (EntityAnimal)entity;
|
|---|
| 18 |
|
|---|
| 19 | if (ea.IsAlive ())
|
|---|
| 20 | _list.Add (ea);
|
|---|
| 21 | }
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 | catch (Exception e) {
|
|---|
| 25 | Log.Exception (e);
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | public static int GetCount () {
|
|---|
| 30 | int count = 0;
|
|---|
| 31 | try {
|
|---|
| 32 | List<Entity> entities = GameManager.Instance.World.Entities.list;
|
|---|
| 33 | for (int i = 0; i < entities.Count; i++) {
|
|---|
| 34 | Entity entity = entities [i];
|
|---|
| 35 |
|
|---|
| 36 | // Kind of hack-ish, but the game is legitimately setting the base type of animals ('entityType') to enum 0 ('EntityType.Unknown').
|
|---|
| 37 | if ((entity.entityType == EntityType.Animal) || (entity is EntityAnimal)) {
|
|---|
| 38 | EntityAnimal ea = (EntityAnimal)entity;
|
|---|
| 39 |
|
|---|
| 40 | if (ea.IsAlive ())
|
|---|
| 41 | count++;
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 | catch (Exception e) {
|
|---|
| 46 | Log.Exception (e);
|
|---|
| 47 | }
|
|---|
| 48 | return count;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.