This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 0e770b2b49
commit 94063e4369
7342 changed files with 1718932 additions and 14 deletions

View File

@@ -0,0 +1,99 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local function GetPhysicsObjectNum( ent, object )
for k = 0, ent:GetPhysicsObjectCount() - 1 do
local obj = ent:GetPhysicsObjectNum( k )
if ( obj == object ) then return k end
end
return 0
end
function gmsave.ConstraintSave( ent )
local t = {}
t.EntOne, t.EntTwo = ent:GetConstrainedEntities()
local PhysA, PhysB = ent:GetConstrainedPhysObjects()
t.BoneOne = GetPhysicsObjectNum( t.EntOne, PhysA )
t.BoneTwo = GetPhysicsObjectNum( t.EntTwo, PhysB )
t.EntOne = gmsave.EntityEncode( t.EntOne )
t.EntTwo = gmsave.EntityEncode( t.EntTwo )
return t
end
--
-- Creates a save table from a table of entities
--
function gmsave.ConstraintSaveList( ents )
local SavedConstraints = {}
for k, v in pairs( ents ) do
if ( !IsValid( v ) ) then continue end
if ( !v:IsConstraint() ) then continue end
SavedConstraints[ k ] = gmsave.ConstraintSave( v )
end
return SavedConstraints
end
--
-- Creates a single entity from a table
--
function gmsave.ConstraintLoad( t, ent, ents )
local EntOne = gmsave.EntityDecode( t.EntOne, ents )
local EntTwo = gmsave.EntityDecode( t.EntTwo, ents )
local PhysOne = EntOne:GetPhysicsObjectNum( t.BoneOne )
local PhysTwo = EntTwo:GetPhysicsObjectNum( t.BoneTwo )
ent:SetPhysConstraintObjects( PhysOne, PhysTwo )
ent:SetParent( ent.LoadData.m_pParent )
ent:Spawn()
ent:Activate()
gmsave.ApplyValuesToEntity( ent, ent.LoadData, ent.LoadData.lua_variables, ents )
ent.LoadData = nil
end
--
-- Restores multiple entitys from a table
--
function gmsave.ConstraintsLoadFromTable( tab, ents )
if ( !tab ) then return end
for k, v in pairs( tab ) do
local ent = ents[ k ]
if ( !IsValid( ent ) ) then continue end
gmsave.ConstraintLoad( v, ent, ents )
end
end

View File

@@ -0,0 +1,89 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local ClassInfo = {}
ClassInfo[ "scene_manager" ] = { ['save'] = false }
ClassInfo[ "predicted_viewmodel" ] = { ['save'] = false }
ClassInfo[ "player" ] = { ['save'] = false }
ClassInfo[ "physgun_beam" ] = { ['save'] = false }
ClassInfo[ "worldspawn" ] = { ['save'] = false }
ClassInfo[ "player_manager" ] = { ['save'] = false }
ClassInfo[ "bodyque" ] = { ['save'] = false }
ClassInfo[ "info_player_start" ] = { ['save'] = false }
ClassInfo[ "ai_hint" ] = { ['save'] = false }
ClassInfo[ "ai_network" ] = { ['save'] = false }
ClassInfo[ "light" ] = { ['save'] = false }
ClassInfo[ "ai_network" ] = { ['save'] = false }
ClassInfo[ "env_tonemap_controller" ] = { ['save'] = false }
ClassInfo[ "path_corner" ] = { ['save'] = false }
ClassInfo[ "point_spotlight" ] = { ['save'] = false }
ClassInfo[ "func_brush" ] = { ['save'] = false }
ClassInfo[ "water_lod_control" ] = { ['save'] = false }
ClassInfo[ "spotlight_end" ] = { ['save'] = false }
ClassInfo[ "beam" ] = { ['save'] = false }
ClassInfo[ "lua_run" ] = { ['save'] = false }
ClassInfo[ "trigger_multiple" ] = { ['save'] = false }
ClassInfo[ "func_button" ] = { ['save'] = false }
ClassInfo[ "soundent" ] = { ['save'] = false }
ClassInfo[ "sky_camera" ] = { ['save'] = false }
ClassInfo[ "env_fog_controller" ] = { ['save'] = false }
ClassInfo[ "env_sun" ] = { ['save'] = false }
ClassInfo[ "phys_constraintsystem" ] = { ['save'] = false }
ClassInfo[ "keyframe_rope" ] = { ['save'] = false }
ClassInfo[ "logic_auto" ] = { ['save'] = false }
ClassInfo[ "physics_npc_solver" ] = { ['save'] = false }
ClassInfo[ "env_sun" ] = { ['save'] = false }
ClassInfo[ "env_wind" ] = { ['save'] = false }
ClassInfo[ "env_fog_controller" ] = { ['save'] = false }
ClassInfo[ "infodecal" ] = { ['save'] = false }
ClassInfo[ "info_projecteddecal" ] = { ['save'] = false }
ClassInfo[ "info_node" ] = { ['save'] = false }
ClassInfo[ "info_map_parameters" ] = { ['save'] = false }
ClassInfo[ "info_ladder" ] = { ['save'] = false }
ClassInfo[ "path_corner" ] = { ['save'] = false }
ClassInfo[ "point_viewcontrol" ] = { ['save'] = false }
ClassInfo[ "scene_manager" ] = { ['save'] = false }
ClassInfo[ "shadow_control" ] = { ['save'] = false }
ClassInfo[ "sky_camera" ] = { ['save'] = false }
ClassInfo[ "soundent" ] = { ['save'] = false }
function gmsave.ShouldSaveEntity( ent, t )
local info = ClassInfo[ t.classname ]
--
-- Filtered out - we don't want to save these entity types!
--
if ( info && info.save == false ) then return false end
--
-- Should we save the parent entity?
-- If not, don't save this!
--
local parent = ent:GetParent()
if ( IsValid( parent ) ) then
if ( !gmsave.ShouldSaveEntity( parent, parent:GetSaveTable() ) ) then return false end
end
--
-- If this is a weapon, and it has a valid owner.. don't save it!
--
if ( ent:IsWeapon() && IsValid( ent:GetOwner() ) ) then
return false
end
--
-- Default action is to save..
--
return true
end

View File

@@ -0,0 +1,106 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
--
-- Creates a save table for a single entity
--
function gmsave.PhysicsSave( ent )
if ( ent:GetPhysicsObjectCount() == 0 ) then return end
local tab = {}
for k = 0, ent:GetPhysicsObjectCount() - 1 do
local obj = ent:GetPhysicsObjectNum( k )
tab[ k ] = {}
tab[ k ].origin = tostring( obj:GetPos() )
tab[ k ].angles = tostring( obj:GetAngles() )
tab[ k ].mass = tostring( obj:GetMass() )
tab[ k ].material = tostring( obj:GetMaterial() )
if ( !obj:IsMotionEnabled() ) then tab[ k ].frozen = 1 end
if ( !obj:IsCollisionEnabled() ) then tab[ k ].nocollide = 1 end
if ( !obj:IsGravityEnabled() ) then tab[ k ].nogravity = 1 end
if ( !obj:IsDragEnabled() ) then tab[ k ].nodrag = 1 end
end
return tab
end
--
-- Creates a save table from a table of entities
--
function gmsave.PhysicsSaveList( ents )
local tabPhys = {}
for k, v in pairs( ents ) do
if ( !IsValid( v ) ) then continue end
tabPhys[ v.GMSaveName ] = gmsave.PhysicsSave( v )
if ( tabPhys[ v.GMSaveName ] ) then
tabPhys[ v.GMSaveName ].entity = v.GMSaveName
end
end
return tabPhys
end
--
-- Creates a single entity from a table
--
function gmsave.PhysicsLoad( t, ent )
for k = 0, ent:GetPhysicsObjectCount() - 1 do
local tab = t[ k ]
if ( !tab ) then continue end
local obj = ent:GetPhysicsObjectNum( k )
if ( !IsValid( obj ) ) then continue end
obj:SetPos( Vector( tab.origin ) )
obj:SetAngles( Angle( tab.angles ) )
obj:SetMass( tab.mass )
obj:SetMaterial( tab.material )
if ( tab.frozen ) then obj:EnableMotion( false ) end
if ( tab.nocollide ) then obj:EnableCollisions( false ) end
if ( tab.nogravity ) then obj:EnableGravity( false ) end
if ( tab.nodrag ) then obj:EnableDrag( false ) end
end
end
--
-- Restores multiple entitys from a table
--
function gmsave.PhysicsLoadFromTable( tab, ents )
if ( !tab ) then return end
for k, v in pairs( tab ) do
local ent = ents[ k ]
if ( !IsValid( ent ) ) then continue end
gmsave.PhysicsLoad( v, ent )
end
end

View File

@@ -0,0 +1,32 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
function gmsave.PlayerSave( ent )
local tab = {}
tab.Origin = ent:GetPos()
tab.Angle = ent:GetAimVector():Angle()
tab.MoveType = ent:GetMoveType()
return tab
end
function gmsave.PlayerLoad( ent, tab )
if ( tab == nil ) then return end
if ( tab.Origin ) then ent:SetPos( tab.Origin ) end
if ( tab.Angle ) then ent:SetEyeAngles( tab.Angle ) end
if ( tab.MoveType ) then ent:SetMoveType( tab.MoveType ) end
end