-
Notifications
You must be signed in to change notification settings - Fork 342
Entity Markers refactor #3459
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
Merged
Merged
Entity Markers refactor #3459
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ed94bee
Entity Marker cleanups
Astralcircle 6ee4d48
Cleanup advanced entity marker too
Astralcircle 373aa85
Don't need to check at this point (self.Marks now guaranteed to conta…
Astralcircle 30c1d5b
Fix dupes + lint pass
Astralcircle 6c5d34a
This looks more clear for me
Astralcircle 27d6310
It's too simple to use PrepareOverlayData
Astralcircle 20184eb
Cleanup freezer too
Astralcircle 0336a06
Missing label
Astralcircle de4743c
Missing space
Astralcircle 500ab5e
Make it single
Astralcircle 1ac83d6
Use ipairs
Astralcircle c42b12d
Fix typo
Astralcircle 86efc0b
Final cleanups
Astralcircle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,81 @@ | ||
| AddCSLuaFile() | ||
| DEFINE_BASECLASS( "base_wire_entity" ) | ||
| ENT.PrintName = "Wire Entity Marker" | ||
|
|
||
| DEFINE_BASECLASS("base_wire_entity") | ||
| ENT.PrintName = "Wire Entity Marker" | ||
| ENT.WireDebugName = "EMarker" | ||
|
|
||
| if CLIENT then return end -- No more client | ||
| if CLIENT then return end | ||
|
|
||
| function ENT:Initialize() | ||
| self:PhysicsInit( SOLID_VPHYSICS ) | ||
| self:SetMoveType( MOVETYPE_VPHYSICS ) | ||
| self:SetSolid( SOLID_VPHYSICS ) | ||
| self:PhysicsInit(SOLID_VPHYSICS) | ||
|
|
||
| self.Outputs = WireLib.CreateSpecialOutputs(self, { "Entity" }, { "ENTITY" }) | ||
| self:SetOverlayText( "No Mark selected" ) | ||
| WireLib.CreateOutputs(self, { "Entity [ENTITY]" }) | ||
| self:SetOverlayText("No linked mark") | ||
| end | ||
|
|
||
| function ENT:LinkEMarker(mark) | ||
| if mark then self.mark = mark end | ||
| if not IsValid(self.mark) then self:SetOverlayText( "No Mark selected" ) return end | ||
| self.mark:CallOnRemove("EMarker.UnLink", function(ent) | ||
| if IsValid(self) and self.mark == ent then self:UnLinkEMarker() end | ||
| end) | ||
| Wire_TriggerOutput(self, "Entity", self.mark) | ||
| self:SetOverlayText( "Linked - " .. self.mark:GetModel() ) | ||
| function ENT:LinkEnt(ent) | ||
| if ent ~= self.Mark then | ||
| if self.Mark then | ||
| self.Mark:RemoveCallOnRemove("EMarker.UnLink" .. self:EntIndex()) | ||
| self.Mark = nil | ||
| end | ||
|
|
||
| ent:CallOnRemove("EMarker.UnLink" .. self:EntIndex(), function(ent) | ||
| self:UnlinkEnt() | ||
| end) | ||
|
|
||
| WireLib.SendMarks(self, { ent }) | ||
| WireLib.TriggerOutput(self, "Entity", ent) | ||
| self:SetOverlayText("Linked to: " .. ent:GetClass()) | ||
| self.Mark = ent | ||
|
|
||
| return true | ||
| end | ||
|
|
||
| return false | ||
| end | ||
|
|
||
| function ENT:UnLinkEMarker() | ||
| self.mark = NULL | ||
| Wire_TriggerOutput(self, "Entity", NULL) | ||
| self:SetOverlayText( "No Mark selected" ) | ||
| function ENT:UnlinkEnt() | ||
| if self.Mark then | ||
| WireLib.SendMarks(self, {}) | ||
| WireLib.TriggerOutput(self, "Entity", NULL) | ||
| self:SetOverlayText("No linked mark") | ||
| self.Mark:RemoveCallOnRemove("EMarker.UnLink" .. self:EntIndex()) | ||
| self.Mark = nil | ||
|
|
||
| return true | ||
| end | ||
|
|
||
| return false | ||
| end | ||
|
|
||
| duplicator.RegisterEntityClass( "gmod_wire_emarker", WireLib.MakeWireEnt, "Data" ) | ||
| function ENT:OnRemove() | ||
| if self.Mark then | ||
| self.Mark:RemoveCallOnRemove("EMarker.UnLink" .. self:EntIndex()) | ||
| self.Mark = nil | ||
| end | ||
| end | ||
|
|
||
| function ENT:BuildDupeInfo() | ||
| local info = BaseClass.BuildDupeInfo(self) or {} | ||
| if ( self.mark ) and ( self.mark:IsValid() ) then | ||
| info.mark = self.mark:EntIndex() | ||
| local info = BaseClass.BuildDupeInfo(self) | ||
|
|
||
| if self.Mark then | ||
| info.mark = self.Mark:EntIndex() | ||
| end | ||
|
|
||
| return info | ||
| end | ||
|
|
||
| function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID) | ||
| BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID) | ||
|
|
||
| self:LinkEMarker(GetEntByID(info.mark)) | ||
| if info.mark then | ||
| local ent = GetEntByID(info.mark) | ||
|
|
||
| if ent:IsValid() then | ||
| self:LinkEnt(ent) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| duplicator.RegisterEntityClass("gmod_wire_emarker", WireLib.MakeWireEnt, "Data") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.