public override void PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContext context) { if (cleanOld) { obj.PrePositionChange(context); } if (!obj.GhostImage) { HandObject = obj; CarryAnimationState = new VMAnimationState(FSO.Content.Content.Get().AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); //set default carry animation obj.Container = this; obj.ContainerSlot = (short)slot; } if (UseWorld) { obj.WorldUI.Container = this.WorldUI; obj.WorldUI.ContainerSlot = slot; if (obj.WorldUI is ObjectComponent) { var objC = (ObjectComponent)obj.WorldUI; objC.ForceDynamic = true; } } obj.Position = Position; //TODO: is physical position the same as the slot offset position? if (cleanOld) { obj.PositionChange(context, false); } }
public override void Update(UpdateState state) { base.Update(state); lock (AnimationRequests) { while (TargetTile != null && AnimationRequests.Count > 0) { var anim = AnimationRequests.Dequeue(); var animation = Content.GameContent.Get.AvatarAnimations.Get(anim + ".anim"); if (animation != null) { var astate = new VMAnimationState(animation, false) { Speed = 30 / 25f, Loop = true }; ((VMAvatar)TargetTile).Animations.Clear(); ((VMAvatar)TargetTile).Animations.Add(astate); } } } state.SharedData["ExternalDraw"] = true; Invalidate(); }
public virtual void Load(VMAvatarMarshal input) { base.Load(input); Animations = new List <VMAnimationState>(); foreach (var anim in input.Animations) { Animations.Add(new VMAnimationState(anim)); } CarryAnimationState = (input.CarryAnimationState == null) ? null : new VMAnimationState(input.CarryAnimationState); Message = input.Message; MessageTimeout = input.MessageTimeout; MotiveChanges = input.MotiveChanges; MotiveDecay = input.MotiveDecay; PersonData = input.PersonData; MotiveData = input.MotiveData; RadianDirection = input.RadianDirection; KillTimeout = input.KillTimeout; DefaultSuits = input.DefaultSuits; BoundAppearances = new HashSet <string>(input.BoundAppearances); foreach (var aprN in BoundAppearances) { var apr = FSO.Content.Content.Get().AvatarAppearances.Get(aprN); if (apr != null) { Avatar.AddAccessory(apr); } } SkinTone = input.SkinTone; if (UseWorld) { WorldUI.ObjectID = ObjectID; } }
public override void ClearSlot(int slot) { HandObject.Container = null; HandObject.ContainerSlot = -1; CarryAnimationState = null; if (UseWorld) { HandObject.WorldUI.Container = null; HandObject.WorldUI.ContainerSlot = 0; if (HandObject.WorldUI is ObjectComponent) { var objC = (ObjectComponent)HandObject.WorldUI; objC.ForceDynamic = false; } } HandObject = null; }
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args) { var operand = (VMAnimateSimOperand)args; var avatar = (VMAvatar)context.Caller; Animation animation = null; var id = (operand.IDFromParam) ? (ushort)(context.Args[operand.AnimationID]) : operand.AnimationID; var newMode = true; // (context.VM.Tuning?.GetTuning("feature", 0, 0) ?? 0) != 0; //might need to disable this suddenly - too many things to test if (id == 0) { //reset avatar.Animations.Clear(); var posture = avatar.GetPersonData(VMPersonDataVariable.Posture); if (posture != 1 && posture != 2) { posture = 3; //sit and kneel are 1 and 2, 0 is stand but in walk animations it's 3. } //todo: swimming?? animation = GameContent.Get.AvatarAnimations.Get(avatar.WalkAnimations[posture] + ".anim"); if (animation == null) { return(VMPrimitiveExitCode.GOTO_TRUE); } var state = new VMAnimationState(animation, operand.PlayBackwards); if (context.VM.TS1 || newMode) { state.Speed = 30 / 25f; } state.Loop = true; avatar.Animations.Add(state); avatar.Avatar.LeftHandGesture = SimHandGesture.Idle; avatar.Avatar.RightHandGesture = SimHandGesture.Idle; if (avatar.GetSlot(0) != null) //if we're carrying something, set carry animation to default carry. { if (avatar.CarryAnimationState == null) { avatar.CarryAnimationState = new VMAnimationState(GameContent.Get.AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); } } else { avatar.CarryAnimationState = null; } return(VMPrimitiveExitCode.GOTO_TRUE); } var source = operand.Source; if (operand.IDFromParam && source == VMAnimationScope.Object) { source = VMAnimationScope.StackObject; //fixes MM rollercoaster } if (!operand.IDFromParam) { var owner = (source == VMAnimationScope.Object) ? context.CodeOwner : ((source == VMAnimationScope.StackObject)? context.StackObject.Object : operand.AnimationSource); if (operand.AnimationCache == null || owner != operand.AnimationSource) { operand.AnimationSource = owner; operand.AnimationCache = VMMemory.GetAnimation(context, source, id); } animation = operand.AnimationCache; } else { animation = VMMemory.GetAnimation(context, source, id); } if (animation == null) { return(VMPrimitiveExitCode.GOTO_TRUE_NEXT_TICK); } switch (operand.Mode) { case 1: avatar.Animations.Clear(); var state = new VMAnimationState(animation, operand.PlayBackwards); if (context.VM.TS1 || newMode) { state.Speed = 30 / 25f; } if (avatar.GetValue(VMStackObjectVariable.WalkStyle) == 1 && operand.Hurryable) { state.Speed *= 2; } state.Loop = true; avatar.Animations.Add(state); avatar.Avatar.LeftHandGesture = SimHandGesture.Idle; avatar.Avatar.RightHandGesture = SimHandGesture.Idle; return(VMPrimitiveExitCode.GOTO_TRUE); case 3: avatar.CarryAnimationState = null; goto case 0; case 0: /** Are we starting the animation or progressing it? **/ if (avatar.CurrentAnimationState == null || avatar.CurrentAnimationState.Anim != animation) { /** Start it **/ avatar.Animations.Clear(); var astate = new VMAnimationState(animation, operand.PlayBackwards); if (context.VM.TS1 || newMode) { astate.Speed = 30 / 25f; } if (avatar.GetValue(VMStackObjectVariable.WalkStyle) == 1 && operand.Hurryable) { astate.Speed *= 2; } avatar.Animations.Add(astate); avatar.Avatar.LeftHandGesture = SimHandGesture.Idle; avatar.Avatar.RightHandGesture = SimHandGesture.Idle; return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } else { var cAnim = avatar.CurrentAnimationState; //SPECIAL CASE: if we are ending the animation, and the number of events run < expected events //forcefully run those events, with id as their event number. (required for bath drain) if (cAnim.EndReached) { while (cAnim.EventsRun < operand.ExpectedEventCount) { cAnim.EventQueue.Add(cAnim.EventsRun++); } } if (cAnim.EventQueue.Count > 0) //favor events over end. do not want to miss any. { var code = cAnim.EventQueue[0]; cAnim.EventQueue.RemoveAt(0); if (operand.StoreFrameInLocal) { VMMemory.SetVariable(context, VMVariableScope.Local, operand.LocalEventNumber, code); } else { VMMemory.SetVariable(context, VMVariableScope.Parameters, 0, code); } return(VMPrimitiveExitCode.GOTO_FALSE); } else if (cAnim.EndReached) { avatar.Animations.Clear(); return(VMPrimitiveExitCode.GOTO_TRUE); } else { return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } } case 2: avatar.CarryAnimationState = new VMAnimationState(animation, false); return(VMPrimitiveExitCode.GOTO_TRUE); } return(VMPrimitiveExitCode.GOTO_TRUE); }
public virtual void Load(VMAvatarMarshal input) { base.Load(input); Animations = new List <VMAnimationState>(); foreach (var anim in input.Animations) { Animations.Add(new VMAnimationState(anim)); } CarryAnimationState = (input.CarryAnimationState == null) ? null : new VMAnimationState(input.CarryAnimationState); Message = input.Message; MessageTimeout = input.MessageTimeout; MotiveChanges = input.MotiveChanges; MotiveDecay = input.MotiveDecay; PersonData = input.PersonData; MotiveData = input.MotiveData; RadianDirection = input.RadianDirection; KillTimeout = input.KillTimeout; DefaultSuits = input.DefaultSuits; DynamicSuits = input.DynamicSuits; Decoration = input.Decoration; BoundAppearances = new HashSet <string>(input.BoundAppearances); if (VM.UseWorld) { foreach (var aprN in BoundAppearances) { var apr = FSO.Content.Content.Get().AvatarAppearances.Get(aprN); if (apr != null) { Avatar.AddAccessory(apr); } } var oftProvider = Content.Content.Get().AvatarOutfits; if (Decoration.Back != 0) { Avatar.DecorationBack = oftProvider.Get(Decoration.Back); } if (Decoration.Head != 0) { Avatar.DecorationHead = oftProvider.Get(Decoration.Head); } if (Decoration.Tail != 0) { Avatar.DecorationTail = oftProvider.Get(Decoration.Tail); } if (Decoration.Shoes != 0) { Avatar.DecorationShoes = oftProvider.Get(Decoration.Shoes); } } SkinTone = input.SkinTone; if (UseWorld) { WorldUI.ObjectID = ObjectID; } }
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args) { var operand = (VMAnimateSimOperand)args; var avatar = (VMAvatar)context.Caller; Animation animation = null; var id = (operand.IDFromParam) ? (ushort)(context.Args[operand.AnimationID]) : operand.AnimationID; if (id == 0) { //reset avatar.Animations.Clear(); var posture = avatar.GetPersonData(VMPersonDataVariable.Posture); if (posture != 1 && posture != 2) { posture = 3; //sit and kneel are 1 and 2, 0 is stand but in walk animations it's 3. } //todo: swimming?? animation = FSO.Content.Content.Get().AvatarAnimations.Get(avatar.WalkAnimations[posture] + ".anim"); var state = new VMAnimationState(animation, operand.PlayBackwards); state.Loop = true; avatar.Animations.Add(state); if (avatar.GetSlot(0) != null) //if we're carrying something, set carry animation to default carry. { if (avatar.CarryAnimationState == null) { avatar.CarryAnimationState = new VMAnimationState(FSO.Content.Content.Get().AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); } } else { avatar.CarryAnimationState = null; } return(VMPrimitiveExitCode.GOTO_TRUE); } var source = operand.Source; if (operand.IDFromParam && source == VMAnimationScope.Object) { source = VMAnimationScope.StackObject; //fixes MM rollercoaster } animation = VMMemory.GetAnimation(context, source, id); if (animation == null) { return(VMPrimitiveExitCode.GOTO_TRUE); } if (operand.Mode == 3) //stop standard carry, then play and wait { avatar.CarryAnimationState = null; } if (operand.Mode == 0 || operand.Mode == 3) //Play and Wait { /** Are we starting the animation or progressing it? **/ if (avatar.CurrentAnimationState == null || avatar.CurrentAnimationState.Anim != animation) { /** Start it **/ avatar.Animations.Clear(); avatar.Animations.Add(new VMAnimationState(animation, operand.PlayBackwards)); avatar.Avatar.LeftHandGesture = SimHandGesture.Idle; avatar.Avatar.RightHandGesture = SimHandGesture.Idle; return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } else { var cAnim = avatar.CurrentAnimationState; //SPECIAL CASE: if we are ending the animation, and the number of events run < expected events //forcefully run those events, with id as their event number. (required for bath drain) if (cAnim.EndReached) { while (cAnim.EventsRun < operand.ExpectedEventCount) { cAnim.EventQueue.Add(cAnim.EventsRun++); } } if (cAnim.EventQueue.Count > 0) //favor events over end. do not want to miss any. { var code = cAnim.EventQueue[0]; cAnim.EventQueue.RemoveAt(0); if (operand.StoreFrameInLocal) { VMMemory.SetVariable(context, VMVariableScope.Local, operand.LocalEventNumber, code); } else { VMMemory.SetVariable(context, VMVariableScope.Parameters, 0, code); } return(VMPrimitiveExitCode.GOTO_FALSE); } else if (cAnim.EndReached) { avatar.Animations.Clear(); return(VMPrimitiveExitCode.GOTO_TRUE); } else { return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } } } else if (operand.Mode == 2) //set custom carry animation { avatar.CarryAnimationState = new VMAnimationState(animation, false); return(VMPrimitiveExitCode.GOTO_TRUE); } else { return(VMPrimitiveExitCode.GOTO_TRUE); } }
public override void Update(UpdateState state) { base.Update(state); lock (AnimationRequests) { while (TargetTile != null && AnimationRequests.Count > 0) { var ava = ((VMAvatar)TargetTile); var anim = AnimationRequests.Dequeue(); var skels = FSO.Content.Content.Get().AvatarSkeletons; var ofts = FSO.Content.Content.Get().AvatarOutfits; if (anim.Length == 0) { continue; } if (LastType != anim[0]) { ava.Avatar.Head = null; ava.Avatar.Handgroup = null; switch (anim[0]) { case 'a': ava.Avatar.Skeleton = skels.Get("adult.skel"); ava.Avatar.Head = FSO.Content.Content.Get().AvatarOutfits.Get(0x000003a00000000D); ava.Avatar.Body = ofts.Get("mab002_slob.oft"); ava.Avatar.Handgroup = ava.Avatar.Body; break; case 'c': ava.Avatar.Skeleton = skels.Get("child.skel"); break; case 'd': ava.Avatar.Skeleton = skels.Get("dog.skel"); ava.Avatar.Body = ofts.Get("uaa012dog_scottish.oft"); break; case 'k': ava.Avatar.Skeleton = skels.Get("cat.skel"); ava.Avatar.Body = ofts.Get("uaa002cat_calico.oft"); break; } ava.Avatar.Skeleton = ava.Avatar.Skeleton.Clone(); ava.Avatar.BaseSkeleton = ava.Avatar.Skeleton; LastType = anim[0]; } var animation = FSO.Content.Content.Get().AvatarAnimations.Get(anim + ".anim"); if (animation != null) { var astate = new VMAnimationState(animation, false); astate.Speed = 30 / 25f; astate.Loop = true; ava.Animations.Clear(); ava.Animations.Add(astate); } } } state.SharedData["ExternalDraw"] = true; Invalidate(); }
public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args) { var operand = (VMAnimateSimOperand)args; var avatar = (VMAvatar)context.Caller; Animation animation = null; if (operand.AnimationID == 0) { //reset avatar.Animations.Clear(); var posture = avatar.GetPersonData(VMPersonDataVariable.Posture); if (posture != 1 && posture != 2) { posture = 3; //sit and kneel are 1 and 2, 0 is stand but in walk animations it's 3. } //todo: swimming?? animation = FSO.Content.Content.Get().AvatarAnimations.Get(avatar.WalkAnimations[posture] + ".anim"); var state = new VMAnimationState(animation, operand.PlayBackwards); state.Loop = true; avatar.Animations.Add(state); if (avatar.GetSlot(0) != null) //if we're carrying something, set carry animation to default carry. { avatar.CarryAnimationState = new VMAnimationState(FSO.Content.Content.Get().AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); } else { avatar.CarryAnimationState = null; } return(VMPrimitiveExitCode.GOTO_TRUE); } animation = VMMemory.GetAnimation(context, operand.Source, operand.AnimationID); if (animation == null) { return(VMPrimitiveExitCode.GOTO_TRUE); } if (operand.Mode == 3) //stop standard carry, then play and wait { avatar.CarryAnimationState = null; } if (operand.Mode == 0 || operand.Mode == 3) //Play and Wait { /** Are we starting the animation or progressing it? **/ if (avatar.CurrentAnimationState == null || avatar.CurrentAnimationState.Anim != animation) { /** Start it **/ avatar.Animations.Clear(); avatar.Animations.Add(new VMAnimationState(animation, operand.PlayBackwards)); avatar.Avatar.LeftHandGesture = SimHandGesture.Idle; avatar.Avatar.RightHandGesture = SimHandGesture.Idle; return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } else { if (avatar.CurrentAnimationState.EndReached) { avatar.Animations.Clear(); return(VMPrimitiveExitCode.GOTO_TRUE); } else if (avatar.CurrentAnimationState.EventFired) { avatar.CurrentAnimationState.EventFired = false; //clear fired flag if (operand.StoreFrameInLocal) { VMMemory.SetVariable(context, VMVariableScope.Local, operand.LocalEventNumber, avatar.CurrentAnimationState.EventCode); } else { VMMemory.SetVariable(context, VMVariableScope.Parameters, 0, avatar.CurrentAnimationState.EventCode); } return(VMPrimitiveExitCode.GOTO_FALSE); } else { return(VMPrimitiveExitCode.CONTINUE_NEXT_TICK); } } } else if (operand.Mode == 2) //set custom carry animation { avatar.CarryAnimationState = new VMAnimationState(animation, false); return(VMPrimitiveExitCode.GOTO_TRUE); } else { return(VMPrimitiveExitCode.GOTO_TRUE); } }
public override void Update(UpdateState state) { base.Update(state); lock (AnimationRequests) { while (TargetTile != null && AnimationRequests.Count > 0) { var ava = ((VMAvatar)TargetTile); var request = AnimationRequests.Dequeue(); switch (request.Type) { case UIAvatarAnimatorRequestType.Animation: var anim = request.Obj as string; var skels = FSO.Content.Content.Get().AvatarSkeletons; var ofts = FSO.Content.Content.Get().AvatarOutfits; if (anim.Length == 0) { continue; } if (LastType != anim[0]) { ava.Avatar.Head = null; ava.Avatar.Handgroup = null; switch (anim[0]) { case 'a': ava.Avatar.Skeleton = skels.Get("adult.skel").Clone(); ava.Avatar.Head = FSO.Content.Content.Get().AvatarOutfits.Get(0x000003a00000000D); ava.Avatar.Body = ofts.Get("mab002_slob.oft"); ava.Avatar.Handgroup = ava.Avatar.Body; break; case 'c': ava.Avatar.Skeleton = skels.Get("child.skel").Clone(); break; case 'd': ava.Avatar.Skeleton = skels.Get("dog.skel").Clone(); ava.Avatar.Body = ofts.Get("uaa012dog_scottish.oft"); break; case 'k': ava.Avatar.Skeleton = skels.Get("cat.skel").Clone(); ava.Avatar.Body = ofts.Get("uaa002cat_calico.oft"); break; } ava.Avatar.Skeleton = ava.Avatar.Skeleton.Clone(); ava.Avatar.BaseSkeleton = ava.Avatar.Skeleton; LastType = anim[0]; } var animation = FSO.Content.Content.Get().AvatarAnimations.Get(anim + ".anim"); if (animation != null) { var astate = new VMAnimationState(animation, false); astate.Speed = 30 / 25f; astate.Loop = true; ava.Animations.Clear(); ava.Animations.Add(astate); } break; case UIAvatarAnimatorRequestType.Outfit: var tuple = request.Obj as Tuple <VMPersonSuits, Outfit>; var oft = tuple.Item2; switch (tuple.Item1) { case VMPersonSuits.DefaultDaywear: ava.Avatar.Body = oft; ava.Avatar.Handgroup = oft; break; case VMPersonSuits.Head: ava.Avatar.Head = oft; break; case VMPersonSuits.DecorationBack: if (ava.Avatar.DecorationBack == oft) { oft = null; } ava.Avatar.DecorationBack = oft; break; case VMPersonSuits.DecorationHead: if (ava.Avatar.DecorationHead == oft) { oft = null; } ava.Avatar.DecorationHead = oft; break; case VMPersonSuits.DecorationTail: if (ava.Avatar.DecorationTail == oft) { oft = null; } ava.Avatar.DecorationTail = oft; break; case VMPersonSuits.DecorationShoes: if (ava.Avatar.DecorationShoes == oft) { oft = null; } ava.Avatar.DecorationShoes = oft; break; } break; case UIAvatarAnimatorRequestType.AddAccessory: { var dress = request.Obj as String + ".apr"; var apr = FSO.Content.Content.Get().AvatarAppearances.Get(dress); ava.BoundAppearances.Add(dress); ava.Avatar.AddAccessory(apr); break; } case UIAvatarAnimatorRequestType.RemoveAccessory: { var undress = request.Obj as String + ".apr"; var apr = FSO.Content.Content.Get().AvatarAppearances.Get(undress); ava.BoundAppearances.Remove(undress); ava.Avatar.RemoveAccessory(apr); break; } case UIAvatarAnimatorRequestType.ClearAccessories: foreach (var aprN in ava.BoundAppearances) { var apr = FSO.Content.Content.Get().AvatarAppearances.Get(aprN); if (apr != null) { ava.Avatar.RemoveAccessory(apr); } } break; } } } state.SharedData["ExternalDraw"] = true; Invalidate(); }