void CreateBall() { var ball = GameObject.Instantiate <Ball>(); balls.Add(ball); ball.OnDestroy += () => balls.Remove(ball); var rnd = new Random(); ball.Position = new Vec3(0, 0, rnd.Next(8, 12)); ball.Scale = new Vec3(Vec3.One * (float)(rnd.Next(5, 7) / 10f)); ball.Rotation = new Quat(new Ang3(rnd.Next(1, 10), rnd.Next(1, 10), rnd.Next(1, 10))); var physParams = new SEntityPhysicalizeParams() { mass = 10, density = -1, type = (int)EPhysicalizationType.ePT_Rigid, }; ball.Entity.BaseEntity.Physicalize(physParams); var physImpulse = new pe_action_set_velocity() { v = new Vec3(rnd.Next(-5, 5), rnd.Next(-5, 5), rnd.Next(1, 5)), }; ball.Physics.Action(physImpulse); }
public void Physicalize(float mass, int density, EPhysicalizationType type) { var physParams = new SEntityPhysicalizeParams(); physParams.mass = mass; physParams.density = density; physParams.type = (int)type; Physicalize(physParams); }
public void Physicalize(float mass, int density, EPhysicalizationType type) { var physParams = new SEntityPhysicalizeParams(); physParams.mass = mass; physParams.density = density; physParams.type = (int)type; OwnerEntity.NativeHandle.Physicalize(physParams); SetType((pe_type)type); }
public static void Physicalize(this IEntity entity) { var physParams = new SEntityPhysicalizeParams() { mass = -1, density = -1, type = (int)EPhysicalizationType.ePT_Rigid, }; entity.Physicalize(physParams); }
/// <summary> /// Physicalize the <see cref="PhysicsEntity"/> with the specified mass and of the specified type. /// </summary> /// <param name="mass"></param> /// <param name="type"></param> public void Physicalize(float mass, PhysicalizationType type) { if (type == PhysicalizationType.None) { Log.Error <PhysicsEntity>("Can't Physicalize an entity with PhysicalizationType.None!"); return; } var physParams = new SEntityPhysicalizeParams(); physParams.mass = mass; physParams.type = (int)type; OwnerEntity.NativeHandle.Physicalize(physParams); }
public override void OnAwake() { base.OnAwake(); AddComponent <Collider>(); Entity.BaseEntity.SetMaterial(Utils.GetMaterial(matNormalPath)); var physParams = new SEntityPhysicalizeParams() { mass = 100, density = 100, }; Entity.BaseEntity.Physicalize(physParams); }
internal virtual SEntityPhysicalizeParams ToNativeParams() { var parameters = new SEntityPhysicalizeParams(); parameters.type = (int)Type; parameters.nSlot = Slot; parameters.mass = Mass; parameters.density = Density; parameters.nFlagsAND = FlagsAND; parameters.nFlagsOR = FlagsOR; parameters.szPropsOverride = PropertyOverrides; return(parameters); }
public override void OnAwake() { base.OnAwake(); Scale = new Vec3(256, 256, 1); Position = new Vec3(0f, 0f, height); var physParams = new SEntityPhysicalizeParams() { mass = -1, density = -1, type = (int)EPhysicalizationType.ePT_Rigid, }; Entity.BaseEntity.Physicalize(physParams); AddComponent <Collider>(); }
public override void OnInitialize() { base.OnInitialize(); collisionListener = AddComponent <CollisionListener>(); collisionListener.OnCollide += CollisionListener_OnCollide; NativeEntity.LoadGeometry(0, "objects/default/primitive_sphere.cgf"); var physParams = new SEntityPhysicalizeParams() { density = 1, mass = 10, type = (int)EPhysicalizationType.ePT_Rigid, }; NativeEntity.Physicalize(physParams); }
/// <summary> /// Instantiates a Ghost version of a Unit based on the provided UnitData. /// </summary> /// <returns>The ghost.</returns> /// <param name="unitData">Unit data.</param> public static Unit CreateGhost(UnitData unitData) { var unit = GameObject.Instantiate <Unit>(); unit.SetUnitData(unitData); unit.NativeEntity.SetMaterial(AssetLibrary.Materials.Ghost); unit.ShowUI = false; // Remove collision var physParams = new SEntityPhysicalizeParams() { type = (int)EPhysicalizationType.ePT_None, }; unit.NativeEntity.Physicalize(physParams); return(unit); }
public override void OnInitialize() { var physParams = new SEntityPhysicalizeParams() { mass = -1, density = -1, type = (int)EPhysicalizationType.ePT_Rigid, }; // Create the mesh that responds to mouse interaction NativeEntity.LoadGeometry(slotInteractionPlate, AssetLibrary.Meshes.Hexagon); NativeEntity.SetSlotMaterial(slotInteractionPlate, AssetLibrary.Materials.GreyMin); // Create the BasePlate that represents the Construction Point. NativeEntity.LoadGeometry(slotBasePlate, AssetLibrary.Meshes.BasePlate); NativeEntity.SetSlotMaterial(slotBasePlate, AssetLibrary.Materials.BasePlate); NativeEntity.Physicalize(physParams); }
/// <summary> /// Initializes a new instance of the <see cref="CryEngine.Sydewinder.Tunnel"/> class. /// </summary> /// <param name="position">Position.</param> /// <param name="tunnelType">Tunnel type.</param> public static Tunnel Create(Vec3 pos, int tunnelType) { if (tunnelType < 0 && tunnelType >= TunnelTypes.Length) { throw new ArgumentOutOfRangeException( string.Format("tunnelType must betwenn 0 and {0}", (TunnelTypes.Length - 1).ToString())); } var tunnel = Entity.Instantiate <Tunnel> (pos, Quat.Identity, 1.0f, TunnelTypes[tunnelType].Geometry); if (tunnelType == 1) { var physics = new SEntityPhysicalizeParams() { density = -1f, mass = 1f, type = (int)EPhysicalizationType.ePT_Rigid, }; tunnel.BaseEntity.Physicalize(physics); } tunnel.AddToGamePoolWithDoor(pos); return(tunnel); }
/// <summary> /// Instantiates an Entity wrapper class, along with a CRYENGINE IEntity object. The IEntity is already setup by various properties as well as physicallized. /// Registers the created Entity class as a unique wrapper for the created IEntity object. /// </summary> /// <param name="pos">Position.</param> /// <param name="rot">Rotation.</param> /// <param name="scale">Scale.</param> /// <param name="model">Model.</param> /// <param name="material">Material.</param> /// <typeparam name="T">Optionally the Type of a class inheriting by Entity.</typeparam> public static T Instantiate <T>(Vec3 pos, Quat rot, float scale = 1.0f, string model = null, string material = null) where T : Entity { lock (_createLock) { SEntitySpawnParams spawnParams = new SEntitySpawnParams() { pClass = Env.EntitySystem.GetClassRegistry().GetDefaultClass(), vPosition = pos, vScale = new Vec3(scale) }; _newEntity = Env.EntitySystem.SpawnEntity(spawnParams, true); if (model != null) { _newEntity.LoadGeometry(0, model); } _newEntity.SetRotation(rot); if (material != null) { IMaterial mat = Env.Engine.GetMaterialManager().LoadMaterial(material); _newEntity.SetMaterial(mat); } var physics = new SEntityPhysicalizeParams() { density = 1, mass = 0f, type = (int)EPhysicalizationType.ePT_Rigid, }; _newEntity.Physicalize(physics); return(Activator.CreateInstance <T>()); } }
public void Physicalize(SEntityPhysicalizeParams phys) { Owner.NativeHandle.Physicalize(phys); }
public void Physicalize(SEntityPhysicalizeParams phys) { GameObject.NativeEntity.Physicalize(phys); }
public void Physicalize(SEntityPhysicalizeParams phys) { OwnerEntity.NativeHandle.Physicalize(phys); SetType((pe_type)phys.type); }
public void Physicalize(SEntityPhysicalizeParams phys) { _entity.NativeEntity.Physicalize(phys); }