Started working on navigation
This commit is contained in:
parent
b7d5a79c07
commit
adc9ad36cd
7
common/Navigation/Campspot.iss
Normal file
7
common/Navigation/Campspot.iss
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef _mr_campspot_
|
||||
#define _mr_campspot_
|
||||
objectdef MRCampSpot
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
85
common/Navigation/Movement.iss
Normal file
85
common/Navigation/Movement.iss
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef _mr_movement_
|
||||
#define _mr_movement_
|
||||
objectdef MovememntKeyMap
|
||||
{
|
||||
variable string MoveForwardKey = "w"
|
||||
}
|
||||
|
||||
objectdef MRNavigation
|
||||
{
|
||||
variable bool MoveToRequested = FALSE
|
||||
variable point3f MoveToPoint
|
||||
variable float Percision = 5
|
||||
|
||||
method SetPercision(float persision)
|
||||
{
|
||||
Percision:Set[${persision}]
|
||||
}
|
||||
|
||||
method MoveTo(point3f point)
|
||||
{
|
||||
MoveToRequested:Set[TRUE]
|
||||
MoveToPoint:Set[${point.X}, ${point.Z}, ${point.Z}]
|
||||
}
|
||||
|
||||
method MoveToComplete()
|
||||
{
|
||||
MoveToRequested:Set[FALSE]
|
||||
}
|
||||
}
|
||||
|
||||
variable(global) MRNavigation MRNav
|
||||
variable MovememntKeyMap MRMoveKeyMap
|
||||
|
||||
variable jsonvalue _debounceChecks = "{}";
|
||||
function Debounce(string command, string id, int interval)
|
||||
{
|
||||
if !${_debounceChecks.Has["${id}"]} || !${_debounceChecks.Get["${id}"]}
|
||||
{
|
||||
variable weakref commandRef = "${command}"
|
||||
_debounceChecks:Set["${id}", TRUE]
|
||||
execute ${command}
|
||||
TimedCommand ${interval} Script["${Script.Filename}"].Variable["_debounceChecks"]:Erase["${id}"]
|
||||
}
|
||||
}
|
||||
|
||||
function FacePoint(point3f point)
|
||||
{
|
||||
call Debounce "face ${point.X} ${point.Z}" "face" 3
|
||||
}
|
||||
|
||||
function MoveTo(point3f point)
|
||||
{
|
||||
|
||||
while ${Math.Distance[${Me.X},${Me.Z},${MRNav.MoveToPoint.X},${MRNav.MoveToPoint.Z}]} > ${MRNav.Percision}
|
||||
{
|
||||
call FacePoint ${point}
|
||||
|
||||
if !${Me.IsMoving}
|
||||
{
|
||||
|
||||
call Debounce "press -hold ${MRMoveKeyMap.MoveForwardKey}" "moveForward" 5
|
||||
}
|
||||
wait 1
|
||||
|
||||
call Debounce "echo Distance ${Math.Distance[${Me.X},${Me.Z},${MRNav.MoveToPoint.X},${MRNav.MoveToPoint.Z}]} > ${MRNav.Percision}" "debugDistance" 5
|
||||
}
|
||||
press -release ${MRMoveKeyMap.MoveForwardKey}
|
||||
MRNav:MoveToComplete
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
while 1
|
||||
{
|
||||
if !${MRNav.MoveToRequested}
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
call Debounce "call MoveTo ${MRNav.MoveToPoint}" "move" 5
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
39
common/Navigation/Test.iss
Normal file
39
common/Navigation/Test.iss
Normal file
@ -0,0 +1,39 @@
|
||||
objectdef TestController
|
||||
{
|
||||
variable string Name="Apple"
|
||||
variable string Color="Red"
|
||||
method Initialize()
|
||||
{
|
||||
echo "TestController::Initialize"
|
||||
LGUI2:LoadPackageFile["Test.json"]
|
||||
RunScript "${LavishScript.HomeDirectory}/Scripts/mr/common/Navigation/Movement"
|
||||
}
|
||||
|
||||
method Shutdown()
|
||||
{
|
||||
echo "TestController::Shutdown"
|
||||
LGUI2:UnloadPackageFile["Test.json"]
|
||||
EndScript Movement
|
||||
}
|
||||
|
||||
method OnClose()
|
||||
{
|
||||
echo "TestController::OnClose"
|
||||
Script:End
|
||||
}
|
||||
|
||||
method Test()
|
||||
{
|
||||
MRNav:MoveTo["${Me.Target.Loc}"]
|
||||
}
|
||||
}
|
||||
|
||||
variable(global) TestController MRTestController
|
||||
function main()
|
||||
{
|
||||
|
||||
while 1
|
||||
{
|
||||
wait 5
|
||||
}
|
||||
}
|
||||
77
common/Navigation/Test.json
Normal file
77
common/Navigation/Test.json
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
|
||||
"skin": {
|
||||
"name": "MRSkin",
|
||||
"brushes": {
|
||||
"window.titleBar.backgroundBrush": {
|
||||
"color": "#211C18"
|
||||
}
|
||||
},
|
||||
"templates": {
|
||||
"window.title": {
|
||||
"verticalAlignment": "center",
|
||||
"margin": [2, 0, 0, 0]
|
||||
},
|
||||
"button": {
|
||||
"jsonTemplate": "default:button",
|
||||
"margin": [2, 2, 2, 2],
|
||||
"color": "#f4f3ee"
|
||||
},
|
||||
"checkbox": {
|
||||
"jsonTemplate": "default:checkbox",
|
||||
"margin": [2, 2, 2, 2]
|
||||
},
|
||||
"window": {
|
||||
"jsonTemplate": "default:window",
|
||||
"backgroundBrush": {
|
||||
"color": "#463f3a"
|
||||
},
|
||||
"color": "#f4f3ee",
|
||||
"font": {
|
||||
"face": "Segoe UI",
|
||||
"height": 16
|
||||
}
|
||||
},
|
||||
"listbox.contentContainerFitWidth": {
|
||||
"jsonTemplate": "listbox.contentContainer",
|
||||
"horizontalScroll": "fit"
|
||||
}
|
||||
}
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"type": "window",
|
||||
"skin": "MRSkin",
|
||||
"title": "MR Test",
|
||||
"name": "mr.test.miniwindow",
|
||||
"borderThickness": 2,
|
||||
"hideOnClose": false,
|
||||
"minSize": {
|
||||
"width": 100,
|
||||
"height": 50
|
||||
},
|
||||
"maxSize": {
|
||||
"width": 150,
|
||||
"height": 125
|
||||
},
|
||||
"eventHandlers": {
|
||||
"onCloseButtonClick": ["method", "MRTestController", "OnClose"]
|
||||
},
|
||||
"content": {
|
||||
"type": "stackpanel",
|
||||
"uniform": true,
|
||||
"heightFactor": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "button",
|
||||
"content": "Test",
|
||||
"horizontalAlignment": "stretch",
|
||||
"eventHandlers": {
|
||||
"onRelease": ["method", "MRTestController", "Test"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
mr.iss
2
mr.iss
@ -17,6 +17,6 @@ function main(... params)
|
||||
elseif ${params[1].Lower.Equal["test"]}
|
||||
{
|
||||
ConsoleClear
|
||||
run mr/test ${params[2]}
|
||||
run "mr/common/Navigation/test"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user