public void RandomInit() { Attributes = new NeedsAttributes(); Attributes.Randomize(); ApplyAttributesToMaterial(); }
public void AssignRandomNeeds() { if (patronHolding?.gameObject != null) { Destroy(patronHolding.gameObject); } var lostItem = Main.Instance.GetRandomSpawnedEntity()?.GetComponent <LostItemEntity>(); Needs = lostItem?.Attributes; patronHands.GetComponent <ItemHinting>().Init(lostItem); }
void Start() { // lazy Instance = this; // Initialize game wide rng Rand = new Random(); // Load Resources _LostItemTextures = LoadAllResourcesAtPathOfType <Texture2D>("ItemTextures"); _LostItemColors = LoadAllResourcesAtPathOfType <AttributeColorWrapper>("ItemColors"); _LostItemMeshes = LoadAllResourcesAtPathOfType <SpawnedEntity>("ItemMeshes"); // Initialize asset enum maps // This must be done after resources are loaded NeedsAttributes.SetEnumAttributeMaps(); }
public override void ForceSpawn() { var attributes = new NeedsAttributes(); attributes.Randomize(); attributes.Model = AllowedMeshes[Main.Instance.Rand.Next(AllowedMeshes.Length)]; var model = attributes.GetModel(); var entity = Instantiate(model, GetNextSpawnLocation(), Quaternion.Euler(ForcedRotation)); var lostItem = entity.GetComponent <LostItemEntity>(); lostItem.Attributes = attributes; lostItem.ApplyAttributesToMaterial(); lostItem.DestroyCallback += OnSpawnedDestroyed; lostItem.tag = "Item"; SpawnedEntities.Add(entity); }