Пример #1
0
 public abstract bool CanBeInteractedWith(Agent agent, Entity entity, Mapping mapping);
Пример #2
0
        public override float CalculateAmount(Agent agent, Entity target, OutputChange outputChange, Mapping mapping)
        {
            if (outputChange.valueType == OutputChange.ValueType.OppPrevOutputAmount)
            {
                return(-mapping.previousOutputChangeAmount);
            }
            else if (outputChange.valueType == OutputChange.ValueType.PrevOutputAmount)
            {
                return(mapping.previousOutputChangeAmount);
            }

            return(outputChange.floatValue);
        }
Пример #3
0
 public override float CalculateAmount(Agent agent, Entity target, OutputChange outputChange, Mapping mapping)
 {
     return(0f);
 }
Пример #4
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            if (agent.inAgentEvent == null)
            {
                return(false);
            }
            agent.QuitEvent();
            return(true);
        }
Пример #5
0
 public override float CalculateSEUtility(Agent agent, Entity target, OutputChange outputChange,
                                          Mapping mapping, DriveType mainDriveType, float amount)
 {
     // Destroying items so return the negative of the value of the items
     return(0);
 }
Пример #6
0
 public override bool Check(InputCondition inputCondition, Agent agent, Mapping mapping, Entity target, bool isRecheck)
 {
     return(target.inventoryType.FindInventorySlot(target, inputCondition.entityType) != null);
 }
Пример #7
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            // This uses mapping.target since target will be the agent if TargetType is ToSelf
            ActionType otherActionType = null;

            if (mapping.target is Agent targetAgent && targetAgent.decider.CurrentMapping != null)
            {
                otherActionType = targetAgent.decider.CurrentMapping.mappingType.actionType;
            }

            Entity            inventoryTarget = mapping.inventoryTargets[outputChange.inventoryTypeGroupMatchIndex];
            List <GameObject> gameObjects     = agent.inventoryType.GetItemVisualEffects(agent, mapping.mappingType.actionType, otherActionType,
                                                                                         ItemCondition.ModifierType.Used, false);

            if (gameObjects == null || gameObjects.Count == 0)
            {
                return(false);
            }

            GameObject vfxPrefab = gameObjects[Random.Range(0, gameObjects.Count)];

            if (vfxPrefab == null)
            {
                Debug.LogError(agent.name + ": MappingType: " + mapping.mappingType.name + " - PlayVisualFromATMOCT: No Visual Effects found.");
                return(false);
            }

            GameObject vfxGameObject = Instantiate(vfxPrefab, target.GetVFXGameObject((int)outputChange.floatValue).transform);

            ParticleSystem particleSystem = vfxGameObject.GetComponent <ParticleSystem>();

            if (particleSystem == null)
            {
                Debug.LogError(agent.name + ": MappingType: " + mapping.mappingType.name + " - PlayVisualFromATMOCT: VFX Prefab has no particle system.");
                return(false);
            }

            if (!particleSystem.isPlaying)
            {
                particleSystem.Play();
            }

            // TODO: Switch to pooling
            // TODO: Add in time to destroy for looping ones
            if (!particleSystem.main.loop)
            {
                Destroy(vfxGameObject, particleSystem.main.duration);
            }

            return(true);
        }
Пример #8
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            Entity entityToThrow = mapping.inventoryTargets[outputChange.inventoryTypeGroupMatchIndex];

            if (entityToThrow == null)
            {
                Debug.LogError(agent.name + ": ThrowEntityOCT - No entity to throw found.");
                return(false);
            }

            // Remove from inventory
            InventoryType.Item item = agent.inventoryType.Remove(agent, entityToThrow);
            if (item == null)
            {
                Debug.LogError(agent.name + ": ThrowEntityOCT - No entity to throw found in agent's inventory.");
                return(false);
            }

            Vector3 targetPosition = target.transform.position;

            if (outputChange.unityObject != null)
            {
                // Move direction by random degrees
                MinMaxCurve minMaxCurve = outputChange.unityObject as MinMaxCurve;
                float       degrees     = minMaxCurve.EvalRandom();

                // Rotate targetPosition relative to agent.position by degrees
                Vector3 forceVector = Quaternion.Euler(0, 0, degrees) * ((Vector2)(targetPosition - agent.transform.position)).normalized;
                Debug.DrawRay(agent.transform.position, forceVector, Color.white, 5f);
                targetPosition = forceVector + agent.transform.position;
            }

            agent.inventoryType.Thrown(entityToThrow, agent, item.inventorySlot, targetPosition, outputChange.floatValue);
            return(true);
        }
Пример #9
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            float actualChange = ((Agent)target).drives[(DriveType)outputChange.levelType].ChangeLevel(actualAmount);

            if (target != null)
            {
                Debug.Log(agent.name + ": target = " + target.name + " - Change drive (" + outputChange.levelType.name + ") level by : " + actualChange);
            }
            else
            {
                Debug.Log(agent.name + ": target = None - Change drive (" + outputChange.levelType.name + ") level by : " + actualChange);
            }
            return(true);
        }
Пример #10
0
 // This allows plannerTypes to save chosen Mapping when Decider Interrupts
 public abstract void NotifyOfInterrupt(Agent agent, Plans plans, Mapping rootMapping);
Пример #11
0
 public abstract void ReevaluateTargets(Agent agent, Mapping mapping);
Пример #12
0
 public abstract float GetDistanceTolerance(Agent agent, Entity entity, Mapping mapping, float defaultTolerance);
Пример #13
0
 public abstract Vector3 GetInteractionSpot(Agent agent, Entity entity, Mapping mapping, bool forGoTo, bool forInventory);
Пример #14
0
 public abstract Vector3 GetRotateTowardsLocation(Agent agent, Entity entity, Mapping mapping);
Пример #15
0
 public int GetRootMappingIndex(Mapping mapping)
 {
     return(rootMappings.IndexOf(mapping));
 }
Пример #16
0
        public override float CalculateAmount(Agent agent, Entity target, OutputChange outputChange, Mapping mapping)
        {
            if (outputChange.valueType == OutputChange.ValueType.ActionSkillCurve)
            {
                return(outputChange.actionSkillCurve.Eval0to100(agent.ActionSkillWithItemModifiers(mapping.mappingType.actionType)));
            }
            else if (outputChange.valueType == OutputChange.ValueType.Selector)
            {
                return(outputChange.selector.GetFloatValue(agent, mapping));
            }

            // This looks at the ENTIRE Plan for an equation DriveType
            // will only do it for root mappings (mapping.parent == null) so there's no double counting the changes
            DriveType driveType = (DriveType)outputChange.levelType;

            if (mapping != null && mapping.parent == null && driveType.syncType == DriveType.SyncType.Equation)
            {
                return(driveType.driveTypeEquation.CalculateEquationDriveLevelChange(agent, driveType, mapping, null));
            }

            return(outputChange.floatValue);
        }
Пример #17
0
        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)
            {
                // TODO: Need to make sure its not taking item from the target container
                // TODO: Fix to not use unityObject
                List <InventoryType.Item> items = agent.inventoryType.Remove(agent, (EntityType)outputChange.unityObject, intAmount, true);
                if (items.Count != intAmount)
                {
                    Debug.LogError(agent.name + ": InventoryMoveToContainerOCT was unable to find Entity to Move (" + (EntityType)outputChange.unityObject +
                                   ").  Tried to take " + intAmount + " - found " + items.Count);
                    return(false);
                }

                Entity entityContainer = mapping.inventoryTargets[outputChange.inventoryTypeGroupMatchIndex];
                if (entityContainer == null)
                {
                    Debug.LogError(agent.name + ": InventoryMoveToContainerOCT was unable to find Entity Container");
                    return(false);
                }

                int numGiven = entityContainer.inventoryType.Add(entityContainer, 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.LogError(agent.name + ": InventoryMoveToContainerOCT was unable to give all to container.  Tried to give " +
                                   intAmount + " - gave " + numGiven);
                    return(false);
                }
            }
            else
            {
                Debug.LogError(agent.name + ": InventoryMoveToContainerOCT has less than 1 amount to take.  Amount To Give must be positive.");
                return(false);
            }
            return(true);
        }
Пример #18
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            // Make sure target is still there
            // TODO: Do an in range check - not exactly sure what the range should be for pickup?
            if (target.inEntityInventory != null)
            {
                Debug.Log(agent.name + ": InventoryPickupOCT - Target Entity " + target.name + " is gone.");
                return(false);
            }

            InventorySlot inventorySlot;

            if (outputChange.boolValue)
            {
                inventorySlot = agent.inventoryType.ClearSlotsAndAdd(agent, target);
            }
            else
            {
                inventorySlot = agent.inventoryType.Add(agent, target);
            }

            if (inventorySlot == null)
            {
                Debug.LogError(agent.name + ": InventoryPickupOCT unable to find inventorySlot for " + target.name);
                return(false);
            }
            return(true);
        }
Пример #19
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            // TODO: Use animationType if agent?
            Animator animator = target.GetComponentInChildren <Animator>();

            // TODO: Feels like checks like these should be done once at start of game - InitCheck?
            if (animator == null)
            {
                Debug.LogError(agent.name + ": MappingType: " + mapping.mappingType.name + " - SetAnimatorParamOCT: target " + target.name + " has no animator.");
                return(false);
            }
            bool selectorValid = outputChange.selector.IsValid();

            if (outputChange.stringValue == "" && !selectorValid)
            {
                Debug.LogError(agent.name + ": MappingType: " + mapping.mappingType.name + " - SetAnimatorParamOCT: Animator Param name " +
                               "String Value is blank and Selector is not valid.  One of them must be set.");
                return(false);
            }

            string paramName = outputChange.stringValue;

            if (selectorValid)
            {
                paramName = outputChange.selector.GetEnumValue <string>(agent, mapping);
            }

            switch (outputChange.valueType)
            {
            case OutputChange.ValueType.None:
                animator.SetTrigger(paramName);
                break;

            case OutputChange.ValueType.OppPrevOutputAmount:
                animator.SetFloat(paramName, -mapping.previousOutputChangeAmount);
                break;

            case OutputChange.ValueType.PrevOutputAmount:
                animator.SetFloat(paramName, mapping.previousOutputChangeAmount);
                break;

            case OutputChange.ValueType.BoolValue:
                animator.SetBool(paramName, outputChange.boolValue);
                break;

            case OutputChange.ValueType.FloatValue:
                animator.SetFloat(paramName, outputChange.floatValue);
                break;

            default:
                break;
            }

            return(true);
        }
Пример #20
0
 public override float CalculateSEUtility(Agent agent, Entity target, OutputChange outputChange,
                                          Mapping mapping, DriveType mainDriveType, float amount)
 {
     return(amount * target.entityType.sideEffectValue);
 }
Пример #21
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            EntityType entityType = outputChange.entityType;

            // If this is an AgentEvent location could need to be synced with WorldObject
            // TODO: if self use inventory drop location?
            Vector3 position = target.transform.position;
            //int prefabVariantIndex = (int)outputChange.floatValue;
            int prefabVariantIndex = 0;

            if (entityType.prefabVariants == null || entityType.prefabVariants.Count <= prefabVariantIndex)
            {
                Debug.LogError(agent.name + ": CreateEntityOCT: " + entityType.name + " does not have enough Prefab Variants.  " +
                               "Tried to access Prefab Variant Index = " + prefabVariantIndex + " - Please Fix.");
                return(false);
            }

            GameObject newGameObject = entityType.CreateEntity(prefabVariantIndex, position, entityType.prefabVariants[prefabVariantIndex].transform.rotation,
                                                               entityType.prefabVariants[prefabVariantIndex].transform.localScale, agent);
            Entity newEntity = newGameObject.GetComponent <Entity>();

            if (outputChange.boolValue)
            {
                mapping.target = newEntity;
            }

            if (outputChange.floatValue > 0f)
            {
                newEntity.DestroySelf(null, outputChange.floatValue);
            }

            return(true);
        }
Пример #22
0
 public abstract float EstimatedTimeToComplete(Agent agent, Mapping mapping);
Пример #23
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;
            if (!agent.animationType.ImplementsAnimationRigging())
            {
                Debug.Log(agent.name + ": SetAnimationRigTargetOCT - agent's AnimationType does not implement AnimationRigging.");
                return(true);
            }

            Vector3    position;
            Quaternion rotation;

            if (outputChange.targetType == OutputChange.TargetType.ToInventoryTarget)
            {
                position = mapping.inventoryTargets[outputChange.inventoryTypeGroupMatchIndex].transform.position;
                position = agent.transform.InverseTransformPoint(position);
                rotation = Quaternion.identity;
            }
            else if (outputChange.targetType == OutputChange.TargetType.ToSelf)
            {
                Transform transform = (Transform)outputChange.unityObject;
                position = transform.position;
                rotation = transform.rotation;
            }
            else
            {
                position = agent.transform.InverseTransformPoint(target.transform.position);
                rotation = Quaternion.identity;
            }

            agent.animationType.WarpRigConstraintTargetTo(agent, (int)outputChange.floatValue, position, rotation);

            return(true);
        }
Пример #24
0
 public abstract float Evaluate(Agent agent, Mapping rootMapping, DriveType driveType,
                                float driveAmount, float timeEst, float sideEffectsUtility);
Пример #25
0
        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);
        }
Пример #26
0
 public abstract string DisplayEquation(Agent agent, Mapping rootMapping, DriveType driveType,
                                        float driveAmount, float timeEst, float sideEffectsUtility);
Пример #27
0
        public override bool MakeChange(Agent agent, Entity target, OutputChange outputChange, Mapping mapping, float actualAmount, out bool forceStop)
        {
            forceStop = false;

            // Near Entity change just passes target up to its parent - agent will be near the target after action (or recheck will fail for next mapping)
            //if (mapping.parent != null)
            //    mapping.parent.target = mapping.target;
            return(true);
        }
Пример #28
0
 public override bool Check(InputCondition inputCondition, Agent agent, Mapping mapping, Entity target, bool isRecheck)
 {
     return(agent.gender == (Agent.Gender)inputCondition.enumValueIndex);
 }
Пример #29
0
 public override float CalculateSEUtility(Agent agent, Entity target, OutputChange outputChange,
                                          Mapping mapping, DriveType mainDriveType, float amount)
 {
     return(0);
 }
Пример #30
0
 public abstract float Evaluate(Selector selector, Agent agent, Mapping mapping, out bool overrideValue);