datamodel

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeNumberSequenceKeypoint rbxfile.Type = rbxfile.TypeSharedString + 1 + iota
	TypeColorSequenceKeypoint               = rbxfile.TypeSharedString + 1 + iota
	TypeNumberSequence                      = rbxfile.TypeSharedString + 1 + iota
	TypeColorSequence                       = rbxfile.TypeSharedString + 1 + iota
	TypeSystemAddress                       = rbxfile.TypeSharedString + 1 + iota
	TypeMap                                 = rbxfile.TypeSharedString + 1 + iota
	TypeDictionary                          = rbxfile.TypeSharedString + 1 + iota
	TypeArray                               = rbxfile.TypeSharedString + 1 + iota
	TypeTuple                               = rbxfile.TypeSharedString + 1 + iota
	TypeRegion3                             = rbxfile.TypeSharedString + 1 + iota
	TypeRegion3int16                        = rbxfile.TypeSharedString + 1 + iota
	TypeReference                           = rbxfile.TypeSharedString + 1 + iota
	TypeToken                               = rbxfile.TypeSharedString + 1 + iota
	// used for terrain
	TypeVector3int32   = rbxfile.TypeSharedString + 1 + iota
	TypePathWaypoint   = rbxfile.TypeSharedString + 1 + iota
	TypeDeferredString = rbxfile.TypeSharedString + 1 + iota
)

Variables

View Source
var CustomTypeNames = map[rbxfile.Type]string{
	TypeNumberSequenceKeypoint: "NumberSequenceKeypoint",
	TypeColorSequenceKeypoint:  "ColorSequenceKeypoint",
	TypeNumberSequence:         "NumberSequence",
	TypeColorSequence:          "ColorSequence",
	TypeSystemAddress:          "SystemAddress",
	TypeMap:                    "Map",
	TypeDictionary:             "Dictionary",
	TypeArray:                  "Array",
	TypeTuple:                  "Tuple",
	TypeRegion3:                "Region3",
	TypeRegion3int16:           "Region3int16",
	TypeReference:              "Reference",
	TypeToken:                  "Token",
	TypeVector3int32:           "Vector3int32",
	TypePathWaypoint:           "PathWaypoint",
	TypeDeferredString:         "SharedString (deferred)",
}
View Source
var ErrInstanceDoesntExist = errors.New("instance doesn't exist")
View Source
var ErrNullInstance = errors.New("instance is null")
View Source
var NullReference = Reference{
	IsNull: true,
	Scope:  "null",
}

Functions

func TypeString

func TypeString(val rbxfile.Value) string

Types

type DataModel

type DataModel struct {
	Instances      []*Instance
	ServiceEmitter *emitter.Emitter
}

func FromRbxfile

func FromRbxfile(dictionary *InstanceDictionary, root *rbxfile.Root) *DataModel

func New

func New() *DataModel

func (*DataModel) AddService

func (model *DataModel) AddService(service *Instance)

func (*DataModel) Copy

func (model *DataModel) Copy() *DataModel

func (*DataModel) FindService

func (model *DataModel) FindService(name string) *Instance

func (*DataModel) ToRbxfile

func (model *DataModel) ToRbxfile() *rbxfile.Root

func (*DataModel) WaitForChild

func (model *DataModel) WaitForChild(ctx context.Context, names ...string) (*Instance, error)

func (*DataModel) WaitForService

func (model *DataModel) WaitForService(ctx context.Context, name string) (*Instance, error)

type Instance

type Instance struct {
	ClassName       string
	PropertiesMutex *sync.RWMutex
	Properties      map[string]rbxfile.Value
	Children        []*Instance
	IsService       bool
	Ref             Reference
	ChildEmitter    *emitter.Emitter
	PropertyEmitter *emitter.Emitter
	EventEmitter    *emitter.Emitter
	ParentEmitter   *emitter.Emitter
	// contains filtered or unexported fields
}

func InstanceFromRbxfile

func InstanceFromRbxfile(inst *rbxfile.Instance, pool *SelfReferencePool, dictionary *InstanceDictionary) *Instance

func NewInstance

func NewInstance(className string, parent *Instance) (*Instance, error)

func (*Instance) AddChild

func (instance *Instance) AddChild(child *Instance) error

func (*Instance) Copy

func (instance *Instance) Copy(pool *SelfReferencePool) *Instance

func (*Instance) FindFirstChild

func (instance *Instance) FindFirstChild(name string) *Instance

func (*Instance) FireEvent

func (instance *Instance) FireEvent(name string, args ...rbxfile.Value)

func (*Instance) Get

func (instance *Instance) Get(name string) rbxfile.Value

func (*Instance) GetFullName

func (instance *Instance) GetFullName() string

func (*Instance) HasAncestor

func (instance *Instance) HasAncestor(ancestor *Instance) bool

func (*Instance) Name

func (instance *Instance) Name() string

func (*Instance) Parent

func (instance *Instance) Parent() *Instance

func (*Instance) Set

func (instance *Instance) Set(name string, value rbxfile.Value)

func (*Instance) SetParent

func (instance *Instance) SetParent(parent *Instance) error

func (*Instance) ToRbxfile

func (instance *Instance) ToRbxfile(pool *RbxfileReferencePool) *rbxfile.Instance

ToRbxfile converts an Instance to the rbxfile format Note: the parent of this instance must be assigned manually, however its children will have their respective parents set correctly

The conv argument is required so that the ValueReferences can be converted without creating duplicate references

func (*Instance) WaitForChild

func (instance *Instance) WaitForChild(ctx context.Context, names ...string) (*Instance, error)

func (*Instance) WaitForProp

func (instance *Instance) WaitForProp(ctx context.Context, name string) (rbxfile.Value, error)

func (*Instance) WaitForRefProp

func (instance *Instance) WaitForRefProp(ctx context.Context, name string) (*Instance, error)

type InstanceDictionary

type InstanceDictionary struct {
	Scope         string
	InstanceIndex uint32
}

TODO: should work with PeerID

func NewInstanceDictionary

func NewInstanceDictionary() *InstanceDictionary

func (*InstanceDictionary) NewReference

func (dictionary *InstanceDictionary) NewReference() Reference

type InstanceList

type InstanceList struct {
	// contains filtered or unexported fields
}

func NewInstanceList

func NewInstanceList() *InstanceList

func (*InstanceList) AddInstance

func (l *InstanceList) AddInstance(ref Reference, instance *Instance)

func (*InstanceList) CreateInstance

func (l *InstanceList) CreateInstance(ref Reference) (*Instance, error)

func (*InstanceList) Populate

func (l *InstanceList) Populate(instances []*Instance)

func (*InstanceList) TryGetInstance

func (l *InstanceList) TryGetInstance(ref Reference) (*Instance, error)

type RbxfileReferencePool

type RbxfileReferencePool struct {
	// contains filtered or unexported fields
}

RbxfileReferencePool holds a collection of visited instances This prevents the conversion from creating a duplicate rbxfile representation of an instance if it is visited twice (e.g.) normally and via ValueReference

func NewRbxfileReferencePool

func NewRbxfileReferencePool() *RbxfileReferencePool

func (*RbxfileReferencePool) Make

func (pool *RbxfileReferencePool) Make(instance *Instance) *rbxfile.Instance

type Reference

type Reference struct {
	IsNull bool
	Scope  string
	Id     uint32
	PeerId uint32
}

func (Reference) String

func (ref Reference) String() string

type SelfReferencePool

type SelfReferencePool struct {
	// contains filtered or unexported fields
}

SelfReferencePool holds a collection of visited instances This prevents the conversion from creating a duplicate rbxfile representation of an instance if it is visited twice (e.g.) normally and via ValueReference

func NewSelfReferencePool

func NewSelfReferencePool() *SelfReferencePool

func (*SelfReferencePool) Make

func (pool *SelfReferencePool) Make(instance *rbxfile.Instance) *Instance

func (*SelfReferencePool) MakeWithRef

func (pool *SelfReferencePool) MakeWithRef(ref string) *Instance

type ValueArray

type ValueArray []rbxfile.Value

func (ValueArray) Copy

func (x ValueArray) Copy() rbxfile.Value

func (ValueArray) String

func (x ValueArray) String() string

func (ValueArray) Type

func (x ValueArray) Type() rbxfile.Type

type ValueColorSequence

type ValueColorSequence []ValueColorSequenceKeypoint

func (ValueColorSequence) Copy

func (x ValueColorSequence) Copy() rbxfile.Value

func (ValueColorSequence) String

func (x ValueColorSequence) String() string

func (ValueColorSequence) Type

func (x ValueColorSequence) Type() rbxfile.Type

type ValueColorSequenceKeypoint

type ValueColorSequenceKeypoint rbxfile.ValueColorSequenceKeypoint

func (ValueColorSequenceKeypoint) Copy

func (ValueColorSequenceKeypoint) String

func (ValueColorSequenceKeypoint) Type

type ValueDeferredString

type ValueDeferredString struct {
	Hash  string
	Value rbxfile.ValueSharedString
}

func (*ValueDeferredString) Copy

func (x *ValueDeferredString) Copy() rbxfile.Value

func (*ValueDeferredString) String

func (x *ValueDeferredString) String() string

func (*ValueDeferredString) Type

func (x *ValueDeferredString) Type() rbxfile.Type

type ValueDictionary

type ValueDictionary map[string]rbxfile.Value

func (ValueDictionary) Copy

func (x ValueDictionary) Copy() rbxfile.Value

func (ValueDictionary) String

func (x ValueDictionary) String() string

func (ValueDictionary) Type

func (x ValueDictionary) Type() rbxfile.Type

type ValueMap

type ValueMap map[string]rbxfile.Value

func (ValueMap) Copy

func (x ValueMap) Copy() rbxfile.Value

func (ValueMap) String

func (x ValueMap) String() string

func (ValueMap) Type

func (x ValueMap) Type() rbxfile.Type

type ValueNumberSequence

type ValueNumberSequence []ValueNumberSequenceKeypoint

func (ValueNumberSequence) Copy

func (ValueNumberSequence) String

func (x ValueNumberSequence) String() string

func (ValueNumberSequence) Type

func (x ValueNumberSequence) Type() rbxfile.Type

type ValueNumberSequenceKeypoint

type ValueNumberSequenceKeypoint rbxfile.ValueNumberSequenceKeypoint

func (ValueNumberSequenceKeypoint) Copy

func (ValueNumberSequenceKeypoint) String

func (ValueNumberSequenceKeypoint) Type

type ValuePathWaypoint

type ValuePathWaypoint struct {
	Position rbxfile.ValueVector3
	Action   uint32
}

func (ValuePathWaypoint) Copy

func (x ValuePathWaypoint) Copy() rbxfile.Value

func (ValuePathWaypoint) String

func (x ValuePathWaypoint) String() string

func (ValuePathWaypoint) Type

func (x ValuePathWaypoint) Type() rbxfile.Type

type ValueReference

type ValueReference struct {
	Reference Reference
	Instance  *Instance
}

func (ValueReference) Copy

func (x ValueReference) Copy() rbxfile.Value

WARNING: Remember to set val.Instance yourself when copying

func (ValueReference) String

func (x ValueReference) String() string

func (ValueReference) Type

func (x ValueReference) Type() rbxfile.Type

type ValueRegion3

type ValueRegion3 struct {
	Start rbxfile.ValueVector3
	End   rbxfile.ValueVector3
}

func (ValueRegion3) Copy

func (x ValueRegion3) Copy() rbxfile.Value

func (ValueRegion3) String

func (x ValueRegion3) String() string

func (ValueRegion3) Type

func (x ValueRegion3) Type() rbxfile.Type

type ValueRegion3int16

type ValueRegion3int16 struct {
	Start rbxfile.ValueVector3int16
	End   rbxfile.ValueVector3int16
}

func (ValueRegion3int16) Copy

func (x ValueRegion3int16) Copy() rbxfile.Value

func (ValueRegion3int16) String

func (x ValueRegion3int16) String() string

func (ValueRegion3int16) Type

func (x ValueRegion3int16) Type() rbxfile.Type

type ValueSystemAddress

type ValueSystemAddress net.UDPAddr

func (ValueSystemAddress) Copy

func (t ValueSystemAddress) Copy() rbxfile.Value

func (ValueSystemAddress) String

func (t ValueSystemAddress) String() string

func (ValueSystemAddress) Type

type ValueToken

type ValueToken struct {
	ID    uint16
	Value uint32
}

func (ValueToken) Copy

func (x ValueToken) Copy() rbxfile.Value

func (ValueToken) String

func (x ValueToken) String() string

func (ValueToken) Type

func (x ValueToken) Type() rbxfile.Type

type ValueTuple

type ValueTuple []rbxfile.Value

func (ValueTuple) Copy

func (x ValueTuple) Copy() rbxfile.Value

func (ValueTuple) String

func (x ValueTuple) String() string

The following types should never be copied

func (ValueTuple) Type

func (x ValueTuple) Type() rbxfile.Type

type ValueVector3int32

type ValueVector3int32 struct {
	X int32
	Y int32
	Z int32
}

func (ValueVector3int32) Copy

func (x ValueVector3int32) Copy() rbxfile.Value

func (ValueVector3int32) String

func (x ValueVector3int32) String() string

func (ValueVector3int32) Type

func (x ValueVector3int32) Type() rbxfile.Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL