本文整理汇总了C#中Universe.ScriptEngine.VirtualScript.LSL_Types.list.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Universe.ScriptEngine.VirtualScript.LSL_Types.list.Add方法的具体用法?C# Universe.ScriptEngine.VirtualScript.LSL_Types.list.Add怎么用?C# Universe.ScriptEngine.VirtualScript.LSL_Types.list.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe.ScriptEngine.VirtualScript.LSL_Types.list
的用法示例。
在下文中一共展示了Universe.ScriptEngine.VirtualScript.LSL_Types.list.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: llParcelMediaQuery
public LSL_List llParcelMediaQuery(LSL_List aList)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
LSL_List list = new LSL_List();
foreach (object t in aList.Data)
{
if (t != null)
{
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
if (parcelManagement != null)
{
LSL_Integer tmp = (LSL_Integer)t;
switch ((ParcelMediaCommandEnum)tmp.value)
{
case ParcelMediaCommandEnum.Url:
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaURL));
break;
case ParcelMediaCommandEnum.Desc:
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y)
.LandData.MediaDescription));
break;
case ParcelMediaCommandEnum.Texture:
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y)
.LandData.MediaID.ToString()));
break;
case ParcelMediaCommandEnum.Type:
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaType));
break;
case ParcelMediaCommandEnum.Loop:
list.Add(
new LSL_Integer(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaLoop
? 1
: 0));
break;
case ParcelMediaCommandEnum.LoopSet:
list.Add(
new LSL_Integer(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaLoopSet));
break;
case ParcelMediaCommandEnum.Size:
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaHeight));
list.Add(
new LSL_String(
parcelManagement.GetLandObject(m_host.AbsolutePosition.X,
m_host.AbsolutePosition.Y).LandData.MediaWidth));
break;
default:
const ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
NotImplemented("llParcelMediaQuery", "Parameter not supported yet: " +
Enum.Parse(mediaCommandEnum.GetType(), t.ToString()));
break;
}
}
}
}
PScriptSleep(m_sleepMsOnParcelMediaQuery);
return list;
}
示例2: llList2ListStrided
/// <summary>
/// Elements in the source list starting with 0 and then
/// every i+stride. If the stride is negative then the scan
/// is backwards producing an inverted result.
/// Only those elements that are also in the specified
/// range are included in the result.
/// </summary>
public LSL_List llList2ListStrided(LSL_List src, int start, int end, int stride)
{
LSL_List result = new LSL_List();
int[] si = new int[2];
int[] ei = new int[2];
bool twopass = false;
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
// First step is always to deal with negative indices
if (start < 0)
start = src.Length + start;
if (end < 0)
end = src.Length + end;
// Out of bounds indices are OK, just trim them
// accordingly
if (start > src.Length)
start = src.Length;
if (end > src.Length)
end = src.Length;
if (stride == 0)
stride = 1;
// There may be one or two ranges to be considered
if (start != end)
{
if (start <= end)
{
si[0] = start;
ei[0] = end;
}
else
{
si[1] = start;
ei[1] = src.Length;
si[0] = 0;
ei[0] = end;
twopass = true;
}
// The scan always starts from the beginning of the
// source list, but members are only selected if they
// fall within the specified sub-range. The specified
// range values are inclusive.
// A negative stride reverses the direction of the
// scan producing an inverted list as a result.
if (stride > 0)
{
for (int i = 0; i < src.Length; i += stride)
{
if (i <= ei[0] && i >= si[0])
result.Add(src.Data[i]);
if (twopass && i >= si[1] && i <= ei[1])
result.Add(src.Data[i]);
}
}
else if (stride < 0)
{
for (int i = src.Length - 1; i >= 0; i += stride)
{
if (i <= ei[0] && i >= si[0])
result.Add(src.Data[i]);
if (twopass && i >= si[1] && i <= ei[1])
result.Add(src.Data[i]);
}
}
}
else
{
if (start % stride == 0)
{
result.Add(src.Data[start]);
}
}
return result;
}
示例3: llListRandomize
/// <summary>
/// Randomizes the list, be arbitrarily reordering
/// sublists of stride elements. As the stride approaches
/// the size of the list, the options become very
/// limited.
/// </summary>
/// <remarks>
/// This could take a while for very large list
/// sizes.
/// </remarks>
public LSL_List llListRandomize(LSL_List src, int stride)
{
LSL_List result;
Random rand = new Random();
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
if (stride <= 0)
{
stride = 1;
}
// Stride MUST be a factor of the list length
// If not, then return the src list. This also
// traps those cases where stride > length.
if (src.Length != stride && src.Length % stride == 0)
{
int chunkk = src.Length / stride;
int[] chunks = new int[chunkk];
for (int i = 0; i < chunkk; i++)
chunks[i] = i;
// Knuth shuffle the chunkk index
for (int i = chunkk - 1; i >= 1; i--)
{
// Elect an unrandomized chunk to swap
int index = rand.Next(i + 1);
// and swap position with first unrandomized chunk
int tmp = chunks[i];
chunks[i] = chunks[index];
chunks[index] = tmp;
}
// Construct the randomized list
result = new LSL_List();
for (int i = 0; i < chunkk; i++)
{
for (int j = 0; j < stride; j++)
{
result.Add(src.Data[chunks[i] * stride + j]);
}
}
}
else
{
object[] array = new object[src.Length];
Array.Copy(src.Data, 0, array, 0, src.Length);
result = new LSL_List(array);
}
return result;
}
示例4: osGetAvatarList
/// <summary>
/// Like osGetAgents but returns enough info for a radar
/// </summary>
/// <returns>Strided list of the UUID, position and name of each avatar in the region</returns>
public LSL_List osGetAvatarList()
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osGetAvatarList", m_host, "OSSL", m_itemID))
return new LSL_List();
LSL_List result = new LSL_List();
World.ForEachScenePresence(delegate(IScenePresence avatar)
{
if (avatar != null && avatar.UUID != m_host.OwnerID)
{
if (!avatar.IsChildAgent)
{
result.Add(new LSL_Key(avatar.UUID.ToString()));
result.Add(new LSL_Vector(avatar.AbsolutePosition.X,
avatar.AbsolutePosition.Y,
avatar.AbsolutePosition.Z));
result.Add(new LSL_String(avatar.Name));
}
}
});
return result;
}
示例5: GetPrimMediaParams
private LSL_List GetPrimMediaParams(ISceneChildEntity obj, int face, LSL_List rules)
{
IMoapModule module = World.RequestModuleInterface<IMoapModule>();
if (null == module)
throw new Exception("Media on a prim functions not available");
MediaEntry me = module.GetMediaEntry(obj, face);
// As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
if (null == me)
return new LSL_List();
LSL_List res = new LSL_List();
for (int i = 0; i < rules.Length; i++)
{
int code = (int)rules.GetLSLIntegerItem(i);
if (code == ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE)
{
// Not implemented
res.Add(new LSL_Integer(0));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_CONTROLS)
{
res.Add(me.Controls == MediaControls.Standard
? new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD)
: new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_CURRENT_URL)
{
res.Add(new LSL_String(me.CurrentURL));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_HOME_URL)
{
res.Add(new LSL_String(me.HomeURL));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP)
{
res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY)
{
res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE)
{
res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM)
{
res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT)
{
res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS)
{
res.Add(new LSL_Integer(me.Width));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS)
{
res.Add(new LSL_Integer(me.Height));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE)
{
res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
}
else if (code == ScriptBaseClass.PRIM_MEDIA_WHITELIST)
{
string[] urls = (string[])me.WhiteList.Clone();
for (int j = 0; j < urls.Length; j++)
urls[j] = Uri.EscapeDataString(urls[j]);
res.Add(new LSL_String(string.Join(", ", urls)));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT)
{
res.Add(new LSL_Integer((int)me.InteractPermissions));
}
else if (code == ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL)
{
res.Add(new LSL_Integer((int)me.ControlPermissions));
}
}
return res;
}
示例6: aaGetTeamMembers
public LSL_List aaGetTeamMembers (LSL_String team)
{
if (!ScriptProtection.CheckThreatLevel (ThreatLevel.Low, "aaGetTeamMembers", m_host, "AA", m_itemID))
return new LSL_List ();
List<UUID> Members = new List<UUID> ();
ICombatModule module = World.RequestModuleInterface<ICombatModule> ();
if (module != null) {
Members = module.GetTeammates (team);
}
LSL_List members = new LSL_List ();
foreach (UUID member in Members)
members.Add (new LSL_Key (member.ToString ()));
return members;
}
示例7: osMatchString
public LSL_List osMatchString(string src, string pattern, int start)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osMatchString", m_host, "OSSL", m_itemID))
return new LSL_List();
LSL_List result = new LSL_List();
// Normalize indices (if negative).
// After normlaization they may still be
// negative, but that is now relative to
// the start, rather than the end, of the
// sequence.
if (start < 0)
{
start = src.Length + start;
}
if (start < 0 || start >= src.Length)
{
return result; // empty list
}
// Find matches beginning at start position
Regex matcher = new Regex(pattern);
Match match = matcher.Match(src, start);
while (match.Success)
{
foreach (Group g in match.Groups)
{
if (g.Success)
{
result.Add(new LSL_Integer(g.Value));
result.Add(new LSL_Integer(g.Index));
}
}
match = match.NextMatch();
}
return result;
}
示例8: llGetAnimationList
public LSL_List llGetAnimationList(string id)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
LSL_List l = new LSL_List();
IScenePresence av = World.GetScenePresence((UUID)id);
if (av == null || av.IsChildAgent) // only if in the region
return l;
UUID[] anims = av.Animator.GetAnimationArray();
foreach (UUID foo in anims)
l.Add(new LSL_Key(foo.ToString()));
return l;
}
示例9: llGetBoundingBox
/// <summary>
/// A partial implementation.
/// http://lslwiki.net/lslwiki/wakka.php?wakka=llGetBoundingBox
/// So far only valid for standing/flying/ground sitting avatars and single prim objects.
/// If the object has multiple prims and/or a sitting avatar then the bounding
/// box is for the root prim only.
/// </summary>
public LSL_List llGetBoundingBox(string obj)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
UUID objID = UUID.Zero;
LSL_List result = new LSL_List();
if (!UUID.TryParse(obj, out objID))
{
result.Add(new LSL_Vector());
result.Add(new LSL_Vector());
return result;
}
IScenePresence presence = World.GetScenePresence(objID);
if (presence != null)
{
if (presence.ParentID == UUID.Zero) // not sat on an object
{
LSL_Vector lower = new LSL_Vector();
LSL_Vector upper = new LSL_Vector();
if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID
== AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
{
// This is for ground sitting avatars
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule>();
if (appearance != null)
{
float height = appearance.Appearance.AvatarHeight / 2.66666667f;
lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
}
}
else
{
// This is for standing/flying avatars
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule>();
if (appearance != null)
{
float height = appearance.Appearance.AvatarHeight / 2.0f;
lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
}
}
result.Add(lower);
result.Add(upper);
return result;
}
// sitting on an object so we need the bounding box of that
// which should include the avatar so set the UUID to the
// UUID of the object the avatar is sat on and allow it to fall through
// to processing an object
ISceneChildEntity p = World.GetSceneObjectPart(presence.ParentID);
objID = p.UUID;
}
ISceneChildEntity part = World.GetSceneObjectPart(objID);
// Currently only works for single prims without a sitting avatar
if (part != null)
{
Vector3 halfSize = part.Scale * 0.5f;
LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f);
LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z);
result.Add(lower);
result.Add(upper);
return result;
}
// Not found so return empty values
result.Add(new LSL_Vector());
result.Add(new LSL_Vector());
return result;
}
示例10: llCSV2List
/// <summary>
/// The supplied string is scanned for commas
/// and converted into a list. Commas are only
/// effective if they are encountered outside
/// of '<' '>' delimiters. Any whitespace
/// before or after an element is trimmed.
/// </summary>
public LSL_List llCSV2List(string src)
{
LSL_List result = new LSL_List();
int parens = 0;
int start = 0;
int length = 0;
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
for (int i = 0; i < src.Length; i++)
{
switch (src[i])
{
case '<':
parens++;
length++;
break;
case '>':
if (parens > 0)
parens--;
length++;
break;
case ',':
if (parens == 0)
{
result.Add(new LSL_String(src.Substring(start, length).Trim()));
start += length + 1;
length = 0;
}
else
{
length++;
}
break;
default:
length++;
break;
}
}
result.Add(new LSL_String(src.Substring(start, length).Trim()));
return result;
}
示例11: llGetAgentList
/// <summary>
/// http://wiki.secondlife.com/wiki/LlGetAgentList
/// The list of options is currently not used in SL
/// scope is one of:-
/// AGENT_LIST_REGION - all in the region
/// AGENT_LIST_PARCEL - all in the same parcel as the scripted object
/// AGENT_LIST_PARCEL_OWNER - all in any parcel owned by the owner of the
/// current parcel.
/// </summary>
public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
// the constants are 1, 2 and 4 so bits are being set, but you
// get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4
bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION;
bool parcelOwned = scope == ScriptBaseClass.AGENT_LIST_PARCEL_OWNER;
bool parcel = scope == ScriptBaseClass.AGENT_LIST_PARCEL;
LSL_List result = new LSL_List();
if (!regionWide && !parcelOwned && !parcel)
{
result.Add("INVALID_SCOPE");
return result;
}
Vector3 pos;
UUID id = UUID.Zero;
if (parcel || parcelOwned)
{
pos = m_host.GetWorldPosition();
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
if (land == null)
{
id = UUID.Zero;
}
else
{
if (parcelOwned)
{
id = land.LandData.OwnerID;
}
else
{
id = land.LandData.GlobalID;
}
}
}
World.ForEachScenePresence(delegate(IScenePresence ssp)
{
// Gods are not listed in SL
if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent)
{
if (!regionWide)
{
pos = ssp.AbsolutePosition;
IParcelManagementModule parcelManagement =
World.RequestModuleInterface<IParcelManagementModule>();
ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
if (land != null)
{
if (parcelOwned && land.LandData.OwnerID == id ||
parcel && land.LandData.GlobalID == id)
{
result.Add(ssp.UUID.ToString());
}
}
}
else
{
result.Add(ssp.UUID.ToString());
}
}
// Maximum of 100 results
if (result.Length > 99)
{
return;
}
});
return result;
}
示例12: llCastRay
public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
LSL_List list = new LSL_List();
Vector3 rayStart = start.ToVector3();
Vector3 rayEnd = end.ToVector3();
Vector3 dir = rayEnd - rayStart;
float dist = Vector3.Mag(dir);
int count = 1;
bool detectPhantom = false;
int dataFlags = 0;
int rejectTypes = 0;
for (int i = 0; i < options.Length; i += 2)
{
if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS)
count = options.GetLSLIntegerItem(i + 1);
else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM)
detectPhantom = (options.GetLSLIntegerItem(i + 1) > 0);
else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS)
dataFlags = options.GetLSLIntegerItem(i + 1);
else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES)
rejectTypes = options.GetLSLIntegerItem(i + 1);
}
if (count > 16)
count = 16;
else if (count <= 0)
{
Error("llCastRay", "You must request at least one result from llCastRay.");
return new LSL_List();
}
List<ContactResult> results = new List<ContactResult>();
bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND);
bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS);
bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
if (checkAgents)
{
ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
foreach (ContactResult r in agentHits)
results.Add(r);
}
if (checkPhysical || checkNonPhysical || detectPhantom)
{
ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom, count + 2);
for (int iter = 0; iter < objectHits.Length; iter++)
{
// Redistance the Depth because the Scene RayCaster returns distance from center to make the rezzing code simpler.
objectHits[iter].Depth = Vector3.Distance(objectHits[iter].Pos, rayStart);
results.Add(objectHits[iter]);
}
}
if (checkTerrain)
{
ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
if (groundContact != null)
results.Add((ContactResult)groundContact);
}
results.Sort(delegate(ContactResult a, ContactResult b)
{
return a.Depth.CompareTo(b.Depth);
});
int values = 0;
ISceneEntity thisgrp = m_host.ParentEntity;
foreach (ContactResult result in results)
{
if (result.Depth > dist)
continue;
// physics ray can return colisions with host prim
// this is supposed to happen
if (m_host.LocalId == result.ConsumerID)
continue;
if (!checkTerrain && result.ConsumerID == 0)
continue; //Terrain
UUID itemID = UUID.Zero;
int linkNum = 0;
ISceneChildEntity part = World.GetSceneObjectPart(result.ConsumerID);
// It's a prim!
if (part != null)
{
// dont detect members of same object ???
if (part.ParentEntity == thisgrp)
//.........这里部分代码省略.........
示例13: ParseString
//.........这里部分代码省略.........
for (j = 0; j < seplen; j++)
{
if (separray[j].ToString() == String.Empty)
active[j] = false;
if (active[j])
{
// scan all of the markers
if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1)
{
// not present at all
active[j] = false;
}
else
{
// present and correct
if (offset[j] < offset[best])
{
// closest so far
best = j;
if (offset[best] == beginning)
break;
}
}
}
}
// Scan for spacers
if (offset[best] != beginning)
{
for (j = seplen; (j < mlen) && (offset[best] > beginning); j++)
{
if (spcarray[j - seplen].ToString() == String.Empty)
active[j] = false;
if (active[j])
{
// scan all of the markers
if ((offset[j] = src.IndexOf(spcarray[j - seplen].ToString(), beginning)) == -1)
{
// not present at all
active[j] = false;
}
else
{
// present and correct
if (offset[j] < offset[best])
{
// closest so far
best = j;
}
}
}
}
}
// This is the normal exit from the scanning loop
if (best == mlen)
{
// no markers were found on this pass
// so we're pretty much done
if ((keepNulls) || ((srclen - beginning) > 0))
tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
break;
}
// Otherwise we just add the newly delimited token
// and recalculate where the search should continue.
if ((keepNulls) || ((offset[best] - beginning) > 0))
tokens.Add(new LSL_String(src.Substring(beginning, offset[best] - beginning)));
if (best < seplen)
{
beginning = offset[best] + (separray[best].ToString()).Length;
}
else
{
beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
string str = spcarray[best - seplen].ToString();
if ((keepNulls) || ((str.Length > 0)))
tokens.Add(new LSL_String(str));
}
}
// This an awkward an not very intuitive boundary case. If the
// last substring is a tokenizer, then there is an implied trailing
// null list entry. Hopefully the single comparison will not be too
// arduous. Alternatively the 'break' could be replced with a return
// but that's shabby programming.
if ((beginning == srclen) && (keepNulls))
{
if (srclen != 0)
tokens.Add(new LSL_String(""));
}
return tokens;
}
示例14: ParseJsonNode
private object ParseJsonNode(OSD node)
{
if (node.Type == OSDType.Integer)
return new LSL_Integer(node.AsInteger());
if (node.Type == OSDType.Boolean)
return new LSL_Integer(node.AsBoolean() ? 1 : 0);
if (node.Type == OSDType.Real)
return new LSL_Float(node.AsReal());
if (node.Type == OSDType.UUID || node.Type == OSDType.String)
return new LSL_String(node.AsString());
if (node.Type == OSDType.Array)
{
LSL_List resp = new LSL_List();
OSDArray ar = node as OSDArray;
foreach (OSD o in ar)
resp.Add(ParseJsonNode(o));
return resp;
}
if (node.Type == OSDType.Map)
{
LSL_List resp = new LSL_List();
OSDMap ar = node as OSDMap;
foreach (KeyValuePair<string, OSD> o in ar)
{
resp.Add(new LSL_String(o.Key));
resp.Add(ParseJsonNode(o.Value));
}
return resp;
}
throw new Exception(ScriptBaseClass.JSON_INVALID);
}
示例15: ConvertWindlightDayCycle
void ConvertWindlightDayCycle (WindlightDayCycle cycle, int preset, int rule, ref LSL_List list)
{
var skyDatas = cycle.Cycle.DataSettings.Values.ToList ();
var skyData = skyDatas [preset];
switch (rule) {
case ScriptBaseClass.WL_AMBIENT:
list.Add (new LSL_Rotation (skyData.ambient.X, skyData.ambient.Y,
skyData.ambient.Z, skyData.ambient.W));
break;
case ScriptBaseClass.WL_SKY_BLUE_DENSITY:
list.Add (new LSL_Rotation (skyData.blue_density.X, skyData.blue_density.Y,
skyData.blue_density.Z, skyData.blue_density.W));
break;
case ScriptBaseClass.WL_SKY_BLUR_HORIZON:
list.Add (new LSL_Rotation (skyData.blue_horizon.X, skyData.blue_horizon.Y,
skyData.blue_horizon.Z, skyData.blue_horizon.W));
break;
case ScriptBaseClass.WL_CLOUD_COLOR:
list.Add (new LSL_Rotation (skyData.cloud_color.X, skyData.cloud_color.Y,
skyData.cloud_color.Z, skyData.cloud_color.W));
break;
case ScriptBaseClass.WL_CLOUD_POS_DENSITY1:
list.Add (new LSL_Rotation (skyData.cloud_pos_density1.X, skyData.cloud_pos_density1.Y,
skyData.cloud_pos_density1.Z, skyData.cloud_pos_density1.W));
break;
case ScriptBaseClass.WL_CLOUD_POS_DENSITY2:
list.Add (new LSL_Rotation (skyData.cloud_pos_density2.X, skyData.cloud_pos_density2.Y,
skyData.cloud_pos_density2.Z, skyData.cloud_pos_density2.W));
break;
case ScriptBaseClass.WL_CLOUD_SCALE:
list.Add (new LSL_Rotation (skyData.cloud_scale.X, skyData.cloud_scale.Y,
skyData.cloud_scale.Z, skyData.cloud_scale.W));
break;
case ScriptBaseClass.WL_CLOUD_SCROLL_X:
list.Add (new LSL_Float (skyData.cloud_scroll_rate.X));
break;
case ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
list.Add (new LSL_Integer (skyData.enable_cloud_scroll.X));
break;
case ScriptBaseClass.WL_CLOUD_SCROLL_Y:
list.Add (new LSL_Float (skyData.cloud_scroll_rate.Y));
break;
case ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
list.Add (new LSL_Integer (skyData.enable_cloud_scroll.Y));
break;
case ScriptBaseClass.WL_CLOUD_SHADOW:
list.Add (new LSL_Rotation (skyData.cloud_shadow.X, skyData.cloud_shadow.Y,
skyData.cloud_shadow.Z, skyData.cloud_shadow.W));
break;
case ScriptBaseClass.WL_SKY_DENSITY_MULTIPLIER:
list.Add (new LSL_Rotation (skyData.density_multiplier.X, skyData.density_multiplier.Y,
skyData.density_multiplier.Z, skyData.density_multiplier.W));
break;
case ScriptBaseClass.WL_SKY_DISTANCE_MULTIPLIER:
list.Add (new LSL_Rotation (skyData.distance_multiplier.X, skyData.distance_multiplier.Y,
skyData.distance_multiplier.Z, skyData.distance_multiplier.W));
break;
case ScriptBaseClass.WL_SKY_GAMMA:
list.Add (new LSL_Rotation (skyData.gamma.X, skyData.gamma.Y, skyData.gamma.Z, skyData.gamma.W));
break;
case ScriptBaseClass.WL_SKY_GLOW:
list.Add (new LSL_Rotation (skyData.glow.X, skyData.glow.Y, skyData.glow.Z, skyData.glow.W));
break;
case ScriptBaseClass.WL_SKY_HAZE_DENSITY:
list.Add (new LSL_Rotation (skyData.haze_density.X, skyData.haze_density.Y,
skyData.haze_density.Z, skyData.haze_density.W));
break;
case ScriptBaseClass.WL_SKY_HAZE_HORIZON:
list.Add (new LSL_Rotation (skyData.haze_horizon.X, skyData.haze_horizon.Y,
skyData.haze_horizon.Z, skyData.haze_horizon.W));
break;
case ScriptBaseClass.WL_SKY_LIGHT_NORMALS:
list.Add (new LSL_Rotation (skyData.lightnorm.X, skyData.lightnorm.Y,
skyData.lightnorm.Z, skyData.lightnorm.W));
break;
case ScriptBaseClass.WL_SKY_MAX_ALTITUDE:
list.Add (new LSL_Rotation (skyData.max_y.X, skyData.max_y.Y, skyData.max_y.Z, skyData.max_y.W));
break;
case ScriptBaseClass.WL_SKY_STAR_BRIGHTNESS:
list.Add (new LSL_Float (skyData.star_brightness));
break;
case ScriptBaseClass.WL_SKY_SUNLIGHT_COLOR:
list.Add (new LSL_Rotation (skyData.sunlight_color.X, skyData.sunlight_color.Y,
skyData.sunlight_color.Z, skyData.sunlight_color.W));
break;
case ScriptBaseClass.WL_WATER_BLUR_MULTIPLIER:
list.Add (new LSL_Float (cycle.Water.blurMultiplier));
break;
case ScriptBaseClass.WL_WATER_FRESNEL_OFFSET:
list.Add (new LSL_Float (cycle.Water.fresnelOffset));
break;
case ScriptBaseClass.WL_WATER_FRESNEL_SCALE:
list.Add (new LSL_Float (cycle.Water.fresnelScale));
break;
case ScriptBaseClass.WL_WATER_NORMAL_MAP:
list.Add (new LSL_String (cycle.Water.normalMap));
break;
case ScriptBaseClass.WL_WATER_NORMAL_SCALE:
list.Add (new LSL_Vector (cycle.Water.normScale.X, cycle.Water.normScale.Y, cycle.Water.normScale.Z));
//.........这里部分代码省略.........