public bool AnyInventoryGroupingMatches(MappingType mappingType, List <EntityType> entityTypes) { List <TypeGroup> groupings = InventoryTypeGroups(mappingType, out List <int> indexesToSet); List <EntityType> matches = TypeGroup.InAllTypeGroups(groupings, entityTypes, true); return(matches != null && matches.Count > 0); }
public override bool PreMatch(OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType, List <EntityType> allEntityTypes) { // Matches OtherInventoryAmountICT // This needs to be giving the corrent EntityType (InventoryGroupings) based on what the ICT needs (InventoryGroupings) if (outputChange.inventoryTypeGroupMatchIndex == -1) { return(false); } InputCondition outputChangeInputCondition = outputChangeMappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex]; List <TypeGroup> groupings = outputChangeInputCondition.InventoryTypeGroups(outputChangeMappingType, out List <int> indexesToSet); // groupings is now the EntityTypes that are possible to be given List <EntityType> entityTypes = TypeGroup.InAllTypeGroups(groupings, allEntityTypes); // See if any of these EntityTypes matches what the IC of OtherInventoryAmountICT needs bool inventoryGroupMatches = inputCondition.AnyInventoryGroupingMatches(inputConditionMappingType, entityTypes); // Also need to make sure that possible EntityTypes from both MappingTypes have some overlap bool groupMatches = outputChangeMappingType.AnyEntityTypeMatchesTypeGroups(inputConditionMappingType, allEntityTypes); if (inventoryGroupMatches && groupMatches) { return(true); } return(false); }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { List <InputCondition> inputConditionsFromOC = outputChangeMappingType.EntityTypeInputConditions(); List <EntityType> entityTypes = TypeGroup.PossibleEntityTypes(inputConditionsFromOC, agent.memoryType.GetKnownEntityTypes(agent)); if (inputConditionMappingType.AnyEntityTypeMatchesTypeGroups(entityTypes) && inputCondition.levelType == outputChange.levelType) { // Same EntityType and same TagType - match adding tag to needing tag and removing tag to can't have tag if (!outputChange.boolValue && ((HasTagICT.Scope)inputCondition.enumValueIndex == HasTagICT.Scope.DoesNotHaveOwnerTag || (HasTagICT.Scope)inputCondition.enumValueIndex == HasTagICT.Scope.DoesNotHaveTag)) { return(true); } else if (outputChange.boolValue && ((HasTagICT.Scope)inputCondition.enumValueIndex == HasTagICT.Scope.HasTagButNotOwner || (HasTagICT.Scope)inputCondition.enumValueIndex == HasTagICT.Scope.HasTagIgnoreOwnership || (HasTagICT.Scope)inputCondition.enumValueIndex == HasTagICT.Scope.HasTagIsOwner)) { return(true); } } return(false); }
public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop) { forceStop = false; int intAmount = (int)actualAmount; if (intAmount > 0) { // Figure out possible EntityTypes from ICs InventoryGroupings - just pick first one List <EntityType> entityTypes; if (outputChange.inventoryTypeGroupMatchIndex > -1 && outputChange.inventoryTypeGroupMatchIndex < mapping.mappingType.inputConditions.Count) { InputCondition inputCondition = mapping.mappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex]; entityTypes = inputCondition.GetInventoryTypeGroup().GetMatches(target.inventoryType.GetAllEntityTypes(target)); } else if (outputChange.inventoryTypeGroupMatchIndex == -1) { entityTypes = TypeGroup.PossibleEntityTypes(mapping.mappingType.inputConditions, agent.inventoryType.GetAllEntityTypes(agent), true); } else { Debug.LogError(agent.name + ": InventoryDropOCT has an invalid value for inventoryGroupingMatchIndex in MT: " + mapping.mappingType.name); return(false); } if (entityTypes == null || entityTypes.Count == 0) { Debug.LogError(agent.name + ": InventoryDropOCT was unable to find an EntityType from ICs InventoryGroupings for MT: " + mapping.mappingType.name); return(false); } // TODO: Add in InventoryTFs to MTs EntityType entityType = entityTypes[0]; // This will do nothing if the target doesn't have all of the amount // TODO: Add in options to handle not enough inventory List <InventoryType.Item> items = target.inventoryType.Remove(target, entityType, intAmount, true); if (items == null) { return(false); } foreach (InventoryType.Item item in items) { // TODO: If Entity was created as Inventory it would have never gone through initialization // so it won't have an inventoryType set. Make sure Entities created in inventory get initialized? //item.entity.inventoryType.Dropped(item.entity, item.inventorySlot); agent.inventoryType.Dropped(item.entity, item.inventorySlot); } } else if (intAmount < 0) { Debug.LogError("InventoryDropOCT has a negative amount to take. Amount To Drop must be positive."); } return(true); }
public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop) { forceStop = false; int intAmount = (int)actualAmount; if (intAmount > 0) { // Figure out possible EntityTypes from ICs InventoryGroupings - just pick first one List <EntityType> entityTypes; if (outputChange.inventoryTypeGroupMatchIndex > -1 && outputChange.inventoryTypeGroupMatchIndex < mapping.mappingType.inputConditions.Count) { InputCondition inputCondition = mapping.mappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex]; entityTypes = inputCondition.GetInventoryTypeGroup().GetMatches(agent.inventoryType.GetAllEntityTypes(agent)); } else if (outputChange.inventoryTypeGroupMatchIndex == -1) { entityTypes = TypeGroup.PossibleEntityTypes(mapping.mappingType.inputConditions, agent.inventoryType.GetAllEntityTypes(agent), true); } else { Debug.LogError(agent.name + ": InventoryGiveOCT has an invalid value for inventoryGroupingMatchIndex in MT: " + mapping.mappingType.name); return(false); } if (entityTypes == null || entityTypes.Count == 0) { Debug.LogError(agent.name + ": InventoryGiveOCT was unable to find an EntityType from ICs InventoryGroupings for MT: " + mapping.mappingType.name); return(false); } // TODO: Add in InventoryTFs to MTs EntityType entityType = entityTypes[0]; List <InventoryType.Item> items = agent.inventoryType.Remove(agent, entityType, intAmount, true); int numGiven = target.inventoryType.Add(target, items); if (numGiven != intAmount) { // TODO: Handle partial gives // Failed to Give items for some reason - give back inventory to agent agent.inventoryType.Add(agent, items); Debug.Log(agent.name + ": InventoryGiveOCT was unable to give all to target. Tried to give " + intAmount + " - gave " + numGiven); return(false); } } else if (intAmount < 0) { Debug.LogError(agent.name + ": InventoryGiveOCT has a negative amount to take. Amount To Give must be positive."); return(false); } return(true); }
static public TypeGroup CreateTypeGroup(TypeCategory typeCategory) { TypeGroup typeGroup = CreateInstance <TypeGroup>(); typeGroup.typeCategories = new List <TypeCategory>() { typeCategory }; typeGroup.ResetCachedMatches(); return(typeGroup); }
static public TypeGroup CreateTypeGroup(EntityType entityType) { TypeGroup typeGroup = CreateInstance <TypeGroup>(); typeGroup.includeEntityTypes = new List <EntityType>() { entityType }; typeGroup.ResetCachedMatches(); return(typeGroup); }
public void GenerateTypeGroup() { if (matchType == MatchType.TypeCategory) { generatedTypeGroup = TypeGroup.CreateTypeGroup(typeCategoryMatch); } else { generatedTypeGroup = TypeGroup.CreateTypeGroup(entityTypeMatch); } }
public void GenerateInventoryTypeGroup() { if (inventoryMatchType == MatchType.TypeCategory) { generatedInventoryTypeGroup = TypeGroup.CreateTypeGroup(inventoryTypeCategoryMatch); } else { generatedInventoryTypeGroup = TypeGroup.CreateTypeGroup(inventoryEntityTypeMatch); } }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { List <InputCondition> inputConditionsFromOC = outputChangeMappingType.EntityTypeInputConditions(); List <EntityType> entityTypes = TypeGroup.PossibleEntityTypes(inputConditionsFromOC, agent.memoryType.GetKnownEntityTypes(agent)); if (inputConditionMappingType.AnyEntityTypeMatchesTypeGroups(entityTypes)) { return(true); } return(false); }
public bool AnyEntityTypeMatchesTypeGroups(List <EntityType> entityTypes) { List <TypeGroup> groupings = EntityTypeGroupings(true); if (groupings.Count == 0) { return(false); } List <EntityType> matches = TypeGroup.InAllTypeGroups(groupings, entityTypes, true); return(matches != null && matches.Count > 0); }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { // This matches WorldObjectStateICT List <InputCondition> inputConditionsFromOC = outputChangeMappingType.EntityTypeInputConditions(); List <EntityType> entityTypes = TypeGroup.PossibleEntityTypes(inputConditionsFromOC, agent.memoryType.GetKnownEntityTypes(agent)); if (inputConditionMappingType.AnyEntityTypeMatchesTypeGroups(entityTypes) && outputChange.stringValue == inputCondition.stringValue) { return(true); } return(false); }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { // Trying to match with ItemAmountICT with this (InventoryPickupOCT) // So make sure InventoryGrouping from ItemAmountICT overlaps with the Grouping for InventoryPickupOCT List <EntityType> entityTypes = TypeGroup.PossibleEntityTypes(outputChangeMappingType.inputConditions, agent.memoryType.GetKnownEntityTypes(agent)); if (inputCondition.GetInventoryTypeGroup().AnyMatches(entityTypes)) { return(true); } return(false); }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { // This matches with InventoryAmountICT // Matches the InventoryAmountICT InventoryGroup with this OC's InventoryGroup InputCondition outputChangeInputCondition = outputChangeMappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex]; List <TypeGroup> groupings = outputChangeInputCondition.InventoryTypeGroups(outputChangeMappingType, out List <int> indexesToSet); // Groupings is now the EntityTypes that are possible to be taken // Need to use allEntityTypes in world since agent may be trying to get an EntityType this is in inventory List <EntityType> entityTypes = TypeGroup.InAllTypeGroups(groupings, agent.totalAIManager.allEntityTypes); if (inputCondition.AnyInventoryGroupingMatches(inputConditionMappingType, entityTypes)) { return(true); } return(false); }
public override bool Match(Agent agent, OutputChange outputChange, MappingType outputChangeMappingType, InputCondition inputCondition, MappingType inputConditionMappingType) { // Matches OtherInventoryAmountICT // This needs to be giving the corrent EntityType (InventoryGroupings) based on what the ICT needs (InventoryGroupings) InputCondition outputChangeInputCondition = outputChangeMappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex]; List <TypeGroup> groupings = outputChangeInputCondition.InventoryTypeGroups(outputChangeMappingType, out List <int> indexesToSet); // groupings is now the EntityTypes that are possible to be given List <EntityType> entityTypes = TypeGroup.InAllTypeGroups(groupings, agent.memoryType.GetKnownEntityTypes(agent, true)); // See if any of these EntityTypes matches what the IC of OtherInventoryAmountICT needs if (inputCondition.AnyInventoryGroupingMatches(inputConditionMappingType, entityTypes)) { return(true); } return(false); }
public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop) { forceStop = false; int intAmount = (int)actualAmount; if (intAmount > 0) { if (outputChange.targetType == OutputChange.TargetType.ToSelf) { Entity inventoryTarget = mapping.inventoryTargets[outputChange.inventoryTypeGroupMatchIndex]; List <InventoryType.Item> items = agent.inventoryType.Remove(agent, inventoryTarget.entityType, intAmount, true); foreach (InventoryType.Item item in items) { item.entity.DestroySelf(agent); } } else { // Currently InventoryGrouping only looks at agent's inventory so mapping.inventoryTarget won't work // Try to find enough of the Grouping in target's inventory // TODO: I think this was fixed? TypeGroup grouping = mapping.mappingType.inputConditions[outputChange.inventoryTypeGroupMatchIndex].GetInventoryTypeGroup(); List <InventoryType.Item> items = target.inventoryType.Remove(target, grouping, intAmount, true); if (items == null) { Debug.LogError(agent.name + " InventoryDestroyOCT on Entity Target " + target.name + " - failed to find items to destroy. " + "MT = " + mapping.mappingType.name + " - Grouping = " + grouping.name); return(false); } foreach (InventoryType.Item item in items) { item.entity.DestroySelf(agent); } } } else if (intAmount <= 0) { Debug.LogError("InventoryDestroyOCT has a negative amount to take. Amount To Destroy must be positive."); return(false); } return(true); }
// Returns true if this and mappingType have any EntityTypes that match both public bool AnyEntityTypeMatchesTypeGroups(MappingType mappingType, List <EntityType> entityTypes) { List <TypeGroup> typeGroups = EntityTypeGroupings(true); if (typeGroups.Count == 0) { return(false); } List <TypeGroup> otherTypeGroups = mappingType.EntityTypeGroupings(true); if (otherTypeGroups.Count == 0) { return(false); } List <TypeGroup> combinedTypeGroups = typeGroups.Union(otherTypeGroups).Distinct().ToList(); List <EntityType> matches = TypeGroup.InAllTypeGroups(combinedTypeGroups, entityTypes, true); return(matches != null && matches.Count > 0); }
public override bool Check(InputCondition inputCondition, Agent agent, Mapping mapping, Entity target, bool isRecheck) { // Look at all of the InventoryGroupings in this MappingType - See what EntityTypes match // TODO: Figure out how inventoryTarget gets set List <TypeGroup> groupings = inputCondition.InventoryTypeGroups(mapping.mappingType, out List <int> indexesToSet); if (groupings == null) { Debug.LogError(agent.name + ": OtherCanAddInventoryICT missing InventoryGroupings - MT = " + mapping.mappingType); return(false); } List <EntityType> possibleEntityTypes = TypeGroup.InAllTypeGroups(groupings, agent.memoryType.GetKnownEntityTypes(agent)); foreach (EntityType entityType in possibleEntityTypes) { if (target.inventoryType.FindInventorySlot(target, entityType) != null) { return(true); } } return(false); }