public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); Vector3 dropPos = UnityPositionUtil.ToVector3(pos.Select(args)); if (player != null) { RaycastHit hit; Ray ray = new Ray(player.position.Value, dropPos); if (Physics.Raycast(ray, out hit, Vector3.Distance(player.position.Value, dropPos), UnityLayers.SceneCollidableLayerMask)) { RaycastHit vhit; if (Physics.Raycast(hit.point, Vector3.down, out vhit, 10000, UnityLayers.SceneCollidableLayerMask)) { dropPos = vhit.point; } else { dropPos = hit.point; } } } SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), dropPos); if (entity != null && !string.IsNullOrEmpty(time)) { entity.AddLifeTime(DateTime.Now, args.GetInt(time)); } Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args)); }
public override void DoAction(IEventArgs args) { SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), UnityPositionUtil.ToVector3(pos.Select(args))); if (entity != null && !string.IsNullOrEmpty(time)) { entity.AddLifeTime(DateTime.Now, args.GetInt(time)); } Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args)); }