Skip to content

Commit

Permalink
Merge pull request #551 from MattJeanes/dev
Browse files Browse the repository at this point in the history
December 2021 Update
  • Loading branch information
MattJeanes authored Dec 15, 2021
2 parents 4f2d793 + 9e87ef7 commit c977c5d
Show file tree
Hide file tree
Showing 58 changed files with 647 additions and 234 deletions.
17 changes: 17 additions & 0 deletions lua/entities/gmod_tardis/modules/cl_classic_doors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ENT:AddHook("ShouldDraw", "classic_doors_exterior", function(self)
if self.metadata.EnableClassicDoors
and wp.drawing and wp.drawingent == self.interior.portals.interior
then
return false
end

end)

ENT:AddHook("ShouldDrawPart", "classic_doors_exterior_door", function(self, part)
if self.metadata.EnableClassicDoors == true and part ~= nil
and wp.drawing and wp.drawingent == self.interior.portals.interior
and part == TARDIS:GetPart(self, "door")
then
return false
end
end)
24 changes: 15 additions & 9 deletions lua/entities/gmod_tardis/modules/sh_cloak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,23 @@ else
if self:GetData("cloak",false) and not self:GetData("cloak-animating",false) then return false end
end)

ENT:OnMessage("cloak", function(self)
ENT:OnMessage("cloak", function(self)
local on = net.ReadBool()
self:SetData("cloak", on)
self:SetData("cloak-animating", true)
local snd = self.metadata.Exterior.Sounds.Cloak
if on and TARDIS:GetSetting("cloaksound-enabled") and TARDIS:GetSetting("sound") then
self:EmitSound(snd)
local snd
if on then
snd = self.metadata.Exterior.Sounds.Cloak
else
snd = self.metadata.Exterior.Sounds.CloakOff
end

if IsValid(self.interior) then
self.interior:EmitSound(snd)
end
end
end)
if TARDIS:GetSetting("cloaksound-enabled") and TARDIS:GetSetting("sound") then
self:EmitSound(snd)

if IsValid(self.interior) then
self.interior:EmitSound(snd)
end
end
end)
end
61 changes: 35 additions & 26 deletions lua/entities/gmod_tardis/modules/sh_doors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if SERVER then
callback(state)
end)
end

function ENT:ToggleDoor(callback)
if not IsValid(self.interior) then return false end
if not self:GetData("doorchangecallback",false) then
Expand All @@ -29,12 +29,12 @@ if SERVER then
return false
end
doorstate=not doorstate

self:SetData("doorstatereal",doorstate,true)
self:SetData("doorchangewait",not doorstate)

self:CallHook("ToggleDoorReal",doorstate)

if doorstate then
self:SetData("doorstate",true,true)
self:SetData("doorchange",CurTime())
Expand All @@ -47,19 +47,23 @@ if SERVER then
if callback then
callbacks[callback]=true
end
self:SetData("doorchange",CurTime()+self.metadata.Exterior.DoorAnimationTime)
local dooranimtime = self.metadata.Exterior.DoorAnimationTime
if self.metadata.EnableClassicDoors == true then
dooranimtime = math.max(dooranimtime, self.metadata.Interior.IntDoorAnimationTime)
end
self:SetData("doorchange",CurTime() + dooranimtime)
end
return true
end

function ENT:OpenDoor(callback)
if self:GetData("doorstate",false) then
delay(callback,true)
else
self:ToggleDoor(callback)
end
end

function ENT:CloseDoor(callback)
if self:GetData("doorstate",false) ~= self:GetData("doorstatereal",false) then
local callbacks=self:GetData("doorchangecallback")
Expand All @@ -70,19 +74,19 @@ if SERVER then
self:ToggleDoor(callback)
end
end

function ENT:DoorOpen(real)
if real then
return self:GetData("doorstatereal",false)
else
return self:GetData("doorstate",false)
end
end

ENT:AddHook("Initialize", "doors", function(self)
self:SetBodygroup(1,1)
end)

ENT:AddHook("ToggleDoor", "intdoors", function(self,open)
local intdoor=TARDIS:GetPart(self.interior,"door")
if IsValid(intdoor) then
Expand Down Expand Up @@ -121,7 +125,7 @@ if SERVER then
net.WriteBool(open)
end)
end)

ENT:AddHook("Think", "doors", function(self)
if self:GetData("doorchangewait",false) and CurTime()>self:GetData("doorchange",0) then
self:SetData("doorchangewait",nil)
Expand All @@ -140,13 +144,13 @@ if SERVER then
end
end
end)

ENT:AddHook("ShouldThinkFast","doors",function(self)
if self:GetData("doorchangewait") then
return true
end
end)

ENT:AddHook("SkinChanged","doors",function(self,i)
local door=TARDIS:GetPart(self,"door")
local intdoor=TARDIS:GetPart(self.interior,"door")
Expand All @@ -157,7 +161,7 @@ if SERVER then
intdoor:SetSkin(i)
end
end)

ENT:AddHook("BodygroupChanged","doors",function(self,bodygroup,value)
local door=TARDIS:GetPart(self,"door")
local intdoor=TARDIS:GetPart(self.interior,"door")
Expand All @@ -178,7 +182,7 @@ else
type="bool",
option=true
})

function ENT:DoorOpen(real)
local door=self:GetPart("door")
if real and IsValid(door) then
Expand All @@ -187,7 +191,7 @@ else
return self:GetData("doorstate",false)
end
end

function ENT:DoorMoving()
local door=self:GetPart("door")
if IsValid(door) then
Expand All @@ -196,23 +200,28 @@ else
return false
end
end

ENT:OnMessage("ToggleDoorReal",function(self)
self:CallHook("ToggleDoorReal",net.ReadBool())
end)

ENT:AddHook("ToggleDoorReal","doorsounds",function(self,open)
local snds = self.metadata.Exterior.Sounds.Door
if snds.enabled and TARDIS:GetSetting("doorsounds-enabled") and TARDIS:GetSetting("sound") then
local extpart = self:GetPart("door")
local snd = open and snds.open or snds.close
if IsValid(extpart) and extpart.exterior:CallHook("ShouldEmitDoorSound")~=false then
extpart:EmitSound(snd)
local extsnds = self.metadata.Exterior.Sounds.Door
local intsnds = self.metadata.Interior.Sounds.Door or extsnds

if TARDIS:GetSetting("doorsounds-enabled") and TARDIS:GetSetting("sound") then
if extsnds.enabled then
local extpart = self:GetPart("door")
local extsnd = open and extsnds.open or extsnds.close
if IsValid(extpart) and extpart.exterior:CallHook("ShouldEmitDoorSound")~=false then
extpart:EmitSound(extsnd)
end
end
if IsValid(self.interior) then
if intsnds.enabled and IsValid(self.interior) then
local intpart = self.interior:GetPart("door")
local intsnd = open and intsnds.open or intsnds.close
if IsValid(intpart) then
intpart:EmitSound(snd)
intpart:EmitSound(intsnd)
end
end
end
Expand Down
Loading

0 comments on commit c977c5d

Please sign in to comment.