fix widget package
This commit is contained in:
parent
c3a64dd96c
commit
570f2b41c6
6
.gitignore
vendored
6
.gitignore
vendored
@ -19,6 +19,6 @@
|
|||||||
go.work
|
go.work
|
||||||
|
|
||||||
# Test builds
|
# Test builds
|
||||||
world_config.json
|
./world_config.json
|
||||||
world_server
|
./world_server
|
||||||
world.db
|
./world.db
|
||||||
|
@ -16,7 +16,7 @@ func (w *Widget) OpenDoor() {
|
|||||||
|
|
||||||
// Set heading if specified
|
// Set heading if specified
|
||||||
if w.openHeading >= 0 {
|
if w.openHeading >= 0 {
|
||||||
w.SetHeading(w.openHeading)
|
w.SetHeadingFromFloat(w.openHeading)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle position changes
|
// Handle position changes
|
||||||
@ -80,10 +80,10 @@ func (w *Widget) CloseDoor() {
|
|||||||
|
|
||||||
// Set heading
|
// Set heading
|
||||||
if w.closedHeading > 0 {
|
if w.closedHeading > 0 {
|
||||||
w.SetHeading(w.closedHeading)
|
w.SetHeadingFromFloat(w.closedHeading)
|
||||||
} else if w.openHeading >= 0 {
|
} else if w.openHeading >= 0 {
|
||||||
// Fall back to original heading
|
// Fall back to original heading
|
||||||
w.SetHeading(w.GetSpawnOrigHeading())
|
w.SetHeadingFromFloat(w.GetSpawnOrigHeading())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update activity status for non-lifts
|
// Update activity status for non-lifts
|
||||||
|
@ -77,7 +77,9 @@ type WidgetTimer struct {
|
|||||||
// WidgetState represents the current state of a widget
|
// WidgetState represents the current state of a widget
|
||||||
type WidgetState struct {
|
type WidgetState struct {
|
||||||
IsOpen bool
|
IsOpen bool
|
||||||
Position spawn.Position
|
X float32
|
||||||
|
Y float32
|
||||||
|
Z float32
|
||||||
Heading float32
|
Heading float32
|
||||||
ActivityStatus int32
|
ActivityStatus int32
|
||||||
}
|
}
|
||||||
@ -89,7 +91,9 @@ func (w *Widget) GetState() WidgetState {
|
|||||||
|
|
||||||
return WidgetState{
|
return WidgetState{
|
||||||
IsOpen: w.isOpen,
|
IsOpen: w.isOpen,
|
||||||
Position: spawn.Position{X: w.GetX(), Y: w.GetY(), Z: w.GetZ()},
|
X: w.GetX(),
|
||||||
|
Y: w.GetY(),
|
||||||
|
Z: w.GetZ(),
|
||||||
Heading: w.GetHeading(),
|
Heading: w.GetHeading(),
|
||||||
ActivityStatus: w.GetActivityStatus(),
|
ActivityStatus: w.GetActivityStatus(),
|
||||||
}
|
}
|
||||||
@ -101,9 +105,9 @@ func (w *Widget) RestoreState(state WidgetState) {
|
|||||||
defer w.mutex.Unlock()
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
w.isOpen = state.IsOpen
|
w.isOpen = state.IsOpen
|
||||||
w.SetX(state.Position.X)
|
w.SetX(state.X)
|
||||||
w.SetY(state.Position.Y)
|
w.SetY(state.Y, false)
|
||||||
w.SetZ(state.Position.Z)
|
w.SetZ(state.Z)
|
||||||
w.SetHeading(state.Heading)
|
w.SetHeadingFromFloat(state.Heading)
|
||||||
w.SetActivityStatus(state.ActivityStatus)
|
w.SetActivityStatus(state.ActivityStatus)
|
||||||
}
|
}
|
||||||
|
@ -484,6 +484,95 @@ func (w *Widget) Copy() *Widget {
|
|||||||
return newWidget
|
return newWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activity status methods
|
||||||
|
|
||||||
|
// GetActivityStatus returns the current activity status
|
||||||
|
func (w *Widget) GetActivityStatus() int32 {
|
||||||
|
// For now, return based on open state
|
||||||
|
if w.IsOpen() {
|
||||||
|
return DefaultActivityOpen
|
||||||
|
}
|
||||||
|
return DefaultActivityClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetActivityStatus sets the activity status
|
||||||
|
func (w *Widget) SetActivityStatus(status int32) {
|
||||||
|
// This method is called but not fully implemented yet
|
||||||
|
// It would normally update some activity state
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPosState sets the position state
|
||||||
|
func (w *Widget) SetPosState(state int32) {
|
||||||
|
// This method is called but not fully implemented yet
|
||||||
|
// It would normally update some position state
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRunningLocation adds a running location for movement
|
||||||
|
func (w *Widget) AddRunningLocation(x, y, z, speed float32) {
|
||||||
|
// For now, just set the position directly
|
||||||
|
// In a full implementation, this would add smooth movement
|
||||||
|
w.SetX(x)
|
||||||
|
w.SetY(y, false)
|
||||||
|
w.SetZ(z)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original position methods (for reset functionality)
|
||||||
|
|
||||||
|
// GetSpawnOrigX returns the original X position
|
||||||
|
func (w *Widget) GetSpawnOrigX() float32 {
|
||||||
|
w.mutex.RLock()
|
||||||
|
defer w.mutex.RUnlock()
|
||||||
|
return w.closeX
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSpawnOrigY returns the original Y position
|
||||||
|
func (w *Widget) GetSpawnOrigY() float32 {
|
||||||
|
w.mutex.RLock()
|
||||||
|
defer w.mutex.RUnlock()
|
||||||
|
return w.closeY
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSpawnOrigZ returns the original Z position
|
||||||
|
func (w *Widget) GetSpawnOrigZ() float32 {
|
||||||
|
w.mutex.RLock()
|
||||||
|
defer w.mutex.RUnlock()
|
||||||
|
return w.closeZ
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSpawnOrigHeading returns the original heading
|
||||||
|
func (w *Widget) GetSpawnOrigHeading() float32 {
|
||||||
|
w.mutex.RLock()
|
||||||
|
defer w.mutex.RUnlock()
|
||||||
|
return w.closedHeading
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTransporterID returns the transporter ID for this widget
|
||||||
|
func (w *Widget) GetTransporterID() int32 {
|
||||||
|
w.mutex.RLock()
|
||||||
|
defer w.mutex.RUnlock()
|
||||||
|
return w.widgetID // For transport widgets, use widget ID as transporter ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIcon sets the icon for this widget (visual appearance)
|
||||||
|
func (w *Widget) SetIcon(icon int8) {
|
||||||
|
// This method is called but not implemented in the base spawn
|
||||||
|
// In a full implementation, this would update the visual appearance
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopySpawnData copies spawn data from another spawn
|
||||||
|
func (w *Widget) CopySpawnData(src *spawn.Spawn) {
|
||||||
|
// Copy basic spawn data
|
||||||
|
w.SetName(src.GetName())
|
||||||
|
w.SetX(src.GetX())
|
||||||
|
w.SetY(src.GetY(), false)
|
||||||
|
w.SetZ(src.GetZ())
|
||||||
|
w.SetHeadingFromFloat(src.GetHeading())
|
||||||
|
w.SetLevel(src.GetLevel())
|
||||||
|
w.SetClass(src.GetClass())
|
||||||
|
w.SetRace(src.GetRace())
|
||||||
|
w.SetGender(src.GetGender())
|
||||||
|
}
|
||||||
|
|
||||||
// calculateDistance calculates 3D distance between two points
|
// calculateDistance calculates 3D distance between two points
|
||||||
func calculateDistance(x1, y1, z1, x2, y2, z2 float32) float32 {
|
func calculateDistance(x1, y1, z1, x2, y2, z2 float32) float32 {
|
||||||
dx := x2 - x1
|
dx := x2 - x1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user