All pastes #211649 Raw Edit

Miscellany

public text v1 · immutable
#211649 ·published 2006-10-20 12:34 UTC
rendered paste body
#ifndef ObjRoam
#define ObjRoam FukabunRoam
#endif

#define STATE_ROAM_NONE 0

objectdef FukabunRoamSpot
{
	variable string Name
	variable point3f Coords
	variable int Visits = 0

	method Initialize(string Name, point3f Coords)
	{
		This.Name:Set[${Name}]
		This.Coords:Set[${Coords}]
	}
}

objectdef FukabunRoamArea
{
	variable string Name
	variable int Visits = 0
	
	method Initialize(string Name)
	{
		This.Name:Set[${Name}]
	}
}

objectdef FukabunRoam inherits ObjBaseObject
{
	variable index:FukabunRoamArea RoamAreas
	variable index:FukabunRoamSpot RoamSpots
	variable int CurrentArea = 1
	variable int CurrentSpot = 1

	member State()
	{
		return STATE_ROAM_NONE
	}

	method ResetRoamAreas()
	{
		RoamAreas:Collapse
		if ${RoamAreas.Get[1](exists)}
		{
			do
			{
				RoamAreas:Remove[1]
			}
			while ${RoamAreas.Get[1](exists)}
		}
	}

	method RoamAreaChanged()
	{
		variable int Total
		variable int Current = 1
		variable int Index = 0
		variable string AreaName
		This:ResetRoamAreas
		
		Total:Set[${UIElement[Areas@Roam areas@Pages@FukabunHuntGUI].SelectedItems}]
		do
		{
			AreaName:Set["${UIElement[Areas@Roam areas@Pages@FukabunHuntGUI].SelectedItem[${Current}]}"]
			RoamAreas:Insert[${AreaName}]
			This:Debug["Fukabun roam: Roam area ${AreaName} added to roam list"]
		}
		while ${Current:Inc}<=${Total}
		
		This.CurrentArea:Set[1]
		This:LoadSpots[${This.CurrentArea}]
	}
	
	method ResetSpots()
	{
		RoamSpots:Collapse
		if ${RoamSpots.Get[1](exists)}
		{
			do
			{
				RoamSpots:Remove[1]
			}
			while ${RoamSpots.Get[1](exists)}
		}
	}
	
	method LoadSpots(int RoamArea)
	{
		variable iterator SpotIterator
		variable settingsetref Area
		variable settingsetref Spot
		variable point3f Coords
		
		This:ResetSpots

		Area:Set[${Config.setHuntGroups.FindSet["${RoamAreas.Get[${This.CurrentArea}].Name}"]}]
		Area:GetSetIterator[SpotIterator]

		if ${SpotIterator:First(exists)}
		{
			do
			{
				Spot:Set[${Area.FindSet[${SpotIterator.Key}]}]
				
				Coords.X:Set[${Spot.FindSetting["X","0"]}]
				Coords.Y:Set[${Spot.FindSetting["Y","0"]}]
				Coords.Z:Set[${Spot.FindSetting["Z","0"]}]
				echo ${SpotIterator.Key},${Coords}
				RoamSpots:Insert[${SpotIterator.Key},${Coords}]
			}
			while ${SpotIterator:Next(exists)}
		}
		
		This.CurrentSpot:Set[1]
	}
	
	method Pulse()
	{
		This.CurrentState:Set[${This.State}]
		
		switch ${This.CurrentState}
		{
			case STATE_ROAM_NONE
				break
		}
	}
	
}