public void ProjectileDataOnCollision(coProjectileData datablock, coProjectile projectile, coShapeBase shapebase, string fad, Point3F pos, string normal) { // Apply damage to the object all shape base objects if (datablock["directDamage"].AsFloat() > 0) if ((console.getTypeMask(shapebase) & (uint) SceneObjectTypesAsUint.ShapeBaseObjectType) == (uint) SceneObjectTypesAsUint.ShapeBaseObjectType) ShapeBaseDamage(shapebase,projectile.ID, pos, datablock["directDamage"].AsFloat(), datablock["damageType"]); }
public Box3F(string box) { string[] parts = box.Split(' '); if (parts.GetUpperBound(0) < 5) return; minExtents = new Point3F(parts[0].AsFloat(), parts[1].AsFloat(), parts[2].AsFloat()); maxExtents = new Point3F(parts[3].AsFloat(), parts[4].AsFloat(), parts[5].AsFloat()); }
public void ProjectileDataOnExplode(coProjectileData data, coProjectile proj, Point3F position, string mod) { // Damage objects within the projectiles damage radius float radius = data["damageRadius"].AsFloat(); if (radius <= 0) return; string damageType = data["damageType"]; float areaImpulse = data["areaImpulse"].AsFloat(); float radiusDamage = data["radiusDamage"].AsFloat(); RadiusDamage((coPlayer) proj.ID, position, radius, radiusDamage, damageType, areaImpulse); }
public void RadiusDamage(coShapeBase sourceobject, Point3F position, float radius, float damage, string damageType, float impulse) { // Use the container system to iterate through all the objects // within our explosion radius. We'll apply damage to all ShapeBase // objects. Dictionary<uint, float> r = console.initContainerRadiusSearch(new Point3F(position), radius, (uint) SceneObjectTypesAsUint.ShapeBaseObjectType); float halfRadius = radius/(float) 2.0; foreach (coPlayer targetObject in r.Keys) { // Calculate how much exposure the current object has to // the explosive force. The object types listed are objects // that will block an explosion. If the object is totally blocked, // then no damage is applied. UInt32 mask = (uint) SceneObjectTypesAsUint.InteriorObjectType | (uint) SceneObjectTypesAsUint.TerrainObjectType | (uint) SceneObjectTypesAsUint.StaticShapeObjectType | (uint) SceneObjectTypesAsUint.VehicleObjectType; float coverage = Util.calcExplosionCoverage(new Point3F(position), targetObject, mask); if (!coverage.AsBool()) continue; float dist = r[targetObject]; // Calculate a distance scale for the damage and the impulse. // Full damage is applied to anything less than half the radius away, // linear scale from there. float distScale = (float) ((dist < halfRadius) ? 1.0 : 1 - ((dist - halfRadius)/halfRadius)); // Apply the damage ShapeBaseDamage(targetObject, sourceobject, position, (((damage)*coverage*distScale)), damageType); // Apply the impulse if (!impulse.AsBool()) continue; TransformF impulseVec = new TransformF(targetObject.getWorldBoxCenter()) - new TransformF(position); impulseVec = impulseVec.normalizeSafe(); impulseVec = impulseVec.vectorScale(impulse*distScale); targetObject.applyImpulse(new Point3F(position), impulseVec.MPosition); } }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="scalar"></param> /// <returns></returns> public static Point3F vectorScale(Point3F point, float scalar) { return(point * scalar); }
/// <summary> /// /// </summary> /// <param name="_test"></param> public void SetMax(Point3F _test) { x = (_test.x > x) ? _test.x : x; y = (_test.y > y) ? _test.y : y; z = (_test.z > z) ? _test.z : z; }
/// <summary> /// /// </summary> /// <param name="p"></param> public Point3F(Point3F p) { x = p.x; y = p.y; z = p.z; }
/// <summary> /// Contructor /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="angle"></param> public AngAxisF(float x, float y, float z, float angle) { _mAxis = new Point3F(x, y, z); _mAxis.OnChangeNotification += _mAxis_OnChangeNotification; _mAngle = angle; }
/// <summary> /// Constructor From String /// </summary> /// <param name="angaxisf"></param> public AngAxisF(string angaxisf) { string[] fl = angaxisf.Split(' '); _mAxis = new Point3F(0, 0, 0); _mAxis.OnChangeNotification += _mAxis_OnChangeNotification; _mAxis.x = fl[0].AsFloat(); _mAxis.y = fl[1].AsFloat(); _mAxis.z = fl[2].AsFloat(); _mAngle = fl[3].AsFloat(); }
/// <summary> /// /// </summary> /// <returns></returns> public Point3F copy() { Point3F t = new Point3F(x, y, z); //, axis_x, axis_y, axis_z, angle); return(t); }
/// <summary> /// Set the velocity for the camera. /// @param velocity The camera's velocity in the form of \"x y z\". /// @note Only affects the Camera when in Newton mode.) /// /// </summary> public void setVelocity(string camera, Point3F velocity){ m_ts.fnCamera_setVelocity(camera, velocity.AsString()); }
/// <summary> /// Set the camera to track a given object. /// @param trackObject The object to track. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @returns false if the given object could not be found.) /// /// </summary> public bool setTrackObject(string camera, string trackObject, Point3F offset){ return m_ts.fnCamera_setTrackObject(camera, trackObject, offset.AsString()); }
/// <summary> /// Set the camera's Euler rotation in radians. /// @param rot The rotation in radians in the form of \"x y z\". /// @note Rotation around the Y axis is ignored ) /// /// </summary> public void setRotation(string camera, Point3F rot){ m_ts.fnCamera_setRotation(camera, rot.AsString()); }
/// <summary> /// Set the camera to orbit around a given point. /// @param orbitPoint The point to orbit around. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform(). /// @param minDistance The minimum distance allowed to the orbit object or point. /// @param maxDistance The maximum distance allowed from the orbit object or point. /// @param initDistance The initial distance from the orbit object or point. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @param locked [optional] Indicates the camera does not receive input from the player. Default is false. /// @see Camera::setOrbitMode()) /// /// </summary> public void setOrbitPoint(string camera, TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, Point3F offset, bool xlocked){ m_ts.fnCamera_setOrbitPoint(camera, orbitPoint.AsString(), minDistance, maxDistance, initDistance, offset.AsString(), xlocked); }
/// <summary> /// Set the camera to orbit around a given object. /// @param orbitObject The object to orbit around. /// @param rotation The initial camera rotation about the object in radians in the form of \"x y z\". /// @param minDistance The minimum distance allowed to the orbit object or point. /// @param maxDistance The maximum distance allowed from the orbit object or point. /// @param initDistance The initial distance from the orbit object or point. /// @param ownClientObject [optional] Are we orbiting an object that is owned by us? Default is false. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @param locked [optional] Indicates the camera does not receive input from the player. Default is false. /// @returns false if the given object could not be found. /// @see Camera::setOrbitMode()) /// /// </summary> public bool setOrbitObject(string camera, string orbitObject, Point3F rotation, float minDistance, float maxDistance, float initDistance, bool ownClientObject, Point3F offset, bool xlocked){ return m_ts.fnCamera_setOrbitObject(camera, orbitObject, rotation.AsString(), minDistance, maxDistance, initDistance, ownClientObject, offset.AsString(), xlocked); }
/// <summary> /// Set the camera to orbit around the given object, or if none is given, around the given point. /// @param orbitObject The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead /// @param orbitPoint The point to orbit around when no object is given. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform(). /// @param minDistance The minimum distance allowed to the orbit object or point. /// @param maxDistance The maximum distance allowed from the orbit object or point. /// @param initDistance The initial distance from the orbit object or point. /// @param ownClientObj [optional] Are we orbiting an object that is owned by us? Default is false. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @param locked [optional] Indicates the camera does not receive input from the player. Default is false. /// @see Camera::setOrbitObject() /// @see Camera::setOrbitPoint()) /// /// </summary> public void setOrbitMode(string camera, string orbitObject, TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, bool ownClientObj, Point3F offset, bool xlocked){ m_ts.fnCamera_setOrbitMode(camera, orbitObject, orbitPoint.AsString(), minDistance, maxDistance, initDistance, ownClientObj, offset.AsString(), xlocked); }
/// <summary> /// /// </summary> /// <param name="velocity"></param> /// <returns></returns> public float vectorDot(Point3F velocity) { return(Point3F.vectorDot(this, velocity)); }
/// <summary> /// /// </summary> /// <param name="c"></param> public void convolve(Point3F c) { x *= c.x; y *= c.y; z *= c.z; }
/// <summary> /// Draws a line primitive between two 3d points. ) /// /// </summary> public void drawLine(string debugdrawer, Point3F a, Point3F b, ColorF color){ m_ts.fnDebugDrawer_drawLine(debugdrawer, a.AsString(), b.AsString(), color.AsString()); }
/// <summary> /// Set the camera's offset. /// The offset is added to the camera's position when set to CameraMode::OrbitObject. /// @param offset The distance to offset the camera by in the form of \"x y z\".) /// /// </summary> public void setOffset(string camera, Point3F offset){ m_ts.fnCamera_setOffset(camera, offset.AsString()); }
/// <summary> /// ) /// /// </summary> public void renderBox(string edittsctrl, Point3F pos, Point3F size){ m_ts.fnEditTSCtrl_renderBox(edittsctrl, pos.AsString(), size.AsString()); }
public Box3F() { minExtents = new Point3F(); maxExtents = new Point3F(); }
/// <summary> /// ) /// /// </summary> public void renderCircle(string edittsctrl, Point3F pos, Point3F normal, float radius, int segments){ m_ts.fnEditTSCtrl_renderCircle(edittsctrl, pos.AsString(), normal.AsString(), radius, segments); }
/// <summary> /// Constructor /// </summary> /// <param name="axis"></param> /// <param name="angle"></param> public AngAxisF(Point3F axis, float angle) { _mAxis = axis; _mAxis.DetachAllEvents(); _mAxis.OnChangeNotification += _mAxis_OnChangeNotification; _mAngle = angle; }
/// <summary> /// ) /// /// </summary> public void renderLine(string edittsctrl, Point3F start, Point3F end, float lineWidth){ m_ts.fnEditTSCtrl_renderLine(edittsctrl, start.AsString(), end.AsString(), lineWidth); }
public void TeleporterTriggerTeleFrag(string thisobj, string player, string exit) { // When a telefrag happens, there are two cases we have to consider. // The first case occurs when the player's bounding box is much larger than the exit location, // it is possible to have players colide even though a player is not within the bounds // of the trigger Because of this we first check a radius the size of a player's bounding // box around the exit location. // Get the bounding box of the player Point3F boundingBoxSize = new Point3F(console.GetVarString(string.Format("{0}.boundingBox", console.getDatablock(player)))); float radius = boundingBoxSize.x; float boxSizeY = boundingBoxSize.y; float boxSizeZ = boundingBoxSize.z; // Use the largest dimention as the radius to check if (boxSizeY > radius) radius = boxSizeY; if (boxSizeZ > radius) radius = boxSizeZ; Point3F position = SceneObject.getTransform(exit).MPosition; // new TransformF(con.getTransform(exit)); uint mask = (uint) SceneObjectTypesAsUint.PlayerObjectType; // Check all objects within the found radius of the exit location, and telefrag // any players that meet the conditions. Dictionary<uint, float> r = console.initContainerRadiusSearch(position, radius, mask); foreach (uint objectNearExit in r.Keys.Where(objectNearExit => SimObject.SimObject_isMemberOfClass(objectNearExit.AsString(), "Player")).Where(objectNearExit => objectNearExit.AsString() != player)) { ShapeBaseDamage(objectNearExit.AsString(), player, SceneObject.getTransform(exit).AsString(), // con.getTransform(exit), "10000", "Telefrag"); } // The second case occurs when the bounds of the trigger are much larger // than the bounding box of the player. (So multiple players can exist within the // same trigger). For this case we check all objects contained within the trigger // and telefrag all players. int objectsInExit = Trigger.getNumObjects(exit); // Loop through all objects in the teleporter exit // And kill any players for (int i = 0; i < objectsInExit; i++) { string objectInTeleporter = console.Call(exit, "getObject", new[] {i.AsString()}); if (SimObject.SimObject_isMemberOfClass(objectInTeleporter, "Player")) continue; // Avoid killing the player that is teleporting in the case of two // Teleporters near eachother. if (objectInTeleporter == player) continue; ShapeBaseDamage(objectInTeleporter, player, SceneObject.getTransform(exit).AsString(), // con.getTransform(exit), "10000", "Telefrag"); } }
/// <summary> /// ) /// /// </summary> public void renderSphere(string edittsctrl, Point3F pos, float radius, int sphereLevel){ m_ts.fnEditTSCtrl_renderSphere(edittsctrl, pos.AsString(), radius, sphereLevel); }
/// <summary> /// /// </summary> /// <param name="_test"></param> public void SetMin(Point3F _test) { x = (_test.x < x) ? _test.x : x; y = (_test.y < y) ? _test.y : y; z = (_test.z < z) ? _test.z : z; }
/// <summary> /// ) /// /// </summary> public void renderTriangle(string edittsctrl, Point3F a, Point3F b, Point3F c){ m_ts.fnEditTSCtrl_renderTriangle(edittsctrl, a.AsString(), b.AsString(), c.AsString()); }
/// <summary> /// /// </summary> /// <param name="_testo"></param> /// <returns></returns> public override bool Equals(object _testo) { Point3F _test = (Point3F)_testo; return((x == _test.x) && (y == _test.y) && (z == _test.z)); }
/// <summary> /// @brief Apply an impulse to this object as defined by a world position and velocity vector. /// /// @param pos impulse world position /// @param vel impulse velocity (impulse force F = m * v) /// @return Always true /// /// @note Not all objects that derrive from GameBase have this defined.) /// /// </summary> public bool applyImpulse(string gamebase, Point3F pos, Point3F vel){ return m_ts.fnGameBase_applyImpulse(gamebase, pos.AsString(), vel.AsString()); }
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> public static float vectorDot(Point3F p1, Point3F p2) { return(p1.x * p2.x + p1.y * p2.y + p1.z * p2.z); }
/// <summary> /// @brief Applies a radial impulse to the object using the given origin and force. /// /// @param origin World point of origin of the radial impulse. /// @param radius The radius of the impulse area. /// @param magnitude The strength of the impulse. /// /// @note Not all objects that derrive from GameBase have this defined.) /// /// </summary> public void applyRadialImpulse(string gamebase, Point3F origin, float radius, float magnitude){ m_ts.fnGameBase_applyRadialImpulse(gamebase, origin.AsString(), radius, magnitude); }
/// <summary> /// /// </summary> /// <param name="compare"></param> /// <param name="epsilon"></param> /// <returns></returns> public bool equal(Point3F compare, double epsilon) { return((Math.Abs(x - compare.x) < epsilon) && (Math.Abs(y - compare.y) < epsilon) && (Math.Abs(z - compare.z) < epsilon)); }
public void ShapeBaseDamage(coShapeBase shapebase, coShapeBase sourceobject, Point3F position, float damage, string damagetype) { // All damage applied by one object to another should go through this method. // This function is provided to allow objects some chance of overriding or // processing damage values and types. As opposed to having weapons call // ShapeBase::applyDamage directly. Damage is redirected to the datablock, // this is standard procedure for many built in callbacks. if (shapebase.isObject()) { coShapeBaseData datablock = shapebase.getDataBlock(); datablock.call("damage", shapebase, position.AsString(), sourceobject, damage.AsString(), damagetype); } }
/// <summary> /// /// </summary> /// <param name="c"></param> public void convolveInverse(Point3F c) { x /= c.x; y /= c.y; z /= c.z; }
/// <summary> /// @brief Tells the AIPlayer to aim at the location provided. /// /// @param target An \"x y z\" position in the game world to target. /// /// @see getAimLocation()) /// /// </summary> public void setAimLocation(Point3F target) { TorqueScriptTemplate.m_ts.fnAIPlayer_setAimLocation(_mSimObjectId, target.AsString()); }
public void ProximityMineDataOnExplode(coProximityMineData datablock, coProximityMine shapebase, Point3F position) { // Damage objects within the mine's damage radius if (datablock["damageRadius"].AsFloat() > 0) RadiusDamage(shapebase, position, datablock["damageRadius"].AsFloat(), datablock["radiusDamage"].AsFloat(), datablock["damageType"], datablock["areaImpulse"].AsFloat()); }
/// <summary> /// Set the editor camera's orbit point. /// @param point The point the camera will orbit in the form of \"x y z\".) /// /// </summary> public void setEditOrbitPoint(string camera, Point3F point){ m_ts.fnCamera_setEditOrbitPoint(camera, point.AsString()); }
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> public static float vectorDot(TransformF p1, Point3F p2) { return(p1.mPosition.x * p2.x + p1.mPosition.y * p2.y + p1.mPosition.z * p2.z); }
public Box3F(float minExtens_x, float minExtens_y, float minExtens_z, float maxExtens_x, float maxExtens_y, float maxExtens_z) { minExtents = new Point3F(minExtens_x, minExtens_y, minExtens_z); maxExtents = new Point3F(maxExtens_x, maxExtens_y, maxExtens_z); }
/// <summary> /// @brief Tells the AI to move to the location provided /// /// @param goal Coordinates in world space representing location to move to. /// @param slowDown A boolean value. If set to true, the bot will slow down /// when it gets within 5-meters of its move destination. If false, the bot /// will stop abruptly when it reaches the move destination. By default, this is true. /// /// @note Upon reaching a move destination, the bot will clear its move destination and /// calls to getMoveDestination will return \"0 0 0\". /// /// @see getMoveDestination()) /// /// </summary> public void setMoveDestination(Point3F goal, bool slowDown) { TorqueScriptTemplate.m_ts.fnAIPlayer_setMoveDestination(_mSimObjectId, goal.AsString(), slowDown); }