本文整理汇总了C#中IScriptInstance类的典型用法代码示例。如果您正苦于以下问题:C# IScriptInstance类的具体用法?C# IScriptInstance怎么用?C# IScriptInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IScriptInstance类属于命名空间,在下文中一共展示了IScriptInstance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: llGetInventoryPermMask
public int llGetInventoryPermMask(IScriptInstance script, string name, int mask)
{
LLPrimitive prim = script.Host as LLPrimitive;
if (prim == null)
return 0;
LLInventoryTaskItem found = prim.Inventory.FindItem(item => item.Name == name);
if (found != null)
{
switch (mask)
{
case LSLConstants.MASK_BASE:
return (int)found.Permissions.BaseMask;
case LSLConstants.MASK_OWNER:
return (int)found.Permissions.OwnerMask;
case LSLConstants.MASK_GROUP:
return (int)found.Permissions.GroupMask;
case LSLConstants.MASK_EVERYONE:
return (int)found.Permissions.EveryoneMask;
case LSLConstants.MASK_NEXT:
return (int)found.Permissions.NextOwnerMask;
}
}
return 0;
}
开发者ID:thoys,项目名称:simian,代码行数:26,代码来源:Inventory.cs
示例2: llAvatarOnSitTarget
public string llAvatarOnSitTarget(IScriptInstance script)
{
if (script.Host is LLPrimitive)
{
LLPrimitive prim = (LLPrimitive)script.Host;
if (prim.SitPosition != Vector3.Zero)
{
ILinkable[] children = ((ILinkable)script.Host).GetChildren();
for (int i = 0, len = children.Length; i < len; i++)
{
if (children[i] is LLAgent)
{
LLAgent childAgent = (LLAgent)children[i];
if (childAgent.RelativePosition == LLUtil.GetSitTarget(prim.SitPosition, childAgent.Scale))
return childAgent.ID.ToString();
}
}
}
}
else
{
// TODO: Warning
}
return UUID.Zero.ToString();
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:28,代码来源:Prims.cs
示例3: llGetAccel
public Vector3 llGetAccel(IScriptInstance script)
{
if (script.Host is IPhysical)
return ((IPhysical)script.Host).Acceleration;
else
return Vector3.Zero;
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:7,代码来源:Prims.cs
示例4: OffsetTexture
private void OffsetTexture(IScriptInstance script, LLPrimitive obj, float u, float v, int side)
{
int sides = GetNumberOfSides(obj);
if (side >= 0 && side < sides)
{
// Change one face
Primitive.TextureEntryFace face = obj.Prim.Textures.CreateFace((uint)side);
face.OffsetU = u;
face.OffsetV = v;
obj.Scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.Textures);
}
else if (side == LSLConstants.ALL_SIDES)
{
// Change all of the faces
for (uint i = 0; i < sides; i++)
{
Primitive.TextureEntryFace face = obj.Prim.Textures.GetFace(i);
if (face != null)
{
face.OffsetU = u;
face.OffsetV = v;
}
}
obj.Scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.Textures);
}
}
开发者ID:thoys,项目名称:simian,代码行数:28,代码来源:PrimParams.cs
示例5: llGetInventoryNumber
public int llGetInventoryNumber(IScriptInstance script, int type)
{
LLPrimitive prim = script.Host as LLPrimitive;
if (prim == null)
return 0;
AssetType assetType = (AssetType)type;
return prim.Inventory.FindAllItems(item => assetType == AssetType.Unknown || item.AssetType == assetType).Count;
}
开发者ID:thoys,项目名称:simian,代码行数:9,代码来源:Inventory.cs
示例6: llGetPermissions
public int llGetPermissions(IScriptInstance script)
{
if (script is LSLScriptInstance)
{
LSLScriptInstance lsl = (LSLScriptInstance)script;
return (int)lsl.Permissions;
}
return 0; // TODO: Warning message
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:10,代码来源:ScriptPermissions.cs
示例7: llGetPermissionsKey
public UUID llGetPermissionsKey(IScriptInstance script)
{
if (script is LSLScriptInstance)
{
LSLScriptInstance lsl = (LSLScriptInstance)script;
return lsl.PermissionsKey;
}
return UUID.Zero; // TODO: Warning message
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:10,代码来源:ScriptPermissions.cs
示例8: llGetSubString
public string llGetSubString(IScriptInstance script, string src, int start, int end)
{
if (start < 0)
start = src.Length + start;
if (end < 0)
end = src.Length + end;
// Conventional substring
if (start <= end)
{
// Implies both bounds are out-of-range.
if (end < 0 || start >= src.Length)
return String.Empty;
// If end is positive, then it directly corresponds to the length of the substring needed (plus one of course).
if (end >= src.Length)
end = src.Length - 1;
if (start < 0)
return src.Substring(0, end + 1);
// Both indices are positive
return src.Substring(start, (end + 1) - start);
}
// Inverted substring (end < start)
else
{
// Implies both indices are below the lower bound.
// In the inverted case, that means the entire string will be returned unchanged.
if (start < 0)
return src;
// If both indices are greater than the upper bound the result may seem initially counter intuitive.
if (end >= src.Length)
return src;
if (end < 0)
{
if (start < src.Length)
return src.Substring(start);
return String.Empty;
}
else
{
if (start < src.Length)
return src.Substring(0, end + 1) + src.Substring(start);
return src.Substring(0, end + 1);
}
}
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:54,代码来源:Strings.cs
示例9: llDumpList2String
public string llDumpList2String(IScriptInstance script, lsl_list src, string separator)
{
int len = src.Length;
string[] arr = new string[len];
for (int i = 0; i < len; i++)
arr[i] = src.Data[i].ToString();
return String.Join(separator, arr);
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:11,代码来源:Lists.cs
示例10: llAxes2Rot
public Quaternion llAxes2Rot(IScriptInstance script, Vector3 fwd, Vector3 left, Vector3 up)
{
float s;
float tr = fwd.X + left.Y + up.Z + 1.0f;
if (tr >= 1.0)
{
s = 0.5f / (float)Math.Sqrt(tr);
return new Quaternion(
(float)((left.Z - up.Y) * s),
(float)((up.X - fwd.Z) * s),
(float)((fwd.Y - left.X) * s),
(float)(0.25 / s));
}
else
{
float max = (left.Y > up.Z) ? left.Y : up.Z;
if (max < fwd.X)
{
s = (float)Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0f);
float x = s * 0.5f;
s = 0.5f / s;
return new Quaternion(
(float)x,
(float)((fwd.Y + left.X) * s),
(float)((up.X + fwd.Z) * s),
(float)((left.Z - up.Y) * s));
}
else if (max == left.Y)
{
s = (float)Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0);
float y = s * 0.5f;
s = 0.5f / s;
return new Quaternion(
(float)((fwd.Y + left.X) * s),
(float)y,
(float)((left.Z + up.Y) * s),
(float)((up.X - fwd.Z) * s));
}
else
{
s = (float)Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0);
float z = s * 0.5f;
s = 0.5f / s;
return new Quaternion(
(float)((up.X + fwd.Z) * s),
(float)((left.Z + up.Y) * s),
(float)z,
(float)((fwd.Y - left.X) * s));
}
}
}
开发者ID:thoys,项目名称:simian,代码行数:53,代码来源:Math.cs
示例11: llAxes2Rot
public Quaternion llAxes2Rot(IScriptInstance script, Vector3 fwd, Vector3 left, Vector3 up)
{
double s;
double tr = fwd.X + left.Y + up.Z + 1.0;
if (tr >= 1.0)
{
s = 0.5 / Math.Sqrt(tr);
return new lsl_rotation(
(left.Z - up.Y) * s,
(up.X - fwd.Z) * s,
(fwd.Y - left.X) * s,
0.25 / s);
}
else
{
double max = (left.Y > up.Z) ? left.Y : up.Z;
if (max < fwd.X)
{
s = Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0);
double x = s * 0.5;
s = 0.5 / s;
return new lsl_rotation(
x,
(fwd.Y + left.X) * s,
(up.X + fwd.Z) * s,
(left.Z - up.Y) * s);
}
else if (max == left.Y)
{
s = Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0);
double y = s * 0.5;
s = 0.5 / s;
return new lsl_rotation(
(fwd.Y + left.X) * s,
y,
(left.Z + up.Y) * s,
(up.X - fwd.Z) * s);
}
else
{
s = Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0);
double z = s * 0.5;
s = 0.5 / s;
return new lsl_rotation(
(up.X + fwd.Z) * s,
(left.Z + up.Y) * s,
z,
(fwd.Y - left.X) * s);
}
}
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:53,代码来源:Math.cs
示例12: llPreloadSound
public void llPreloadSound(IScriptInstance script, string sound)
{
UUID soundID = KeyOrName(script, sound, AssetType.Sound);
if (soundID == UUID.Zero)
{
script.Host.Scene.EntityChat(this, script.Host, 0f, "Cannot find sound " + sound, Int32.MaxValue, EntityChatType.Debug);
return;
}
if (m_sounds != null)
m_sounds.PreloadSound(script.Host, soundID, DEFAULT_SOUND_RADIUS);
script.AddSleepMS(1000);
}
开发者ID:thoys,项目名称:simian,代码行数:14,代码来源:Sound.cs
示例13: llBase64ToString
public string llBase64ToString(IScriptInstance script, string str)
{
try
{
Decoder utf8Decode = UTF8Encoding.UTF8.GetDecoder();
byte[] data = Convert.FromBase64String(str);
int charCount = utf8Decode.GetCharCount(data, 0, data.Length);
char[] chars = new char[charCount];
utf8Decode.GetChars(data, 0, data.Length, chars, 0);
return new String(chars);
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
}
开发者ID:thoys,项目名称:simian,代码行数:18,代码来源:Strings.cs
示例14: llRequestPermissions
public void llRequestPermissions(IScriptInstance script, UUID agentID, int perms)
{
if (script is LSLScriptInstance)
{
LSLScriptInstance lsl = (LSLScriptInstance)script;
if (agentID != lsl.PermissionsKey)
lsl.Permissions = ScriptPermission.None;
// TODO: Send script permission dialog to the user
//script.Host.Scene.RequestScriptPermissions(this, script.Host, agentID, perms);
// HACK: Automatically grant permissions and fire event, since we don't have a permission dialog yet
lsl.PermissionsKey = agentID;
lsl.Permissions = (ScriptPermission)perms;
m_lslScriptEngine.PostObjectEvent(script.Host.ID, "run_time_permissions", new object[] { perms }, new DetectParams[0]);
}
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:18,代码来源:ScriptPermissions.cs
示例15: llGetInventoryName
public string llGetInventoryName(IScriptInstance script, int type, int number)
{
LLPrimitive prim = script.Host as LLPrimitive;
if (prim == null)
return String.Empty;
AssetType assetType = (AssetType)type;
IList<LLInventoryTaskItem> items = prim.Inventory.FindAllItems(item => assetType == AssetType.Unknown || item.AssetType == assetType);
if (items.Count >= number)
return String.Empty;
SortedList<string, LLInventoryTaskItem> sortedItems = new SortedList<string, LLInventoryTaskItem>(items.Count);
for (int i = 0; i < items.Count; i++)
sortedItems.Add(items[i].Name, items[i]);
return sortedItems.Values[number].Name;
}
开发者ID:thoys,项目名称:simian,代码行数:18,代码来源:Inventory.cs
示例16: llDeleteSubString
public string llDeleteSubString(IScriptInstance script, string src, int start, int end)
{
if (start < 0)
start = src.Length + start;
if (end < 0)
end = src.Length + end;
if (start <= end)
{
if (end < 0 || start >= src.Length)
return src;
if (start < 0)
start = 0;
if (end >= src.Length)
end = src.Length - 1;
return src.Remove(start, end - start + 1);
}
else
{
if (start < 0 || end >= src.Length)
return String.Empty;
if (end > 0)
{
if (start < src.Length)
return src.Remove(start).Remove(0, end + 1);
else
return src.Remove(0, end + 1);
}
else
{
if (start < src.Length)
return src.Remove(start);
else
return src;
}
}
}
开发者ID:thoys,项目名称:simian,代码行数:42,代码来源:Strings.cs
示例17: llLoopSound
public void llLoopSound(IScriptInstance script, string sound, float volume)
{
LLPrimitive prim = script.Host as LLPrimitive;
if (prim == null)
return;
if (prim.Prim.Sound != UUID.Zero)
llStopSound(script);
UUID soundID = KeyOrName(script, sound, AssetType.Sound);
if (soundID != UUID.Zero)
{
prim.Prim.Sound = soundID;
prim.Prim.SoundGain = Utils.Clamp(volume, 0f, 1f);
prim.Prim.SoundFlags = SoundFlags.Loop;
prim.Prim.SoundRadius = DEFAULT_SOUND_RADIUS;
prim.Scene.EntityAddOrUpdate(this, prim, 0, (uint)LLUpdateFlags.Sound);
}
}
开发者ID:thoys,项目名称:simian,代码行数:20,代码来源:Sound.cs
示例18: llCSV2List
public object[] llCSV2List(IScriptInstance script, string csv)
{
List<object> result = new List<object>();
int parens = 0;
int start = 0;
int length = 0;
for (int i = 0; i < csv.Length; i++)
{
switch (csv[i])
{
case '<':
parens++;
length++;
break;
case '>':
if (parens > 0)
parens--;
length++;
break;
case ',':
if (parens == 0)
{
result.Add(csv.Substring(start, length).Trim());
start += length + 1;
length = 0;
}
else
{
length++;
}
break;
default:
length++;
break;
}
}
result.Add(csv.Substring(start, length).Trim());
return result.ToArray();
}
开发者ID:thoys,项目名称:simian,代码行数:41,代码来源:Lists.cs
示例19: llBase64ToString
public string llBase64ToString(IScriptInstance script, string str)
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
string result = String.Empty;
try
{
byte[] todecode_byte = Convert.FromBase64String(str);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
result = new String(decoded_char);
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
return result;
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:21,代码来源:Conversions.cs
示例20: llGround
public double llGround(IScriptInstance script, Vector3 offset)
{
Vector3 pos = script.Host.ScenePosition + offset;
// Clamp to valid position
pos.X = Utils.Clamp(pos.X, 0f, 255f);
pos.Y = Utils.Clamp(pos.Y, 0f, 255f);
//Get the slope normal. This gives us the equation of the plane tangent to the slope.
Vector3 normal = llGroundNormal(script, offset);
// Get the height for the integer coordinates from the Heightmap
float baseheight = (m_terrain != null)
? m_terrain.GetHeightmap()[(int)pos.Y * 256 + (int)pos.X]
: 0f;
// Calculate the difference between the actual coordinates and the integer coordinates
double xdiff = pos.X - Math.Floor(pos.X);
double ydiff = pos.Y - Math.Floor(pos.Y);
// Use the equation of the tangent plane to adjust the height to account for slope
return (((normal.X * xdiff) + (normal.Y * ydiff)) / (normal.Z * -1f)) + baseheight;
}
开发者ID:osgrid,项目名称:openmetaverse,代码行数:23,代码来源:World.cs
注:本文中的IScriptInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论