private void HandleTimePropsEvent(TimePropertyListItem tp) { VMAvatar avatar = this; var evt = tp.Properties["xevt"]; if (evt != null) { var eventValue = short.Parse(evt); avatar.CurrentAnimationState.EventCode = eventValue; avatar.CurrentAnimationState.EventFired = true; } var rhevt = tp.Properties["righthand"]; if (rhevt != null) { var eventValue = short.Parse(rhevt); avatar.Avatar.RightHandGesture = (SimHandGesture)eventValue; } var lhevt = tp.Properties["lefthand"]; if (lhevt != null) { var eventValue = short.Parse(lhevt); avatar.Avatar.LeftHandGesture = (SimHandGesture)eventValue; } var soundevt = tp.Properties["sound"]; if (soundevt != null) { var thread = TSO.HIT.HITVM.Get().PlaySoundEvent(soundevt); if (thread != null) { var owner = this; if (!thread.AlreadyOwns(owner.ObjectID)) { thread.AddOwner(owner.ObjectID); } var entry = new VMSoundEntry() { Thread = thread, Pan = true, Zoom = true, }; owner.SoundThreads.Add(entry); owner.TickSounds(); } } }
public VMMultitileGroup CreateObjectInstance(UInt32 GUID, LotTilePos pos, Direction direction, short MainStackOBJ, short MainParam) { VMMultitileGroup group = new VMMultitileGroup(); var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID); if (objDefinition == null) { return null; } var master = objDefinition.OBJ.MasterID; if (master != 0) { group.MultiTile = true; var objd = objDefinition.Resource.List<OBJD>(); for (int i = 0; i < objd.Count; i++) { if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it! { var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID); if (subObjDefinition != null) { var worldObject = new ObjectComponent(subObjDefinition); var vmObject = new VMGameObject(subObjDefinition, worldObject); vmObject.MasterDefinition = objDefinition.OBJ; vmObject.UseTreeTableOf(objDefinition); vmObject.MainParam = MainParam; vmObject.MainStackOBJ = MainStackOBJ; group.Objects.Add(vmObject); vmObject.MultitileGroup = group; VM.AddEntity(vmObject); } } } group.Init(this); VMPlacementError couldPlace = group.ChangePosition(pos, direction, this); if (couldPlace != VMPlacementError.Success); return group; } else { if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person { var vmObject = new VMAvatar(objDefinition); vmObject.MultitileGroup = group; group.Objects.Add(vmObject); VM.AddEntity(vmObject); Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI); vmObject.MainParam = MainParam; vmObject.MainStackOBJ = MainStackOBJ; group.Init(this); vmObject.SetPosition(pos, direction, this); return group; } else { var worldObject = new ObjectComponent(objDefinition); var vmObject = new VMGameObject(objDefinition, worldObject); vmObject.MultitileGroup = group; group.Objects.Add(vmObject); VM.AddEntity(vmObject); vmObject.MainParam = MainParam; vmObject.MainStackOBJ = MainStackOBJ; group.Init(this); vmObject.SetPosition(pos, direction, this); return group; } } }
public override void Tick() { base.Tick(); //animation update for avatars VMAvatar avatar = this; if (avatar.CurrentAnimation != null && !avatar.CurrentAnimationState.EndReached) { if (avatar.CurrentAnimationState.PlayingBackwards) { avatar.CurrentAnimationState.CurrentFrame--; } else { avatar.CurrentAnimationState.CurrentFrame++; } var currentFrame = avatar.CurrentAnimationState.CurrentFrame; var currentTime = currentFrame * 33.33f; var timeProps = avatar.CurrentAnimationState.TimePropertyLists; if (!avatar.CurrentAnimationState.PlayingBackwards) { for (var i = 0; i < timeProps.Count; i++) { var tp = timeProps[i]; if (tp.ID > currentTime) { break; } timeProps.RemoveAt(0); i--; HandleTimePropsEvent(tp); } } else { for (var i = timeProps.Count - 1; i >= 0; i--) { var tp = timeProps[i]; if (tp.ID < currentTime) { break; } timeProps.RemoveAt(timeProps.Count - 1); HandleTimePropsEvent(tp); } } var status = Animator.RenderFrame(avatar.Avatar, avatar.CurrentAnimation, avatar.CurrentAnimationState.CurrentFrame, 0.0f); if (status != AnimationStatus.IN_PROGRESS) { avatar.CurrentAnimationState.EndReached = true; } } if (avatar.CarryAnimation != null) { var status = Animator.RenderFrame(avatar.Avatar, avatar.CarryAnimation, avatar.CarryAnimationState.CurrentFrame, 0.0f); //currently don't advance frames... I don't think any of them are animated anyways. } for (int i = 0; i < 16; i++) { MotiveChanges[i].Tick(this); //tick over motive changes } PersonData[(int)VMPersonDataVariable.TickCounter]++; }
public VMEntity CreateObjectInstance(UInt32 GUID, short x, short y, sbyte level, Direction direction) { var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID); if (objDefinition == null) { return(null); } var master = objDefinition.OBJ.MasterID; if (master != 0) { var objd = objDefinition.Resource.List <OBJD>(); VMMultitileGroup group = new VMMultitileGroup(); for (int i = 0; i < objd.Count; i++) { if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it! { var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID); if (subObjDefinition != null) { var worldObject = new ObjectComponent(subObjDefinition); var vmObject = new VMGameObject(subObjDefinition, worldObject); vmObject.MasterDefinition = objDefinition.OBJ; vmObject.UseTreeTableOf(objDefinition); group.Objects.Add(vmObject); VM.AddEntity(vmObject); vmObject.MultitileGroup = group; } } } group.ChangePosition(x, y, level, direction, this); return((VMGameObject)group.Objects[0]); } else { if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person { var vmObject = new VMAvatar(objDefinition); VM.AddEntity(vmObject); //this.InitWorldComponent(vmObject.WorldUI); Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI); vmObject.SetPosition(x, y, level, direction, this); return(vmObject); } else { var worldObject = new ObjectComponent(objDefinition); var vmObject = new VMGameObject(objDefinition, worldObject); VM.AddEntity(vmObject); vmObject.SetPosition(x, y, level, direction, this); return(vmObject); } } }
public VMEntity CreateObjectInstance(UInt32 GUID, short x, short y, sbyte level, Direction direction) { var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID); if (objDefinition == null) { return null; } var master = objDefinition.OBJ.MasterID; if (master != 0) { var objd = objDefinition.Resource.List<OBJD>(); VMMultitileGroup group = new VMMultitileGroup(); for (int i = 0; i < objd.Count; i++) { if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it! { var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID); if (subObjDefinition != null) { var worldObject = new ObjectComponent(subObjDefinition); var vmObject = new VMGameObject(subObjDefinition, worldObject); vmObject.MasterDefinition = objDefinition.OBJ; vmObject.UseTreeTableOf(objDefinition); group.Objects.Add(vmObject); VM.AddEntity(vmObject); vmObject.MultitileGroup = group; } } } group.ChangePosition(x, y, level, direction, this); return (VMGameObject)group.Objects[0]; } else { if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person { var vmObject = new VMAvatar(objDefinition); VM.AddEntity(vmObject); //this.InitWorldComponent(vmObject.WorldUI); Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI); vmObject.SetPosition(x, y, level, direction, this); return vmObject; } else { var worldObject = new ObjectComponent(objDefinition); var vmObject = new VMGameObject(objDefinition, worldObject); VM.AddEntity(vmObject); vmObject.SetPosition(x, y, level, direction, this); return vmObject; } } }