diff --git a/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua b/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua index 5935869a83..d6cd5e109b 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/constraintcore.lua @@ -659,13 +659,6 @@ e2function void noCollide(entity ent1, entity ent2) noCollideCreate(self, ent1, ent2) end -e2function void entity:noCollideAll(state) - if not IsValid(this) then return self:throw("Invalid entity!", nil) end - if not isOwner(self, this) then return self:throw("You do not own this prop!", nil) end - - this:SetCollisionGroup(state == 0 and COLLISION_GROUP_NONE or COLLISION_GROUP_WORLD) -end - --- Nocollides to entities/players, just like Right Click of No-Collide Stool [deprecated] e2function void noCollideAll(entity ent, state) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index d874ae95de..de6141c170 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -1009,6 +1009,50 @@ e2function void entity:extinguish() this:Extinguish() end +E2Lib.registerConstant("COLLISION_GROUP_NONE", COLLISION_GROUP_NONE) +E2Lib.registerConstant("COLLISION_GROUP_DEBRIS", COLLISION_GROUP_DEBRIS) +E2Lib.registerConstant("COLLISION_GROUP_DEBRIS_TRIGGER", COLLISION_GROUP_DEBRIS_TRIGGER) +E2Lib.registerConstant("COLLISION_GROUP_INTERACTIVE_DEBRIS", COLLISION_GROUP_INTERACTIVE_DEBRIS) +E2Lib.registerConstant("COLLISION_GROUP_INTERACTIVE", COLLISION_GROUP_INTERACTIVE) +E2Lib.registerConstant("COLLISION_GROUP_PLAYER", COLLISION_GROUP_PLAYER) +E2Lib.registerConstant("COLLISION_GROUP_BREAKABLE_GLASS", COLLISION_GROUP_BREAKABLE_GLASS) +E2Lib.registerConstant("COLLISION_GROUP_VEHICLE", COLLISION_GROUP_VEHICLE) +E2Lib.registerConstant("COLLISION_GROUP_PLAYER_MOVEMENT", COLLISION_GROUP_PLAYER_MOVEMENT) +E2Lib.registerConstant("COLLISION_GROUP_NPC", COLLISION_GROUP_NPC) +E2Lib.registerConstant("COLLISION_GROUP_IN_VEHICLE", COLLISION_GROUP_IN_VEHICLE) +E2Lib.registerConstant("COLLISION_GROUP_WEAPON", COLLISION_GROUP_WEAPON) +E2Lib.registerConstant("COLLISION_GROUP_VEHICLE_CLIP", COLLISION_GROUP_VEHICLE_CLIP) +E2Lib.registerConstant("COLLISION_GROUP_PROJECTILE", COLLISION_GROUP_PROJECTILE) +E2Lib.registerConstant("COLLISION_GROUP_DOOR_BLOCKER", COLLISION_GROUP_DOOR_BLOCKER) +E2Lib.registerConstant("COLLISION_GROUP_PASSABLE_DOOR", COLLISION_GROUP_PASSABLE_DOOR) +E2Lib.registerConstant("COLLISION_GROUP_DISSOLVING", COLLISION_GROUP_DISSOLVING) +E2Lib.registerConstant("COLLISION_GROUP_PUSHAWAY", COLLISION_GROUP_PUSHAWAY) +E2Lib.registerConstant("COLLISION_GROUP_NPC_ACTOR", COLLISION_GROUP_NPC_ACTOR) +E2Lib.registerConstant("COLLISION_GROUP_NPC_SCRIPTED", COLLISION_GROUP_NPC_SCRIPTED) +E2Lib.registerConstant("COLLISION_GROUP_WORLD", COLLISION_GROUP_WORLD) + +[nodiscard] +e2function number entity:getCollisionGroup() + if not IsValid(this) then return self:throw("Invalid entity!", -1) end + return this:GetCollisionGroup() +end + +e2function void entity:setCollisionGroup(number group) + if not IsValid(this) then return self:throw("Invalid entity!", nil) end + if group < 0 or group > 20 then return self:throw("Invalid collision group", nil) end + if not isOwner(self, this) then return self:throw("You do not own this entity!", nil) end + if this:IsPlayer() then return self:throw("You cannot set the collision group of a player!", nil) end + + this:SetCollisionGroup(group) +end + +e2function void entity:noCollideAll(number state) + if not IsValid(this) then return self:throw("Invalid entity!", nil) end + if not isOwner(self, this) then return self:throw("You do not own this prop!", nil) end + + this:SetCollisionGroup(state == 0 and COLLISION_GROUP_NONE or COLLISION_GROUP_WORLD) +end + hook.Add("OnEntityCreated", "E2_entityCreated", function(ent) if not IsValid(ent) then return end -- Engine is precaching a model or bad addon diff --git a/lua/wire/client/e2descriptions.lua b/lua/wire/client/e2descriptions.lua index fda591fa45..fd3f3eaee1 100644 --- a/lua/wire/client/e2descriptions.lua +++ b/lua/wire/client/e2descriptions.lua @@ -371,6 +371,9 @@ E2Helper.Descriptions["ignite(e:)"] = "Ignites an entity for 360 seconds (same a E2Helper.Descriptions["ignite(e:n)"] = "Ignites an entity for the given length in seconds. Requires wire_expression2_entity_ignite_enabled" E2Helper.Descriptions["ignite(e:nn)"] = "Creates a fire at an entity with given radius and length in seconds. Requires wire_expression2_entity_ignite_enabled" E2Helper.Descriptions["extinguish(e:)"] = "Extinguishes an entity granted you have permission. Does not work inside of entityDamage event if the attacker is the fire itself" +E2Helper.Descriptions["getCollisionGroup(e:)"] = "Returns the collision group of the entity" +E2Helper.Descriptions["setCollisionGroup(e:n)"] = "Sets the collision group of the entity. Does not work on players. Use one of the _COLLISION_GROUP constants" +E2Helper.Descriptions["noCollideAll"] = "Nocollides an entity to all entities/players, just like the tool's right-click" -- Attachment E2Helper.Descriptions["lookupAttachment(e:s)"] = "Returns Es attachment ID associated with attachmentName"