本文整理汇总了C#中VMStackFrame类的典型用法代码示例。如果您正苦于以下问题:C# VMStackFrame类的具体用法?C# VMStackFrame怎么用?C# VMStackFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VMStackFrame类属于命名空间,在下文中一共展示了VMStackFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeBHAVCommand
public ChangeBHAVCommand(BHAV target, EditorScope scope, VMStackFrame frame, BHAVPrimSelect callback)
{
Target = target;
TargetScope = scope;
Frame = frame;
SelectCallback = callback;
}
示例2: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMGotoRelativePositionOperand>();
var obj = (VMGameObject)context.Callee;
var avatar = (VMAvatar)context.Caller;
/**
* Examples for reference
* Fridge - Have Snack - In front of, facing
*/
if (operand.Location == VMGotoRelativeLocation.InFrontOf){
/** Need to work out which side is in front? **/
//TODO: My positions are wrong, what i call left front etc is wrong. Need to correct this eventually
var location = obj.Position;
switch(obj.Direction){
case tso.world.model.Direction.LeftFront:
location += new Vector3(0.0f, 1.0f, 0.0f);
break;
case tso.world.model.Direction.LeftBack:
location += new Vector3(-1.0f, 0.0f, 0.0f);
break;
case tso.world.model.Direction.RightFront:
location += new Vector3(1.0f, 0.0f, 0.0f);
break;
case tso.world.model.Direction.RightBack:
location += new Vector3(0.0f, -1.0f, 0.0f);
break;
}
avatar.Position = location + new Vector3(0.5f, 0.5f, 0.0f);
return VMPrimitiveExitCode.GOTO_TRUE_NEXT_TICK;
}
throw new Exception("Unknown goto relative");
}
示例3: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMGenericTSOCallOperand>();
if (
operand.Call == VMGenericTSOCallMode.GetIsPendingDeletion ||
operand.Call == VMGenericTSOCallMode.IsTemp0AvatarIgnoringTemp1Avatar ||
operand.Call == VMGenericTSOCallMode.IsGlobalBroken
) return VMPrimitiveExitCode.GOTO_FALSE;
else if (operand.Call == VMGenericTSOCallMode.SwapMyAndStackObjectsSlots)
{
int total = Math.Min(context.StackObject.TotalSlots(), context.Caller.TotalSlots());
for (int i = 0; i < total; i++)
{
VMEntity temp1 = context.Caller.GetSlot(i);
VMEntity temp2 = context.StackObject.GetSlot(i);
context.Caller.ClearSlot(i);
context.StackObject.ClearSlot(i);
context.Caller.PlaceInSlot(temp2, i);
context.StackObject.PlaceInSlot(temp1, i);
}
}
else if (operand.Call == VMGenericTSOCallMode.TestStackObject) return (context.StackObject != null) ? VMPrimitiveExitCode.GOTO_TRUE : VMPrimitiveExitCode.GOTO_FALSE;
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例4: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMPlaySoundOperand>();
FWAV fwav = context.CodeOwner.Get<FWAV>(operand.EventID);
if (fwav == null) fwav = context.VM.Context.Globals.Resource.Get<FWAV>(operand.EventID);
if (fwav != null)
{
var thread = HITVM.Get().PlaySoundEvent(fwav.Name);
if (thread != null)
{
var owner = (operand.StackObjAsSource)?context.StackObject:context.Caller;
if (!thread.AlreadyOwns(owner.ObjectID)) thread.AddOwner(owner.ObjectID);
var entry = new VMSoundEntry()
{
Thread = thread,
Pan = !operand.NoPan,
Zoom = !operand.NoZoom,
Loop = operand.Loop,
Name = fwav.Name
};
owner.SoundThreads.Add(entry);
owner.TickSounds();
}
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例5: Execute
//TODO: Behaviour for being notified out of idle and interaction canceling
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMIdleForInputOperand)args;
if (operand.AllowPush == 1 && context.Thread.Queue.Count > 1)
{ //if there are any more interactions, we have been interrupted
return VMPrimitiveExitCode.INTERRUPT;
}
if (context.Thread.Queue[0].Cancelled)
{
context.Caller.SetFlag(VMEntityFlags.NotifiedByIdleForInput, true);
return VMPrimitiveExitCode.GOTO_TRUE;
}
if (context.Thread.Interrupt)
{
context.Thread.Interrupt = false;
return VMPrimitiveExitCode.GOTO_TRUE;
}
var ticks = VMMemory.GetVariable(context, FSO.SimAntics.Engine.Scopes.VMVariableScope.Parameters, operand.StackVarToDec);
ticks--;
if (ticks < 0)
{
return VMPrimitiveExitCode.GOTO_TRUE;
}
else
{
VMMemory.SetVariable(context, FSO.SimAntics.Engine.Scopes.VMVariableScope.Parameters, operand.StackVarToDec, ticks);
return VMPrimitiveExitCode.CONTINUE_NEXT_TICK;
}
}
示例6: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMChangeSuitOrAccessoryOperand>();
var avatar = (VMAvatar)context.Caller;
if ((operand.Flags & VMChangeSuitOrAccessoryFlags.Update) == VMChangeSuitOrAccessoryFlags.Update)
{ //update outfit with outfit in stringset 304 with index in temp 0
avatar.BodyOutfit = Convert.ToUInt64(context.Callee.Object.Resource.Get<STR>(304).GetString((context.Thread.TempRegisters[0])), 16);
}
else
{
var suit = VMMemory.GetSuit(context, operand.SuitScope, operand.SuitData);
if(suit == null){
return VMPrimitiveExitCode.GOTO_TRUE;
}
if ((operand.Flags & VMChangeSuitOrAccessoryFlags.Remove) == VMChangeSuitOrAccessoryFlags.Remove)
{
avatar.Avatar.RemoveAccessory(suit);
}
else
{
avatar.Avatar.AddAccessory(suit);
}
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例7: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMRefreshOperand)args;
VMEntity target = null;
switch (operand.TargetObject)
{
case 0:
target = context.Caller;
break;
case 1:
target = context.StackObject;
break;
}
switch (operand.RefreshType)
{
case 0: //graphic
if (target is VMGameObject)
{
var TargObj = (VMGameObject)target;
TargObj.RefreshGraphic();
}
break;
case 1:
context.VM.Context.RefreshLighting(context.VM.Context.GetObjectRoom(target), true);
if (target is VMGameObject) ((VMGameObject)target).RefreshLight();
break;
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例8: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMSetBalloonHeadlineOperand)args;
var obj = (operand.OfStackOBJ) ? context.StackObject : context.Caller;
if (obj.HeadlineRenderer != null) obj.HeadlineRenderer.Dispose();
if (operand.Index == -1 || operand.Duration == 0)
{
obj.Headline = null;
obj.HeadlineRenderer = null;
}
else
{
VMEntity icon = null;
int index = operand.Index;
if (operand.Group == VMSetBalloonHeadlineOperandGroup.Algorithmic)
icon = (index < 2) ? context.StackObject : context.VM.GetObjectById(context.Locals[operand.Algorithmic]);
else if (operand.Indexed)
index += context.Thread.TempRegisters[0];
obj.Headline = new VMRuntimeHeadline(operand, obj, icon, (sbyte)index);
obj.HeadlineRenderer = context.VM.Headline.Get(obj.Headline);
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例9: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMLookTowardsOperand>();
//TODO: primitive fails if object calls it
VMAvatar sim = (VMAvatar)context.Caller;
var result = new VMFindLocationResult();
result.Position = new LotTilePos(sim.Position);
switch (operand.Mode)
{
case VMLookTowardsMode.HeadTowardsObject:
return VMPrimitiveExitCode.GOTO_TRUE; //TODO: turning head towards things, with head seek timeout
case VMLookTowardsMode.BodyTowardsCamera:
return VMPrimitiveExitCode.GOTO_TRUE; //does not work in TSO
case VMLookTowardsMode.BodyTowardsStackObj:
result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
result.Flags = RadianToFlags(result.RadianDirection);
break;
case VMLookTowardsMode.BodyAwayFromStackObj:
result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
result.RadianDirection = (float)((result.RadianDirection + Math.PI) % (Math.PI*2));
result.Flags = RadianToFlags(result.RadianDirection);
break;
}
var pathFinder = context.Thread.PushNewPathFinder(context, new List<VMFindLocationResult>() { result });
if (pathFinder != null) return VMPrimitiveExitCode.CONTINUE;
else return VMPrimitiveExitCode.GOTO_TRUE;
}
示例10: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMRunTreeByNameOperand>();
string name;
if (operand.StringScope == 1)
{//global
name = context.Global.Resource.Get<STR>(operand.StringTable).GetString(operand.StringID-1);
}
else
{//local
name = context.CodeOwner.Get<STR>(operand.StringTable).GetString(operand.StringID-1);
}
if (context.Callee.TreeByName.ContainsKey(name))
{
var tree = context.Callee.TreeByName[name];
//found it! now lets call the tree ;)
}
else
{
return VMPrimitiveExitCode.GOTO_FALSE;
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例11: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
if (!VM.UseWorld) return VMPrimitiveExitCode.GOTO_TRUE;
var operand = (VMPlaySoundOperand)args;
FWAV fwav = context.ScopeResource.Get<FWAV>(operand.EventID);
if (fwav == null) fwav = context.VM.Context.Globals.Resource.Get<FWAV>(operand.EventID);
var owner = (operand.StackObjAsSource) ? context.StackObject : context.Caller;
if (fwav != null && owner.SoundThreads.FirstOrDefault(x => x.Name == fwav.Name) == null)
{
var thread = HITVM.Get().PlaySoundEvent(fwav.Name);
if (thread != null)
{
if (owner == null) return VMPrimitiveExitCode.GOTO_TRUE;
if (!thread.AlreadyOwns(owner.ObjectID)) thread.AddOwner(owner.ObjectID);
if (owner is VMAvatar && thread is HITThread) ((VMAvatar)owner).SubmitHITVars((HITThread)thread);
var entry = new VMSoundEntry()
{
Sound = thread,
Pan = !operand.NoPan,
Zoom = !operand.NoZoom,
Loop = operand.Loop,
Name = fwav.Name
};
owner.SoundThreads.Add(entry);
if (owner.Thread != null) owner.TickSounds();
}
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例12: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMGotoRelativePositionOperand)args;
var obj = context.StackObject;
var avatar = (VMAvatar)context.Caller;
if (obj.Position == LotTilePos.OUT_OF_WORLD) return VMPrimitiveExitCode.GOTO_FALSE;
var slot = new SLOTItem { Type = 3, Standing = 1 };
if (operand.Location != VMGotoRelativeLocation.OnTopOf) { //default slot is on top of
slot.MinProximity = 16;
slot.MaxProximity = 24;
if (operand.Location == VMGotoRelativeLocation.AnywhereNear) slot.Rsflags |= (SLOTFlags)255;
else slot.Rsflags |= (SLOTFlags)(1 << (((int)operand.Location) % 8));
}
if (operand.Direction == VMGotoRelativeDirection.AnyDirection) slot.Facing = SLOTFacing.FaceAnywhere; //TODO: verify. not sure where this came from?
else slot.Facing = (SLOTFacing)operand.Direction;
var pathFinder = context.Thread.PushNewRoutingFrame(context, !operand.NoFailureTrees);
var success = pathFinder.InitRoutes(slot, context.StackObject);
return VMPrimitiveExitCode.CONTINUE;
}
示例13: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context)
{
var operand = context.GetCurrentOperand<VMRefreshOperand>();
VMEntity target = null;
switch (operand.TargetObject)
{
case 0:
target = context.Caller;
break;
case 1:
target = context.StackObject;
break;
}
switch (operand.RefreshType)
{
case 0: //graphic
if (target.GetType() == typeof(VMGameObject))
{
var TargObj = (VMGameObject)target;
TargObj.RefreshGraphic();
}
break;
}
return VMPrimitiveExitCode.GOTO_TRUE;
}
示例14: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMLookTowardsOperand)args;
//TODO: primitive fails if object calls it
VMAvatar sim = (VMAvatar)context.Caller;
var result = new VMFindLocationResult();
result.Position = new LotTilePos(sim.Position);
switch (operand.Mode)
{
case VMLookTowardsMode.HeadTowardsObject:
return VMPrimitiveExitCode.GOTO_TRUE; //TODO: turning head towards things, with head seek timeout
case VMLookTowardsMode.BodyTowardsCamera:
return VMPrimitiveExitCode.GOTO_TRUE; //does not work in TSO
case VMLookTowardsMode.BodyTowardsStackObj:
result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
break;
case VMLookTowardsMode.BodyAwayFromStackObj:
result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
result.RadianDirection = (float)((result.RadianDirection + Math.PI) % (Math.PI*2));
break;
}
var pathFinder = context.Thread.PushNewRoutingFrame(context, false); //use the path finder to do the turn animation.
pathFinder.InitRoutes(new List<VMFindLocationResult>() { result });
return VMPrimitiveExitCode.CONTINUE;
}
示例15: Execute
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
{
var operand = (VMSetMotiveChangeOperand)args;
var avatar = ((VMAvatar)context.Caller);
if (operand.Once) { }
if (operand.ClearAll)
{
avatar.ClearMotiveChanges();
}
else
{
var rate = VMMemory.GetVariable(context, (VMVariableScope)operand.DeltaOwner, operand.DeltaData);
var MaxValue = VMMemory.GetVariable(context, (VMVariableScope)operand.MaxOwner, operand.MaxData);
if (operand.Once) {
var motive = avatar.GetMotiveData(operand.Motive);
if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue))) { return VMPrimitiveExitCode.GOTO_TRUE; }
// ^ we're already over, do nothing. (do NOT clamp)
motive += rate;
if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue))) { motive = MaxValue; }
avatar.SetMotiveData(operand.Motive, motive);
}
else avatar.SetMotiveChange(operand.Motive, rate, MaxValue);
}
return VMPrimitiveExitCode.GOTO_TRUE;
}