public override void Perform(MobUpdateContext context) { NavMesh navMesh= context.moveRequest.Room.runtime_nav_mesh; float max_range= 5.0f; // Compute max range from mob type uint[] navCells = navMesh.ComputeNavCellsInRadius(context.mob.Position, max_range, false); Random rng = context.mob.AIState.behavior_data.GetMobRandomNumberGenerator(); RNGUtilities.DeterministicKnuthShuffle(rng, navCells); Point3d targetPosition = new Point3d(context.mob.Position); // Pick the first random nav cell in range that we have line of sight to foreach (uint navCellIndex in navCells) { Point3d testTarget = navMesh.ComputeNavCellCenter(navCellIndex); bool canSee = navMesh.PointCanSeeOtherPoint(context.mob.Position, testTarget); if (canSee) { targetPosition = testTarget; break; } } // Compute the side effect of actually moving the mob on the update context context.MoveMob(targetPosition); context.MobPostDialog("Soo bored..."); }
public override void Perform(MobUpdateContext context) { NavMesh navMesh = context.moveRequest.Room.runtime_nav_mesh; float max_range = 5.0f; // Compute max range from mob type uint[] navCells = navMesh.ComputeNavCellsInRadius(context.mob.Position, max_range, false); Random rng = context.mob.AIState.behavior_data.GetMobRandomNumberGenerator(); RNGUtilities.DeterministicKnuthShuffle(rng, navCells); Point3d targetPosition = new Point3d(context.mob.Position); // Pick the first random nav cell in range that we have line of sight to foreach (uint navCellIndex in navCells) { Point3d testTarget = navMesh.ComputeNavCellCenter(navCellIndex); bool canSee = navMesh.PointCanSeeOtherPoint(context.mob.Position, testTarget); if (canSee) { targetPosition = testTarget; break; } } // Compute the side effect of actually moving the mob on the update context context.MoveMob(targetPosition); context.MobPostDialog("Soo bored..."); }
public override bool CanActivate(MobUpdateContext context) { MobAIPerceptionState perception = context.mob.AIState.perception_data; EntityProp prop = perception.GetPlayerTargetProp(); bool canActivate = (prop != null && prop.propStatus == EntityProp.ePropStatus.orphaned); return(canActivate); }
public override bool CanActivate(MobUpdateContext context) { EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp(); return (energyTankProp != null && energyTankProp.propStatus >= EntityProp.ePropStatus.assumed && energyTankProp.faction != GameConstants.eFaction.ai && energyTankProp.energy > 0); }
public void Update( MobUpdateContext context) { // Get the current behavior running, if any MobAIBehaviorState behaviorState = context.mob.AIState.behavior_data; behaviorState.active_behavior_stack = ""; ActivateBehaviors(context, m_root); //currentBehavior.GetType().Name; }
public override void Perform(MobUpdateContext context) { MobAIPerceptionState perception = context.mob.AIState.perception_data; EntityProp prop = perception.GetPlayerTargetProp(); if (prop.distance >= WorldConstants.ROOM_TILE_SIZE) { context.MobPostDialog("I though I saw someone over here"); context.MoveMob(prop.GetPosition()); } }
public override bool CanActivate(MobUpdateContext context) { EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp(); return (energyTankProp != null && context.mob.MobType.Abilities.energy_tank_drain_per_turn > 0 && // Even if we can't use the energy, we can deny the player from having it //energyTankProp.energy < context.mob.MobType.MaxEnergy && energyTankProp.propStatus >= EntityProp.ePropStatus.assumed && energyTankProp.faction == GameConstants.eFaction.ai && energyTankProp.energy > 0); }
public override bool CanActivate(MobUpdateContext context) { EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp(); return energyTankProp != null && context.mob.MobType.Abilities.energy_tank_drain_per_turn > 0 && // Even if we can't use the energy, we can deny the player from having it //energyTankProp.energy < context.mob.MobType.MaxEnergy && energyTankProp.propStatus >= EntityProp.ePropStatus.assumed && energyTankProp.faction == GameConstants.eFaction.ai && energyTankProp.energy > 0; }
public override void Perform(MobUpdateContext context) { EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp(); EnergyTank energyTank = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id); if (energyTank.Faction == GameConstants.eFaction.ai) { // We can only drain up to what we can take and whats left in the energy tank int drainAmount = Math.Min(energyTank.Energy, context.mob.MobType.Abilities.energy_tank_drain_per_turn); context.MobDrainEnergyTank(energyTank, drainAmount); context.MobPostDialog("Sweet Sweet Energy..."); } else { context.MoveMob(energyTank.Position); context.MobPostDialog("What?! Someone hacked this! Grrr..."); } // Update the energy on the prop energyTankProp.energy = energyTank.Energy; }
private bool ActivateBehaviors( MobUpdateContext context, MobBehavior behavior) { bool foundBehaviorToActivate = false; // Can the behavior be activated if (behavior.CanActivate(context)) { foundBehaviorToActivate = true; // Perform the behavior we can activate behavior.Perform(context); // Add the behavior to the list of behaviors that was activated if (context.mob.AIState.behavior_data.active_behavior_stack.Length > 0) { context.mob.AIState.behavior_data.active_behavior_stack += "."; } context.mob.AIState.behavior_data.active_behavior_stack += behavior.GetType().Name; // Try to activate children behaviors if (behavior.Children != null) { foreach (MobBehavior childBehavior in behavior.Children) { // Stop searching if this child behavior could be activated if (ActivateBehaviors(context, childBehavior)) { break; } } } } return(foundBehaviorToActivate); }
public override void Perform(MobUpdateContext context) { EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp(); EnergyTank energyTank = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id); if (energyTank.Faction == GameConstants.eFaction.player) { context.MobHackEnergyTank(energyTank); context.MobPostDialog("Which team owns one less energy tank? Team Player!"); } else if (energyTank.Faction == GameConstants.eFaction.neutral) { context.MobHackEnergyTank(energyTank); context.MobPostDialog("Energy Tank claimed for the AI Team!"); } else if (energyTank.Faction == GameConstants.eFaction.ai) { context.MobHackEnergyTank(energyTank); context.MobPostDialog("Oh! I guess we already owned this energy tank"); } // Update the faction on the prop energyTankProp.faction = energyTank.Faction; }
public override bool CanActivate(MobUpdateContext context) { return(false); }
public override bool CanActivate(MobUpdateContext context) { return false; }
public virtual bool CanActivate(MobUpdateContext context) { return true; }
public virtual void Perform(MobUpdateContext context) { // Nothing to do }
public void Update( MobUpdateContext context) { MobBehaviorTree.GetInstance().Update(context); }
public virtual bool CanActivate(MobUpdateContext context) { return(true); }
private bool ActivateBehaviors( MobUpdateContext context, MobBehavior behavior) { bool foundBehaviorToActivate = false; // Can the behavior be activated if (behavior.CanActivate(context)) { foundBehaviorToActivate = true; // Perform the behavior we can activate behavior.Perform(context); // Add the behavior to the list of behaviors that was activated if (context.mob.AIState.behavior_data.active_behavior_stack.Length > 0) { context.mob.AIState.behavior_data.active_behavior_stack += "."; } context.mob.AIState.behavior_data.active_behavior_stack += behavior.GetType().Name; // Try to activate children behaviors if (behavior.Children != null) { foreach (MobBehavior childBehavior in behavior.Children) { // Stop searching if this child behavior could be activated if (ActivateBehaviors(context, childBehavior)) { break; } } } } return foundBehaviorToActivate; }
public override bool CanActivate(MobUpdateContext context) { EntityProp energyTankProp= context.mob.AIState.perception_data.GetEnergyTankTargetProp(); return energyTankProp != null && energyTankProp.propStatus >= EntityProp.ePropStatus.assumed && energyTankProp.faction != GameConstants.eFaction.ai && energyTankProp.energy > 0; }