// Checks current inventory and belief to determine the number of casualties to deliver private int RequestCasualtyDelivery(int currentInventory) { Belief_Casualty_Delivery b = thisSoaActor.Find <Belief_Casualty_Delivery>(soa.Belief.BeliefType.CASUALTY_DELIVERY, thisSoaActor.unique_id); if (b != null) { if (b.getGreedy() || b.getMultiplicity() < 0) { // Greedy behavior, deliver all of current inventory. No information to update // Negative multiplicity is also greedy return(currentInventory); } else { // Only deliver min of currentInventory and multiplicity int quantityToDeliver = (currentInventory < b.getMultiplicity()) ? currentInventory : b.getMultiplicity(); // Update the belief if we are delivering anything if (quantityToDeliver > 0) { Belief_Casualty_Delivery newBelief = new Belief_Casualty_Delivery( b.getRequest_time(), b.getActor_id(), b.getGreedy(), b.getMultiplicity() - quantityToDeliver); thisSoaActor.addBeliefToBeliefDictionary(newBelief); } // Return the quantity to deliver return(quantityToDeliver); } } else { // No entry exists, default to greedy behavior. return(currentInventory); } }
// Cone beam antenna pattern public bool CheckSensorFootprint(GameObject target) { // Re-evaluate boresight if sensor is gimbaled (balloon) if (soaActor.type == (int)SoaActor.ActorType.BALLOON) { // Get the belief dictionary and SPOI Belief Belief_SPOI b = soaActor.Find <Belief_SPOI>(soa.Belief.BeliefType.SPOI, soaActor.unique_id); if (b != null) { // Extract SPOI (x,y,z) in sim coordinates [km] Vector3 spoi_km = new Vector3( b.getPos_x(), b.getPos_y(), b.getPos_z()); // Update the sensor boresight vector boresightUnitVector.x = spoi_km.x - transform.position.x / SimControl.KmToUnity; // [km] boresightUnitVector.y = spoi_km.y - soaActor.simAltitude_km; // [km] boresightUnitVector.z = spoi_km.z - transform.position.z / SimControl.KmToUnity; // [km] boresightUnitVector.Normalize(); } } // Compute relative vector SoaActor targetActor = target.GetComponent <SoaActor>(); Vector3 sensorToTargetUnitVector; sensorToTargetUnitVector.x = (target.transform.position.x - transform.position.x) / SimControl.KmToUnity; // [km] sensorToTargetUnitVector.y = targetActor.simAltitude_km - soaActor.simAltitude_km; // [km] sensorToTargetUnitVector.z = (target.transform.position.z - transform.position.z) / SimControl.KmToUnity; // [km] sensorToTargetUnitVector.Normalize(); // Compute target cone angle relative to boresight double coneAngleDeg = (180.0f / Mathf.PI) * Mathf.Acos( sensorToTargetUnitVector.x * boresightUnitVector.x + sensorToTargetUnitVector.y * boresightUnitVector.y + sensorToTargetUnitVector.z * boresightUnitVector.z); // Check if target is within beamwidthDeg/2 of boresight return(coneAngleDeg <= (beamwidthDeg / 2)); }