From b7e409d8c0c7508f60ede877efad79a394487dff Mon Sep 17 00:00:00 2001 From: Jip Date: Fri, 3 Feb 2023 08:28:26 +0100 Subject: [PATCH] Fix trees not falling when colliding with units (#4668) --- lua/proptree.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lua/proptree.lua b/lua/proptree.lua index 92979e5d89..56d44425fc 100644 --- a/lua/proptree.lua +++ b/lua/proptree.lua @@ -38,6 +38,9 @@ local EffectOffsetEmitter = EffectMethods.OffsetEmitter local EffectSetEmitterCurveParam = EffectMethods.SetEmitterCurveParam ---@class Tree : Prop +---@field Fallen? boolean +---@field Burning? boolean +---@field NoBurn? boolean Tree = Class(Prop) { ---@param self Tree @@ -50,6 +53,14 @@ Tree = Class(Prop) { end end, + --- Collision check with projectiles + ---@param self Tree + ---@param other Projectile + ---@return boolean + OnCollisionCheck = function(self, other) + return not self.Fallen + end, + --- Collision check with units ---@param self Tree ---@param other Unit @@ -58,11 +69,11 @@ Tree = Class(Prop) { ---@param nz number ---@param depth number OnCollision = function(self, other, nx, ny, nz, depth) - if not self:BeenDestroyed() then + if self.Fallen then return end - if self.Fallen then + if self:BeenDestroyed() then return end @@ -263,8 +274,7 @@ TreeGroup = Class(Prop) { ---@param other string ---@return boolean OnCollisionCheck = function(self, other) - self:Breakup() - return false + return true end, --- Break when colliding with something / someone @@ -291,15 +301,15 @@ TreeGroup = Class(Prop) { ---@param amount number ---@param direction Vector ---@param type DamageType - ---@return Tree[] - Breakup = function(self, instigator, amount, direction, type) + ---@return (Tree[])? + Breakup = function(self) -- can't do much when we're destroyed if EntityBeenDestroyed(self) then return end -- a group with a single prop type in it - if self.blueprint.SingleTreeBlueprint then + if self.Blueprint.SingleTreeBlueprint then return SplitProp(self, self.Blueprint.SingleTreeBlueprint) -- a group with multiple prop types in it else