Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance persistence plugin #464

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions plugins/persistence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,27 @@ if (SERVER) then
entity:Spawn()
entity:Activate()

if (v.bNoCollision) then
if (v.Mins and v.Maxs) then
entity:SetCollisionBounds(v.Mins, v.Maxs)
end

if (v.ColGroup) then
entity:SetCollisionGroup(v.ColGroup)
elseif (v.bNoCollision) then
entity:SetCollisionGroup(COLLISION_GROUP_WORLD)
end

if (v.Name) then
entity:SetName(v.Name)
end

if (v.CurHealth) then
entity:SetHealth(v.CurHealth)
end
if (v.MaxHealth) then
entity:SetMaxHealth(v.MaxHealth)
end

if (istable(v.BodyGroups)) then
for k2, v2 in pairs(v.BodyGroups) do
entity:SetBodygroup(k2, v2)
Expand All @@ -129,6 +146,14 @@ if (SERVER) then
physicsObject:EnableMotion(v.Movable)
end

if (entity.RestoreNetworkVars and v.DT) then
entity:RestoreNetworkVars(v.DT)
end

if (entity.OnHelixPersistLoad) then
entity:OnHelixPersistLoad(v)
end

self.stored[#self.stored + 1] = entity

entity:SetNetVar("Persistent", true)
Expand All @@ -149,7 +174,6 @@ if (SERVER) then
data.Skin = v:GetSkin()
data.Color = v:GetColor()
data.Material = v:GetMaterial()
data.bNoCollision = v:GetCollisionGroup() == COLLISION_GROUP_WORLD

local materials = v:GetMaterials()

Expand Down Expand Up @@ -181,6 +205,21 @@ if (SERVER) then
data.Movable = physicsObject:IsMoveable()
end

data.Mins, data.Maxs = v:GetCollisionBounds()
data.ColGroup = v:GetCollisionGroup()
data.Name = v:GetName()

data.CurHealth = v:Health()
data.MaxHealth = v:GetMaxHealth()

if (v.GetNetworkVars) then
data.DT = v:GetNetworkVars()
end

if (v.OnHelixPersistSave) then
v:OnHelixPersistSave(data)
end

entities[#entities + 1] = data
end
end
Expand Down
10 changes: 0 additions & 10 deletions plugins/stamina/sh_plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ local function CalcStaminaChange(client)
return 0
end

local runSpeed

if (SERVER) then
runSpeed = ix.config.Get("runSpeed") + character:GetAttribute("stm", 0)

if (client:WaterLevel() > 1) then
runSpeed = runSpeed * 0.775
end
end

local walkSpeed = ix.config.Get("walkSpeed")
local maxAttributes = ix.config.Get("maxAttributes", 100)
local offset
Expand Down
Loading